]> code.delx.au - spectrwm/blobdiff - spectrwm.c
Redraw the focus window frame when changing regions with the pointer.
[spectrwm] / spectrwm.c
index d67d875026a1b8032c8ce8f6c5bca4cdaf463434..f68e08bf74a07a6dbecf1c1209441e754930cef0 100644 (file)
@@ -824,6 +824,7 @@ enum actionid {
        FN_FOCUS_NEXT,
        FN_FOCUS_PREV,
        FN_FOCUS_URGENT,
+       FN_FULLSCREEN_TOGGLE,
        FN_MAXIMIZE_TOGGLE,
        FN_HEIGHT_GROW,
        FN_HEIGHT_SHRINK,
@@ -1061,6 +1062,7 @@ void       focusout(xcb_focus_out_event_t *);
 void    focusrg(struct binding *, struct swm_region *, union arg *);
 void    fontset_init(void);
 void    free_window(struct ws_win *);
+void    fullscreen_toggle(struct binding *, struct swm_region *, union arg *);
 xcb_atom_t get_atom_from_string(const char *);
 #ifdef SWM_DEBUG
 char   *get_atom_name(xcb_atom_t);
@@ -3710,7 +3712,16 @@ spawn(int ws_idx, union arg *args, bool close_fd)
 
        close(xcb_get_file_descriptor(conn));
 
-       setenv("LD_PRELOAD", SWM_LIB, 1);
+       if ((ret = getenv("LD_PRELOAD"))) {
+               if (asprintf(&ret, "%s:%s", SWM_LIB, ret) == -1) {
+                       warn("spawn: asprintf LD_PRELOAD");
+                       _exit(1);
+               }
+               setenv("LD_PRELOAD", ret, 1);
+               free(ret);
+       } else {
+               setenv("LD_PRELOAD", SWM_LIB, 1);
+       }
 
        if (asprintf(&ret, "%d", ws_idx) == -1) {
                warn("spawn: asprintf SWM_WS");
@@ -4133,6 +4144,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();
 }
 
@@ -6552,6 +6567,32 @@ floating_toggle(struct binding *bp, struct swm_region *r, union arg *args)
        DNPRINTF(SWM_D_MISC, "floating_toggle: done\n");
 }
 
+void
+fullscreen_toggle(struct binding *bp, struct swm_region *r, union arg *args)
+{
+       struct ws_win           *w = r->ws->focus;
+
+       /* suppress unused warning since var is needed */
+       (void)bp;
+       (void)args;
+
+       if (w == NULL)
+               return;
+
+       DNPRINTF(SWM_D_MISC, "fullscreen_toggle: win %#x\n", w->id);
+
+       ewmh_apply_flags(w, w->ewmh_flags ^ EWMH_F_FULLSCREEN);
+       ewmh_update_wm_state(w);
+
+       stack(r);
+
+       if (w == w->ws->focus)
+               focus_win(w);
+
+       center_pointer(r);
+       focus_flush();
+       DNPRINTF(SWM_D_MISC, "fullscreen_toggle: done\n");
+}
 void
 region_containment(struct ws_win *win, struct swm_region *r, int opts)
 {
@@ -7338,6 +7379,7 @@ struct action {
        { "focus_next",         focus,          0, {.id = SWM_ARG_ID_FOCUSNEXT} },
        { "focus_prev",         focus,          0, {.id = SWM_ARG_ID_FOCUSPREV} },
        { "focus_urgent",       focus,          0, {.id = SWM_ARG_ID_FOCUSURGENT} },
+       { "fullscreen_toggle",  fullscreen_toggle, 0, {0} },
        { "maximize_toggle",    maximize_toggle,0, {0} },
        { "height_grow",        resize,         0, {.id = SWM_ARG_ID_HEIGHTGROW} },
        { "height_shrink",      resize,         0, {.id = SWM_ARG_ID_HEIGHTSHRINK} },
@@ -8124,6 +8166,7 @@ setup_keybindings(void)
        BINDKEY(MODKEY,         XK_k,                   FN_FOCUS_PREV);
        BINDKEY(MODSHIFT,       XK_Tab,                 FN_FOCUS_PREV);
        BINDKEY(MODKEY,         XK_u,                   FN_FOCUS_URGENT);
+       BINDKEY(MODSHIFT,       XK_e,                   FN_FULLSCREEN_TOGGLE);
        BINDKEY(MODKEY,         XK_e,                   FN_MAXIMIZE_TOGGLE);
        BINDKEY(MODSHIFT,       XK_equal,               FN_HEIGHT_GROW);
        BINDKEY(MODSHIFT,       XK_minus,               FN_HEIGHT_SHRINK);