mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:17:42 +00:00
WindowServer+LibGUI: Send the window size along with Paint server messages.
This way GWindow doesn't need to do synchronous IPC to fetch the appropriate size for the window's backing store. This is mostly only relevant during live resize.
This commit is contained in:
parent
1effe70543
commit
ae90043424
5 changed files with 12 additions and 5 deletions
|
@ -56,15 +56,19 @@ public:
|
||||||
|
|
||||||
class GPaintEvent final : public GEvent {
|
class GPaintEvent final : public GEvent {
|
||||||
public:
|
public:
|
||||||
explicit GPaintEvent(const Rect& rect = Rect())
|
explicit GPaintEvent(const Rect& rect, const Size& window_size = Size())
|
||||||
: GEvent(GEvent::Paint)
|
: GEvent(GEvent::Paint)
|
||||||
, m_rect(rect)
|
, m_rect(rect)
|
||||||
|
, m_window_size(window_size)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const Rect& rect() const { return m_rect; }
|
Rect rect() const { return m_rect; }
|
||||||
|
Size window_size() const { return m_window_size; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Rect m_rect;
|
Rect m_rect;
|
||||||
|
Size m_window_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GResizeEvent final : public GEvent {
|
class GResizeEvent final : public GEvent {
|
||||||
|
|
|
@ -119,7 +119,7 @@ void GEventLoop::handle_paint_event(const WSAPI_ServerMessage& event, GWindow& w
|
||||||
#ifdef GEVENTLOOP_DEBUG
|
#ifdef GEVENTLOOP_DEBUG
|
||||||
dbgprintf("WID=%x Paint [%d,%d %dx%d]\n", event.window_id, event.paint.rect.location.x, event.paint.rect.location.y, event.paint.rect.size.width, event.paint.rect.size.height);
|
dbgprintf("WID=%x Paint [%d,%d %dx%d]\n", event.window_id, event.paint.rect.location.x, event.paint.rect.location.y, event.paint.rect.size.width, event.paint.rect.size.height);
|
||||||
#endif
|
#endif
|
||||||
post_event(window, make<GPaintEvent>(event.paint.rect));
|
post_event(window, make<GPaintEvent>(event.paint.rect, event.paint.window_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GEventLoop::handle_resize_event(const WSAPI_ServerMessage& event, GWindow& window)
|
void GEventLoop::handle_resize_event(const WSAPI_ServerMessage& event, GWindow& window)
|
||||||
|
|
|
@ -168,9 +168,9 @@ void GWindow::event(GEvent& event)
|
||||||
auto rect = paint_event.rect();
|
auto rect = paint_event.rect();
|
||||||
bool created_new_backing_store = !m_backing;
|
bool created_new_backing_store = !m_backing;
|
||||||
if (!m_backing) {
|
if (!m_backing) {
|
||||||
// NOTE: size() may change at any time since it's synchronously retrieved from the WindowServer.
|
|
||||||
ASSERT(GEventLoop::main().server_pid());
|
ASSERT(GEventLoop::main().server_pid());
|
||||||
Size new_backing_store_size = size();
|
ASSERT(!paint_event.window_size().is_empty());
|
||||||
|
Size new_backing_store_size = paint_event.window_size();
|
||||||
size_t size_in_bytes = new_backing_store_size.area() * sizeof(RGBA32);
|
size_t size_in_bytes = new_backing_store_size.area() * sizeof(RGBA32);
|
||||||
void* buffer;
|
void* buffer;
|
||||||
int shared_buffer_id = create_shared_buffer(GEventLoop::main().server_pid(), size_in_bytes, (void**)&buffer);
|
int shared_buffer_id = create_shared_buffer(GEventLoop::main().server_pid(), size_in_bytes, (void**)&buffer);
|
||||||
|
|
|
@ -101,6 +101,7 @@ struct WSAPI_ServerMessage {
|
||||||
} window;
|
} window;
|
||||||
struct {
|
struct {
|
||||||
WSAPI_Rect rect;
|
WSAPI_Rect rect;
|
||||||
|
WSAPI_Size window_size;
|
||||||
} paint;
|
} paint;
|
||||||
struct {
|
struct {
|
||||||
WSAPI_Point position;
|
WSAPI_Point position;
|
||||||
|
|
|
@ -349,10 +349,12 @@ void WSClientConnection::handle_request(WSAPIInvalidateRectRequest& request)
|
||||||
post_error("Bad window ID");
|
post_error("Bad window ID");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto& window = *(*it).value;
|
||||||
WSAPI_ServerMessage response;
|
WSAPI_ServerMessage response;
|
||||||
response.type = WSAPI_ServerMessage::Type::Paint;
|
response.type = WSAPI_ServerMessage::Type::Paint;
|
||||||
response.window_id = window_id;
|
response.window_id = window_id;
|
||||||
response.paint.rect = request.rect();
|
response.paint.rect = request.rect();
|
||||||
|
response.paint.window_size = window.size();
|
||||||
post_message(response);
|
post_message(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue