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

WindowServer+LibGUI: Handle mouse wheel deltas in the mouse event stream.

The wheel events will end up in GWidget::mousewheel_event(GMouseEvent&)
on the client-side. This patch also implements basic wheel scrolling in
GScrollableWidget via this mechanism. :^)
This commit is contained in:
Andreas Kling 2019-05-13 19:52:57 +02:00
parent dae8eb6454
commit dab9901235
13 changed files with 58 additions and 25 deletions

View file

@ -58,7 +58,7 @@ void WSScreen::set_resolution(int width, int height)
m_cursor_location.constrain(rect());
}
void WSScreen::on_receive_mouse_data(int dx, int dy, unsigned buttons)
void WSScreen::on_receive_mouse_data(int dx, int dy, int dz, unsigned buttons)
{
auto prev_location = m_cursor_location;
m_cursor_location.move_by(dx, dy);
@ -80,6 +80,11 @@ void WSScreen::on_receive_mouse_data(int dx, int dy, unsigned buttons)
WSEventLoop::the().post_event(WSWindowManager::the(), move(message));
}
if (dz) {
auto message = make<WSMouseEvent>(WSEvent::MouseWheel, m_cursor_location, buttons, MouseButton::None, m_modifiers, dz);
WSEventLoop::the().post_event(WSWindowManager::the(), move(message));
}
if (m_cursor_location != prev_location)
WSWindowManager::the().invalidate_cursor();
}