Author: olivier
Date: 2008-10-21 20:28:13 +0000 (Tue, 21 Oct 2008)
New Revision: 28349

Modified:
   xfwm4/branches/xfce_4_4/NEWS
   xfwm4/branches/xfce_4_4/src/client.c
   xfwm4/branches/xfce_4_4/src/client.h
   xfwm4/branches/xfce_4_4/src/display.c
   xfwm4/branches/xfce_4_4/src/display.h
   xfwm4/branches/xfce_4_4/src/events.c
   xfwm4/branches/xfce_4_4/src/hints.c
   xfwm4/branches/xfce_4_4/src/netwm.c
   xfwm4/branches/xfce_4_4/src/netwm.h
Log:
Backport fron trunk, Add support for NET_MOVERESIZE_WINDOW, take gravity bit 
into account in configure resize only requests to comply with standard (bug 
#3634)

Modified: xfwm4/branches/xfce_4_4/NEWS
===================================================================
--- xfwm4/branches/xfce_4_4/NEWS        2008-10-21 20:12:41 UTC (rev 28348)
+++ xfwm4/branches/xfce_4_4/NEWS        2008-10-21 20:28:13 UTC (rev 28349)
@@ -15,6 +15,9 @@
 - Loosen the rule that prevents an application from iconifying itself when 
   skip_taskbar is set (Bug #4434)
 - Rework visual depth selection of the frame window (Bug #4452)
+- Add support for NET_MOVERESIZE_WINDOW
+- Take gravity bit into account in configure resize only requests to comply 
+  with standard (bug #3634)
 
 4.4.2
 =====

Modified: xfwm4/branches/xfce_4_4/src/client.c
===================================================================
--- xfwm4/branches/xfce_4_4/src/client.c        2008-10-21 20:12:41 UTC (rev 
28348)
+++ xfwm4/branches/xfce_4_4/src/client.c        2008-10-21 20:28:13 UTC (rev 
28349)
@@ -236,8 +236,8 @@
         }
         if (mask & UPDATE_GRAVITY)
         {
-            clientGravitate (c, REMOVE);
-            clientGravitate (c, APPLY);
+            clientCoordGravitate (c, c->gravity, REMOVE, &c->x, &c->y);
+            clientCoordGravitate (c, c->gravity, APPLY, &c->x, &c->y);
             setNetFrameExtents (screen_info->display_info,
                                 c->window,
                                 frameTop (c),
@@ -364,15 +364,14 @@
 }
 
 void
-clientCoordGravitate (Client * c, int mode, int *x, int *y)
+clientCoordGravitate (Client * c, int gravity, int mode, int *x, int *y)
 {
     int dx, dy;
 
     g_return_if_fail (c != NULL);
     TRACE ("entering clientCoordGravitate");
 
-    c->gravity = c->size->flags & PWinGravity ? c->size->win_gravity : 
NorthWestGravity;
-    switch (c->gravity)
+    switch (gravity)
     {
         case CenterGravity:
             dx = (c->border_width * 2) - ((frameLeft (c) +
@@ -426,6 +425,83 @@
 }
 
 void
+clientAdjustCoordGravity (Client * c, int gravity, unsigned long *mask, 
XWindowChanges *wc)
+{
+    int tx, ty, dw, dh;
+
+    g_return_if_fail (c != NULL);
+    TRACE ("entering clientAdjustCoordGravity");
+
+    tx = wc->x;
+    ty = wc->y;
+    clientCoordGravitate (c, gravity, APPLY, &tx, &ty);
+
+    switch (gravity)
+    {
+        case CenterGravity:
+            dw = (c->width  - wc->width)  / 2;
+            dh = (c->height - wc->height) / 2;
+            break;
+        case NorthGravity:
+            dw = (c->width - wc->width) / 2;
+            dh = 0;
+            break;
+        case SouthGravity:
+            dw = (c->width  - wc->width) / 2;
+            dh = (c->height - wc->height);
+            break;
+        case EastGravity:
+            dw = (c->width  - wc->width);
+            dh = (c->height - wc->height) / 2;
+            break;
+        case WestGravity:
+            dw = 0;
+            dh = (c->height - wc->height) / 2;
+            break;
+        case NorthWestGravity:
+            dw = 0;
+            dh = 0;
+            break;
+        case NorthEastGravity:
+            dw = (c->width - wc->width);
+            dh = 0;
+            break;
+        case SouthWestGravity:
+            dw = 0;
+            dh = (c->height - wc->height);
+            break;
+        case SouthEastGravity:
+            dw = (c->width  - wc->width);
+            dh = (c->height - wc->height);
+            break;
+        default:
+            dw = 0;
+            dh = 0;
+            break;
+    }
+
+    if (*mask & CWX)
+    {
+        wc->x = tx;
+    }
+    else if (*mask & CWWidth)
+    {
+        wc->x = c->x + dw;
+        *mask |= CWX;
+    }
+
+    if (*mask & CWY)
+    {
+        wc->y = ty;
+    }
+    else if (*mask & CWHeight)
+    {
+        wc->y = c->y + dh;
+        *mask |= CWY;
+    }
+}
+
+void
 clientGravitate (Client * c, int mode)
 {
     int x, y;
@@ -435,7 +511,7 @@
 
     x = c->x;
     y = c->y;
-    clientCoordGravitate (c, mode, &x, &y);
+    clientCoordGravitate (c, c->gravity, mode, &x, &y);
     c->x = x;
     c->y = y;
 }
@@ -851,6 +927,110 @@
 }
 
 void
+clientMoveResizeWindow (Client * c, XWindowChanges * wc, unsigned long mask)
+{
+    ScreenInfo *screen_info;
+    DisplayInfo *display_info;
+    gboolean constrained;
+
+    g_return_if_fail (c != NULL);
+    TRACE ("entering clientMoveResizeWindow");
+    TRACE ("client \"%s\" (0x%lx)", c->name, c->window);
+
+    screen_info = c->screen_info;
+    display_info = screen_info->display_info;
+    if (c->type == WINDOW_DESKTOP)
+    {
+        /* Ignore stacking request for DESKTOP windows */
+        mask &= ~(CWSibling | CWStackMode);
+    }
+    if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
+    {
+        GdkRectangle rect;
+        gint monitor_nbr;
+        int cx, cy;
+
+        /* size request from fullscreen windows get fullscreen */
+
+        cx = frameX (c) + (frameWidth (c) / 2);
+        cy = frameY (c) + (frameHeight (c) / 2);
+
+        monitor_nbr = find_monitor_at_point (screen_info->gscr, cx, cy);
+        gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr, 
&rect);
+
+        wc->x = rect.x;
+        wc->y = rect.y;
+        wc->width = rect.width;
+        wc->height = rect.height;
+
+        mask |= (CWX | CWY | CWWidth | CWHeight);
+    }
+    else if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED)
+             && (screen_info->params->borderless_maximize))
+    {
+        wc->x = c->x;
+        wc->y = c->y;
+        wc->width = c->width;
+        wc->height = c->height;
+    }
+    /* Clean up buggy requests that set all flags */
+    if ((mask & CWX) && (wc->x == c->x))
+    {
+        mask &= ~CWX;
+    }
+    if ((mask & CWY) && (wc->y == c->y))
+    {
+        mask &= ~CWY;
+    }
+    if ((mask & CWWidth) && (wc->width == c->width))
+    {
+        mask &= ~CWWidth;
+    }
+    if ((mask & CWHeight) && (wc->height == c->height))
+    {
+        mask &= ~CWHeight;
+    }
+
+    /* Still a move/resize after cleanup? */
+    constrained = FALSE;
+    if (mask & (CWX | CWY | CWWidth | CWHeight))
+    {
+        if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
+        {
+            clientRemoveMaximizeFlag (c);
+        }
+        constrained = TRUE;
+    }
+    /*
+       Let's say that if the client performs a XRaiseWindow, we show the 
window if focus
+       stealing prevention is not activated, otherwise we just set the 
"demands attention"
+       flag...
+     */
+    if ((mask & CWStackMode) && (wc->stack_mode == Above) && (wc->sibling == 
None) && !(c->type & WINDOW_TYPE_DONT_FOCUS))
+    {
+        Client *last_raised;
+
+        last_raised = clientGetLastRaise (screen_info);
+        if (last_raised && (c != last_raised))
+        {
+            if ((screen_info->params->prevent_focus_stealing) && 
(screen_info->params->activate_action == ACTIVATE_ACTION_NONE))
+            {
+                mask &= ~(CWSibling | CWStackMode);
+                TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" 
(0x%lx)", c->name, c->window);
+                FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
+                clientSetNetState (c);
+            }
+            else
+            {
+                clientActivate (c, getXServerTime (display_info));
+            }
+        }
+    }
+    /* And finally, configure the window */
+    clientConfigure (c, wc, mask, (constrained ? CFG_CONSTRAINED : 0) | 
CFG_REQUEST);
+}
+
+void
 clientGetMWMHints (Client * c, gboolean update)
 {
     ScreenInfo *screen_info;
@@ -986,6 +1166,9 @@
         c->size->flags = 0;
     }
 
+    /* Set/update gravity */
+    c->gravity = c->size->flags & PWinGravity ? c->size->win_gravity : 
NorthWestGravity;
+
     previous_value = FLAG_TEST (c->xfwm_flags, XFWM_FLAG_IS_RESIZABLE);
     FLAG_UNSET (c->xfwm_flags, XFWM_FLAG_IS_RESIZABLE);
 

Modified: xfwm4/branches/xfce_4_4/src/client.h
===================================================================
--- xfwm4/branches/xfce_4_4/src/client.h        2008-10-21 20:12:41 UTC (rev 
28348)
+++ xfwm4/branches/xfce_4_4/src/client.h        2008-10-21 20:28:13 UTC (rev 
28349)
@@ -308,14 +308,22 @@
 void                     clientUpdateUrgency                    (Client *);
 void                     clientCoordGravitate                   (Client *,
                                                                  int,
+                                                                 int,
                                                                  int *,
                                                                  int *);
+void                     clientAdjustCoordGravity               (Client *,
+                                                                 int,
+                                                                 unsigned long 
*,
+                                                                 
XWindowChanges *);
 void                     clientGravitate                        (Client *,
                                                                  int);
 void                     clientConfigure                        (Client *,
                                                                  
XWindowChanges *,
                                                                  unsigned long,
                                                                  unsigned 
short);
+void                     clientMoveResizeWindow                 (Client *,
+                                                                 
XWindowChanges *,
+                                                                 unsigned 
long);
 void                     clientGetMWMHints                      (Client *,
                                                                  gboolean);
 void                     clientGetWMNormalHints                 (Client *,

Modified: xfwm4/branches/xfce_4_4/src/display.c
===================================================================
--- xfwm4/branches/xfce_4_4/src/display.c       2008-10-21 20:12:41 UTC (rev 
28348)
+++ xfwm4/branches/xfce_4_4/src/display.c       2008-10-21 20:28:13 UTC (rev 
28349)
@@ -88,6 +88,7 @@
         "_NET_DESKTOP_NAMES",
         "_NET_DESKTOP_VIEWPORT",
         "_NET_FRAME_EXTENTS",
+        "_NET_MOVERESIZE_WINDOW",
         "_NET_NUMBER_OF_DESKTOPS",
         "_NET_REQUEST_FRAME_EXTENTS",
         "_NET_SHOWING_DESKTOP",

Modified: xfwm4/branches/xfce_4_4/src/display.h
===================================================================
--- xfwm4/branches/xfce_4_4/src/display.h       2008-10-21 20:12:41 UTC (rev 
28348)
+++ xfwm4/branches/xfce_4_4/src/display.h       2008-10-21 20:28:13 UTC (rev 
28349)
@@ -130,6 +130,7 @@
     NET_DESKTOP_NAMES,
     NET_DESKTOP_VIEWPORT,
     NET_FRAME_EXTENTS,
+    NET_MOVERESIZE_WINDOW,
     NET_NUMBER_OF_DESKTOPS,
     NET_REQUEST_FRAME_EXTENTS,
     NET_SHOWING_DESKTOP,

Modified: xfwm4/branches/xfce_4_4/src/events.c
===================================================================
--- xfwm4/branches/xfce_4_4/src/events.c        2008-10-21 20:12:41 UTC (rev 
28348)
+++ xfwm4/branches/xfce_4_4/src/events.c        2008-10-21 20:28:13 UTC (rev 
28349)
@@ -1370,95 +1370,8 @@
             /* Sorry, but it's not the right time for configure request */
             return;
         }
-        if (c->type == WINDOW_DESKTOP)
-        {
-            /* Ignore stacking request for DESKTOP windows */
-            ev->value_mask &= ~(CWSibling | CWStackMode);
-        }
-        clientCoordGravitate (c, APPLY, &wc.x, &wc.y);
-        if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
-        {
-            GdkRectangle rect;
-            gint monitor_nbr;
-            int cx, cy;
-
-            /* size request from fullscreen windows get fullscreen */
-
-            cx = frameX (c) + (frameWidth (c) / 2);
-            cy = frameY (c) + (frameHeight (c) / 2);
-
-            monitor_nbr = find_monitor_at_point (screen_info->gscr, cx, cy);
-            gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr, 
&rect);
-
-            wc.x = rect.x;
-            wc.y = rect.y;
-            wc.width = rect.width;
-            wc.height = rect.height;
-
-            ev->value_mask |= (CWX | CWY | CWWidth | CWHeight);
-        }
-        else if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED)
-                 && (screen_info->params->borderless_maximize))
-        {
-            wc.x = c->x;
-            wc.y = c->y;
-            wc.width = c->width;
-            wc.height = c->height;
-        }
-        /* Clean up buggy requests that set all flags */
-        if ((ev->value_mask & CWX) && (wc.x == c->x))
-        {
-            ev->value_mask &= ~CWX;
-        }
-        if ((ev->value_mask & CWY) && (wc.y == c->y))
-        {
-            ev->value_mask &= ~CWY;
-        }
-        if ((ev->value_mask & CWWidth) && (wc.width == c->width))
-        {
-            ev->value_mask &= ~CWWidth;
-        }
-        if ((ev->value_mask & CWHeight) && (wc.height == c->height))
-        {
-            ev->value_mask &= ~CWHeight;
-        }
-        /* Still a move/resize after cleanup? */
-        if (ev->value_mask & (CWX | CWY | CWWidth | CWHeight))
-        {
-            if (FLAG_TEST (c->flags, CLIENT_FLAG_MAXIMIZED))
-            {
-                clientRemoveMaximizeFlag (c);
-            }
-            constrained = TRUE;
-        }
-
-        /*
-           Let's say that if the client performs a XRaiseWindow, we show the 
window if focus
-           stealing prevention is not activated, otherwise we just set the 
"demands attention"
-           flag...
-         */
-        if ((ev->value_mask & CWStackMode) && (wc.stack_mode == Above) && 
(wc.sibling == None))
-        {
-            Client *last_raised;
-
-            last_raised = clientGetLastRaise (screen_info);
-            if (last_raised && (c != last_raised))
-            {
-                if ((screen_info->params->prevent_focus_stealing) && 
(screen_info->params->activate_action == ACTIVATE_ACTION_NONE))
-                {
-                    ev->value_mask &= ~(CWSibling | CWStackMode);
-                    TRACE ("Setting WM_STATE_DEMANDS_ATTENTION flag on \"%s\" 
(0x%lx)", c->name, c->window);
-                    FLAG_SET (c->flags, CLIENT_FLAG_DEMANDS_ATTENTION);
-                    clientSetNetState (c);
-                }
-                else
-                {
-                    clientActivate (c, getXServerTime (display_info));
-                }
-            }
-        }
-
-        clientConfigure (c, &wc, ev->value_mask, (constrained ? 
CFG_CONSTRAINED : 0) | CFG_REQUEST);
+        clientAdjustCoordGravity (c, c->gravity, &ev->value_mask, &wc);
+        clientMoveResizeWindow (c, &wc, ev->value_mask);
     }
     else
     {
@@ -2089,6 +2002,11 @@
             TRACE ("client \"%s\" (0x%lx) has received a NET_WM_MOVERESIZE 
event", c->name, c->window);
             clientNetMoveResize (c, ev);
         }
+        else if ((ev->message_type == 
display_info->atoms[NET_MOVERESIZE_WINDOW]) && (ev->format == 32))
+        {
+            TRACE ("client \"%s\" (0x%lx) has received a NET_MOVERESIZE_WINDOW 
event", c->name, c->window);
+            clientNetMoveResizeWindow (c, ev);
+        }
         else if ((ev->message_type == display_info->atoms[NET_ACTIVE_WINDOW]) 
&& (ev->format == 32))
         {
             gboolean source_is_application;

Modified: xfwm4/branches/xfce_4_4/src/hints.c
===================================================================
--- xfwm4/branches/xfce_4_4/src/hints.c 2008-10-21 20:12:41 UTC (rev 28348)
+++ xfwm4/branches/xfce_4_4/src/hints.c 2008-10-21 20:28:13 UTC (rev 28349)
@@ -397,7 +397,7 @@
 void
 setNetSupportedHint (DisplayInfo *display_info, Window root, Window check_win)
 {
-    Atom atoms[64];
+    Atom atoms[ATOM_COUNT];
     unsigned long data[1];
     int i;
 
@@ -412,6 +412,7 @@
     atoms[i++] = display_info->atoms[NET_DESKTOP_NAMES];
     atoms[i++] = display_info->atoms[NET_DESKTOP_VIEWPORT];
     atoms[i++] = display_info->atoms[NET_FRAME_EXTENTS];
+    atoms[i++] = display_info->atoms[NET_MOVERESIZE_WINDOW];
     atoms[i++] = display_info->atoms[NET_NUMBER_OF_DESKTOPS];
     atoms[i++] = display_info->atoms[NET_REQUEST_FRAME_EXTENTS];
     atoms[i++] = display_info->atoms[NET_SHOWING_DESKTOP];
@@ -463,7 +464,7 @@
 #ifdef HAVE_LIBSTARTUP_NOTIFICATION
     atoms[i++] = display_info->atoms[NET_STARTUP_ID];
 #endif
-    g_assert (i < 64);
+    g_assert (i < ATOM_COUNT);
     data[0] = check_win;
     XChangeProperty (display_info->dpy, root, 
display_info->atoms[NET_SUPPORTED],
                      XA_ATOM, 32, PropModeReplace, (unsigned char *) atoms, i);

Modified: xfwm4/branches/xfce_4_4/src/netwm.c
===================================================================
--- xfwm4/branches/xfce_4_4/src/netwm.c 2008-10-21 20:12:41 UTC (rev 28348)
+++ xfwm4/branches/xfce_4_4/src/netwm.c 2008-10-21 20:28:13 UTC (rev 28349)
@@ -687,6 +687,39 @@
 }
 
 void
+clientNetMoveResizeWindow (Client * c, XClientMessageEvent * ev)
+{
+    XWindowChanges wc;
+    unsigned long mask;
+    int gravity;
+
+    g_return_if_fail (c != NULL);
+    TRACE ("entering clientNetMoveResizeWindow");
+    TRACE ("client \"%s\" (0x%lx)", c->name, c->window);
+
+    if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MOVING_RESIZING))
+    {
+        /* not allowed */
+        return;
+    }
+
+    gravity = (ev->data.l[0] & 0xff);
+    if (!gravity)
+    {
+        gravity = c->gravity;
+    }
+
+    wc.x = ev->data.l[1];
+    wc.y = ev->data.l[2];
+    wc.width = ev->data.l[3];
+    wc.height = ev->data.l[4];
+    mask = (ev->data.l[0] & 0xf00) >> 8;
+
+    clientAdjustCoordGravity (c, gravity, &mask, &wc);
+    clientMoveResizeWindow (c, &wc, mask);
+}
+
+void
 clientUpdateFullscreenState (Client * c)
 {
     ScreenInfo *screen_info;

Modified: xfwm4/branches/xfce_4_4/src/netwm.h
===================================================================
--- xfwm4/branches/xfce_4_4/src/netwm.h 2008-10-21 20:12:41 UTC (rev 28348)
+++ xfwm4/branches/xfce_4_4/src/netwm.h 2008-10-21 20:28:13 UTC (rev 28349)
@@ -35,8 +35,10 @@
 void                     clientGetNetState                      (Client *);
 void                     clientUpdateNetState                   (Client *, 
                                                                  
XClientMessageEvent *);
-void                     clientNetMoveResize                    (Client *, 
+void                     clientNetMoveResize                    (Client *,
                                                                  
XClientMessageEvent *);
+void                     clientNetMoveResizeWindow              (Client *,
+                                                                 
XClientMessageEvent *);
 void                     clientUpdateFullscreenState            (Client *);
 void                     clientGetNetWmType                     (Client *);
 void                     clientGetInitialNetWmDesktop           (Client *);

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to