1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:58:12 +00:00

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.
This commit is contained in:
Peter Elliott 2020-08-21 14:19:10 -06:00 committed by Andreas Kling
parent c68537271c
commit 45ed58865e
8 changed files with 51 additions and 1 deletions

View file

@ -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())