[Xfce4-commits] [xfce/xfwm4] 01/03: Revert "Optimize smart placement (bug #5785)."

noreply at xfce.org noreply at xfce.org
Tue Mar 10 22:14:17 CET 2015


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

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

commit 82e061dc853808920dd5647d3da515113854f331
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Mon Mar 9 18:14:40 2015 +0100

    Revert "Optimize smart placement (bug #5785)."
    
    Bug: 11671
    
    This reverts commit b42ba05a6b37f0834c1f4e80696ca4d36f9cb322.
---
 src/placement.c |  135 +++++++++++--------------------------------------------
 1 file changed, 27 insertions(+), 108 deletions(-)

diff --git a/src/placement.c b/src/placement.c
index 2476892..d4d335a 100644
--- a/src/placement.c
+++ b/src/placement.c
@@ -560,8 +560,10 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
     guint i;
     gint test_x, test_y, xmax, ymax, best_x, best_y;
     gint frame_height, frame_width, frame_left, frame_top;
+    gboolean first;
     gint c2_x, c2_y;
-    gint xmin, ymin;
+    gint c2_frame_height;
+    gint c2_frame_width;
 
     g_return_if_fail (c != NULL);
     TRACE ("entering smartPlacement");
@@ -571,42 +573,24 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
     frame_width = frameExtentWidth (c);
     frame_left = frameExtentLeft(c);
     frame_top = frameExtentTop (c);
+    test_x = 0;
+    test_y = 0;
+    best_overlaps = 0.0;
+    first = TRUE;
 
-    /* max coordinates (bottom-right) */
     xmax = full_x + full_w - c->width - frameExtentRight (c);
     ymax = full_y + full_h - c->height - frameExtentBottom (c);
+    best_x = full_x + frameExtentLeft (c);
+    best_y = full_y + frameExtentTop (c);
 
-    /* min coordinates (top-left) */
-    xmin = full_x + frameExtentLeft (c);
-    ymin = full_y + frameExtentTop (c);
-
-    /* start with worst-case position at top-left */
-    best_overlaps = G_MAXFLOAT;
-    best_x = xmin;
-    best_y = ymin;
-
-    TRACE ("analyzing %i clients", screen_info->client_count);
-
-    test_y = ymin;
+    test_y = full_y + frameExtentTop (c);
     do
     {
-        gint next_test_y = G_MAXINT;
-        gboolean first_test_x = TRUE;
-
-        TRACE ("testing y position %d", test_y);
-
-        test_x = xmin;
+        test_x = full_x + frameExtentLeft (c);
         do
         {
             gfloat count_overlaps = 0.0;
-            gint next_test_x = G_MAXINT;
-            gint c2_next_test_x;
-            gint c2_next_test_y;
-            gint c2_frame_height;
-            gint c2_frame_width;
-
-            TRACE ("testing x position %d", test_x);
-
+            TRACE ("analyzing %i clients", screen_info->client_count);
             for (c2 = screen_info->clients, i = 0; i < screen_info->client_count; c2 = c2->next, i++)
             {
                 if ((c2 != c) && (c2->type != WINDOW_DESKTOP)
@@ -615,8 +599,7 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
                 {
                     c2_x = frameExtentX (c2);
                     c2_frame_width = frameExtentWidth (c2);
-                    if (c2_x >= full_x + full_w
-                        || c2_x + c2_frame_width < full_x)
+                    if (c2_x >= full_x + full_w || c2_x + c2_frame_width < full_x)
                     {
                         /* skip clients on right-of or left-of monitor */
                         continue;
@@ -624,8 +607,7 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
 
                     c2_y = frameExtentY (c2);
                     c2_frame_height = frameExtentHeight (c2);
-                    if (c2_y >= full_y + full_h
-                        || c2_y + c2_frame_height < full_y)
+                    if (c2_y >= full_y + full_h || c2_y + c2_frame_height < full_y)
                     {
                         /* skip clients on above-of or below-of monitor */
                         continue;
@@ -639,96 +621,33 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
                                                c2_y,
                                                c2_x + c2_frame_width,
                                                c2_y + c2_frame_height);
-
-                    /* find the next x boundy for the step */
-                    if (test_x > c2_x)
-                    {
-                        /* test location is beyond the x of the window,
-                         * take the window right corner as next target */
-                        c2_x += c2_frame_width;
-                    }
-                    c2_next_test_x = MIN (c2_x, xmax);
-                    if (c2_next_test_x < next_test_x
-                        && c2_next_test_x > test_x)
-                    {
-                        /* set new optimal next x step position */
-                        next_test_x = c2_next_test_x;
-                    }
-
-                    if (first_test_x)
-                    {
-                        /* find the next y boundry step */
-                        if (test_y > c2_y)
-                        {
-                            /* test location is beyond the y of the window,
-                             * take the window bottom corner as next target */
-                            c2_y += c2_frame_height;
-                        }
-                        c2_next_test_y = MIN (c2_y, ymax);
-                        if (c2_next_test_y < next_test_y
-                            && c2_next_test_y > test_y)
-                        {
-                            /* set new optimal next y step position */
-                            next_test_y = c2_next_test_y;
-                        }
-                    }
                 }
             }
+            if (count_overlaps < 0.1)
+            {
+                TRACE ("overlaps is 0 so it's the best we can get");
+                c->x = test_x;
+                c->y = test_y;
 
-            /* don't look for the next y boundry this x row */
-            first_test_x = FALSE;
-
-            if (count_overlaps < best_overlaps)
+                return;
+            }
+            else if ((count_overlaps < best_overlaps) || (first))
             {
-                /* found position with less overlap */
                 best_x = test_x;
                 best_y = test_y;
                 best_overlaps = count_overlaps;
-
-                if (count_overlaps == 0.0f)
-                {
-                    /* overlap is ideal, stop searching */
-                    TRACE ("found position without overlap");
-                    goto found_best;
-                }
-            }
-
-            if (G_LIKELY (next_test_x != G_MAXINT))
-            {
-                test_x = MAX (next_test_x, next_test_x + frameExtentLeft (c));
-                if (test_x > xmax)
-                {
-                   /* always clamp on the monitor */
-                   test_x = xmax;
-                }
-            }
-            else
-            {
-                test_x++;
             }
-        }
-        while (test_x < xmax);
-
-        if (G_LIKELY (next_test_y != G_MAXINT))
-        {
-            test_y = MAX (next_test_y, next_test_y + frameExtentTop (c));
-            if (test_y > ymax)
+            if (first)
             {
-                /* always clamp on the monitor */
-                test_y = ymax;
+                first = FALSE;
             }
+            test_x += 8;
         }
-        else
-        {
-            test_y++;
-        }
+        while (test_x <= xmax);
+        test_y += 8;
     }
     while (test_y < ymax);
 
-    found_best:
-
-    TRACE ("overlaps %f at %d,%d (x,y)", best_overlaps, best_x, best_y);
-
     c->x = best_x;
     c->y = best_y;
 }

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


More information about the Xfce4-commits mailing list