summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-26 10:50:25 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-26 10:53:21 +0100
commitae9004342462e6cce4eb6f980825ade641b2c1a2 (patch)
treecee8ff119b88d0197ba0762f39c9fbd84bf365d0
parent1effe705432318363bbd1dcf4b42acf03ca3dce1 (diff)
downloadserenity-ae9004342462e6cce4eb6f980825ade641b2c1a2.zip
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.
-rw-r--r--LibGUI/GEvent.h8
-rw-r--r--LibGUI/GEventLoop.cpp2
-rw-r--r--LibGUI/GWindow.cpp4
-rw-r--r--WindowServer/WSAPITypes.h1
-rw-r--r--WindowServer/WSClientConnection.cpp2
5 files changed, 12 insertions, 5 deletions
diff --git a/LibGUI/GEvent.h b/LibGUI/GEvent.h
index a0cdff198c..5f1527c5a2 100644
--- a/LibGUI/GEvent.h
+++ b/LibGUI/GEvent.h
@@ -56,15 +56,19 @@ public:
class GPaintEvent final : public GEvent {
public:
- explicit GPaintEvent(const Rect& rect = Rect())
+ explicit GPaintEvent(const Rect& rect, const Size& window_size = Size())
: GEvent(GEvent::Paint)
, 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:
Rect m_rect;
+ Size m_window_size;
};
class GResizeEvent final : public GEvent {
diff --git a/LibGUI/GEventLoop.cpp b/LibGUI/GEventLoop.cpp
index 2e0a2ba4c9..d1353e433c 100644
--- a/LibGUI/GEventLoop.cpp
+++ b/LibGUI/GEventLoop.cpp
@@ -119,7 +119,7 @@ void GEventLoop::handle_paint_event(const WSAPI_ServerMessage& event, GWindow& w
#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);
#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)
diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp
index 0b61f922cf..7bcca70015 100644
--- a/LibGUI/GWindow.cpp
+++ b/LibGUI/GWindow.cpp
@@ -168,9 +168,9 @@ void GWindow::event(GEvent& event)
auto rect = paint_event.rect();
bool created_new_backing_store = !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());
- 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);
void* buffer;
int shared_buffer_id = create_shared_buffer(GEventLoop::main().server_pid(), size_in_bytes, (void**)&buffer);
diff --git a/WindowServer/WSAPITypes.h b/WindowServer/WSAPITypes.h
index 9084190ad7..e7fd570809 100644
--- a/WindowServer/WSAPITypes.h
+++ b/WindowServer/WSAPITypes.h
@@ -101,6 +101,7 @@ struct WSAPI_ServerMessage {
} window;
struct {
WSAPI_Rect rect;
+ WSAPI_Size window_size;
} paint;
struct {
WSAPI_Point position;
diff --git a/WindowServer/WSClientConnection.cpp b/WindowServer/WSClientConnection.cpp
index 2e5fcf5e07..0cf421b0f4 100644
--- a/WindowServer/WSClientConnection.cpp
+++ b/WindowServer/WSClientConnection.cpp
@@ -349,10 +349,12 @@ void WSClientConnection::handle_request(WSAPIInvalidateRectRequest& request)
post_error("Bad window ID");
return;
}
+ auto& window = *(*it).value;
WSAPI_ServerMessage response;
response.type = WSAPI_ServerMessage::Type::Paint;
response.window_id = window_id;
response.paint.rect = request.rect();
+ response.paint.window_size = window.size();
post_message(response);
}