diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-01 22:59:38 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-02 01:29:55 +0200 |
commit | 6228f72b87a87e6ce50bef75eb1bb947acff6e10 (patch) | |
tree | d157a8fad567489b1488ef41bb884665292995fa /Libraries | |
parent | e9b7a51a9ad76decf118a7c0399dd49bc517f120 (diff) | |
download | serenity-6228f72b87a87e6ce50bef75eb1bb947acff6e10.zip |
LibGUI+WindowServer: Inform WindowServer about parent/child windows
If a window has another window in its Core::Object ancestor chain,
we now communicate that relationship to WindowServer so that it can
act with awareness of parent/child windows.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibGUI/Window.cpp | 15 | ||||
-rw-r--r-- | Libraries/LibGUI/Window.h | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/Libraries/LibGUI/Window.cpp b/Libraries/LibGUI/Window.cpp index ead7ba78fa..60d80d938e 100644 --- a/Libraries/LibGUI/Window.cpp +++ b/Libraries/LibGUI/Window.cpp @@ -89,6 +89,9 @@ void Window::show() { if (is_visible()) return; + + auto* parent_window = find_parent_window(); + m_override_cursor = StandardCursor::None; auto response = WindowServerConnection::the().send_sync<Messages::WindowServer::CreateWindow>( m_rect_when_windowless, @@ -102,7 +105,8 @@ void Window::show() m_base_size, m_size_increment, (i32)m_window_type, - m_title_when_windowless); + m_title_when_windowless, + parent_window ? parent_window->window_id() : 0); m_window_id = response->window_id(); m_visible = true; @@ -113,6 +117,15 @@ void Window::show() update(); } +Window* Window::find_parent_window() +{ + for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) { + if (ancestor->is_window()) + return static_cast<Window*>(ancestor); + } + return nullptr; +} + void Window::hide() { if (!is_visible()) diff --git a/Libraries/LibGUI/Window.h b/Libraries/LibGUI/Window.h index 59d20a1bcd..20f20eac71 100644 --- a/Libraries/LibGUI/Window.h +++ b/Libraries/LibGUI/Window.h @@ -182,6 +182,8 @@ public: void did_remove_widget(Badge<Widget>, const Widget&); + Window* find_parent_window(); + protected: Window(Core::Object* parent = nullptr); virtual void wm_event(WMEvent&); |