[Xfce4-commits] [xfce/xfwm4] 01/02: Fix gravity

noreply at xfce.org noreply at xfce.org
Sat Mar 14 22:19:58 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 76bfe009afcfa1cd2884e202dfc8f5d10bfa604c
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Sat Mar 14 22:02:01 2015 +0100

    Fix gravity
    
    Bug: 11693
    
    Fix a long standing bug with gravity which was partly due to a wrong
    interpretation of the gravity definition from bug 3634 where the
    reproducer provided was actually wrong.
    
    Gravity does not change the actual reference point of the client
    window, but rather "specifies how and whether the client window wants
    to be shifted to make room for the window manager frame" (from the
    ICCCM definition).
    
    This makes xfwm4 behave the same as other window managers such as
    metacity/mutter or kwin with regard to window gravity.
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/client.c     |   60 +++++++++++++++++++++++++++++++------------------
 src/moveresize.c |   66 +++++++++++++++++++++++++++++-------------------------
 src/moveresize.h |    4 ++--
 3 files changed, 76 insertions(+), 54 deletions(-)

diff --git a/src/client.c b/src/client.c
index 117ad51..7fa9e36 100644
--- a/src/client.c
+++ b/src/client.c
@@ -480,41 +480,42 @@ clientCoordGravitate (Client *c, int gravity, int mode, int *x, int *y)
     switch (gravity)
     {
         case CenterGravity:
-            dx = (c->border_width * 2) - (frameExtentWidth (c) / 2) + frameExtentLeft (c);
-            dy = (c->border_width * 2) - (frameExtentHeight (c) / 2) + frameExtentTop (c);
+            dx = (frameLeft (c) - frameRight (c) + 1) / 2;
+            dy = (frameTop (c) - frameBottom (c) + 1) / 2;
             break;
         case NorthGravity:
-            dx = (c->border_width * 2) - (frameExtentWidth (c) / 2) + frameExtentLeft (c);
-            dy = frameExtentTop (c);
+            dx = (frameLeft (c) - frameRight (c) + 1) / 2;
+            dy = frameTop (c);
             break;
         case SouthGravity:
-            dx = (c->border_width * 2) - (frameExtentWidth (c) / 2) + frameExtentLeft (c);
-            dy = (c->border_width * 2) - c->height - frameExtentBottom (c);
+            dx = (frameLeft (c) - frameRight (c) + 1) / 2;
+            dy = - frameBottom (c);
             break;
         case EastGravity:
-            dx = (c->border_width * 2) - c->width - frameExtentRight (c);
-            dy = (c->border_width * 2) - (frameExtentHeight (c) / 2) + frameExtentTop (c);
+            dx = - frameRight (c);
+            dy = (frameTop (c) - frameBottom (c) + 1) / 2;
             break;
         case WestGravity:
-            dx = frameExtentLeft (c);
-            dy = (c->border_width * 2) - (frameExtentHeight (c) / 2) + frameExtentTop (c);
+            dx = frameLeft (c);
+            dy = (frameTop (c) - frameBottom (c) + 1) / 2;
             break;
         case NorthWestGravity:
-            dx = frameExtentLeft (c);
-            dy = frameExtentTop (c);
+            dx = frameLeft (c);
+            dy = frameTop (c);
             break;
         case NorthEastGravity:
-            dx = (c->border_width * 2) - c->width - frameExtentRight (c);
-            dy = frameExtentTop (c);
+            dx = - frameRight (c);
+            dy = frameTop (c);
             break;
         case SouthWestGravity:
-            dx = frameExtentLeft (c);
-            dy = (c->border_width * 2) - c->height - frameExtentBottom (c);
+            dx = frameLeft (c);
+            dy = - frameBottom (c);
             break;
         case SouthEastGravity:
-            dx = (c->border_width * 2) - c->width - frameExtentRight (c);
-            dy = (c->border_width * 2) - c->height - frameExtentBottom (c);
+            dx = - frameRight (c);
+            dy = - frameBottom (c);
             break;
+        case StaticGravity:
         default:
             dx = 0;
             dy = 0;
@@ -534,12 +535,26 @@ clientAdjustCoordGravity (Client *c, int gravity, XWindowChanges *wc, unsigned l
 
     tx = wc->x;
     ty = wc->y;
-    clientCoordGravitate (c, gravity, APPLY, &tx, &ty);
+
+    if (*mask & (CWX | CWY))
+    {
+        clientCoordGravitate (c, gravity, APPLY, &tx, &ty);
+    }
+
+    if (*mask & CWWidth)
+    {
+        wc->width = clientCheckHeight (c, wc->width, TRUE);
+    }
+
+    if (*mask & CWWidth)
+    {
+        wc->height = clientCheckWidth (c, wc->height, TRUE);
+    }
 
     switch (gravity)
     {
         case CenterGravity:
-            dw = (c->width  - wc->width)  / 2;
+            dw = (c->width - wc->width) / 2;
             dh = (c->height - wc->height) / 2;
             break;
         case NorthGravity:
@@ -574,6 +589,7 @@ clientAdjustCoordGravity (Client *c, int gravity, XWindowChanges *wc, unsigned l
             dw = (c->width  - wc->width);
             dh = (c->height - wc->height);
             break;
+        case StaticGravity:
         default:
             dw = 0;
             dh = 0;
@@ -710,11 +726,11 @@ clientConfigure (Client *c, XWindowChanges * wc, unsigned long mask, unsigned sh
     }
     if (mask & CWWidth)
     {
-        clientSetWidth (c, wc->width, flags & CFG_REQUEST);
+        c-> width = clientCheckWidth (c, wc->width, flags & CFG_REQUEST);
     }
     if (mask & CWHeight)
     {
-        clientSetHeight (c, wc->height, flags & CFG_REQUEST);
+        c->height = clientCheckHeight (c, wc->height, flags & CFG_REQUEST);
     }
     if (mask & CWBorderWidth)
     {
diff --git a/src/moveresize.c b/src/moveresize.c
index fdc4c11..515b169 100644
--- a/src/moveresize.c
+++ b/src/moveresize.c
@@ -88,12 +88,15 @@ struct _MoveResizeData
     Poswin *poswin;
 };
 
-static void
-clientSetSize (Client * c, int *size, int base, int min, int max, int incr, gboolean source_is_application)
+static int
+clientCheckSize (Client * c, int size, int base, int min, int max, int incr, gboolean source_is_application)
 {
+    int size_return;
+
     g_return_if_fail (c != NULL);
-    g_return_if_fail (size != NULL);
-    TRACE ("entering clientSetSize");
+    TRACE ("entering clientCheckSize");
+
+    size_return = size;
 
     /* Bypass resize increment and max sizes for fullscreen */
     if (!FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)
@@ -111,57 +114,60 @@ clientSetSize (Client * c, int *size, int base, int min, int max, int incr, gboo
                 b = base;
             }
 
-            a = (*size - b) / incr;
-            *size = b + (a * incr);
+            a = (size_return - b) / incr;
+            size_return = b + (a * incr);
         }
         if (c->size->flags & PMaxSize)
         {
-            if (*size > max)
+            if (size_return > max)
             {
-                *size = max;
+                size_return = max;
             }
         }
     }
 
     if (c->size->flags & PMinSize)
     {
-        if (*size < min)
+        if (size_return < min)
         {
-            *size = min;
+            size_return = min;
         }
     }
-    if (*size < 1)
+    if (size_return < 1)
     {
-        *size = 1;
+        size_return = 1;
     }
+    return size_return;
 }
 
-void
-clientSetWidth (Client * c, int w, gboolean source_is_application)
+int
+clientCheckWidth (Client * c, int w, gboolean source_is_application)
 {
-    int temp;
-
     g_return_if_fail (c != NULL);
-    TRACE ("entering clientSetWidth");
+    TRACE ("entering clientCheckWidth");
     TRACE ("setting width %i for client \"%s\" (0x%lx)", w, c->name, c->window);
 
-    temp = w;
-    clientSetSize (c, &temp,  c->size->base_width, c->size->min_width, c->size->max_width, c->size->width_inc, source_is_application);
-    c->width = temp;
+    return clientCheckSize (c, w,
+                            c->size->base_width,
+                            c->size->min_width,
+                            c->size->max_width,
+                            c->size->width_inc,
+                            source_is_application);
 }
 
-void
-clientSetHeight (Client * c, int h, gboolean source_is_application)
+int
+clientCheckHeight (Client * c, int h, gboolean source_is_application)
 {
-    int temp;
-
     g_return_if_fail (c != NULL);
-    TRACE ("entering clientSetHeight");
+    TRACE ("entering clientCheckHeight");
     TRACE ("setting height %i for client \"%s\" (0x%lx)", h, c->name, c->window);
 
-    temp = h;
-    clientSetSize (c, &temp, c->size->base_height, c->size->min_height, c->size->max_height, c->size->height_inc, source_is_application);
-    c->height = temp;
+    return clientCheckSize (c, h,
+                            c->size->base_height,
+                            c->size->min_height,
+                            c->size->max_height,
+                            c->size->height_inc,
+                            source_is_application);
 }
 
 static void
@@ -1597,13 +1603,13 @@ clientResizeEventFilter (XEvent * xevent, gpointer data)
         /* Apply contrain ratio if any, only once the expected size is set */
         clientConstrainRatio (c, passdata->handle);
 
-        clientSetWidth (c, c->width, FALSE);
+        clientCheckWidth (c, c->width, FALSE);
         if (move_left)
         {
             c->x = right_edge - c->width;
         }
 
-        clientSetHeight (c, c->height, FALSE);
+        clientCheckHeight (c, c->height, FALSE);
         if (move_top && !FLAG_TEST (c->flags, CLIENT_FLAG_SHADED))
         {
             c->y =  bottom_edge - c->height;
diff --git a/src/moveresize.h b/src/moveresize.h
index 07ab639..7e4f2ea 100644
--- a/src/moveresize.h
+++ b/src/moveresize.h
@@ -33,10 +33,10 @@
 
 #ifndef INC_MOVERESIZE_H
 #define INC_MOVERESIZE_H
-void                     clientSetWidth                         (Client *,
+int                      clientCheckWidth                       (Client *,
                                                                  int,
                                                                  gboolean);
-void                     clientSetHeight                        (Client *,
+int                      clientCheckHeight                      (Client *,
                                                                  int,
                                                                  gboolean);
 void                     clientMoveWarp                         (Client *,

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


More information about the Xfce4-commits mailing list