Browse Source

WindowServer: Don't spam clients with resize events.

Wait for them to finish a paint, then send them a new resize event.
The exception is when releasing the mouse button to end the resize.
Then we send a new resize event right away.
Andreas Kling 6 years ago
parent
commit
d054fbee91

+ 1 - 0
WindowServer/WSClientConnection.cpp

@@ -358,6 +358,7 @@ void WSClientConnection::handle_request(WSAPIDidFinishPaintingNotification& requ
         return;
         return;
     }
     }
     auto& window = *(*it).value;
     auto& window = *(*it).value;
+    window.set_has_painted_since_last_resize(true);
     WSWindowManager::the().invalidate(window, request.rect());
     WSWindowManager::the().invalidate(window, request.rect());
 }
 }
 
 

+ 4 - 0
WindowServer/WSWindow.h

@@ -63,6 +63,9 @@ public:
     bool has_alpha_channel() const { return m_has_alpha_channel; }
     bool has_alpha_channel() const { return m_has_alpha_channel; }
     void set_has_alpha_channel(bool value) { m_has_alpha_channel = value; }
     void set_has_alpha_channel(bool value) { m_has_alpha_channel = value; }
 
 
+    void set_has_painted_since_last_resize(bool b) { m_has_painted_since_last_resize = b; }
+    bool has_painted_since_last_resize() const { return m_has_painted_since_last_resize; }
+
     // For InlineLinkedList.
     // For InlineLinkedList.
     // FIXME: Maybe make a ListHashSet and then WSWindowManager can just use that.
     // FIXME: Maybe make a ListHashSet and then WSWindowManager can just use that.
     WSWindow* m_next { nullptr };
     WSWindow* m_next { nullptr };
@@ -76,6 +79,7 @@ private:
     bool m_global_cursor_tracking_enabled { false };
     bool m_global_cursor_tracking_enabled { false };
     bool m_visible { true };
     bool m_visible { true };
     bool m_has_alpha_channel { false };
     bool m_has_alpha_channel { false };
+    bool m_has_painted_since_last_resize { false };
     WSMenu* m_menu { nullptr };
     WSMenu* m_menu { nullptr };
     RetainPtr<GraphicsBitmap> m_backing;
     RetainPtr<GraphicsBitmap> m_backing;
     int m_window_id { -1 };
     int m_window_id { -1 };

+ 5 - 2
WindowServer/WSWindowManager.cpp

@@ -531,7 +531,7 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& event_
 #ifdef RESIZE_DEBUG
 #ifdef RESIZE_DEBUG
             printf("[WM] Finish resizing WSWindow{%p}\n", m_resize_window.ptr());
             printf("[WM] Finish resizing WSWindow{%p}\n", m_resize_window.ptr());
 #endif
 #endif
-            invalidate(*m_resize_window);
+            WSMessageLoop::the().post_message(m_resize_window.ptr(), make<WSResizeEvent>(m_resize_window->rect(), m_resize_window->rect()));
             m_resize_window = nullptr;
             m_resize_window = nullptr;
             return;
             return;
         }
         }
@@ -553,7 +553,10 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& event_
             if (new_rect.height() < 50)
             if (new_rect.height() < 50)
                 new_rect.set_height(50);
                 new_rect.set_height(50);
             m_resize_window->set_rect(new_rect);
             m_resize_window->set_rect(new_rect);
-            WSMessageLoop::the().post_message(m_resize_window.ptr(), make<WSResizeEvent>(old_rect, new_rect));
+            if (m_resize_window->has_painted_since_last_resize()) {
+                m_resize_window->set_has_painted_since_last_resize(false);
+                WSMessageLoop::the().post_message(m_resize_window.ptr(), make<WSResizeEvent>(old_rect, new_rect));
+            }
             return;
             return;
         }
         }
     }
     }