diff options
author | Peter Elliott <pelliott@ualberta.ca> | 2020-07-30 19:52:45 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-01 08:06:48 +0200 |
commit | 5ae9eee4a37a473ef768a2fe8d95d84202443cbe (patch) | |
tree | de8530dec7fb7d3290c6ca86253e090192dedc30 /Libraries | |
parent | 586ada7a148d350a7d699c35cf8a0b30bc829e77 (diff) | |
download | serenity-5ae9eee4a37a473ef768a2fe8d95d84202443cbe.zip |
LibGUI+WindowServer: Provide default placement to windows
This prevents windows from being opened directly on top of eachother,
and provides default behavior for when window position is not specified.
The new behavior is as follows:
- Windows that have been created without a set position are assigned one
by WindowServer.
- The assigned position is either offset from the last window that is
still in an assigned position, or a default position if no such window
is available.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibGUI/Window.cpp | 7 | ||||
-rw-r--r-- | Libraries/LibGUI/Window.h | 1 |
2 files changed, 7 insertions, 1 deletions
diff --git a/Libraries/LibGUI/Window.cpp b/Libraries/LibGUI/Window.cpp index f590184ff2..9add84eebf 100644 --- a/Libraries/LibGUI/Window.cpp +++ b/Libraries/LibGUI/Window.cpp @@ -62,7 +62,7 @@ Window::Window(Core::Object* parent) : Core::Object(parent) { all_windows->set(this); - m_rect_when_windowless = { 100, 400, 140, 140 }; + m_rect_when_windowless = { -5000, -5000, 140, 140 }; m_title_when_windowless = "GUI::Window"; } @@ -95,6 +95,7 @@ void Window::show() m_override_cursor = StandardCursor::None; auto response = WindowServerConnection::the().send_sync<Messages::WindowServer::CreateWindow>( m_rect_when_windowless, + !m_moved_by_client, m_has_alpha_channel, m_modal, m_minimizable, @@ -192,6 +193,10 @@ Gfx::IntRect Window::rect() const void Window::set_rect(const Gfx::IntRect& a_rect) { + if (a_rect.location() != m_rect_when_windowless.location()) { + m_moved_by_client = true; + } + m_rect_when_windowless = a_rect; if (!is_visible()) { if (m_main_widget) diff --git a/Libraries/LibGUI/Window.h b/Libraries/LibGUI/Window.h index 64542e6dbb..94de9fa5d8 100644 --- a/Libraries/LibGUI/Window.h +++ b/Libraries/LibGUI/Window.h @@ -262,6 +262,7 @@ private: bool m_visible_for_timer_purposes { true }; bool m_visible { false }; bool m_accessory { false }; + bool m_moved_by_client { false }; }; } |