Jacek Caban : winex11.drv: Use grabbed window display in SetCapture.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Mar 14 09:05:21 CDT 2016


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Mar 10 14:03:02 2016 +0100

winex11.drv: Use grabbed window display in SetCapture.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winex11.drv/mouse.c  |  4 ++--
 dlls/winex11.drv/window.c | 28 ++++++++++++++++------------
 dlls/winex11.drv/x11drv.h |  2 +-
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 63d202c..677acfa 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -602,7 +602,7 @@ static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPU
 
     /* update the wine server Z-order */
 
-    if (window != x11drv_thread_data()->grab_window &&
+    if (hwnd != x11drv_thread_data()->grab_hwnd &&
         /* ignore event if a button is pressed, since the mouse is then grabbed too */
         !(state & (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask|Button6Mask|Button7Mask)))
     {
@@ -1611,7 +1611,7 @@ void X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
     TRACE( "hwnd %p/%lx pos %d,%d detail %d\n", hwnd, event->window, event->x, event->y, event->detail );
 
     if (event->detail == NotifyVirtual) return;
-    if (event->window == x11drv_thread_data()->grab_window) return;
+    if (hwnd == x11drv_thread_data()->grab_hwnd) return;
 
     /* simulate a mouse motion event */
     input.u.mi.dx          = event->x;
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 4a047e2..4789f98 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -2116,27 +2116,31 @@ BOOL CDECL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, HRGN update )
 void CDECL X11DRV_SetCapture( HWND hwnd, UINT flags )
 {
     struct x11drv_thread_data *thread_data = x11drv_thread_data();
+    struct x11drv_win_data *data;
 
-    if (!thread_data) return;
     if (!(flags & (GUI_INMOVESIZE | GUI_INMENUMODE))) return;
 
     if (hwnd)
     {
-        Window grab_win = X11DRV_get_whole_window( GetAncestor( hwnd, GA_ROOT ) );
-
-        if (!grab_win) return;
-        XFlush( gdi_display );
-        XGrabPointer( thread_data->display, grab_win, False,
-                      PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
-                      GrabModeAsync, GrabModeAsync, None, None, CurrentTime );
-        thread_data->grab_window = grab_win;
+        if (!(data = get_win_data( GetAncestor( hwnd, GA_ROOT )))) return;
+        if (data->whole_window)
+        {
+            XFlush( gdi_display );
+            XGrabPointer( data->display, data->whole_window, False,
+                          PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
+                          GrabModeAsync, GrabModeAsync, None, None, CurrentTime );
+            thread_data->grab_hwnd = data->hwnd;
+        }
+        release_win_data( data );
     }
     else  /* release capture */
     {
+        if (!(data = get_win_data( thread_data->grab_hwnd ))) return;
         XFlush( gdi_display );
-        XUngrabPointer( thread_data->display, CurrentTime );
-        XFlush( thread_data->display );
-        thread_data->grab_window = None;
+        XUngrabPointer( data->display, CurrentTime );
+        XFlush( data->display );
+        thread_data->grab_hwnd = NULL;
+        release_win_data( data );
     }
 }
 
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 2694d23..23f4ab6 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -308,7 +308,7 @@ struct x11drv_thread_data
 {
     Display *display;
     XEvent  *current_event;        /* event currently being processed */
-    Window   grab_window;          /* window that currently grabs the mouse */
+    HWND     grab_hwnd;            /* window that currently grabs the mouse */
     HWND     last_focus;           /* last window that had focus */
     XIM      xim;                  /* input method */
     HWND     last_xic_hwnd;        /* last xic window */




More information about the wine-cvs mailing list