Author: olivier
Date: 2008-12-14 21:55:28 +0000 (Sun, 14 Dec 2008)
New Revision: 29025

Modified:
   xfwm4/trunk/ChangeLog
   xfwm4/trunk/NEWS
   xfwm4/trunk/src/client.c
   xfwm4/trunk/src/client.h
   xfwm4/trunk/src/placement.c
   xfwm4/trunk/src/placement.h
Log:
        * src/placement.c, src/placement.h, src/client.c, src/client.h:
          Fix fill horizontally and vertically not working as expected 
          (Bug #4712)

Modified: xfwm4/trunk/ChangeLog
===================================================================
--- xfwm4/trunk/ChangeLog       2008-12-14 12:29:48 UTC (rev 29024)
+++ xfwm4/trunk/ChangeLog       2008-12-14 21:55:28 UTC (rev 29025)
@@ -1,5 +1,11 @@
 2008-12-14  olivier
 
+       * src/placement.c, src/placement.h, src/client.c, src/client.h:
+         Fix fill horizontally and vertically not working as expected 
+         (Bug #4712)
+
+2008-12-14  olivier
+
        * settings-dialogs/xfwm4-dialog.glade, 
          settings-dialogs/xfwm4-tweaks-dialog.glade: String review by 
          Josh Saddler <nightmo...@gentoo.org> (Bug #4703)

Modified: xfwm4/trunk/NEWS
===================================================================
--- xfwm4/trunk/NEWS    2008-12-14 12:29:48 UTC (rev 29024)
+++ xfwm4/trunk/NEWS    2008-12-14 21:55:28 UTC (rev 29025)
@@ -7,6 +7,7 @@
   actual screen size (Bug# 3126).
 - Remove maximization if a client updates its size max size hint (Bug #4706).
 - String review by Josh Saddler <nightmo...@gentoo.org> (Bug #4703).
+- Fix fill horizontally and vertically not working as expected (Bug #4712).
 
 4.5.92 (Xfce 4.6beta2)
 ======================

Modified: xfwm4/trunk/src/client.c
===================================================================
--- xfwm4/trunk/src/client.c    2008-12-14 12:29:48 UTC (rev 29024)
+++ xfwm4/trunk/src/client.c    2008-12-14 21:55:28 UTC (rev 29025)
@@ -3235,224 +3235,6 @@
 }
 
 void
-clientFill (Client * c, int fill_type)
-{
-    ScreenInfo *screen_info;
-    DisplayInfo *display_info;
-    Client *east_neighbour;
-    Client *west_neighbour;
-    Client *north_neighbour;
-    Client *south_neighbour;
-    Client *c2;
-    GdkRectangle rect;
-    XWindowChanges wc;
-    unsigned short mask;
-    int i, cx, cy, full_x, full_y, full_w, full_h;
-    int tmp_x, tmp_y, tmp_w, tmp_h;
-    gint monitor_nbr;
-
-    g_return_if_fail (c != NULL);
-
-    if (!CLIENT_CAN_FILL_WINDOW (c))
-    {
-        return;
-    }
-
-    screen_info = c->screen_info;
-    display_info = screen_info->display_info;
-    mask = 0;
-    east_neighbour = NULL;
-    west_neighbour = NULL;
-    north_neighbour = NULL;
-    south_neighbour = NULL;
-
-    for (c2 = screen_info->clients, i = 0; i < screen_info->client_count; c2 = 
c2->next, i++)
-    {
-
-        /* Filter out all windows which are not visible, or not on the same 
layer
-         * as well as the client window itself
-         */
-        if ((c != c2) && FLAG_TEST (c2->xfwm_flags, XFWM_FLAG_VISIBLE) && 
(c2->win_layer == c->win_layer))
-        {
-            /* Fill horizontally */
-            if (fill_type & CLIENT_FILL_HORIZ)
-            {
-                /*
-                 * check if the neigbour client (c2) is located
-                 * east or west of our client.
-                 */
-                if (!(((frameY(c) + frameHeight(c)) < (frameY(c2) - 
frameTop(c2))) || ((frameY(c2) + frameHeight(c2)) < (frameY(c) - frameTop(c)))))
-                {
-                    if ((frameX(c2) + frameWidth(c2)) < frameX(c))
-                    {
-                        if (east_neighbour)
-                        {
-                            /* Check if c2 is closer to the client
-                             * then the east neighbour already found
-                             */
-                            if ((frameX(east_neighbour) + 
frameWidth(east_neighbour)) < (frameX(c2) + frameWidth(c2)))
-                            {
-                                east_neighbour = c2;
-                            }
-                        }
-                        else
-                        {
-                            east_neighbour = c2;
-                        }
-                    }
-                    if ((frameX(c) + frameWidth(c)) < frameX(c2))
-                    {
-                        /* Check if c2 is closer to the client
-                         * then the west neighbour already found
-                         */
-                        if (west_neighbour)
-                        {
-                            if (frameX(c2) < frameX(west_neighbour))
-                            {
-                                west_neighbour = c2;
-                            }
-                        }
-                        else
-                        {
-                            west_neighbour = c2;
-                        }
-                    }
-                }
-            }
-
-            /* Fill vertically */
-            if (fill_type & CLIENT_FILL_VERT)
-            {
-                /* check if the neigbour client (c2) is located
-                 * north or south of our client.
-                 */
-                if (!(((frameX(c) + frameWidth(c)) < frameX(c2)) || 
((frameX(c2) + frameWidth(c2)) < frameX(c))))
-                {
-                    if ((frameY(c2) + frameHeight(c2)) < frameY(c))
-                    {
-                        if (north_neighbour)
-                        {
-                            /* Check if c2 is closer to the client
-                             * then the north neighbour already found
-                             */
-                            if ((frameY(north_neighbour) + 
frameHeight(north_neighbour)) < (frameY(c2) + frameHeight(c2)))
-                            {
-                                north_neighbour = c2;
-                            }
-                        }
-                        else
-                        {
-                            north_neighbour = c2;
-                        }
-                    }
-                    if ((frameY(c) + frameHeight(c)) < frameY(c2))
-                    {
-                        if (south_neighbour)
-                        {
-                            /* Check if c2 is closer to the client
-                             * then the south neighbour already found
-                             */
-                            if (frameY(c2) < frameY(south_neighbour))
-                            {
-                                south_neighbour = c2;
-                            }
-                        }
-                        else
-                        {
-                            south_neighbour = c2;
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /* Compute the largest size available, based on struts, margins and 
Xinerama layout */
-    tmp_x = frameX (c);
-    tmp_y = frameY (c);
-    tmp_h = frameHeight (c);
-    tmp_w = frameWidth (c);
-
-    cx = tmp_x + (tmp_w / 2);
-    cy = tmp_y + (tmp_h / 2);
-
-    monitor_nbr = find_monitor_at_point (screen_info->gscr, cx, cy);
-    gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr, &rect);
-
-    full_x = MAX (screen_info->params->xfwm_margins[STRUTS_LEFT], rect.x);
-    full_y = MAX (screen_info->params->xfwm_margins[STRUTS_TOP], rect.y);
-    full_w = MIN (screen_info->width - 
screen_info->params->xfwm_margins[STRUTS_RIGHT],
-                  rect.x + rect.width) - full_x;
-    full_h = MIN (screen_info->height - 
screen_info->params->xfwm_margins[STRUTS_BOTTOM],
-                  rect.y + rect.height) - full_y;
-
-    if ((fill_type & CLIENT_FILL) == CLIENT_FILL)
-    {
-        mask = CWX | CWY | CWHeight | CWWidth;
-        /* Adjust size to the largest size available, not covering struts */
-        clientMaxSpace (screen_info, &full_x, &full_y, &full_w, &full_h);
-    }
-    else if (fill_type & CLIENT_FILL_VERT)
-    {
-        mask = CWY | CWHeight;
-        /* Adjust size to the tallest size available, for the current 
horizontal position/width */
-        clientMaxSpace (screen_info, &tmp_x, &full_y, &tmp_w, &full_h);
-    }
-    else if (fill_type & CLIENT_FILL_HORIZ)
-    {
-        mask = CWX | CWWidth;
-        /* Adjust size to the widest size available, for the current vertical 
position/height */
-        clientMaxSpace (screen_info, &full_x, &tmp_y, &full_w, &tmp_h);
-    }
-
-    /* If there are neighbours, resize to their borders.
-     * If not, resize to the largest size available taht you just have 
computed.
-     */
-
-    if (east_neighbour)
-    {
-        wc.x = frameX(east_neighbour) + frameWidth(east_neighbour) + 
frameLeft(c);
-    }
-    else
-    {
-        wc.x = full_x + frameLeft(c);
-    }
-
-    if (west_neighbour)
-    {
-        wc.width = full_x + frameX(west_neighbour) - frameRight(c) - wc.x;
-    }
-    else
-    {
-        wc.width = full_x + full_w - frameRight(c) - wc.x;
-    }
-
-    if (north_neighbour)
-    {
-        wc.y = frameY(north_neighbour) + frameHeight(north_neighbour) + 
frameTop(c);
-    }
-    else
-    {
-        wc.y = full_y + frameTop(c);
-    }
-
-    if (south_neighbour)
-    {
-        wc.height = full_y + frameY(south_neighbour) - frameBottom(c) - wc.y;
-    }
-    else
-    {
-        wc.height = full_y + full_h - frameBottom(c) - wc.y;
-    }
-
-    TRACE ("Fill size request: (%d,%d) %dx%d", wc.x, wc.y, wc.width, 
wc.height);
-    if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MANAGED))
-    {
-        clientConfigure(c, &wc, mask, NO_CFG_FLAG);
-    }
-}
-
-void
 clientUpdateOpacity (Client *c)
 {
     ScreenInfo *screen_info;

Modified: xfwm4/trunk/src/client.h
===================================================================
--- xfwm4/trunk/src/client.h    2008-12-14 12:29:48 UTC (rev 29024)
+++ xfwm4/trunk/src/client.h    2008-12-14 21:55:28 UTC (rev 29025)
@@ -416,8 +416,6 @@
 void                     clientToggleMaximized                  (Client *,
                                                                  int,
                                                                  gboolean);
-void                     clientFill                             (Client *,
-                                                                 int);
 void                     clientUpdateOpacity                    (Client *);
 void                     clientUpdateAllOpacity                 (ScreenInfo *);
 void                     clientSetOpacity                       (Client *,

Modified: xfwm4/trunk/src/placement.c
===================================================================
--- xfwm4/trunk/src/placement.c 2008-12-14 12:29:48 UTC (rev 29024)
+++ xfwm4/trunk/src/placement.c 2008-12-14 21:55:28 UTC (rev 29025)
@@ -38,15 +38,10 @@
 #include "frame.h"
 #include "netwm.h"
 
-static unsigned long overlapX (int x0, int x1, int tx0, int tx1);
-static unsigned long overlapY (int y0, int y1, int ty0, int ty1);
-static unsigned long overlap (int x0, int y0, int x1, int y1,
-                              int tx0, int ty0, int tx1, int ty1);
-
 /* Compute rectangle overlap area */
 
 static unsigned long
-overlapX (int x0, int x1, int tx0, int tx1)
+segment_overlap (int x0, int x1, int tx0, int tx1)
 {
     if (tx0 > x0)
     {
@@ -64,28 +59,11 @@
 }
 
 static unsigned long
-overlapY (int y0, int y1, int ty0, int ty1)
-{
-    if (ty0 > y0)
-    {
-        y0 = ty0;
-    }
-    if (ty1 < y1)
-    {
-        y1 = ty1;
-    }
-    if (y1 <= y0)
-    {
-        return 0;
-    }
-    return (y1 - y0);
-}
-
-static unsigned long
 overlap (int x0, int y0, int x1, int y1, int tx0, int ty0, int tx1, int ty1)
 {
     /* Compute overlapping box */
-    return (overlapX (x0, x1, tx0, tx1) * overlapY (y0, y1, ty0, ty1));
+    return (segment_overlap (x0, x1, tx0, tx1)
+            * segment_overlap (y0, y1, ty0, ty1));
 }
 
 static unsigned long
@@ -275,10 +253,10 @@
                 && (c2 != c))
             {
                 /* Right */
-                if (overlapY (frame_y, frame_y + frame_height,
+                if (segment_overlap (frame_y, frame_y + frame_height,
                               c2->struts[STRUTS_RIGHT_START_Y], 
c2->struts[STRUTS_RIGHT_END_Y]))
                 {
-                    if (overlapX (frame_x, frame_x + frame_width,
+                    if (segment_overlap (frame_x, frame_x + frame_width,
                                   screen_width - c2->struts[STRUTS_RIGHT],
                                   screen_width))
                     {
@@ -289,10 +267,10 @@
                 }
 
                 /* Bottom */
-                if (overlapX (frame_x, frame_x + frame_width,
+                if (segment_overlap (frame_x, frame_x + frame_width,
                               c2->struts[STRUTS_BOTTOM_START_X], 
c2->struts[STRUTS_BOTTOM_END_X]))
                 {
-                    if (overlapY (frame_y, frame_y + frame_height,
+                    if (segment_overlap (frame_y, frame_y + frame_height,
                                   screen_height - c2->struts[STRUTS_BOTTOM],
                                   screen_height))
                     {
@@ -337,10 +315,10 @@
                 && (c2 != c))
             {
                 /* Left */
-                if (overlapY (frame_y, frame_y + frame_height,
+                if (segment_overlap (frame_y, frame_y + frame_height,
                               c2->struts[STRUTS_LEFT_START_Y], 
c2->struts[STRUTS_LEFT_END_Y]))
                 {
-                    if (overlapX (frame_x, frame_x + frame_width,
+                    if (segment_overlap (frame_x, frame_x + frame_width,
                                   0, c2->struts[STRUTS_LEFT]))
                     {
                         c->x = c2->struts[STRUTS_LEFT] + frame_left;
@@ -350,12 +328,12 @@
                 }
 
                 /* Top */
-                if (overlapX (frame_x,
+                if (segment_overlap (frame_x,
                               frame_x + frame_width,
                               c2->struts[STRUTS_TOP_START_X],
                               c2->struts[STRUTS_TOP_END_X]))
                 {
-                    if (overlapY (frame_y, frame_y + frame_height,
+                    if (segment_overlap (frame_y, frame_y + frame_height,
                                   0, c2->struts[STRUTS_TOP]))
                     {
                         c->y = c2->struts[STRUTS_TOP] + frame_top;
@@ -406,7 +384,7 @@
                 && (c2 != c))
             {
                 /* Right */
-                if (overlapY (frame_y, frame_y + frame_height,
+                if (segment_overlap (frame_y, frame_y + frame_height,
                               c2->struts[STRUTS_RIGHT_START_Y], 
c2->struts[STRUTS_RIGHT_END_Y]))
                 {
                     if (frame_x >= screen_width - c2->struts[STRUTS_RIGHT] - 
min_visible)
@@ -418,7 +396,7 @@
                 }
 
                 /* Left */
-                if (overlapY (frame_y, frame_y + frame_height,
+                if (segment_overlap (frame_y, frame_y + frame_height,
                               c2->struts[STRUTS_LEFT_START_Y], 
c2->struts[STRUTS_LEFT_END_Y]))
                 {
                     if (frame_x + frame_width <= c2->struts[STRUTS_LEFT] + 
min_visible)
@@ -430,7 +408,7 @@
                 }
 
                 /* Bottom */
-                if (overlapX (frame_x, frame_x + frame_width,
+                if (segment_overlap (frame_x, frame_x + frame_width,
                               c2->struts[STRUTS_BOTTOM_START_X], 
c2->struts[STRUTS_BOTTOM_END_X]))
                 {
                     if (frame_y >= screen_height - c2->struts[STRUTS_BOTTOM] - 
min_visible)
@@ -442,10 +420,10 @@
                 }
 
                 /* Top */
-                if (overlapX (frame_x, frame_x + frame_width,
+                if (segment_overlap (frame_x, frame_x + frame_width,
                               c2->struts[STRUTS_TOP_START_X], 
c2->struts[STRUTS_TOP_END_X]))
                 {
-                    if (overlapY (frame_y, frame_y + frame_visible, 0, 
c2->struts[STRUTS_TOP]))
+                    if (segment_overlap (frame_y, frame_y + frame_visible, 0, 
c2->struts[STRUTS_TOP]))
                     {
                         c->y = c2->struts[STRUTS_TOP] + frame_top;
                         frame_y = frameY (c);
@@ -766,3 +744,223 @@
         clientAutoMaximize (c, full_w, full_h);
     }
 }
+
+
+void
+clientFill (Client * c, int fill_type)
+{
+    ScreenInfo *screen_info;
+    DisplayInfo *display_info;
+    Client *east_neighbour;
+    Client *west_neighbour;
+    Client *north_neighbour;
+    Client *south_neighbour;
+    Client *c2;
+    GdkRectangle rect;
+    XWindowChanges wc;
+    unsigned short mask;
+    int i, cx, cy, full_x, full_y, full_w, full_h;
+    int tmp_x, tmp_y, tmp_w, tmp_h;
+    gint monitor_nbr;
+
+    g_return_if_fail (c != NULL);
+
+    if (!CLIENT_CAN_FILL_WINDOW (c))
+    {
+        return;
+    }
+
+    screen_info = c->screen_info;
+    display_info = screen_info->display_info;
+    mask = 0;
+    east_neighbour = NULL;
+    west_neighbour = NULL;
+    north_neighbour = NULL;
+    south_neighbour = NULL;
+
+    for (c2 = screen_info->clients, i = 0; i < screen_info->client_count; c2 = 
c2->next, i++)
+    {
+
+        /* Filter out all windows which are not visible, or not on the same 
layer
+         * as well as the client window itself
+         */
+        if ((c != c2) && FLAG_TEST (c2->xfwm_flags, XFWM_FLAG_VISIBLE) && 
(c2->win_layer == c->win_layer))
+        {
+            /* Fill horizontally */
+            if (fill_type & CLIENT_FILL_HORIZ)
+            {
+                /*
+                 * check if the neigbour client (c2) is located
+                 * east or west of our client.
+                 */
+                if (segment_overlap (frameY(c), frameY(c) + frameHeight(c), 
frameY(c2), frameY(c2) + frameHeight(c2)))
+                {
+                    if ((frameX(c2) + frameWidth(c2)) < frameX(c))
+                    {
+                        if (east_neighbour)
+                        {
+                            /* Check if c2 is closer to the client
+                             * then the east neighbour already found
+                             */
+                            if ((frameX(east_neighbour) + 
frameWidth(east_neighbour)) < (frameX(c2) + frameWidth(c2)))
+                            {
+                                east_neighbour = c2;
+                            }
+                        }
+                        else
+                        {
+                            east_neighbour = c2;
+                        }
+                    }
+                    if ((frameX(c) + frameWidth(c)) < frameX(c2))
+                    {
+                        /* Check if c2 is closer to the client
+                         * then the west neighbour already found
+                         */
+                        if (west_neighbour)
+                        {
+                            if (frameX(c2) < frameX(west_neighbour))
+                            {
+                                west_neighbour = c2;
+                            }
+                        }
+                        else
+                        {
+                            west_neighbour = c2;
+                        }
+                    }
+                }
+            }
+
+            /* Fill vertically */
+            if (fill_type & CLIENT_FILL_VERT)
+            {
+                /* check if the neigbour client (c2) is located
+                 * north or south of our client.
+                 */
+                if (segment_overlap (frameX(c), frameX(c) + frameWidth(c), 
frameX(c2), frameX(c2) + frameWidth(c2)))
+                {
+                    if ((frameY(c2) + frameHeight(c2)) < frameY(c))
+                    {
+                        if (north_neighbour)
+                        {
+                            /* Check if c2 is closer to the client
+                             * then the north neighbour already found
+                             */
+                            if ((frameY(north_neighbour) + 
frameHeight(north_neighbour)) < (frameY(c2) + frameHeight(c2)))
+                            {
+                                north_neighbour = c2;
+                            }
+                        }
+                        else
+                        {
+                            north_neighbour = c2;
+                        }
+                    }
+                    if ((frameY(c) + frameHeight(c)) < frameY(c2))
+                    {
+                        if (south_neighbour)
+                        {
+                            /* Check if c2 is closer to the client
+                             * then the south neighbour already found
+                             */
+                            if (frameY(c2) < frameY(south_neighbour))
+                            {
+                                south_neighbour = c2;
+                            }
+                        }
+                        else
+                        {
+                            south_neighbour = c2;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /* Compute the largest size available, based on struts, margins and 
Xinerama layout */
+    tmp_x = frameX (c);
+    tmp_y = frameY (c);
+    tmp_h = frameHeight (c);
+    tmp_w = frameWidth (c);
+
+    cx = tmp_x + (tmp_w / 2);
+    cy = tmp_y + (tmp_h / 2);
+
+    monitor_nbr = find_monitor_at_point (screen_info->gscr, cx, cy);
+    gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_nbr, &rect);
+
+    full_x = MAX (screen_info->params->xfwm_margins[STRUTS_LEFT], rect.x);
+    full_y = MAX (screen_info->params->xfwm_margins[STRUTS_TOP], rect.y);
+    full_w = MIN (screen_info->width - 
screen_info->params->xfwm_margins[STRUTS_RIGHT],
+                  rect.x + rect.width) - full_x;
+    full_h = MIN (screen_info->height - 
screen_info->params->xfwm_margins[STRUTS_BOTTOM],
+                  rect.y + rect.height) - full_y;
+
+    if ((fill_type & CLIENT_FILL) == CLIENT_FILL)
+    {
+        mask = CWX | CWY | CWHeight | CWWidth;
+        /* Adjust size to the largest size available, not covering struts */
+        clientMaxSpace (screen_info, &full_x, &full_y, &full_w, &full_h);
+    }
+    else if (fill_type & CLIENT_FILL_VERT)
+    {
+        mask = CWY | CWHeight;
+        /* Adjust size to the tallest size available, for the current 
horizontal position/width */
+        clientMaxSpace (screen_info, &tmp_x, &full_y, &tmp_w, &full_h);
+    }
+    else if (fill_type & CLIENT_FILL_HORIZ)
+    {
+        mask = CWX | CWWidth;
+        /* Adjust size to the widest size available, for the current vertical 
position/height */
+        clientMaxSpace (screen_info, &full_x, &tmp_y, &full_w, &tmp_h);
+    }
+
+    /* If there are neighbours, resize to their borders.
+     * If not, resize to the largest size available taht you just have 
computed.
+     */
+
+    if (east_neighbour)
+    {
+        wc.x = frameX(east_neighbour) + frameWidth(east_neighbour) + 
frameLeft(c);
+    }
+    else
+    {
+        wc.x = full_x + frameLeft(c);
+    }
+
+    if (west_neighbour)
+    {
+        wc.width = full_x + frameX(west_neighbour) - frameRight(c) - wc.x;
+    }
+    else
+    {
+        wc.width = full_x + full_w - frameRight(c) - wc.x;
+    }
+
+    if (north_neighbour)
+    {
+        wc.y = frameY(north_neighbour) + frameHeight(north_neighbour) + 
frameTop(c);
+    }
+    else
+    {
+        wc.y = full_y + frameTop(c);
+    }
+
+    if (south_neighbour)
+    {
+        wc.height = full_y + frameY(south_neighbour) - frameBottom(c) - wc.y;
+    }
+    else
+    {
+        wc.height = full_y + full_h - frameBottom(c) - wc.y;
+    }
+
+    TRACE ("Fill size request: (%d,%d) %dx%d", wc.x, wc.y, wc.width, 
wc.height);
+    if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_MANAGED))
+    {
+        clientConfigure(c, &wc, mask, NO_CFG_FLAG);
+    }
+}
+

Modified: xfwm4/trunk/src/placement.h
===================================================================
--- xfwm4/trunk/src/placement.h 2008-12-14 12:29:48 UTC (rev 29024)
+++ xfwm4/trunk/src/placement.h 2008-12-14 21:55:28 UTC (rev 29025)
@@ -44,5 +44,7 @@
 unsigned int             clientConstrainPos                     (Client *,
                                                                  gboolean);
 void                     clientInitPosition                     (Client *);
+void                     clientFill                             (Client *,
+                                                                 int);
 
 #endif /* INC_PLACEMENT_H */

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to