1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:37:46 +00:00

WindowServer: Broadcast screen rect changes to all clients.

GUI clients can now obtain the screen rect via GDesktop::rect().
This commit is contained in:
Andreas Kling 2019-04-03 17:22:14 +02:00
parent c02c9880b6
commit 318db1e48e
7 changed files with 40 additions and 0 deletions

View file

@ -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;

View file

@ -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;
};

View file

@ -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;
}