]> code.delx.au - spectrwm/blobdiff - spectrwm.c
Trim trailing whitespace when loading config
[spectrwm] / spectrwm.c
index e566741c6d885136f2b331d47add86620fe844df..ae753c8762ca1c56e4c45d2a54031cd276804bc7 100644 (file)
@@ -69,6 +69,7 @@
 #include <X11/Xcursor/Xcursor.h>
 #include <X11/Xft/Xft.h>
 #include <X11/Xlib-xcb.h>
+#include <xcb/xcb.h>
 #include <xcb/xcb_atom.h>
 #include <xcb/xcb_aux.h>
 #include <xcb/xcb_event.h>
@@ -4144,6 +4145,10 @@ set_region(struct swm_region *r)
 
        r->s->r_focus = r;
 
+       /* Update the focus window frame on the now unfocused region. */
+       if (rf && rf->ws->focus)
+               draw_frame(rf->ws->focus);
+
        ewmh_update_current_desktop();
 }
 
@@ -9565,6 +9570,10 @@ conf_load(const char *filename, int keymapping)
                            configopt[optidx].optname);
                        continue;
                }
+               /* trim trailing spaces */
+               ce = optval + strlen(optval) - 1;
+               while (ce > optval && isspace(*ce)) --ce;
+               *(ce + 1) = '\0';
                /* call function to deal with it all */
                if (configopt[optidx].func(optsub, optval,
                    configopt[optidx].funcflags) != 0) {
@@ -11092,7 +11101,7 @@ reparentnotify(xcb_reparent_notify_event_t *e)
                if (win->state == SWM_WIN_STATE_REPARENTING) {
                        win->state = SWM_WIN_STATE_REPARENTED;
 
-                       if (win->ws->r)
+                       if (win->ws->r && !ICONIC(win))
                                map_window(win);
                        else
                                unmap_window(win);
@@ -11518,7 +11527,6 @@ scan_randr(int idx)
        int                                             ncrtc = 0;
 #endif /* SWM_XRR_HAS_CRTC */
        struct swm_region                               *r;
-       struct ws_win                                   *win;
        int                                             num_screens;
        xcb_randr_get_screen_resources_current_cookie_t src;
        xcb_randr_get_screen_resources_current_reply_t  *srr;
@@ -11593,13 +11601,8 @@ scan_randr(int idx)
                    screen->height_in_pixels);
 
 out:
-       /* Cleanup unused previously visible workspaces. */
+       /* The screen shouldn't focus on unused regions. */
        TAILQ_FOREACH(r, &screens[idx].orl, entry) {
-               TAILQ_FOREACH(win, &r->ws->winlist, entry)
-                       unmap_window(win);
-               r->ws->state = SWM_WS_STATE_HIDDEN;
-
-               /* The screen shouldn't focus on an unused region. */
                if (screens[idx].r_focus == r)
                        screens[idx].r_focus = NULL;
        }
@@ -11611,7 +11614,9 @@ void
 screenchange(xcb_randr_screen_change_notify_event_t *e)
 {
        struct swm_region               *r;
-       int                             i, num_screens;
+       struct workspace                *ws;
+       struct ws_win                   *win;
+       int                             i, j, num_screens;
 
        DNPRINTF(SWM_D_EVENT, "screenchange: root: %#x\n", e->root);
 
@@ -11644,6 +11649,16 @@ screenchange(xcb_randr_screen_change_notify_event_t *e)
                        focus_region(r);
        }
 
+       /* Cleanup unused previously visible workspaces. */
+       for (j = 0; j < workspace_limit; j++) {
+               ws = &screens[i].ws[j];
+               if (ws->r == NULL && ws->state != SWM_WS_STATE_HIDDEN) {
+                       TAILQ_FOREACH(win, &ws->winlist, entry)
+                               unmap_window(win);
+                       ws->state = SWM_WS_STATE_HIDDEN;
+               }
+       }
+
        focus_flush();
 
        /* Update workspace state and bar on all regions. */