Browse Source

WindowServer: Rename the two painting phases.

Work now happens in terms of two messages:

    - WM_ClientWantsToPaint
    - WM_ClientFinishedPaint

This feels fairly obvious compared to the old Paint/Invalidate.
Andreas Kling 6 years ago
parent
commit
9fa8d4e22f

+ 4 - 4
Kernel/ProcessGUI.cpp

@@ -145,7 +145,7 @@ int Process::gui$invalidate_window(int window_id, const GUI_Rect* a_rect)
     Rect rect;
     if (a_rect)
         rect = *a_rect;
-    WSMessageLoop::the().post_message(&window, make<WSPaintEvent>(rect));
+    WSMessageLoop::the().post_message(&window, make<WSClientWantsToPaintMessage>(rect));
     WSMessageLoop::the().server_process().request_wakeup();
     return 0;
 }
@@ -169,7 +169,7 @@ int Process::gui$notify_paint_finished(int window_id, const GUI_Rect* a_rect)
     Rect rect;
     if (a_rect)
         rect = *a_rect;
-    WSMessageLoop::the().post_message(&window, make<WSWindowInvalidationEvent>(rect));
+    WSMessageLoop::the().post_message(&window, make<WSClientFinishedPaintMessage>(rect));
     WSMessageLoop::the().server_process().request_wakeup();
     return 0;
 }
@@ -207,7 +207,7 @@ int Process::gui$set_window_title(int window_id, const char* title, size_t size)
         return -EBADWINDOW;
     auto& window = *(*it).value;
     String new_title(title, size);
-    WSMessageLoop::the().post_message(&window, make<WSSetWindowTitle>(move(new_title)));
+    WSMessageLoop::the().post_message(&window, make<WSSetWindowTitleMessage>(move(new_title)));
     WSMessageLoop::the().server_process().request_wakeup();
     return 0;
 }
@@ -240,7 +240,7 @@ int Process::gui$set_window_rect(int window_id, const GUI_Rect* rect)
         return -EBADWINDOW;
     auto& window = *(*it).value;
     Rect new_rect = *rect;
-    WSMessageLoop::the().post_message(&window, make<WSSetWindowRect>(new_rect));
+    WSMessageLoop::the().post_message(&window, make<WSSetWindowRectMessage>(new_rect));
     WSMessageLoop::the().server_process().request_wakeup();
     return 0;
 }

+ 16 - 16
WindowServer/WSMessage.h

@@ -9,18 +9,18 @@ class WSMessage {
 public:
     enum Type {
         Invalid = 0,
-        Paint,
+        WM_ClientWantsToPaint,
+        WM_ClientFinishedPaint,
+        WM_SetWindowTitle,
+        WM_SetWindowRect,
+        WM_DeferredCompose,
         MouseMove,
         MouseDown,
         MouseUp,
         KeyDown,
         KeyUp,
-        WM_Compose,
-        WM_Invalidate,
         WindowActivated,
         WindowDeactivated,
-        WM_SetWindowTitle,
-        WM_SetWindowRect,
     };
 
     WSMessage() { }
@@ -31,16 +31,16 @@ public:
 
     bool is_mouse_event() const { return m_type == MouseMove || m_type == MouseDown || m_type == MouseUp; }
     bool is_key_event() const { return m_type == KeyUp || m_type == KeyDown; }
-    bool is_paint_event() const { return m_type == Paint; }
+    bool is_paint_event() const { return m_type == WM_ClientWantsToPaint; }
 
 private:
     Type m_type { Invalid };
 };
 
-class WSWindowInvalidationEvent final : public WSMessage {
+class WSClientFinishedPaintMessage final : public WSMessage {
 public:
-    explicit WSWindowInvalidationEvent(const Rect& rect = Rect())
-        : WSMessage(WSMessage::WM_Invalidate)
+    explicit WSClientFinishedPaintMessage(const Rect& rect = Rect())
+        : WSMessage(WSMessage::WM_ClientFinishedPaint)
         , m_rect(rect)
     {
     }
@@ -50,9 +50,9 @@ private:
     Rect m_rect;
 };
 
-class WSSetWindowTitle final : public WSMessage {
+class WSSetWindowTitleMessage final : public WSMessage {
 public:
-    explicit WSSetWindowTitle(String&& title)
+    explicit WSSetWindowTitleMessage(String&& title)
         : WSMessage(WSMessage::WM_SetWindowTitle)
         , m_title(move(title))
     {
@@ -64,9 +64,9 @@ private:
     String m_title;
 };
 
-class WSSetWindowRect final : public WSMessage {
+class WSSetWindowRectMessage final : public WSMessage {
 public:
-    explicit WSSetWindowRect(const Rect& rect)
+    explicit WSSetWindowRectMessage(const Rect& rect)
         : WSMessage(WSMessage::WM_SetWindowRect)
         , m_rect(rect)
     {
@@ -78,10 +78,10 @@ private:
     Rect m_rect;
 };
 
-class WSPaintEvent final : public WSMessage {
+class WSClientWantsToPaintMessage final : public WSMessage {
 public:
-    explicit WSPaintEvent(const Rect& rect = Rect())
-        : WSMessage(WSMessage::Paint)
+    explicit WSClientWantsToPaintMessage(const Rect& rect = Rect())
+        : WSMessage(WSMessage::WM_ClientWantsToPaint)
         , m_rect(rect)
     {
     }

+ 10 - 10
WindowServer/WSMessageLoop.cpp

@@ -79,14 +79,14 @@ void WSMessageLoop::post_message(WSMessageReceiver* receiver, OwnPtr<WSMessage>&
     dbgprintf("WSMessageLoop::post_message: {%u} << receiver=%p, message=%p\n", m_queued_messages.size(), receiver, message.ptr());
 #endif
 
-    if (message->type() == WSMessage::WM_Invalidate) {
-        auto& invalidation_message = static_cast<WSWindowInvalidationEvent&>(*message);
+    if (message->type() == WSMessage::WM_ClientFinishedPaint) {
+        auto& invalidation_message = static_cast<WSClientFinishedPaintMessage&>(*message);
         for (auto& queued_message : m_queued_messages) {
-            if (receiver == queued_message.receiver && queued_message.message->type() == WSMessage::WM_Invalidate) {
-                auto& queued_invalidation_message = static_cast<WSWindowInvalidationEvent&>(*queued_message.message);
+            if (receiver == queued_message.receiver && queued_message.message->type() == WSMessage::WM_ClientFinishedPaint) {
+                auto& queued_invalidation_message = static_cast<WSClientFinishedPaintMessage&>(*queued_message.message);
                 if (queued_invalidation_message.rect().is_empty() || queued_invalidation_message.rect().contains(invalidation_message.rect())) {
 #ifdef WSEVENTLOOP_DEBUG
-                    dbgprintf("Swallow WM_Invalidate\n");
+                    dbgprintf("Swallow WM_ClientFinishedPaint\n");
 #endif
                     return;
                 }
@@ -94,14 +94,14 @@ void WSMessageLoop::post_message(WSMessageReceiver* receiver, OwnPtr<WSMessage>&
         }
     }
 
-    if (message->type() == WSMessage::Paint) {
-        auto& invalidation_message = static_cast<WSPaintEvent&>(*message);
+    if (message->type() == WSMessage::WM_ClientWantsToPaint) {
+        auto& invalidation_message = static_cast<WSClientWantsToPaintMessage&>(*message);
         for (auto& queued_message : m_queued_messages) {
-            if (receiver == queued_message.receiver && queued_message.message->type() == WSMessage::Paint) {
-                auto& queued_invalidation_message = static_cast<WSPaintEvent&>(*queued_message.message);
+            if (receiver == queued_message.receiver && queued_message.message->type() == WSMessage::WM_ClientWantsToPaint) {
+                auto& queued_invalidation_message = static_cast<WSClientWantsToPaintMessage&>(*queued_message.message);
                 if (queued_invalidation_message.rect().is_empty() || queued_invalidation_message.rect().contains(invalidation_message.rect())) {
 #ifdef WSEVENTLOOP_DEBUG
-                    dbgprintf("Swallow WM_Paint\n");
+                    dbgprintf("Swallow WM_ClientWantsToPaint\n");
 #endif
                     return;
                 }

+ 6 - 6
WindowServer/WSWindow.cpp

@@ -60,9 +60,9 @@ void WSWindow::on_message(WSMessage& message)
     gui_event.window_id = window_id();
 
     switch (message.type()) {
-    case WSMessage::Paint:
+    case WSMessage::WM_ClientWantsToPaint:
         gui_event.type = GUI_Event::Type::Paint;
-        gui_event.paint.rect = static_cast<WSPaintEvent&>(message).rect();
+        gui_event.paint.rect = static_cast<WSClientWantsToPaintMessage&>(message).rect();
         break;
     case WSMessage::MouseMove:
         gui_event.type = GUI_Event::Type::MouseMove;
@@ -90,14 +90,14 @@ void WSWindow::on_message(WSMessage& message)
         gui_event.key.ctrl = static_cast<WSKeyEvent&>(message).ctrl();
         gui_event.key.shift = static_cast<WSKeyEvent&>(message).shift();
         break;
-    case WSMessage::WM_Invalidate:
-        WSWindowManager::the().invalidate(*this, static_cast<WSWindowInvalidationEvent&>(message).rect());
+    case WSMessage::WM_ClientFinishedPaint:
+        WSWindowManager::the().invalidate(*this, static_cast<WSClientFinishedPaintMessage&>(message).rect());
         return;
     case WSMessage::WM_SetWindowRect:
-        set_rect(static_cast<WSSetWindowRect&>(message).rect());
+        set_rect(static_cast<WSSetWindowRectMessage&>(message).rect());
         return;
     case WSMessage::WM_SetWindowTitle:
-        set_title(static_cast<WSSetWindowTitle&>(message).title());
+        set_title(static_cast<WSSetWindowTitleMessage&>(message).title());
         return;
     case WSMessage::WindowActivated:
         gui_event.type = GUI_Event::Type::WindowActivated;

+ 2 - 2
WindowServer/WSWindowManager.cpp

@@ -401,7 +401,7 @@ void WSWindowManager::on_message(WSMessage& message)
         return;
     }
 
-    if (message.type() == WSMessage::WM_Compose) {
+    if (message.type() == WSMessage::WM_DeferredCompose) {
         m_pending_compose_event = false;
         compose();
         return;
@@ -454,7 +454,7 @@ void WSWindowManager::invalidate(const Rect& a_rect)
 
     if (!m_pending_compose_event) {
         ASSERT_INTERRUPTS_ENABLED();
-        WSMessageLoop::the().post_message(this, make<WSMessage>(WSMessage::WM_Compose));
+        WSMessageLoop::the().post_message(this, make<WSMessage>(WSMessage::WM_DeferredCompose));
         m_pending_compose_event = true;
     }
 }

+ 1 - 1
WindowServer/WSWindowManager.h

@@ -11,7 +11,7 @@
 
 class WSScreen;
 class WSMouseEvent;
-class WSPaintEvent;
+class WSClientWantsToPaintMessage;
 class WSWindow;
 class CharacterBitmap;
 class GraphicsBitmap;