This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project wmaker-crm.git.

The branch, next has been updated
       via  25ae1fe05308dd9326e00977d447ebc0a9ce290c (commit)
       via  125c50b5d103a1d98fa264e37d7c7383a50a40f5 (commit)
       via  222802320a2a3cf9e057cd56c757d886504a2f67 (commit)
       via  2cf4914283e64b17473badd6984ed3dbec85786d (commit)
      from  3981805ec78adf4479f0988cfc2174a02d58a738 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://repo.or.cz/w/wmaker-crm.git/commit/25ae1fe05308dd9326e00977d447ebc0a9ce290c

commit 25ae1fe05308dd9326e00977d447ebc0a9ce290c
Author: Yuri Karaban <[email protected]>
Date:   Sat Apr 12 18:55:57 2014 +0300

    autoPlaceWindow: try placing window at center first

diff --git a/src/placement.c b/src/placement.c
index 9621d269..bc9e6bbd 100644
--- a/src/placement.c
+++ b/src/placement.c
@@ -434,6 +434,14 @@ autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret,
        sw = usableArea.x2 - usableArea.x1;
        sh = usableArea.y2 - usableArea.y1;
 
+       /* try placing at center first */
+       if (center_place_window(wwin, &x, &y, width, height, usableArea) &&
+           screen_has_space(scr, x, y, width, height, False)) {
+               *x_ret = x;
+               *y_ret = y;
+               return True;
+       }
+
        /* this was based on fvwm2's smart placement */
        for (y = Y_ORIGIN; (y + height) < sh; y += PLACETEST_VSTEP) {
                for (x = X_ORIGIN; (x + width) < sw; x += PLACETEST_HSTEP) {

http://repo.or.cz/w/wmaker-crm.git/commit/125c50b5d103a1d98fa264e37d7c7383a50a40f5

commit 125c50b5d103a1d98fa264e37d7c7383a50a40f5
Author: Yuri Karaban <[email protected]>
Date:   Sat Apr 12 18:55:56 2014 +0300

    autoPlaceWindow: rename mysterious parameter tryCount to ignore_sunken

diff --git a/src/placement.c b/src/placement.c
index 111cc0f2..9621d269 100644
--- a/src/placement.c
+++ b/src/placement.c
@@ -424,7 +424,7 @@ center_place_window(WWindow *wwin, int *x_ret, int *y_ret,
 static Bool
 autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret,
                unsigned int width, unsigned int height,
-               int tryCount, WArea usableArea)
+               Bool ignore_sunken, WArea usableArea)
 {
        WScreen *scr = wwin->screen_ptr;
        int x, y;
@@ -438,7 +438,7 @@ autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret,
        for (y = Y_ORIGIN; (y + height) < sh; y += PLACETEST_VSTEP) {
                for (x = X_ORIGIN; (x + width) < sw; x += PLACETEST_HSTEP) {
                        if (screen_has_space(scr, x, y,
-                                            width, height, tryCount)) {
+                                            width, height, ignore_sunken)) {
                                *x_ret = x;
                                *y_ret = y;
                                return True;
@@ -511,9 +511,9 @@ void PlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, 
unsigned width, unsigned
                        break;
 
        case WPM_AUTO:
-               if (autoPlaceWindow(wwin, x_ret, y_ret, width, height, 0, 
usableArea)) {
+               if (autoPlaceWindow(wwin, x_ret, y_ret, width, height, False, 
usableArea)) {
                        break;
-               } else if (autoPlaceWindow(wwin, x_ret, y_ret, width, height, 
1, usableArea)) {
+               } else if (autoPlaceWindow(wwin, x_ret, y_ret, width, height, 
True, usableArea)) {
                        break;
                }
                /* there isn't a break here, because if we fail, it should fall

http://repo.or.cz/w/wmaker-crm.git/commit/222802320a2a3cf9e057cd56c757d886504a2f67

commit 222802320a2a3cf9e057cd56c757d886504a2f67
Author: Yuri Karaban <[email protected]>
Date:   Sat Apr 12 18:55:55 2014 +0300

    autoPlaceWindow: rewrite iteration to more comprehensible form

diff --git a/src/placement.c b/src/placement.c
index fb7a17ff..111cc0f2 100644
--- a/src/placement.c
+++ b/src/placement.c
@@ -423,30 +423,27 @@ center_place_window(WWindow *wwin, int *x_ret, int *y_ret,
 
 static Bool
 autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret,
-               unsigned int width, unsigned int height, int tryCount, WArea 
usableArea)
+               unsigned int width, unsigned int height,
+               int tryCount, WArea usableArea)
 {
        WScreen *scr = wwin->screen_ptr;
-       int test_x = 0, test_y = Y_ORIGIN;
-       int swidth, sx;
+       int x, y;
+       int sw, sh;
 
        set_width_height(wwin, &width, &height);
-       swidth = usableArea.x2 - usableArea.x1;
-       sx = X_ORIGIN;
+       sw = usableArea.x2 - usableArea.x1;
+       sh = usableArea.y2 - usableArea.y1;
 
        /* this was based on fvwm2's smart placement */
-       while (((test_y + height) < (usableArea.y2 - usableArea.y1))) {
-               test_x = sx;
-
-               while (((test_x + width) < swidth)) {
-                       if (screen_has_space(scr, test_x, test_y,
+       for (y = Y_ORIGIN; (y + height) < sh; y += PLACETEST_VSTEP) {
+               for (x = X_ORIGIN; (x + width) < sw; x += PLACETEST_HSTEP) {
+                       if (screen_has_space(scr, x, y,
                                             width, height, tryCount)) {
-                               *x_ret = test_x;
-                               *y_ret = test_y;
+                               *x_ret = x;
+                               *y_ret = y;
                                return True;
                        }
-                       test_x += PLACETEST_HSTEP;
                }
-               test_y += PLACETEST_VSTEP;
        }
 
        return False;

http://repo.or.cz/w/wmaker-crm.git/commit/2cf4914283e64b17473badd6984ed3dbec85786d

commit 2cf4914283e64b17473badd6984ed3dbec85786d
Author: Yuri Karaban <[email protected]>
Date:   Sat Apr 12 18:55:54 2014 +0300

    split autoPlaceWindow to smaller functions

diff --git a/src/placement.c b/src/placement.c
index f48ee3ca..fb7a17ff 100644
--- a/src/placement.c
+++ b/src/placement.c
@@ -294,6 +294,53 @@ static void set_width_height(WWindow *wwin, unsigned int 
*width, unsigned int *h
        }
 }
 
+static Bool
+window_overlaps(WWindow *win, int x, int y, int w, int h, Bool ignore_sunken)
+{
+       int tw, th, tx, ty;
+
+       if (ignore_sunken &&
+           win->frame->core->stacking->window_level < WMNormalLevel) {
+               return False;
+       }
+
+       tw = win->frame->core->width;
+       th = win->frame->core->height;
+       tx = win->frame_x;
+       ty = win->frame_y;
+
+       if ((tx < (x + w)) && ((tx + tw) > x) &&
+           (ty < (y + h)) && ((ty + th) > y) &&
+           (win->flags.mapped ||
+            (win->flags.shaded &&
+             win->frame->workspace == w_global.workspace.current &&
+             !(win->flags.miniaturized || win->flags.hidden)))) {
+               return True;
+       }
+
+       return False;
+}
+
+static Bool
+screen_has_space(WScreen *scr, int x, int y, int w, int h, Bool ignore_sunken)
+{
+       WWindow *focused = scr->focused_window, *i;
+
+       for (i = focused; i; i = i->next) {
+               if (window_overlaps(i, x, y, w, h, ignore_sunken)) {
+                       return False;
+               }
+       }
+
+       for (i = focused->prev; i; i = i->prev) {
+               if (window_overlaps(i, x, y, w, h, ignore_sunken)) {
+                       return False;
+               }
+       }
+
+       return True;
+}
+
 static void
 smartPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret, unsigned int width,
                 unsigned int height, WArea usableArea)
@@ -380,83 +427,29 @@ autoPlaceWindow(WWindow *wwin, int *x_ret, int *y_ret,
 {
        WScreen *scr = wwin->screen_ptr;
        int test_x = 0, test_y = Y_ORIGIN;
-       int loc_ok = False, tw, tx, ty, th;
        int swidth, sx;
-       WWindow *test_window;
 
        set_width_height(wwin, &width, &height);
        swidth = usableArea.x2 - usableArea.x1;
        sx = X_ORIGIN;
 
        /* this was based on fvwm2's smart placement */
-       while (((test_y + height) < (usableArea.y2 - usableArea.y1)) && 
!loc_ok) {
+       while (((test_y + height) < (usableArea.y2 - usableArea.y1))) {
                test_x = sx;
 
-               while (((test_x + width) < swidth) && (!loc_ok)) {
-
-                       loc_ok = True;
-                       test_window = scr->focused_window;
-
-                       while ((test_window != NULL) && (loc_ok == True)) {
-
-                               if 
(test_window->frame->core->stacking->window_level
-                                   < WMNormalLevel && tryCount > 0) {
-                                       test_window = test_window->next;
-                                       continue;
-                               }
-                               tw = test_window->frame->core->width;
-                               th = test_window->frame->core->height;
-                               tx = test_window->frame_x;
-                               ty = test_window->frame_y;
-
-                               if ((tx < (test_x + width)) && ((tx + tw) > 
test_x) &&
-                                   (ty < (test_y + height)) && ((ty + th) > 
test_y) &&
-                                   (test_window->flags.mapped ||
-                                    (test_window->flags.shaded &&
-                                     test_window->frame->workspace == 
w_global.workspace.current &&
-                                     !(test_window->flags.miniaturized || 
test_window->flags.hidden)))) {
-
-                                       loc_ok = False;
-                               }
-                               test_window = test_window->next;
-                       }
-
-                       test_window = scr->focused_window;
-
-                       while ((test_window != NULL) && (loc_ok == True)) {
-
-                               if 
(test_window->frame->core->stacking->window_level
-                                   < WMNormalLevel && tryCount > 0) {
-                                       test_window = test_window->prev;
-                                       continue;
-                               }
-                               tw = test_window->frame->core->width;
-                               th = test_window->frame->core->height;
-                               tx = test_window->frame_x;
-                               ty = test_window->frame_y;
-
-                               if ((tx < (test_x + width)) && ((tx + tw) > 
test_x) &&
-                                   (ty < (test_y + height)) && ((ty + th) > 
test_y) &&
-                                   (test_window->flags.mapped ||
-                                    (test_window->flags.shaded &&
-                                     test_window->frame->workspace == 
w_global.workspace.current &&
-                                     !(test_window->flags.miniaturized || 
test_window->flags.hidden)))) {
-
-                                       loc_ok = False;
-                               }
-                               test_window = test_window->prev;
-                       }
-                       if (loc_ok == True) {
+               while (((test_x + width) < swidth)) {
+                       if (screen_has_space(scr, test_x, test_y,
+                                            width, height, tryCount)) {
                                *x_ret = test_x;
                                *y_ret = test_y;
-                               break;
+                               return True;
                        }
                        test_x += PLACETEST_HSTEP;
                }
                test_y += PLACETEST_VSTEP;
        }
 
-       return loc_ok;
+       return False;
 }
 
 static void

-----------------------------------------------------------------------

Summary of changes:
 src/placement.c |  144 +++++++++++++++++++++++++++----------------------------
 1 files changed, 71 insertions(+), 73 deletions(-)


repo.or.cz automatic notification. Contact project admin [email protected]
if you want to unsubscribe, or site admin [email protected] if you receive
no reply.
-- 
wmaker-crm.git ("The Window Maker window manager")


-- 
To unsubscribe, send mail to [email protected].

Reply via email to