summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2022-08-24 06:23:25 -0400
committerAndreas Kling <kling@serenityos.org>2022-08-25 13:28:50 +0200
commit609391b46e3ccc07dd86fd3c298909dc14e6949a (patch)
tree95f8edfd3198906d2ea29a575e823faf377bcdc3 /Userland/Services
parentab517aa21d539c38f767ca74fde44b389ff7a173 (diff)
downloadserenity-609391b46e3ccc07dd86fd3c298909dc14e6949a.zip
WindowServer: Add modeless_ancestor() helper
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/WindowServer/Window.cpp11
-rw-r--r--Userland/Services/WindowServer/Window.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp
index b2d14112ed..3c648bcec5 100644
--- a/Userland/Services/WindowServer/Window.cpp
+++ b/Userland/Services/WindowServer/Window.cpp
@@ -989,6 +989,17 @@ void Window::set_parent_window(Window& parent_window)
parent_window.add_child_window(*this);
}
+Window* Window::modeless_ancestor()
+{
+ if (!is_modal())
+ return this;
+ for (auto parent = m_parent_window; parent; parent = parent->parent_window()) {
+ if (!parent->is_modal())
+ return parent;
+ }
+ return nullptr;
+}
+
bool Window::is_accessory() const
{
if (!m_accessory)
diff --git a/Userland/Services/WindowServer/Window.h b/Userland/Services/WindowServer/Window.h
index bc915aa71a..6a19a51722 100644
--- a/Userland/Services/WindowServer/Window.h
+++ b/Userland/Services/WindowServer/Window.h
@@ -184,6 +184,7 @@ public:
bool is_modal() const;
bool is_modal_dont_unparent() const { return m_modal && m_parent_window; }
+ Window* modeless_ancestor();
Gfx::IntRect rect() const { return m_rect; }
void set_rect(Gfx::IntRect const&);