]> code.delx.au - spectrwm/blobdiff - spectrwm.c
Fix unmapnotify to update the win mapping and iconic state.
[spectrwm] / spectrwm.c
index b250a20d66cb1b06b8a5b354eb4f6bbadaac2f11..f550e1a27c07d68741e1367d2dc28a15732b1991 100644 (file)
@@ -269,8 +269,8 @@ xcb_atom_t          a_swm_iconic;
 xcb_atom_t             a_swm_ws;
 volatile sig_atomic_t   running = 1;
 volatile sig_atomic_t   restart_wm = 0;
+xcb_timestamp_t                last_event_time = 0;
 int                    outputs = 0;
-/*int                  last_focus_event = FocusOut;*/
 int                    other_wm;
 int                    ss_enabled = 0;
 int                    xrandr_support;
@@ -280,7 +280,6 @@ unsigned int                numlockmask = 0;
 Display                        *display;
 xcb_connection_t       *conn;
 xcb_key_symbols_t      *syms;
-xcb_timestamp_t                last_event_time;
 
 int                    cycle_empty = 0;
 int                    cycle_visible = 0;
@@ -851,7 +850,6 @@ get_swm_iconic(struct ws_win *win)
        int32_t                         v = 0;
        xcb_get_property_reply_t        *pr = NULL;
 
-
        pr = xcb_get_property_reply(conn,
            xcb_get_property(conn, 0, win->id, a_swm_iconic,
            XCB_ATOM_INTEGER, 0, 1), NULL);
@@ -2148,7 +2146,8 @@ set_win_state(struct ws_win *win, uint16_t state)
 {
        uint16_t                data[2] = { state, XCB_ATOM_NONE };
 
-       DNPRINTF(SWM_D_EVENT, "set_win_state: window: 0x%x\n", win->id);
+       DNPRINTF(SWM_D_EVENT, "set_win_state: window: 0x%x, state: %u\n",
+           win->id, state);
 
        if (win == NULL)
                return;
@@ -3029,7 +3028,6 @@ swapwin(struct swm_region *r, union arg *args)
        struct ws_win           *cur_focus;
        struct ws_win_list      *wl;
 
-
        DNPRINTF(SWM_D_WS, "swapwin: id: %d, screen[%d]:%dx%d+%d+%d, ws: %d\n",
            args->id, r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r), r->ws->idx);
 
@@ -4434,7 +4432,6 @@ wkill(struct swm_region *r, union arg *args)
        xcb_flush(conn);
 }
 
-
 int
 floating_toggle_win(struct ws_win *win)
 {
@@ -4898,7 +4895,6 @@ move_step(struct swm_region *r, union arg *args)
        move(win, args);
 }
 
-
 /* user/key callable function IDs */
 enum keyfuncid {
        KF_BAR_TOGGLE,
@@ -6507,7 +6503,6 @@ struct config_option configopt[] = {
        { "layout",                     setlayout,      0 },
 };
 
-
 int
 conf_load(char *filename, int keymapping)
 {
@@ -6515,7 +6510,7 @@ conf_load(char *filename, int keymapping)
        char                    *line, *cp, *optsub, *optval;
        size_t                  linelen, lineno = 0;
        int                     wordlen, i, optidx;
-       struct config_option    *opt;
+       struct config_option    *opt = NULL;
 
        DNPRINTF(SWM_D_CONF, "conf_load: begin\n");
 
@@ -6916,7 +6911,6 @@ manage_window(xcb_window_t id, uint16_t mapped)
                update_window(win);
        }
 
-
        /* Select which X events to monitor and set border pixel color. */
        wa[0] = win->s->c[SWM_S_COLOR_UNFOCUS].pixel;
        wa[1] = XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_PROPERTY_CHANGE |
@@ -7570,12 +7564,14 @@ propertynotify(xcb_property_notify_event_t *e)
                        focus_flush();
                        return;
                } else if (e->state == XCB_PROPERTY_NEW_VALUE) {
+                       win->ws->focus_pending = get_focus_prev(win);
                        unfocus_win(win);
                        unmap_window(win);
 
                        if (win->ws->r) {
-                               focus_win(get_focus_prev(win));
                                stack();
+                               focus_win(win->ws->focus_pending);
+                               win->ws->focus_pending = NULL;
                                focus_flush();
                        }
                }
@@ -7616,6 +7612,9 @@ unmapnotify(xcb_unmap_notify_event_t *e)
                if (win == win->ws->focus)
                        win->ws->focus_pending = get_focus_prev(win);
 
+               win->mapped = 0;
+               set_win_state(win, XCB_ICCCM_WM_STATE_ICONIC);
+
                unmanage_window(win);
                stack();