From: Yuri D'Elia Date: Mon, 29 Apr 2013 16:27:23 +0000 (+0200) Subject: Implement the "raise_focused" function X-Git-Tag: SPECTRWM_3_0_0~12 X-Git-Url: https://code.delx.au/spectrwm/commitdiff_plain/df6ae9dcd4ee0b8472c8819e47f951c21569c855 Implement the "raise_focused" function --- diff --git a/spectrwm.1 b/spectrwm.1 index cdf91f9..02ed83c 100644 --- a/spectrwm.1 +++ b/spectrwm.1 @@ -714,6 +714,8 @@ iconify uniconify .It Cm M-e maximize_toggle +.It Cm Aq Ar unbound +raise_focused .It Cm M-S-r always_raise .It Cm M-v @@ -894,6 +896,8 @@ Restore (map) window returned by selection. .It Cm maximize_toggle Toggle maximization of focused window. +.It Cm raise_focused +Raise the current window. .It Cm always_raise When set tiled windows are allowed to obscure floating windows. .It Cm button2 diff --git a/spectrwm.c b/spectrwm.c index d3ea727..61d21f5 100644 --- a/spectrwm.c +++ b/spectrwm.c @@ -534,6 +534,7 @@ struct workspace { struct ws_win *focus; /* may be NULL */ struct ws_win *focus_prev; /* may be NULL */ struct ws_win *focus_pending; /* may be NULL */ + struct ws_win *raised; /* may be NULL */ struct swm_region *r; /* may be NULL */ struct swm_region *old_r; /* may be NULL */ struct ws_win_list winlist; /* list of windows in ws */ @@ -869,6 +870,7 @@ enum actionid { FN_MVWS_22, FN_NAME_WORKSPACE, FN_QUIT, + FN_RAISE_FOCUSED, FN_RAISE_TOGGLE, FN_RESIZE, FN_RESIZE_CENTERED, @@ -1132,6 +1134,7 @@ void quirk_remove(struct quirk *); void quirk_replace(struct quirk *, const char *, const char *, const char *, uint32_t, int); void quit(struct binding *, struct swm_region *, union arg *); +void raise_focused(struct binding *, struct swm_region *, union arg *); void raise_toggle(struct binding *, struct swm_region *, union arg *); void raise_window(struct ws_win *); void region_containment(struct ws_win *, struct swm_region *, int); @@ -3770,6 +3773,8 @@ kill_refs(struct ws_win *win) ws->focus_prev = NULL; if (win == ws->focus_pending) ws->focus_pending = NULL; + if (win == ws->raised) + ws->raised = NULL; if (TRANS(win)) TAILQ_FOREACH(w, &ws->winlist, entry) @@ -3855,6 +3860,9 @@ unfocus_win(struct ws_win *win) if (win->ws->focus == win) { win->ws->focus = NULL; win->ws->focus_prev = win; + if(win->ws->raised == win && !FLOATING(win)) { + update_win_stacking(win); + } } if (validate_win(win->ws->focus)) { @@ -5732,6 +5740,31 @@ pressbutton(struct binding *bp, struct swm_region *r, union arg *args) XCB_CURRENT_TIME, XCB_WINDOW_NONE, 0, 0, 0); } +void +raise_focused(struct binding *bp, struct swm_region *r, union arg *args) +{ + struct ws_win *win; + uint32_t val; + + /* Suppress warning. */ + (void)bp; + (void)args; + + if (r == NULL || r->ws == NULL || r->ws->focus == NULL) + return; + + win = r->ws->focus; + r->ws->raised = win; + raise_window(win); + + /* Temporarily override stacking order also in the stack */ + if (!FLOATING(win)) { + val = XCB_STACK_MODE_ABOVE; + xcb_configure_window(conn, win->frame, + XCB_CONFIG_WINDOW_STACK_MODE, &val); + } +} + void raise_toggle(struct binding *bp, struct swm_region *r, union arg *args) { @@ -7324,6 +7357,7 @@ struct action { { "mvws_22", send_to_ws, 0, {.id = 21} }, { "name_workspace", name_workspace, 0, {0} }, { "quit", quit, 0, {0} }, + { "raise_focused", raise_focused, 0, {0} }, { "raise_toggle", raise_toggle, 0, {0} }, { "resize", resize, FN_F_NOREPLAY, {.id = SWM_ARG_ID_DONTCENTER} }, { "resize_centered", resize, FN_F_NOREPLAY, {.id = SWM_ARG_ID_CENTER} }, @@ -11714,6 +11748,7 @@ setup_screens(void) ws->focus = NULL; ws->focus_prev = NULL; ws->focus_pending = NULL; + ws->raised = NULL; ws->r = NULL; ws->old_r = NULL; ws->state = SWM_WS_STATE_HIDDEN;