mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
WindowServer: Fix the drain mouse mechanism
Now we actually check if the Mouse packet relative flag is enabled or not. In addition to that, we have debug messages for mouse point changes.
This commit is contained in:
parent
e94484d208
commit
44ddfd2bf5
Notes:
sideshowbarker
2024-07-19 09:40:16 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/44ddfd2bf5e Pull-request: https://github.com/SerenityOS/serenity/pull/1173
2 changed files with 24 additions and 5 deletions
|
@ -98,8 +98,12 @@ void WSEventLoop::drain_mouse()
|
|||
if (nread == 0)
|
||||
break;
|
||||
ASSERT(nread == sizeof(packet));
|
||||
#ifdef WSMESSAGELOOP_DEBUG
|
||||
dbgprintf("WSEventLoop: Mouse X %d, Y %d, Z %d, relative %d\n", packet.x, packet.y, packet.z, packet.is_relative);
|
||||
#endif
|
||||
buttons = packet.buttons;
|
||||
|
||||
state.is_relative = packet.is_relative;
|
||||
if (packet.is_relative) {
|
||||
state.x += packet.x;
|
||||
state.y -= packet.y;
|
||||
|
@ -112,14 +116,21 @@ void WSEventLoop::drain_mouse()
|
|||
|
||||
if (buttons != state.buttons) {
|
||||
state.buttons = buttons;
|
||||
#ifdef WSMESSAGELOOP_DEBUG
|
||||
dbgprintf("WSEventLoop: Mouse Button Event\n");
|
||||
#endif
|
||||
screen.on_receive_mouse_data(state);
|
||||
state.x = 0;
|
||||
state.y = 0;
|
||||
state.z = 0;
|
||||
if (state.is_relative) {
|
||||
state.x = 0;
|
||||
state.y = 0;
|
||||
state.z = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state.is_relative && (state.x || state.y || state.z))
|
||||
screen.on_receive_mouse_data(state);
|
||||
if (!state.is_relative)
|
||||
screen.on_receive_mouse_data(state);
|
||||
}
|
||||
|
||||
void WSEventLoop::drain_keyboard()
|
||||
|
|
|
@ -105,10 +105,18 @@ void WSScreen::set_buffer(int index)
|
|||
void WSScreen::on_receive_mouse_data(const MousePacket& packet)
|
||||
{
|
||||
auto prev_location = m_cursor_location;
|
||||
if (packet.is_relative)
|
||||
if (packet.is_relative) {
|
||||
m_cursor_location.move_by(packet.x, packet.y);
|
||||
else
|
||||
#ifdef WSSCREEN_DEBUG
|
||||
dbgprintf("WSScreen: New Relative mouse point @ X %d, Y %d\n", m_cursor_location.x(), m_cursor_location.y());
|
||||
#endif
|
||||
} else {
|
||||
m_cursor_location = { packet.x * m_width / 0xffff, packet.y * m_height / 0xffff };
|
||||
#ifdef WSSCREEN_DEBUG
|
||||
dbgprintf("WSScreen: New Absolute mouse point @ X %d, Y %d\n", m_cursor_location.x(), m_cursor_location.y());
|
||||
#endif
|
||||
}
|
||||
|
||||
m_cursor_location.constrain(rect());
|
||||
|
||||
unsigned buttons = packet.buttons;
|
||||
|
|
Loading…
Reference in a new issue