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 #include #include +#include GDesktop& GDesktop::the() { @@ -13,6 +14,11 @@ GDesktop::GDesktop() { } +void GDesktop::did_receive_screen_rect(Badge, 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 +#include #include +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, 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 #include #include +#include #include #include #include @@ -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(), event.greeting.screen_rect); + continue; + } + + if (event.type == WSAPI_ServerMessage::Type::ScreenRectChanged) { + GDesktop::the().did_receive_screen_rect(Badge(), event.screen.rect); continue; } diff --git a/Servers/WindowServer/WSAPITypes.h b/Servers/WindowServer/WSAPITypes.h index cc3318aa24..3b69eace6b 100644 --- a/Servers/WindowServer/WSAPITypes.h +++ b/Servers/WindowServer/WSAPITypes.h @@ -91,6 +91,7 @@ struct WSAPI_ServerMessage { DidSetWindowBackingStore, DidSetWallpaper, DidGetWallpaper, + ScreenRectChanged, }; Type type { Invalid }; int window_id { -1 }; @@ -101,7 +102,11 @@ struct WSAPI_ServerMessage { union { struct { int server_pid; + WSAPI_Rect screen_rect; } greeting; + struct { + WSAPI_Rect rect; + } screen; struct { WSAPI_Rect rect; WSAPI_Rect old_rect; diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp index 3aa1dc95d2..74f27e63f3 100644 --- a/Servers/WindowServer/WSClientConnection.cpp +++ b/Servers/WindowServer/WSClientConnection.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,7 @@ WSClientConnection::WSClientConnection(int fd) WSAPI_ServerMessage message; message.type = WSAPI_ServerMessage::Type::Greeting; message.greeting.server_pid = getpid(); + message.greeting.screen_rect = WSScreen::the().rect(); post_message(message); } @@ -83,6 +85,14 @@ void WSClientConnection::post_message(const WSAPI_ServerMessage& message) ASSERT(nwritten == sizeof(message)); } +void WSClientConnection::notify_about_new_screen_rect(const Rect& rect) +{ + WSAPI_ServerMessage message; + message.type = WSAPI_ServerMessage::Type::ScreenRectChanged; + message.screen.rect = rect; + post_message(message); +} + void WSClientConnection::on_message(const WSMessage& message) { if (message.is_client_request()) { diff --git a/Servers/WindowServer/WSClientConnection.h b/Servers/WindowServer/WSClientConnection.h index e636efe5b2..0d61aebf3c 100644 --- a/Servers/WindowServer/WSClientConnection.h +++ b/Servers/WindowServer/WSClientConnection.h @@ -36,6 +36,8 @@ public: template void for_each_window_matching(Matching, Callback); template void for_each_window(Callback); + void notify_about_new_screen_rect(const Rect&); + private: virtual void on_message(const WSMessage&) override; diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index 61942df828..43ac5c3c95 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -349,6 +349,10 @@ void WSWindowManager::set_resolution(int width, int height) m_buffers_are_flipped = false; invalidate(); compose(); + + WSClientConnection::for_each_client([&] (WSClientConnection& client) { + client.notify_about_new_screen_rect(m_screen_rect); + }); } template