summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/Window.cpp
diff options
context:
space:
mode:
authorPeter Elliott <pelliott@ualberta.ca>2020-08-21 14:19:10 -0600
committerAndreas Kling <kling@serenityos.org>2020-08-23 01:05:22 +0200
commit45ed58865ed7ae26a61f8710dc2bba4a667221a3 (patch)
tree38f94e2c99995aece462cb91b6e217e78923ec54 /Libraries/LibGUI/Window.cpp
parentc68537271ca4430baa27f677511637e8648502c1 (diff)
downloadserenity-45ed58865ed7ae26a61f8710dc2bba4a667221a3.zip
LibGUI+WindowServer: Add resize_aspect_ratio()
When a resize_aspect_ratio is specified, and window will only be resized to a multiple of that ratio. When resize_aspect_ratio is set, windows cannot be tiled.
Diffstat (limited to 'Libraries/LibGUI/Window.cpp')
-rw-r--r--Libraries/LibGUI/Window.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/Libraries/LibGUI/Window.cpp b/Libraries/LibGUI/Window.cpp
index de1206b918..72a6885b54 100644
--- a/Libraries/LibGUI/Window.cpp
+++ b/Libraries/LibGUI/Window.cpp
@@ -107,6 +107,7 @@ void Window::show()
m_opacity_when_windowless,
m_base_size,
m_size_increment,
+ m_resize_aspect_ratio,
(i32)m_window_type,
m_title_when_windowless,
parent_window ? parent_window->window_id() : 0);
@@ -837,6 +838,16 @@ void Window::set_size_increment(const Gfx::IntSize& size_increment)
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement>(m_window_id, m_base_size, m_size_increment);
}
+void Window::set_resize_aspect_ratio(const Optional<Gfx::IntSize>& ratio)
+{
+ if (m_resize_aspect_ratio == ratio)
+ return;
+
+ m_resize_aspect_ratio = ratio;
+ if (is_visible())
+ WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowResizeAspectRatio>(m_window_id, m_resize_aspect_ratio);
+}
+
void Window::did_add_widget(Badge<Widget>, Widget& widget)
{
if (!m_focused_widget && widget.accepts_focus())