浏览代码

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.
Liav A 5 年之前
父节点
当前提交
44ddfd2bf5
共有 2 个文件被更改,包括 24 次插入5 次删除
  1. 14 3
      Servers/WindowServer/WSEventLoop.cpp
  2. 10 2
      Servers/WindowServer/WSScreen.cpp

+ 14 - 3
Servers/WindowServer/WSEventLoop.cpp

@@ -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()

+ 10 - 2
Servers/WindowServer/WSScreen.cpp

@@ -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;