JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fix longstanding bug where fullscreen was off by one
[spectrwm.git] / scrotwm.c
index e544df5..aab81c0 100644 (file)
--- a/scrotwm.c
+++ b/scrotwm.c
@@ -100,7 +100,7 @@ static const char   *cvstag = "$scrotwm$";
 #endif
 #endif
 
-/* #define SWM_DEBUG */
+/*#define SWM_DEBUG*/
 #ifdef SWM_DEBUG
 #define DPRINTF(x...)          do { if (swm_debug) fprintf(stderr, x); } while (0)
 #define DNPRINTF(n,x...)       do { if (swm_debug & n) fprintf(stderr, x); } while (0)
@@ -656,7 +656,7 @@ ewmh_set_win_fullscreen(struct ws_win *win, int fs)
                win->g.y = rg.y;
                win->g.w = rg.w;
                win->g.h = rg.h;
-       }       else {
+       } else {
                if (win->g_floatvalid) {
                        /* refloat at last floating relative position */
                        win->g.x = win->g_float.x - win->rg_float.x + rg.x;
@@ -2237,6 +2237,13 @@ focus(struct swm_region *r, union arg *args)
                                head = TAILQ_LAST(wl, ws_win_list);
                        winfocus = head;
                }
+
+               /* skip iconics */
+               if (winfocus && winfocus->iconic) {
+                       TAILQ_FOREACH_REVERSE(winfocus, wl, ws_win_list, entry)
+                               if (winfocus->iconic == 0)
+                                       break;
+               }
                break;
 
        case SWM_ARG_ID_FOCUSNEXT:
@@ -2244,6 +2251,13 @@ focus(struct swm_region *r, union arg *args)
                if (head == NULL)
                        head = TAILQ_FIRST(wl);
                winfocus = head;
+
+               /* skip iconics */
+               if (winfocus && winfocus->iconic) {
+                       TAILQ_FOREACH(winfocus, wl, entry)
+                               if (winfocus->iconic == 0)
+                                       break;
+               }
                break;
 
        case SWM_ARG_ID_FOCUSMAIN:
@@ -2392,22 +2406,22 @@ stack_floater(struct ws_win *win, struct swm_region *r)
                 * floaters and transients are auto-centred unless moved
                 * or resized
                 */
-               win->g.x = r->g.x + (WIDTH(r) - win->g.w) / 2 - border_width;
-               win->g.y = r->g.y + (HEIGHT(r) - win->g.h) / 2 - border_width;
+               win->g.x = r->g.x + (WIDTH(r) - win->g.w) / 2 - wc.border_width;
+               win->g.y = r->g.y + (HEIGHT(r) - win->g.h) / 2 - wc.border_width;
        }
 
        /* win can be outside r if new r smaller than old r */
        /* Ensure top left corner inside r (move probs otherwise) */
-       if (win->g.x < r->g.x - border_width)
-               win->g.x = r->g.x - border_width;
+       if (win->g.x < r->g.x - wc.border_width)
+               win->g.x = r->g.x - wc.border_width;
        if (win->g.x > r->g.x + r->g.w - 1)
                win->g.x = (win->g.w > r->g.w) ? r->g.x :
-                   (r->g.x + r->g.w - win->g.w - 2 * border_width);
-       if (win->g.y < r->g.y - border_width)
-               win->g.y = r->g.y - border_width;
+                   (r->g.x + r->g.w - win->g.w - 2 * wc.border_width);
+       if (win->g.y < r->g.y - wc.border_width)
+               win->g.y = r->g.y - wc.border_width;
        if (win->g.y > r->g.y + r->g.h - 1)
                win->g.y = (win->g.h > r->g.h) ? r->g.y :
-                   (r->g.y + r->g.h - win->g.h - 2 * border_width);
+                   (r->g.y + r->g.h - win->g.h - 2 * wc.border_width);
 
        wc.x = win->g.x;
        wc.y = win->g.y;
@@ -2640,14 +2654,13 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
                j++;
        }
 
- notiles:
+notiles:
        /* now, stack all the floaters and transients */
        TAILQ_FOREACH(win, &ws->winlist, entry) {
                if (win->transient == 0 && win->floating == 0)
                        continue;
-               if (win->iconic == 0)
+               if (win->iconic == 1)
                        continue;
-
                if (win->ewmh_flags & EWMH_F_FULLSCREEN) {
                        fs_win = win;
                        continue;