[Pkg-xfce-commits] r7233 - in desktop/branches/experimental/xfwm4/debian: . patches
Yves-Alexis Perez
corsac at alioth.debian.org
Sun Dec 2 10:35:25 UTC 2012
Author: corsac
Date: 2012-12-02 22:35:25 +0000 (Sun, 02 Dec 2012)
New Revision: 7233
Added:
desktop/branches/experimental/xfwm4/debian/patches/0003-Some-small-optimizations-in-placement-code.patch
desktop/branches/experimental/xfwm4/debian/patches/0004-Optimize-smart-placement-bug-5785.patch
Modified:
desktop/branches/experimental/xfwm4/debian/changelog
desktop/branches/experimental/xfwm4/debian/patches/series
Log:
* debian/patches:
- 0003-Some-small-optimizations-in-placement-code, 0004_smart-placement
added, improve smart placement algorithm.
Modified: desktop/branches/experimental/xfwm4/debian/changelog
===================================================================
--- desktop/branches/experimental/xfwm4/debian/changelog 2012-12-02 22:35:13 UTC (rev 7232)
+++ desktop/branches/experimental/xfwm4/debian/changelog 2012-12-02 22:35:25 UTC (rev 7233)
@@ -1,3 +1,11 @@
+xfwm4 (4.10.0-4) UNRELEASED; urgency=low
+
+ * debian/patches:
+ - 0003-Some-small-optimizations-in-placement-code, 0004_smart-placement
+ added, improve smart placement algorithm.
+
+ -- Yves-Alexis Perez <corsac at debian.org> Sat, 01 Dec 2012 14:01:48 +0100
+
xfwm4 (4.10.0-3) experimental; urgency=low
* debian/patches:
Added: desktop/branches/experimental/xfwm4/debian/patches/0003-Some-small-optimizations-in-placement-code.patch
===================================================================
--- desktop/branches/experimental/xfwm4/debian/patches/0003-Some-small-optimizations-in-placement-code.patch (rev 0)
+++ desktop/branches/experimental/xfwm4/debian/patches/0003-Some-small-optimizations-in-placement-code.patch 2012-12-02 22:35:25 UTC (rev 7233)
@@ -0,0 +1,72 @@
+From e207a6bb16b5396544fa57e0b5cb5e621e8eaefb Mon Sep 17 00:00:00 2001
+From: Nick Schermer <nick at xfce.org>
+Date: Fri, 30 Nov 2012 22:50:59 +0100
+Subject: [PATCH] Some small optimizations in placement code.
+
+Callgrind showed that the frameX/Y functions were called
+a lot, so save the result inside the loop to do less calls.
+
+Also inline the overlap functions, both are just simple calculations
+so help the compiler a bit.
+---
+ src/placement.c | 17 +++++++++++------
+ 1 file changed, 11 insertions(+), 6 deletions(-)
+
+diff --git a/src/placement.c b/src/placement.c
+index f926de3..01f2590 100644
+--- a/src/placement.c
++++ b/src/placement.c
+@@ -38,9 +38,10 @@
+ #include "frame.h"
+ #include "netwm.h"
+
++
+ /* Compute rectangle overlap area */
+
+-static unsigned long
++static inline unsigned long
+ segment_overlap (int x0, int x1, int tx0, int tx1)
+ {
+ if (tx0 > x0)
+@@ -58,7 +59,7 @@ segment_overlap (int x0, int x1, int tx0, int tx1)
+ return (x1 - x0);
+ }
+
+-static unsigned long
++static inline unsigned long
+ overlap (int x0, int y0, int x1, int y1, int tx0, int ty0, int tx1, int ty1)
+ {
+ /* Compute overlapping box */
+@@ -541,6 +542,7 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
+ 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;
+
+ g_return_if_fail (c != NULL);
+ TRACE ("entering smartPlacement");
+@@ -574,14 +576,17 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
+ && (c->win_workspace == c2->win_workspace)
+ && FLAG_TEST (c2->xfwm_flags, XFWM_FLAG_VISIBLE))
+ {
++ c2_x = frameX (c2);
++ c2_y = frameY (c2);
++
+ count_overlaps += overlap (test_x - frame_left,
+ test_y - frame_top,
+ test_x - frame_left + frame_width,
+ test_y - frame_top + frame_height,
+- frameX (c2),
+- frameY (c2),
+- frameX (c2) + frameWidth (c2),
+- frameY (c2) + frameHeight (c2));
++ c2_x,
++ c2_y,
++ c2_x + frameWidth (c2),
++ c2_y + frameHeight (c2));
+ }
+ }
+ if (count_overlaps < 0.1)
+--
+1.7.10.4
+
Added: desktop/branches/experimental/xfwm4/debian/patches/0004-Optimize-smart-placement-bug-5785.patch
===================================================================
--- desktop/branches/experimental/xfwm4/debian/patches/0004-Optimize-smart-placement-bug-5785.patch (rev 0)
+++ desktop/branches/experimental/xfwm4/debian/patches/0004-Optimize-smart-placement-bug-5785.patch 2012-12-02 22:35:25 UTC (rev 7233)
@@ -0,0 +1,217 @@
+From be645e649c1684bc88a1ae51f29afe03e3048102 Mon Sep 17 00:00:00 2001
+From: Nick Schermer <nick at xfce.org>
+Date: Sat, 1 Dec 2012 13:43:44 +0100
+Subject: [PATCH] Optimize smart placement (bug #5785).
+
+Make efficient steps in smart placement code. This both saves
+a large amount of loops in the code and also make the windows
+align next to each other, instead of a possible gap of (x % 8) pixels.
+---
+ src/placement.c | 144 +++++++++++++++++++++++++++++++++++++++++++++----------
+ 1 file changed, 120 insertions(+), 24 deletions(-)
+
+diff --git a/src/placement.c b/src/placement.c
+index 01f2590..732f01d 100644
+--- a/src/placement.c
++++ b/src/placement.c
+@@ -541,8 +541,8 @@ 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;
+
+ g_return_if_fail (c != NULL);
+ TRACE ("entering smartPlacement");
+@@ -552,24 +552,42 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
+ frame_width = frameWidth (c);
+ frame_left = frameLeft(c);
+ frame_top = frameTop (c);
+- test_x = 0;
+- test_y = 0;
+- best_overlaps = 0.0;
+- first = TRUE;
+
++ /* max coordinates (bottom-right) */
+ xmax = full_x + full_w - c->width - frameRight (c);
+ ymax = full_y + full_h - c->height - frameBottom (c);
+- best_x = full_x + frameLeft (c);
+- best_y = full_y + frameTop (c);
+
+- test_y = full_y + frameTop (c);
++ /* min coordinates (top-left) */
++ xmin = full_x + frameLeft (c);
++ ymin = full_y + frameTop (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;
+ do
+ {
+- test_x = full_x + frameLeft (c);
++ gint next_test_y = G_MAXINT;
++ gboolean first_test_x = TRUE;
++
++ TRACE ("testing y position %d", test_y);
++
++ test_x = xmin;
+ do
+ {
+ gfloat count_overlaps = 0.0;
+- TRACE ("analyzing %i clients", screen_info->client_count);
++ 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);
++
+ for (c2 = screen_info->clients, i = 0; i < screen_info->client_count; c2 = c2->next, i++)
+ {
+ if ((c2 != c) && (c2->type != WINDOW_DESKTOP)
+@@ -577,7 +595,22 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
+ && FLAG_TEST (c2->xfwm_flags, XFWM_FLAG_VISIBLE))
+ {
+ c2_x = frameX (c2);
++ c2_frame_width = frameWidth (c2);
++ if (c2_x >= full_x + full_w
++ || c2_x + c2_frame_width < full_x)
++ {
++ /* skip clients on right-of or left-of monitor */
++ continue;
++ }
++
+ c2_y = frameY (c2);
++ c2_frame_height = frameHeight (c2);
++ if (c2_y >= full_y + full_h
++ || c2_y + c2_frame_height < full_y)
++ {
++ /* skip clients on above-of or below-of monitor */
++ continue;
++ }
+
+ count_overlaps += overlap (test_x - frame_left,
+ test_y - frame_top,
+@@ -585,35 +618,98 @@ smartPlacement (Client * c, int full_x, int full_y, int full_w, int full_h)
+ test_y - frame_top + frame_height,
+ c2_x,
+ c2_y,
+- c2_x + frameWidth (c2),
+- c2_y + frameHeight (c2));
++ 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 poistion */
++ 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 poistion */
++ 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;
+
+- return;
+- }
+- else if ((count_overlaps < best_overlaps) || (first))
++ /* don't look for the next y boundry this x row */
++ first_test_x = FALSE;
++
++ if (count_overlaps < best_overlaps)
+ {
++ /* 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 (first)
++
++ if (G_LIKELY (next_test_x != G_MAXINT))
+ {
+- first = FALSE;
++ test_x = next_test_x + frameLeft (c);
++ if (test_x > xmax)
++ {
++ /* always clamp on the monitor */
++ test_x = xmax;
++ }
++ }
++ else
++ {
++ test_x++;
+ }
+- test_x += 8;
+ }
+ while (test_x <= xmax);
+- test_y += 8;
++
++ if (G_LIKELY (next_test_y != G_MAXINT))
++ {
++ test_y = next_test_y + frameTop (c);
++ if (test_y > ymax)
++ {
++ /* always clamp on the monitor */
++ test_y = ymax;
++ }
++ }
++ else
++ {
++ test_y++;
++ }
+ }
+ 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;
+ }
+--
+1.7.10.4
+
Modified: desktop/branches/experimental/xfwm4/debian/patches/series
===================================================================
--- desktop/branches/experimental/xfwm4/debian/patches/series 2012-12-02 22:35:13 UTC (rev 7232)
+++ desktop/branches/experimental/xfwm4/debian/patches/series 2012-12-02 22:35:25 UTC (rev 7233)
@@ -1,2 +1,4 @@
0001-Revert-part-of-git-commit-8637c3a-as-this-breaks-del.patch
0002-Implement-NET_WM_MOVERESIZE_CANCEL-message-bug-8949.patch
+0003-Some-small-optimizations-in-placement-code.patch
+0004-Optimize-smart-placement-bug-5785.patch
More information about the Pkg-xfce-commits
mailing list