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

noreply at xfce.org noreply at xfce.org
Tue Mar 10 22:24:55 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 80647b97e23782c925cb1c2c99ff38e9bae50722
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Tue Mar 10 21:54:02 2015 +0100

    Fix window positioning and gravity
    
    Bug: 11670
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/client.c |   54 +++++++++++++++++++++++++++++++++++-------------------
 src/client.h |    4 ++--
 src/events.c |    2 +-
 src/netwm.c  |    2 +-
 4 files changed, 39 insertions(+), 23 deletions(-)

diff --git a/src/client.c b/src/client.c
index 79de331..117ad51 100644
--- a/src/client.c
+++ b/src/client.c
@@ -447,6 +447,28 @@ clientUpdateUrgency (Client *c)
     }
 }
 
+/* ICCCM Section 4 - Client to Window Manager Communication
+ *
+ * The win_gravity may be any of the values specified for WINGRAVITY in the core
+ * protocol  except  for  Unmap  :  NorthWest (1),  North  (2),  NorthEast  (3),
+ * West (4), Center (5), East (6), SouthWest (7), South (8),  and SouthEast (9).
+ * It specifies how  and whether the client  window wants to be shifted to  make
+ * room for the window manager frame.
+ *
+ * If the win_gravity is Static , the window manager frame is positioned so that
+ * the  inside  border of  the  client  window  inside the frame  is in the same
+ * position  on the screen  as it was when the client  requested  the transition
+ * from Withdrawn state.  Other values of win_gravity specify a window reference
+ * point.  For NorthWest ,  NorthEast ,  SouthWest , and SouthEast the reference
+ * point  is  the  specified outer  corner of the window  (on the outside border
+ * edge).  For North , South , East , and West the reference point is the center
+ * of the specified  outer edge of the window border.   For Center the reference
+ * point is the center of the window.  The reference point of the window manager
+ * frame is placed  at the location on the screen  where the reference point  of
+ * the client window was when the client requested the transition from Withdrawn
+ * state.
+ */
+
 void
 clientCoordGravitate (Client *c, int gravity, int mode, int *x, int *y)
 {
@@ -458,46 +480,40 @@ clientCoordGravitate (Client *c, int gravity, int mode, int *x, int *y)
     switch (gravity)
     {
         case CenterGravity:
-            dx = (c->border_width * 2) - ((frameExtentLeft (c) +
-                    frameExtentRight (c)) / 2);
-            dy = (c->border_width * 2) - ((frameExtentTop (c) +
-                    frameExtentBottom (c)) / 2);
+            dx = (c->border_width * 2) - (frameExtentWidth (c) / 2) + frameExtentLeft (c);
+            dy = (c->border_width * 2) - (frameExtentHeight (c) / 2) + frameExtentTop (c);
             break;
         case NorthGravity:
-            dx = (c->border_width * 2) - ((frameExtentLeft (c) +
-                    frameExtentRight (c)) / 2);
+            dx = (c->border_width * 2) - (frameExtentWidth (c) / 2) + frameExtentLeft (c);
             dy = frameExtentTop (c);
             break;
         case SouthGravity:
-            dx = (c->border_width * 2) - ((frameExtentLeft (c) +
-                    frameExtentRight (c)) / 2);
-            dy = (c->border_width * 2) - frameExtentBottom (c);
+            dx = (c->border_width * 2) - (frameExtentWidth (c) / 2) + frameExtentLeft (c);
+            dy = (c->border_width * 2) - c->height - frameExtentBottom (c);
             break;
         case EastGravity:
-            dx = (c->border_width * 2) - frameExtentRight (c);
-            dy = (c->border_width * 2) - ((frameExtentTop (c) +
-                    frameExtentBottom (c)) / 2);
+            dx = (c->border_width * 2) - c->width - frameExtentRight (c);
+            dy = (c->border_width * 2) - (frameExtentHeight (c) / 2) + frameExtentTop (c);
             break;
         case WestGravity:
             dx = frameExtentLeft (c);
-            dy = (c->border_width * 2) - ((frameExtentTop (c) +
-                    frameExtentBottom (c)) / 2);
+            dy = (c->border_width * 2) - (frameExtentHeight (c) / 2) + frameExtentTop (c);
             break;
         case NorthWestGravity:
             dx = frameExtentLeft (c);
             dy = frameExtentTop (c);
             break;
         case NorthEastGravity:
-            dx = (c->border_width * 2) - frameExtentRight (c);
+            dx = (c->border_width * 2) - c->width - frameExtentRight (c);
             dy = frameExtentTop (c);
             break;
         case SouthWestGravity:
             dx = frameExtentLeft (c);
-            dy = (c->border_width * 2) - frameExtentBottom (c);
+            dy = (c->border_width * 2) - c->height - frameExtentBottom (c);
             break;
         case SouthEastGravity:
-            dx = (c->border_width * 2) - frameExtentRight (c);
-            dy = (c->border_width * 2) - frameExtentBottom (c);
+            dx = (c->border_width * 2) - c->width - frameExtentRight (c);
+            dy = (c->border_width * 2) - c->height - frameExtentBottom (c);
             break;
         default:
             dx = 0;
@@ -509,7 +525,7 @@ clientCoordGravitate (Client *c, int gravity, int mode, int *x, int *y)
 }
 
 void
-clientAdjustCoordGravity (Client *c, int gravity, unsigned long *mask, XWindowChanges *wc)
+clientAdjustCoordGravity (Client *c, int gravity, XWindowChanges *wc, unsigned long *mask)
 {
     int tx, ty, dw, dh;
 
diff --git a/src/client.h b/src/client.h
index 4dc2fac..7aa93f3 100644
--- a/src/client.h
+++ b/src/client.h
@@ -381,8 +381,8 @@ void                     clientCoordGravitate                   (Client *,
                                                                  int *);
 void                     clientAdjustCoordGravity               (Client *,
                                                                  int,
-                                                                 unsigned long *,
-                                                                 XWindowChanges *);
+                                                                 XWindowChanges *,
+                                                                 unsigned long *);
 void                     clientSendConfigureNotify              (Client *);
 void                     clientConfigure                        (Client *,
                                                                  XWindowChanges *,
diff --git a/src/events.c b/src/events.c
index 561cd5c..2613196 100644
--- a/src/events.c
+++ b/src/events.c
@@ -1357,8 +1357,8 @@ handleConfigureRequest (DisplayInfo *display_info, XConfigureRequestEvent * ev)
             /* Sorry, but it's not the right time for configure request */
             return EVENT_FILTER_REMOVE;
         }
+        clientAdjustCoordGravity (c, c->gravity, &wc, &ev->value_mask);
         clientMoveResizeWindow (c, &wc, ev->value_mask);
-        clientAdjustCoordGravity (c, c->gravity, &ev->value_mask, &wc);
     }
     else
     {
diff --git a/src/netwm.c b/src/netwm.c
index 81e830a..3359201 100644
--- a/src/netwm.c
+++ b/src/netwm.c
@@ -753,7 +753,7 @@ clientNetMoveResizeWindow (Client * c, XClientMessageEvent * ev)
     wc.height = ev->data.l[4];
     mask = (ev->data.l[0] & 0xf00) >> 8;
 
-    clientAdjustCoordGravity (c, gravity, &mask, &wc);
+    clientAdjustCoordGravity (c, gravity, &wc, &mask);
     clientMoveResizeWindow (c, &wc, mask);
 }
 

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


More information about the Xfce4-commits mailing list