From: Reginald Kennedy Date: Mon, 14 Sep 2015 18:16:20 +0000 (+0800) Subject: Add new fullscreen_toggle action. X-Git-Tag: SPECTRWM_3_0_0~9 X-Git-Url: https://code.delx.au/spectrwm/commitdiff_plain/6b0c4d149311ff3ce8a79e23e78e80f4a936bf0e Add new fullscreen_toggle action. Toggles _NET_WM_STATE_FULLSCREEN on the current window. Default binding: M-S-e --- diff --git a/spectrwm.1 b/spectrwm.1 index 982092f..6e7f521 100644 --- a/spectrwm.1 +++ b/spectrwm.1 @@ -718,6 +718,8 @@ iconify uniconify .It Cm M-e maximize_toggle +.It Cm M-S-e +fullscreen_toggle .It Cm M-r raise .It Cm M-S-r @@ -904,6 +906,8 @@ Restore (map) window returned by selection. .It Cm maximize_toggle Toggle maximization of focused window. +.It Cm fullscreen_toggle +Toggle fullscreen state of focused window. .It Cm raise Raise the current window. .It Cm always_raise diff --git a/spectrwm.c b/spectrwm.c index d67d875..37b0d2e 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -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); @@ -6552,6 +6554,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 +7366,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 +8153,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);