1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

LibGUI+WindowServer: Create and broadcast an event when a window moves

LibWeb's Window object will need to know the OS-level position and size
of the GUI::Window for e.g. screenX, screenY, outerWidth, outerHeight.
It will also need to know about changes to that data.
This commit is contained in:
Timothy Flynn 2022-11-01 14:23:22 -04:00 committed by Linus Groh
parent 6b41da0b9e
commit f7e747b68e
7 changed files with 47 additions and 0 deletions

View file

@ -102,6 +102,12 @@ void ConnectionToWindowServer::window_resized(i32 window_id, Gfx::IntRect const&
}
}
void ConnectionToWindowServer::window_moved(i32 window_id, Gfx::IntRect const& new_rect)
{
if (auto* window = Window::from_window_id(window_id))
Core::EventLoop::current().post_event(*window, make<MoveEvent>(new_rect.location()));
}
void ConnectionToWindowServer::window_activated(i32 window_id)
{
if (auto* window = Window::from_window_id(window_id))

View file

@ -41,6 +41,7 @@ private:
virtual void window_input_left(i32) override;
virtual void window_close_request(i32) override;
virtual void window_resized(i32, Gfx::IntRect const&) override;
virtual void window_moved(i32, Gfx::IntRect const&) override;
virtual void menu_item_activated(i32, u32) override;
virtual void menu_item_entered(i32, u32) override;
virtual void menu_item_left(i32, u32) override;

View file

@ -28,6 +28,7 @@ public:
Paint,
MultiPaint,
Resize,
Move,
MouseMove,
MouseDown,
MouseDoubleClick,
@ -310,6 +311,20 @@ private:
Gfx::IntSize m_size;
};
class MoveEvent final : public Event {
public:
explicit MoveEvent(Gfx::IntPoint const& size)
: Event(Event::Move)
, m_position(size)
{
}
Gfx::IntPoint const& position() const { return m_position; }
private:
Gfx::IntPoint m_position;
};
class ContextMenuEvent final : public Event {
public:
explicit ContextMenuEvent(Gfx::IntPoint const& position, Gfx::IntPoint const& screen_position)