Browse Source

LibGUI+WindowServer: Remove ResizeEvent::old_size()

Turns out nobody was using this information anyway, so let's not go
through all the trouble of plumbing it from WindowServer to LibGUI.

Fixes #3247.
Andreas Kling 4 years ago
parent
commit
e374eb3035

+ 1 - 4
Libraries/LibGUI/Event.h

@@ -221,18 +221,15 @@ private:
 
 class ResizeEvent final : public Event {
 public:
-    explicit ResizeEvent(const Gfx::IntSize& old_size, const Gfx::IntSize& size)
+    explicit ResizeEvent(const Gfx::IntSize& size)
         : Event(Event::Resize)
-        , m_old_size(old_size)
         , m_size(size)
     {
     }
 
-    const Gfx::IntSize& old_size() const { return m_old_size; }
     const Gfx::IntSize& size() const { return m_size; }
 
 private:
-    Gfx::IntSize m_old_size;
     Gfx::IntSize m_size;
 };
 

+ 1 - 1
Libraries/LibGUI/Widget.cpp

@@ -151,7 +151,7 @@ void Widget::set_relative_rect(const Gfx::IntRect& a_rect)
     m_relative_rect = rect;
 
     if (size_changed) {
-        ResizeEvent resize_event(m_relative_rect.size(), rect.size());
+        ResizeEvent resize_event(rect.size());
         event(resize_event);
     }
 

+ 1 - 1
Libraries/LibGUI/WindowServerConnection.cpp

@@ -90,7 +90,7 @@ void WindowServerConnection::handle(const Messages::WindowClient::Paint& message
 void WindowServerConnection::handle(const Messages::WindowClient::WindowResized& message)
 {
     if (auto* window = Window::from_window_id(message.window_id())) {
-        Core::EventLoop::current().post_event(*window, make<ResizeEvent>(message.old_rect().size(), message.new_rect().size()));
+        Core::EventLoop::current().post_event(*window, make<ResizeEvent>(message.new_rect().size()));
     }
 }
 

+ 3 - 6
Services/WindowServer/Event.h

@@ -56,12 +56,12 @@ public:
         WindowResized,
     };
 
-    Event() {}
+    Event() { }
     explicit Event(Type type)
         : Core::Event(type)
     {
     }
-    virtual ~Event() {}
+    virtual ~Event() { }
 
     bool is_mouse_event() const { return type() == MouseMove || type() == MouseDown || type() == MouseDoubleClick || type() == MouseUp || type() == MouseWheel; }
     bool is_key_event() const { return type() == KeyUp || type() == KeyDown; }
@@ -144,18 +144,15 @@ private:
 
 class ResizeEvent final : public Event {
 public:
-    ResizeEvent(const Gfx::IntRect& old_rect, const Gfx::IntRect& rect)
+    ResizeEvent(const Gfx::IntRect& rect)
         : Event(Event::WindowResized)
-        , m_old_rect(old_rect)
         , m_rect(rect)
     {
     }
 
-    Gfx::IntRect old_rect() const { return m_old_rect; }
     Gfx::IntRect rect() const { return m_rect; }
 
 private:
-    Gfx::IntRect m_old_rect;
     Gfx::IntRect m_rect;
 };
 

+ 8 - 15
Services/WindowServer/Window.cpp

@@ -302,7 +302,6 @@ void Window::set_maximized(bool maximized)
     set_tiled(WindowTileType::None);
     m_maximized = maximized;
     update_menu_item_text(PopupMenuItem::Maximize);
-    auto old_rect = m_rect;
     if (maximized) {
         m_unmaximized_rect = m_rect;
         set_rect(WindowManager::the().maximized_window_rect(*this));
@@ -310,7 +309,7 @@ void Window::set_maximized(bool maximized)
         set_rect(m_unmaximized_rect);
     }
     m_frame.did_set_maximized({}, maximized);
-    Core::EventLoop::current().post_event(*this, make<ResizeEvent>(old_rect, m_rect));
+    Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
     set_default_positioned(false);
 }
 
@@ -376,11 +375,7 @@ void Window::event(Core::Event& event)
         m_client->post_message(Messages::WindowClient::WindowCloseRequest(m_window_id));
         break;
     case Event::WindowResized:
-        m_client->post_message(
-            Messages::WindowClient::WindowResized(
-                m_window_id,
-                static_cast<const ResizeEvent&>(event).old_rect(),
-                static_cast<const ResizeEvent&>(event).rect()));
+        m_client->post_message(Messages::WindowClient::WindowResized(m_window_id, static_cast<const ResizeEvent&>(event).rect()));
         break;
     default:
         break;
@@ -400,9 +395,9 @@ void Window::set_visible(bool b)
 
     Compositor::the().invalidate_occlusions();
     if (m_visible)
-         invalidate(true);
+        invalidate(true);
     else
-         Compositor::the().invalidate_screen(frame().rect());
+        Compositor::the().invalidate_screen(frame().rect());
 }
 
 void Window::invalidate(bool invalidate_frame)
@@ -472,7 +467,7 @@ Window* Window::is_blocked_by_modal_window()
 {
     // A window is blocked if any immediate child, or any child further
     // down the chain is modal
-    for (auto& window: m_child_windows) {
+    for (auto& window : m_child_windows) {
         if (window && !window->is_destroyed()) {
             if (window->is_modal())
                 return window;
@@ -591,7 +586,7 @@ void Window::set_fullscreen(bool fullscreen)
         new_window_rect = m_saved_nonfullscreen_rect;
     }
 
-    Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect, new_window_rect));
+    Core::EventLoop::current().post_event(*this, make<ResizeEvent>(new_window_rect));
     set_rect(new_window_rect);
 }
 
@@ -622,11 +617,10 @@ void Window::set_tiled(WindowTileType tiled)
         return;
 
     m_tiled = tiled;
-    auto old_rect = m_rect;
     if (tiled != WindowTileType::None)
         m_untiled_rect = m_rect;
     set_rect(tiled_rect(tiled));
-    Core::EventLoop::current().post_event(*this, make<ResizeEvent>(old_rect, m_rect));
+    Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
 }
 
 void Window::detach_client(Badge<ClientConnection>)
@@ -639,7 +633,6 @@ void Window::recalculate_rect()
     if (!is_resizable())
         return;
 
-    auto old_rect = m_rect;
     bool send_event = true;
     if (m_tiled != WindowTileType::None) {
         set_rect(tiled_rect(m_tiled));
@@ -652,7 +645,7 @@ void Window::recalculate_rect()
     }
 
     if (send_event) {
-        Core::EventLoop::current().post_event(*this, make<ResizeEvent>(old_rect, m_rect));
+        Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
     }
 }
 

+ 1 - 1
Services/WindowServer/WindowClient.ipc

@@ -16,7 +16,7 @@ endpoint WindowClient = 4
     WindowDeactivated(i32 window_id) =|
     WindowStateChanged(i32 window_id, bool minimized, bool occluded) =|
     WindowCloseRequest(i32 window_id) =|
-    WindowResized(i32 window_id, Gfx::IntRect old_rect, Gfx::IntRect new_rect) =|
+    WindowResized(i32 window_id, Gfx::IntRect new_rect) =|
 
     MenuItemActivated(i32 menu_id, i32 identifier) =|
 

+ 3 - 5
Services/WindowServer/WindowManager.cpp

@@ -179,7 +179,7 @@ void WindowManager::add_window(Window& window)
     m_windows_in_order.append(&window);
 
     if (window.is_fullscreen()) {
-        Core::EventLoop::current().post_event(window, make<ResizeEvent>(window.rect(), Screen::the().rect()));
+        Core::EventLoop::current().post_event(window, make<ResizeEvent>(Screen::the().rect()));
         window.set_rect(Screen::the().rect());
     }
 
@@ -577,7 +577,7 @@ bool WindowManager::process_ongoing_window_resize(const MouseEvent& event, Windo
 #ifdef RESIZE_DEBUG
         dbg() << "[WM] Finish resizing Window{" << m_resize_window << "}";
 #endif
-        Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(m_resize_window->rect(), m_resize_window->rect()));
+        Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(m_resize_window->rect()));
         m_resize_window->invalidate();
         if (m_resize_window->rect().contains(event.position()))
             hovered_window = m_resize_window;
@@ -589,8 +589,6 @@ bool WindowManager::process_ongoing_window_resize(const MouseEvent& event, Windo
     if (event.type() != Event::MouseMove)
         return false;
 
-    auto old_rect = m_resize_window->rect();
-
     int diff_x = event.x() - m_resize_origin.x();
     int diff_y = event.y() - m_resize_origin.y();
 
@@ -679,7 +677,7 @@ bool WindowManager::process_ongoing_window_resize(const MouseEvent& event, Windo
     dbg() << "[WM] Resizing, original: " << m_resize_window_original_rect << ", now: " << new_rect;
 #endif
     m_resize_window->set_rect(new_rect);
-    Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(old_rect, new_rect));
+    Core::EventLoop::current().post_event(*m_resize_window, make<ResizeEvent>(new_rect));
     return true;
 }