1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +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

@ -62,6 +62,7 @@ void WSEventLoop::drain_mouse()
unsigned prev_buttons = screen.mouse_button_state();
int dx = 0;
int dy = 0;
int dz = 0;
unsigned buttons = prev_buttons;
for (;;) {
MousePacket packet;
@ -73,15 +74,17 @@ void WSEventLoop::drain_mouse()
dx += packet.dx;
dy += -packet.dy;
dz += packet.dz;
if (buttons != prev_buttons) {
screen.on_receive_mouse_data(dx, dy, buttons);
screen.on_receive_mouse_data(dx, dy, dz, buttons);
dx = 0;
dy = 0;
dz = 0;
prev_buttons = buttons;
}
}
if (dx || dy)
screen.on_receive_mouse_data(dx, dy, buttons);
if (dx || dy || dz)
screen.on_receive_mouse_data(dx, dy, dz, buttons);
}
void WSEventLoop::drain_keyboard()