diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-03 17:22:14 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-03 17:22:14 +0200 |
commit | 318db1e48e49a6eec5a27355e39a38cbc243475c (patch) | |
tree | cf4eeb98b4a27a87a1b5cf4953b3527979390a2c /LibGUI | |
parent | c02c9880b61569455eeea1dacaa15d29c33021ea (diff) | |
download | serenity-318db1e48e49a6eec5a27355e39a38cbc243475c.zip |
WindowServer: Broadcast screen rect changes to all clients.
GUI clients can now obtain the screen rect via GDesktop::rect().
Diffstat (limited to 'LibGUI')
-rw-r--r-- | LibGUI/GDesktop.cpp | 6 | ||||
-rw-r--r-- | LibGUI/GDesktop.h | 6 | ||||
-rw-r--r-- | LibGUI/GEventLoop.cpp | 7 |
3 files changed, 19 insertions, 0 deletions
diff --git a/LibGUI/GDesktop.cpp b/LibGUI/GDesktop.cpp index faf8ed6af0..161778ae6f 100644 --- a/LibGUI/GDesktop.cpp +++ b/LibGUI/GDesktop.cpp @@ -2,6 +2,7 @@ #include <LibGUI/GEventLoop.h> #include <AK/Eternal.h> #include <string.h> +#include <unistd.h> GDesktop& GDesktop::the() { @@ -13,6 +14,11 @@ GDesktop::GDesktop() { } +void GDesktop::did_receive_screen_rect(Badge<GEventLoop>, const Rect& rect) +{ + m_rect = rect; +} + bool GDesktop::set_wallpaper(const String& path) { WSAPI_ClientMessage message; diff --git a/LibGUI/GDesktop.h b/LibGUI/GDesktop.h index 88341cfd7c..4553468815 100644 --- a/LibGUI/GDesktop.h +++ b/LibGUI/GDesktop.h @@ -1,8 +1,11 @@ #pragma once #include <AK/AKString.h> +#include <AK/Badge.h> #include <SharedGraphics/Rect.h> +class GEventLoop; + class GDesktop { public: static GDesktop& the(); @@ -11,6 +14,9 @@ public: String wallpaper() const; bool set_wallpaper(const String& path); + Rect rect() const { return m_rect; } + void did_receive_screen_rect(Badge<GEventLoop>, const Rect&); + private: Rect m_rect; }; diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp index 1756198b2e..16f7996d22 100644 --- a/LibGUI/GEventLoop.cpp +++ b/LibGUI/GEventLoop.cpp @@ -6,6 +6,7 @@ #include <LibGUI/GAction.h> #include <LibGUI/GNotifier.h> #include <LibGUI/GMenu.h> +#include <LibGUI/GDesktop.h> #include <LibC/unistd.h> #include <LibC/stdio.h> #include <LibC/fcntl.h> @@ -339,6 +340,12 @@ void GEventLoop::process_unprocessed_messages() for (auto& event : unprocessed_events) { if (event.type == WSAPI_ServerMessage::Type::Greeting) { s_server_pid = event.greeting.server_pid; + GDesktop::the().did_receive_screen_rect(Badge<GEventLoop>(), event.greeting.screen_rect); + continue; + } + + if (event.type == WSAPI_ServerMessage::Type::ScreenRectChanged) { + GDesktop::the().did_receive_screen_rect(Badge<GEventLoop>(), event.screen.rect); continue; } |