diff options
author | Peter Elliott <pelliott@ualberta.ca> | 2021-07-18 12:41:12 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-19 18:21:40 +0200 |
commit | b8f34413000ec9ad2439cbab83420966a7e68c00 (patch) | |
tree | 742ac2eb51709bf8cfb95846b2bc6a7b0ae8f88b /Userland/Libraries | |
parent | 222b97488ae0939edf5e8c5541c672c0b388075f (diff) | |
download | serenity-b8f34413000ec9ad2439cbab83420966a7e68c00.zip |
LibGUI: Add callback for screen rect change to Desktop.h
callbacks for screen rect changes can be added with
on_receive_screen_rects()
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGUI/Desktop.cpp | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Desktop.h | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Desktop.cpp b/Userland/Libraries/LibGUI/Desktop.cpp index 3363c448e8..bcbb0d8c4e 100644 --- a/Userland/Libraries/LibGUI/Desktop.cpp +++ b/Userland/Libraries/LibGUI/Desktop.cpp @@ -39,6 +39,9 @@ void Desktop::did_receive_screen_rects(Badge<WindowServerConnection>, const Vect m_virtual_desktop_rows = virtual_desktop_rows; m_virtual_desktop_columns = virtual_desktop_columns; + + for (auto& callback : m_receive_rects_callbacks) + callback(*this); } void Desktop::set_background_color(const StringView& background_color) diff --git a/Userland/Libraries/LibGUI/Desktop.h b/Userland/Libraries/LibGUI/Desktop.h index bdcda74973..554b723ad4 100644 --- a/Userland/Libraries/LibGUI/Desktop.h +++ b/Userland/Libraries/LibGUI/Desktop.h @@ -43,12 +43,19 @@ public: void did_receive_screen_rects(Badge<WindowServerConnection>, const Vector<Gfx::IntRect, 4>&, size_t, unsigned, unsigned); + template<typename F> + void on_receive_screen_rects(F&& callback) + { + m_receive_rects_callbacks.append(forward<F>(callback)); + } + private: Vector<Gfx::IntRect, default_screen_rect_count> m_rects; size_t m_main_screen_index { 0 }; Gfx::IntRect m_bounding_rect; unsigned m_virtual_desktop_rows { 1 }; unsigned m_virtual_desktop_columns { 1 }; + Vector<Function<void(Desktop&)>> m_receive_rects_callbacks; }; } |