mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 10:55:07 +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:
parent
c02c9880b6
commit
318db1e48e
7 changed files with 40 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include <LibGUI/GEventLoop.h>
|
#include <LibGUI/GEventLoop.h>
|
||||||
#include <AK/Eternal.h>
|
#include <AK/Eternal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
GDesktop& GDesktop::the()
|
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)
|
bool GDesktop::set_wallpaper(const String& path)
|
||||||
{
|
{
|
||||||
WSAPI_ClientMessage message;
|
WSAPI_ClientMessage message;
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/AKString.h>
|
#include <AK/AKString.h>
|
||||||
|
#include <AK/Badge.h>
|
||||||
#include <SharedGraphics/Rect.h>
|
#include <SharedGraphics/Rect.h>
|
||||||
|
|
||||||
|
class GEventLoop;
|
||||||
|
|
||||||
class GDesktop {
|
class GDesktop {
|
||||||
public:
|
public:
|
||||||
static GDesktop& the();
|
static GDesktop& the();
|
||||||
|
@ -11,6 +14,9 @@ public:
|
||||||
String wallpaper() const;
|
String wallpaper() const;
|
||||||
bool set_wallpaper(const String& path);
|
bool set_wallpaper(const String& path);
|
||||||
|
|
||||||
|
Rect rect() const { return m_rect; }
|
||||||
|
void did_receive_screen_rect(Badge<GEventLoop>, const Rect&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Rect m_rect;
|
Rect m_rect;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <LibGUI/GAction.h>
|
#include <LibGUI/GAction.h>
|
||||||
#include <LibGUI/GNotifier.h>
|
#include <LibGUI/GNotifier.h>
|
||||||
#include <LibGUI/GMenu.h>
|
#include <LibGUI/GMenu.h>
|
||||||
|
#include <LibGUI/GDesktop.h>
|
||||||
#include <LibC/unistd.h>
|
#include <LibC/unistd.h>
|
||||||
#include <LibC/stdio.h>
|
#include <LibC/stdio.h>
|
||||||
#include <LibC/fcntl.h>
|
#include <LibC/fcntl.h>
|
||||||
|
@ -339,6 +340,12 @@ void GEventLoop::process_unprocessed_messages()
|
||||||
for (auto& event : unprocessed_events) {
|
for (auto& event : unprocessed_events) {
|
||||||
if (event.type == WSAPI_ServerMessage::Type::Greeting) {
|
if (event.type == WSAPI_ServerMessage::Type::Greeting) {
|
||||||
s_server_pid = event.greeting.server_pid;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@ struct WSAPI_ServerMessage {
|
||||||
DidSetWindowBackingStore,
|
DidSetWindowBackingStore,
|
||||||
DidSetWallpaper,
|
DidSetWallpaper,
|
||||||
DidGetWallpaper,
|
DidGetWallpaper,
|
||||||
|
ScreenRectChanged,
|
||||||
};
|
};
|
||||||
Type type { Invalid };
|
Type type { Invalid };
|
||||||
int window_id { -1 };
|
int window_id { -1 };
|
||||||
|
@ -101,7 +102,11 @@ struct WSAPI_ServerMessage {
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
int server_pid;
|
int server_pid;
|
||||||
|
WSAPI_Rect screen_rect;
|
||||||
} greeting;
|
} greeting;
|
||||||
|
struct {
|
||||||
|
WSAPI_Rect rect;
|
||||||
|
} screen;
|
||||||
struct {
|
struct {
|
||||||
WSAPI_Rect rect;
|
WSAPI_Rect rect;
|
||||||
WSAPI_Rect old_rect;
|
WSAPI_Rect old_rect;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <WindowServer/WSWindowManager.h>
|
#include <WindowServer/WSWindowManager.h>
|
||||||
#include <WindowServer/WSAPITypes.h>
|
#include <WindowServer/WSAPITypes.h>
|
||||||
#include <WindowServer/WSClipboard.h>
|
#include <WindowServer/WSClipboard.h>
|
||||||
|
#include <WindowServer/WSScreen.h>
|
||||||
#include <SharedBuffer.h>
|
#include <SharedBuffer.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -47,6 +48,7 @@ WSClientConnection::WSClientConnection(int fd)
|
||||||
WSAPI_ServerMessage message;
|
WSAPI_ServerMessage message;
|
||||||
message.type = WSAPI_ServerMessage::Type::Greeting;
|
message.type = WSAPI_ServerMessage::Type::Greeting;
|
||||||
message.greeting.server_pid = getpid();
|
message.greeting.server_pid = getpid();
|
||||||
|
message.greeting.screen_rect = WSScreen::the().rect();
|
||||||
post_message(message);
|
post_message(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +85,14 @@ void WSClientConnection::post_message(const WSAPI_ServerMessage& message)
|
||||||
ASSERT(nwritten == sizeof(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)
|
void WSClientConnection::on_message(const WSMessage& message)
|
||||||
{
|
{
|
||||||
if (message.is_client_request()) {
|
if (message.is_client_request()) {
|
||||||
|
|
|
@ -36,6 +36,8 @@ public:
|
||||||
template<typename Matching, typename Callback> void for_each_window_matching(Matching, Callback);
|
template<typename Matching, typename Callback> void for_each_window_matching(Matching, Callback);
|
||||||
template<typename Callback> void for_each_window(Callback);
|
template<typename Callback> void for_each_window(Callback);
|
||||||
|
|
||||||
|
void notify_about_new_screen_rect(const Rect&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void on_message(const WSMessage&) override;
|
virtual void on_message(const WSMessage&) override;
|
||||||
|
|
||||||
|
|
|
@ -349,6 +349,10 @@ void WSWindowManager::set_resolution(int width, int height)
|
||||||
m_buffers_are_flipped = false;
|
m_buffers_are_flipped = false;
|
||||||
invalidate();
|
invalidate();
|
||||||
compose();
|
compose();
|
||||||
|
|
||||||
|
WSClientConnection::for_each_client([&] (WSClientConnection& client) {
|
||||||
|
client.notify_about_new_screen_rect(m_screen_rect);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue