Vitaliy Margolen : winex11.drv: Only events with MOUSEEVENTF_MOVE flag should change mouse position.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Dec 13 10:03:51 CST 2006


Module: wine
Branch: master
Commit: b13681797aa27f42f79f50c980d5b98151f3bbcc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b13681797aa27f42f79f50c980d5b98151f3bbcc

Author: Vitaliy Margolen <wine-patches at kievinfo.com>
Date:   Tue Dec 12 15:57:22 2006 -0700

winex11.drv: Only events with MOUSEEVENTF_MOVE flag should change mouse position.

---

 dlls/user32/tests/input.c |   25 +++++++++++++++++++++++--
 dlls/winex11.drv/mouse.c  |    9 ++++++---
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index c024960..bfd8c10 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -568,7 +568,7 @@ static LRESULT CALLBACK hook_proc2( int
     if (code == HC_ACTION)
     {
         ok(hook->pt.x == pt_new.x && hook->pt.y == pt_new.y,
-           "Wrong hook coords: (%d,%d)\n", pt_new.x, pt_new.y);
+           "Wrong hook coords: (%d %d) != (%d,%d)\n", hook->pt.x, hook->pt.y, pt_new.x, pt_new.y);
 
         /* Should match position set above */
         GetCursorPos(&pt);
@@ -582,7 +582,7 @@ static void test_mouse_ll_hook(void)
 {
     HWND hwnd;
     HHOOK hook1, hook2;
-    POINT pt_org;
+    POINT pt_org, pt;
 
     GetCursorPos(&pt_org);
     hwnd = CreateWindow("static", "Title", WS_OVERLAPPEDWINDOW,
@@ -607,6 +607,27 @@ static void test_mouse_ll_hook(void)
     ok(pt_old.x == pt_new.x && pt_old.y == pt_new.y, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
 
     UnhookWindowsHookEx(hook1);
+
+    /* Now check that mouse buttons do not change mouse position
+       if we don't have MOUSEEVENTF_MOVE flag specified. */
+
+    /* We reusing the same hook callback, so make it happy */
+    pt_old.x = pt_new.x - STEP;
+    pt_old.y = pt_new.y - STEP;
+    mouse_event(MOUSEEVENTF_LEFTUP, 123, 456, 0, 0);
+    GetCursorPos(&pt);
+    ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%d,%d)\n", pt.x, pt.y);
+    mouse_event(MOUSEEVENTF_RIGHTUP, 456, 123, 0, 0);
+    GetCursorPos(&pt);
+    ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%d,%d)\n", pt.x, pt.y);
+
+    mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, 123, 456, 0, 0);
+    GetCursorPos(&pt);
+    ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%d,%d)\n", pt.x, pt.y);
+    mouse_event(MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE, 456, 123, 0, 0);
+    GetCursorPos(&pt);
+    ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%d,%d)\n", pt.x, pt.y);
+
     UnhookWindowsHookEx(hook2);
     DestroyWindow(hwnd);
     SetCursorPos(pt_org.x, pt_org.y);
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 5067acd..e2c7dd0 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -216,7 +216,7 @@ void X11DRV_send_mouse_input( HWND hwnd,
 {
     POINT pt;
 
-    if (flags & MOUSEEVENTF_ABSOLUTE)
+    if (flags & MOUSEEVENTF_MOVE && flags & MOUSEEVENTF_ABSOLUTE)
     {
         if (injected_flags & LLMHF_INJECTED)
         {
@@ -227,6 +227,9 @@ void X11DRV_send_mouse_input( HWND hwnd,
         {
             pt.x = x;
             pt.y = y;
+            wine_tsx11_lock();
+            if (cursor_pos.x == x && cursor_pos.y == y) flags &= ~MOUSEEVENTF_MOVE;
+            wine_tsx11_unlock();
         }
         wine_tsx11_lock();
         cursor_pos = pt;
@@ -748,7 +751,7 @@ void X11DRV_ButtonPress( HWND hwnd, XEve
 
     update_mouse_state( hwnd, event->window, event->x, event->y, event->state, &pt );
 
-    X11DRV_send_mouse_input( hwnd, button_down_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE,
+    X11DRV_send_mouse_input( hwnd, button_down_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,
                              pt.x, pt.y, wData, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
 }
 
@@ -778,7 +781,7 @@ void X11DRV_ButtonRelease( HWND hwnd, XE
 
     update_mouse_state( hwnd, event->window, event->x, event->y, event->state, &pt );
 
-    X11DRV_send_mouse_input( hwnd, button_up_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE,
+    X11DRV_send_mouse_input( hwnd, button_up_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,
                              pt.x, pt.y, wData, EVENT_x11_time_to_win32_time(event->time), 0, 0 );
 }
 




More information about the wine-cvs mailing list