[Xfce4-commits] [xfce/xfwm4] 01/01: Limit parallel moves before wrapping

noreply at xfce.org noreply at xfce.org
Tue Jan 13 23:04:41 CET 2015


This is an automated email from the git hooks/post-receive script.

olivier pushed a commit to branch master
in repository xfce/xfwm4.

commit df707c36a4d0d2903593855dd3575ff4a6aade23
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Tue Jan 13 23:00:31 2015 +0100

    Limit parallel moves before wrapping
    
    Bug 11456
    
    And a bit of code cleanup/refactorization as well.
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/client.h     |    4 ++
 src/events.c     |  104 +---------------------------
 src/moveresize.c |  202 +++++++++++++++++++++++++++---------------------------
 src/moveresize.h |    5 ++
 4 files changed, 111 insertions(+), 204 deletions(-)

diff --git a/src/client.h b/src/client.h
index 711d88c..1ca1afe 100644
--- a/src/client.h
+++ b/src/client.h
@@ -116,6 +116,10 @@
 #define MAX_BLINK_ITERATIONS            5
 #endif
 
+#ifndef MAX_SNAP_DRIFT
+#define MAX_SNAP_DRIFT                  5
+#endif
+
 #define XFWM_FLAG_HAS_BORDER            (1L<<0)
 #define XFWM_FLAG_HAS_MENU              (1L<<1)
 #define XFWM_FLAG_HAS_MAXIMIZE          (1L<<2)
diff --git a/src/events.c b/src/events.c
index fa21cd0..6e18983 100644
--- a/src/events.c
+++ b/src/events.c
@@ -82,8 +82,6 @@
 
 static GdkAtom atom_rcfiles = GDK_NONE;
 static xfwmWindow menu_event_window;
-static int edge_scroll_x = 0;
-static int edge_scroll_y = 0;
 
 /* Forward decl. */
 
@@ -1441,107 +1439,9 @@ handleEnterNotify (DisplayInfo *display_info, XCrossingEvent * ev)
         return EVENT_FILTER_PASS;
     }
 
-    if (screen_info->workspace_count && screen_info->params->wrap_workspaces
-        && screen_info->params->wrap_resistance)
+    if (screen_info->params->wrap_workspaces && screen_info->workspace_count > 1)
     {
-        int msx, msy, maxx, maxy;
-        int rx, ry, delta;
-
-        msx = ev->x_root;
-        msy = ev->y_root;
-        maxx = screen_info->width - 1;
-        maxy = screen_info->height - 1;
-        rx = 0;
-        ry = 0;
-        warp_pointer = FALSE;
-
-        if ((msx == 0) || (msx == maxx))
-        {
-            if ((ev->time - lastresist) > 250)  /* ms */
-            {
-                edge_scroll_x = 0;
-            }
-            else
-            {
-                edge_scroll_x++;
-            }
-            if (msx == 0)
-            {
-                rx = 1;
-            }
-            else
-            {
-                rx = -1;
-            }
-            warp_pointer = TRUE;
-            lastresist = ev->time;
-        }
-        if ((msy == 0) || (msy == maxy))
-        {
-            if ((ev->time - lastresist) > 250)  /* ms */
-            {
-                edge_scroll_y = 0;
-            }
-            else
-            {
-                edge_scroll_y++;
-            }
-            if (msy == 0)
-            {
-                ry = 1;
-            }
-            else
-            {
-                ry = -1;
-            }
-            warp_pointer = TRUE;
-            lastresist = ev->time;
-        }
-
-        if (edge_scroll_x > screen_info->params->wrap_resistance)
-        {
-            edge_scroll_x = 0;
-            delta = MAX (9 * maxx / 10, maxx - 5 * screen_info->params->wrap_resistance);
-            if (msx == 0)
-            {
-                if (workspaceMove (screen_info, 0, -1, NULL, ev->time))
-                {
-                    rx = delta;
-                }
-            }
-            else
-            {
-                if (workspaceMove (screen_info, 0, 1, NULL, ev->time))
-                {
-                    rx = -delta;
-                }
-            }
-            warp_pointer = TRUE;
-        }
-        if (edge_scroll_y > screen_info->params->wrap_resistance)
-        {
-            edge_scroll_y = 0;
-            delta = MAX (9 * maxy / 10, maxy - 5 * screen_info->params->wrap_resistance);
-            if (msy == 0)
-            {
-                if (workspaceMove (screen_info, -1, 0, NULL, ev->time))
-                {
-                    ry = delta;
-                }
-            }
-            else
-            {
-                if (workspaceMove (screen_info, 1, 0, NULL, ev->time))
-                {
-                    ry = -delta;
-                }
-            }
-            warp_pointer = TRUE;
-        }
-        if (warp_pointer)
-        {
-            XWarpPointer (display_info->dpy, None, None, 0, 0, 0, 0, rx, ry);
-        }
+        clientMoveWarp (NULL, screen_info, ev->x_root, ev->y_root, ev->time);
     }
 
     return EVENT_FILTER_REMOVE;
diff --git a/src/moveresize.c b/src/moveresize.c
index 73ac570..a957341 100644
--- a/src/moveresize.c
+++ b/src/moveresize.c
@@ -611,144 +611,140 @@ clientButtonReleaseFilter (XEvent * xevent, gpointer data)
     return EVENT_FILTER_CONTINUE;
 }
 
-static void
-clientMoveWarp (Client * c, XMotionEvent *xevent)
+void
+clientMoveWarp (Client * c, ScreenInfo * screen_info, int x_root, int y_root, guint32 timestamp)
 {
     static guint32 lastresist = 0;
     static int edge_scroll_x = 0;
     static int edge_scroll_y = 0;
-    ScreenInfo *screen_info;
-    DisplayInfo *display_info;
+    static int original_x = 0;
+    static int original_y = 0;
     gboolean warp_pointer = FALSE;
-    int msx, msy, maxx, maxy;
+    int maxx, maxy;
     int rx, ry, delta;
 
-    g_return_if_fail (c != NULL);
+    g_return_if_fail (screen_info != NULL);
     TRACE ("entering clientMoveWarp");
 
-    screen_info = c->screen_info;
-    display_info = screen_info->display_info;
-
-    if (xevent == NULL)
+    if ((c != NULL) && !(screen_info->params->wrap_windows))
     {
-        /* Cleanup */
-        edge_scroll_x = 0;
-        edge_scroll_y = 0;
         return;
     }
 
-    if ((screen_info->params->wrap_windows) && (screen_info->params->wrap_resistance))
+    if (!(screen_info->params->wrap_resistance) || !(screen_info->workspace_count > 1))
     {
+        return;
+    }
 
-        msx = xevent->x_root;
-        msy = xevent->y_root;
-        maxx = screen_info->width - 1;
-        maxy = screen_info->height - 1;
-        rx = 0;
-        ry = 0;
-        warp_pointer = FALSE;
+    maxx = screen_info->width - 1;
+    maxy = screen_info->height - 1;
+    rx = 0;
+    ry = 0;
+    warp_pointer = FALSE;
 
-        if ((msx == 0) || (msx == maxx))
+    if (edge_scroll_x == 0)
+    {
+        original_y = y_root;
+    }
+    if (edge_scroll_y == 0)
+    {
+        original_x = x_root;
+    }
+    if ((x_root == 0) || (x_root == maxx))
+    {
+        if ((timestamp - lastresist) > 250)  /* ms */
         {
-            if ((xevent->time - lastresist) > 250)  /* ms */
-            {
-                edge_scroll_x = 0;
-            }
-            else
-            {
-                edge_scroll_x++;
-            }
-            if (msx == 0)
-            {
-                rx = 1;
-            }
-            else
-            {
-                rx = -1;
-            }
-            warp_pointer = TRUE;
-            lastresist = xevent->time;
+            edge_scroll_x = 0;
         }
-        if ((msy == 0) || (msy == maxy))
+        else
         {
-            if ((xevent->time - lastresist) > 250)  /* ms */
-            {
-                edge_scroll_y = 0;
-            }
-            else
-            {
-                edge_scroll_y++;
-            }
-            if (msy == 0)
-            {
-                ry = 1;
-            }
-            else
-            {
-                ry = -1;
-            }
-            warp_pointer = TRUE;
-            lastresist = xevent->time;
+            edge_scroll_x++;
+        }
+        if (x_root == 0)
+        {
+            rx = 1;
+        }
+        else
+        {
+            rx = -1;
+        }
+        warp_pointer = TRUE;
+        lastresist = timestamp;
+    }
+    if ((y_root == 0) || (y_root == maxy))
+    {
+        if ((timestamp - lastresist) > 250)  /* ms */
+        {
+            edge_scroll_y = 0;
+        }
+        else
+        {
+            edge_scroll_y++;
+        }
+        if (y_root == 0)
+        {
+            ry = 1;
+        }
+        else
+        {
+            ry = -1;
         }
+        warp_pointer = TRUE;
+        lastresist = timestamp;
+    }
 
-        if (edge_scroll_x > screen_info->params->wrap_resistance)
+    if (edge_scroll_x > screen_info->params->wrap_resistance)
+    {
+        edge_scroll_x = 0;
+        if ((ABS(y_root - original_y) < MAX_SNAP_DRIFT) && ((x_root == 0) || (x_root == maxx)))
         {
-            edge_scroll_x = 0;
-            if ((msx == 0) || (msx == maxx))
+            delta = MAX (9 * maxx / 10, maxx - 5 * screen_info->params->wrap_resistance);
+            if (x_root == 0)
             {
-                delta = MAX (9 * maxx / 10, maxx - 5 * screen_info->params->wrap_resistance);
-                if (msx == 0)
+                if (workspaceMove (screen_info, 0, -1, c, timestamp))
                 {
-                    if (workspaceMove (screen_info, 0, -1, c, xevent->time))
-                    {
-                        rx = delta;
-                    }
+                    rx = delta;
                 }
-                else
+            }
+            else
+            {
+                if (workspaceMove (screen_info, 0, 1, c, timestamp))
                 {
-                    if (workspaceMove (screen_info, 0, 1, c, xevent->time))
-                    {
-                        rx = -delta;
-                    }
+                    rx = -delta;
                 }
-                warp_pointer = TRUE;
             }
-            lastresist = 0;
+            warp_pointer = TRUE;
         }
-        if (edge_scroll_y > screen_info->params->wrap_resistance)
+        lastresist = 0;
+    }
+    if (edge_scroll_y > screen_info->params->wrap_resistance)
+    {
+        edge_scroll_y = 0;
+        if ((ABS(x_root - original_x) < MAX_SNAP_DRIFT) && ((y_root == 0) || (y_root == maxy)))
         {
-            edge_scroll_y = 0;
-            if ((msy == 0) || (msy == maxy))
+            delta = MAX (9 * maxy / 10, maxy - 5 * screen_info->params->wrap_resistance);
+            if (y_root == 0)
             {
-                delta = MAX (9 * maxy / 10, maxy - 5 * screen_info->params->wrap_resistance);
-                if (msy == 0)
+                if (workspaceMove (screen_info, -1, 0, c, timestamp))
                 {
-                    if (workspaceMove (screen_info, -1, 0, c, xevent->time))
-                    {
-                        ry = delta;
-                    }
+                    ry = delta;
                 }
-                else
+            }
+            else
+            {
+                if (workspaceMove (screen_info, 1, 0, c, timestamp))
                 {
-                    if (workspaceMove (screen_info, 1, 0, c, xevent->time))
-                    {
-                        ry = -delta;
-                    }
+                    ry = -delta;
                 }
-                warp_pointer = TRUE;
             }
-            lastresist = 0;
-        }
-
-        if (warp_pointer)
-        {
-            XWarpPointer (display_info->dpy, None, None, 0, 0, 0, 0, rx, ry);
-            msx += rx;
-            msy += ry;
+            warp_pointer = TRUE;
         }
+        lastresist = 0;
+    }
 
-        xevent->x_root = msx;
-        xevent->y_root = msy;
+    if (warp_pointer)
+    {
+        XWarpPointer (myScreenGetXDisplay(screen_info), None, None, 0, 0, 0, 0, rx, ry);
     }
 }
 
@@ -926,7 +922,10 @@ clientMoveEventFilter (XEvent * xevent, gpointer data)
         }
         if ((screen_info->workspace_count > 1) && !(passdata->is_transient))
         {
-            clientMoveWarp (c, (XMotionEvent *) xevent);
+            clientMoveWarp (c, screen_info,
+                            xevent->xmotion.x_root,
+                            xevent->xmotion.y_root,
+                            xevent->xmotion.time);
         }
 
         if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
@@ -1025,7 +1024,6 @@ clientMoveEventFilter (XEvent * xevent, gpointer data)
     if (!moving)
     {
         TRACE ("event loop now finished");
-        clientMoveWarp (c, NULL);
         if (!FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
         {
             clientSaveSizePos (c);
diff --git a/src/moveresize.h b/src/moveresize.h
index f6ffc9b..1344d08 100644
--- a/src/moveresize.h
+++ b/src/moveresize.h
@@ -39,6 +39,11 @@ void                     clientSetWidth                         (Client *,
 void                     clientSetHeight                        (Client *,
                                                                  int,
                                                                  gboolean);
+void                     clientMoveWarp                         (Client *,
+                                                                 ScreenInfo *,
+                                                                 int,
+                                                                 int,
+                                                                 guint32);
 void                     clientMove                             (Client *,
                                                                  XEvent *);
 void                     clientResize                           (Client *,

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list