X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=scrotwm.c;h=5757fc3f146c83514413dce515a766678488926d;hb=641cdb0fc683e4645bd45f3d3c744f95da1153eb;hp=3ea31dbacbcd99da8f58357988fba550d456c33d;hpb=b1d1bb436052a1b7f902ad17e6ff9f658b4313a3;p=spectrwm.git diff --git a/scrotwm.c b/scrotwm.c index 3ea31db..5757fc3 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -423,9 +423,11 @@ struct workspace { int horizontal_msize; int horizontal_mwin; int horizontal_stacks; + int horizontal_flip; int vertical_msize; int vertical_mwin; int vertical_stacks; + int vertical_flip; } l_state; }; @@ -467,6 +469,7 @@ union arg { #define SWM_ARG_ID_MASTERGROW (21) #define SWM_ARG_ID_MASTERADD (22) #define SWM_ARG_ID_MASTERDEL (23) +#define SWM_ARG_ID_FLIPLAYOUT (24) #define SWM_ARG_ID_STACKRESET (30) #define SWM_ARG_ID_STACKINIT (31) #define SWM_ARG_ID_CYCLEWS_UP (40) @@ -1215,10 +1218,12 @@ fancy_stacker(struct workspace *ws) { strlcpy(ws->stacker, "[ ]", sizeof ws->stacker); if (ws->cur_layout->l_stack == vertical_stack) - snprintf(ws->stacker, sizeof ws->stacker, "[%d|%d]", + snprintf(ws->stacker, sizeof ws->stacker, + ws->l_state.vertical_flip ? "[%d>%d]" : "[%d|%d]", ws->l_state.vertical_mwin, ws->l_state.vertical_stacks); if (ws->cur_layout->l_stack == horizontal_stack) - snprintf(ws->stacker, sizeof ws->stacker, "[%d-%d]", + snprintf(ws->stacker, sizeof ws->stacker, + ws->l_state.horizontal_flip ? "[%dv%d]" : "[%d-%d]", ws->l_state.horizontal_mwin, ws->l_state.horizontal_stacks); } @@ -1227,9 +1232,11 @@ plain_stacker(struct workspace *ws) { strlcpy(ws->stacker, "[ ]", sizeof ws->stacker); if (ws->cur_layout->l_stack == vertical_stack) - strlcpy(ws->stacker, "[|]", sizeof ws->stacker); + strlcpy(ws->stacker, ws->l_state.vertical_flip ? "[>]" : "[|]", + sizeof ws->stacker); if (ws->cur_layout->l_stack == horizontal_stack) - strlcpy(ws->stacker, "[-]", sizeof ws->stacker); + strlcpy(ws->stacker, ws->l_state.horizontal_flip ? "[v]" : "[-]", + sizeof ws->stacker); } void @@ -1478,6 +1485,13 @@ bar_update(void) } void +bar_check_opts(void) +{ + if (title_class_enabled || title_name_enabled || window_name_enabled) + bar_update(); +} + +void bar_signal(int sig) { bar_alarm = 1; @@ -2208,8 +2222,7 @@ focus_win(struct ws_win *win) PropModeReplace, (unsigned char *)&win->id,1); } - if (window_name_enabled || title_class_enabled || title_name_enabled) - bar_update(); + bar_check_opts(); } void @@ -2525,15 +2538,8 @@ focus_prev(struct ws_win *win) winfocus = TAILQ_LAST(wl, ws_win_list); if (winfocus == NULL || winfocus == win) winfocus = TAILQ_NEXT(cur_focus, entry); -done: - if (winfocus == winlostfocus || winfocus == NULL) { - /* update the bar so that title/class/name will be cleared. */ - if (window_name_enabled || title_name_enabled || - title_class_enabled) - bar_update(); - return; - } +done: focus_magic(winfocus); } @@ -2637,14 +2643,6 @@ focus(struct swm_region *r, union arg *args) default: return; } - if (winfocus == winlostfocus || winfocus == NULL) { - /* update the bar so that title/class/name will be cleared. */ - if (window_name_enabled || title_name_enabled || - title_class_enabled) - bar_update(); - - return; - } focus_magic(winfocus); } @@ -3091,6 +3089,9 @@ vertical_config(struct workspace *ws, int id) if (ws->l_state.vertical_stacks > 1) ws->l_state.vertical_stacks--; break; + case SWM_ARG_ID_FLIPLAYOUT: + ws->l_state.vertical_flip = !ws->l_state.vertical_flip; + break; default: return; } @@ -3101,7 +3102,7 @@ vertical_stack(struct workspace *ws, struct swm_geometry *g) { DNPRINTF(SWM_D_STACK, "vertical_stack: workspace: %d\n", ws->idx); - stack_master(ws, g, 0, 0); + stack_master(ws, g, 0, ws->l_state.vertical_flip); } void @@ -3138,6 +3139,9 @@ horizontal_config(struct workspace *ws, int id) if (ws->l_state.horizontal_stacks > 1) ws->l_state.horizontal_stacks--; break; + case SWM_ARG_ID_FLIPLAYOUT: + ws->l_state.horizontal_flip = !ws->l_state.horizontal_flip; + break; default: return; } @@ -3148,7 +3152,7 @@ horizontal_stack(struct workspace *ws, struct swm_geometry *g) { DNPRINTF(SWM_D_STACK, "horizontal_stack: workspace: %d\n", ws->idx); - stack_master(ws, g, 1, 0); + stack_master(ws, g, 1, ws->l_state.horizontal_flip); } /* fullscreen view */ @@ -4147,6 +4151,7 @@ move_step(struct swm_region *r, union arg *args) /* user/key callable function IDs */ enum keyfuncid { kf_cycle_layout, + kf_flip_layout, kf_stack_reset, kf_master_shrink, kf_master_grow, @@ -4238,6 +4243,7 @@ struct keyfunc { } keyfuncs[kf_invalid + 1] = { /* name function argument */ { "cycle_layout", cycle_layout, {0} }, + { "flip_layout", stack_config, {.id = SWM_ARG_ID_FLIPLAYOUT} }, { "stack_reset", stack_config, {.id = SWM_ARG_ID_STACKRESET} }, { "master_shrink", stack_config, {.id = SWM_ARG_ID_MASTERSHRINK} }, { "master_grow", stack_config, {.id = SWM_ARG_ID_MASTERGROW} }, @@ -4820,6 +4826,7 @@ void setup_keys(void) { setkeybinding(MODKEY, XK_space, kf_cycle_layout,NULL); + setkeybinding(MODKEY|ShiftMask, XK_backslash, kf_flip_layout, NULL); setkeybinding(MODKEY|ShiftMask, XK_space, kf_stack_reset, NULL); setkeybinding(MODKEY, XK_h, kf_master_shrink,NULL); setkeybinding(MODKEY, XK_l, kf_master_grow, NULL); @@ -5981,8 +5988,11 @@ focus_magic(struct ws_win *win) { DNPRINTF(SWM_D_FOCUS, "focus_magic: window: 0x%lx\n", WINID(win)); - if (win == NULL) + if (win == NULL) { + /* if there are no windows clear the status-bar */ + bar_check_opts(); return; + } if (win->child_trans) { /* win = parent & has a transient so focus on that */ @@ -5991,7 +6001,7 @@ focus_magic(struct ws_win *win) if (win->child_trans->take_focus) client_msg(win, takefocus); } else { - /* make sure transient hasn't dissapeared */ + /* make sure transient hasn't disappeared */ if (validate_win(win->child_trans) == 0) { focus_win(win->child_trans); if (win->child_trans->take_focus)