minor changes to x11 cursor grab wrapping
authorCampbell Barton <ideasman42@gmail.com>
Sun, 18 Oct 2009 09:55:39 +0000 (09:55 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 18 Oct 2009 09:55:39 +0000 (09:55 +0000)
- when wrapping 2 mouse events were added.
- on release blender still had the last event (possibly outside the screen), where menus would fail to show. Add a mouse event by calling XWarpPointer with no movement when leaving grab.

intern/ghost/intern/GHOST_SystemX11.cpp
intern/ghost/intern/GHOST_WindowX11.cpp
source/blender/windowmanager/intern/wm_cursors.c

index 774fd025b854ef25f35db3ac25fb1c65d90a8110..ff4a5956a1287243a4d998171ff8841c84cbf35b 100644 (file)
@@ -405,19 +405,21 @@ GHOST_SystemX11::processEvent(XEvent *xe)
                                window->getCursorGrabAccum(x_accum, y_accum);
 
                                if(x_new != xme.x_root || y_new != xme.y_root) {
+                                       /* when wrapping we don't need to add an event because the
+                                        * setCursorPosition call will cause a new event after */
                                        setCursorPosition(x_new, y_new); /* wrap */
                                        window->setCursorGrabAccum(x_accum + (xme.x_root - x_new), y_accum + (xme.y_root - y_new));
                                }
-
-                               g_event = new
-                               GHOST_EventCursor(
-                                       getMilliSeconds(),
-                                       GHOST_kEventCursorMove,
-                                       window,
-                                       xme.x_root + x_accum,
-                                       xme.y_root + y_accum
-                               );
-
+                               else {
+                                       g_event = new
+                                       GHOST_EventCursor(
+                                               getMilliSeconds(),
+                                               GHOST_kEventCursorMove,
+                                               window,
+                                               xme.x_root + x_accum,
+                                               xme.y_root + y_accum
+                                       );
+                               }
                        }
                        else {
                                g_event = new
index dba1be1b86275b8521e73bfcfc236e3557f74794..95441e74771b9dd56050e07cb693d452d1ae6f28 100644 (file)
@@ -1419,6 +1419,13 @@ setWindowCursorGrab(
                        setWindowCursorVisibility(true);
                }
 
+               if(m_cursorGrab != GHOST_kGrabNormal) {
+                       /* use to generate a mouse move event, otherwise the last event
+                        * blender gets can be outside the screen causing menus not to show
+                        * properly unless the user moves the mouse */
+                       XWarpPointer(m_display,None,None,0,0,0,0,0,0);
+               }
+
                /* Almost works without but important otherwise the mouse GHOST location can be incorrect on exit */
                setCursorGrabAccum(0, 0);
                m_cursorGrabBounds.m_l= m_cursorGrabBounds.m_r= -1; /* disable */
index 5fe62157979f51b4746114229f44b8b0d4e48972..e2aedf42bd81a55d9458831ac76c2757092e00e0 100644 (file)
@@ -169,7 +169,6 @@ void WM_cursor_grab(wmWindow *win, int wrap, int hide, int *bounds)
         * It helps not to get a stuck WM when hitting a breakpoint  
         * */
        GHOST_TGrabCursorMode mode = GHOST_kGrabNormal;
-       int bounds_arr[4] = {-1, -1, -1, -1}; /* l/t/r/b */
 
        if(hide)                mode = GHOST_kGrabHide;
        else if(wrap)   mode = GHOST_kGrabWrap;