1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 15:38:12 +00:00

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.
This commit is contained in:
Andreas Kling 2020-08-22 13:10:35 +02:00
parent 683ae4f7ad
commit e374eb3035
7 changed files with 18 additions and 33 deletions

View file

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

View file

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

View file

@ -90,7 +90,7 @@ void WindowServerConnection::handle(const Messages::WindowClient::Paint& message
void WindowServerConnection::handle(const Messages::WindowClient::WindowResized& message) void WindowServerConnection::handle(const Messages::WindowClient::WindowResized& message)
{ {
if (auto* window = Window::from_window_id(message.window_id())) { 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()));
} }
} }

View file

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

View file

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

View file

@ -16,7 +16,7 @@ endpoint WindowClient = 4
WindowDeactivated(i32 window_id) =| WindowDeactivated(i32 window_id) =|
WindowStateChanged(i32 window_id, bool minimized, bool occluded) =| WindowStateChanged(i32 window_id, bool minimized, bool occluded) =|
WindowCloseRequest(i32 window_id) =| 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) =| MenuItemActivated(i32 menu_id, i32 identifier) =|

View file

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