X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=scrotwm.c;h=227c3f4ea353ca3da2b82e7658b7e80e3a00410d;hb=623ccee72222f16ed35512484589d92232685815;hp=2762142073ed6e727f63307f1aba6ee0f93c85bd;hpb=6c7fab8bc6d62d8be35014a749509b0e78fc61d8;p=spectrwm.git diff --git a/scrotwm.c b/scrotwm.c index 2762142..227c3f4 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -55,7 +55,7 @@ static const char *cvstag = "$scrotwm$"; -#define SWM_VERSION "0.9.32" +#define SWM_VERSION "0.9.33" #include #include @@ -220,6 +220,7 @@ int bar_verbose = 1; int bar_height = 0; int stack_enabled = 1; int clock_enabled = 1; +int urgent_enabled = 0; char *clock_format = NULL; int title_name_enabled = 0; int title_class_enabled = 0; @@ -227,6 +228,7 @@ int window_name_enabled = 0; int focus_mode = SWM_FOCUS_DEFAULT; int disable_border = 0; int border_width = 1; +int verbose_layout = 0; pid_t bar_pid; GC bar_gc; XGCValues bar_gcv; @@ -309,6 +311,8 @@ void vertical_stack(struct workspace *, struct swm_geometry *); void horizontal_config(struct workspace *, int); void horizontal_stack(struct workspace *, struct swm_geometry *); void max_stack(struct workspace *, struct swm_geometry *); +void plain_stacker(struct workspace *); +void fancy_stacker(struct workspace *); struct ws_win *find_window(Window); @@ -323,13 +327,13 @@ struct layout { u_int32_t flags; #define SWM_L_FOCUSPREV (1<<0) #define SWM_L_MAPONFOCUS (1<<1) - char *name; + void (*l_string)(struct workspace *); } layouts[] = { /* stack, configure */ - { vertical_stack, vertical_config, 0, "[|]" }, - { horizontal_stack, horizontal_config, 0, "[-]" }, + { vertical_stack, vertical_config, 0, plain_stacker }, + { horizontal_stack, horizontal_config, 0, plain_stacker }, { max_stack, NULL, - SWM_L_MAPONFOCUS | SWM_L_FOCUSPREV, "[ ]" }, + SWM_L_MAPONFOCUS | SWM_L_FOCUSPREV, plain_stacker }, { NULL, NULL, 0, NULL }, }; @@ -352,6 +356,7 @@ struct workspace { struct swm_region *old_r; /* may be NULL */ struct ws_win_list winlist; /* list of windows in ws */ struct ws_win_list unmanagedlist; /* list of dead windows in ws */ + char stacker[10]; /* display stacker and layout */ /* stacker state */ struct { @@ -1124,6 +1129,28 @@ setscreencolor(char *val, int i, int c) } void +fancy_stacker(struct workspace *ws) +{ + strcpy(ws->stacker, "[ ]"); + if (ws->cur_layout->l_stack == vertical_stack) + snprintf(ws->stacker, sizeof ws->stacker, "[%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]", + ws->l_state.horizontal_mwin, ws->l_state.horizontal_stacks); +} + +void +plain_stacker(struct workspace *ws) +{ + strcpy(ws->stacker, "[ ]"); + if (ws->cur_layout->l_stack == vertical_stack) + strcpy(ws->stacker, "[|]"); + if (ws->cur_layout->l_stack == horizontal_stack) + strcpy(ws->stacker, "[-]"); +} + +void custom_region(char *val) { unsigned int sidx, x, y, w, h; @@ -1236,6 +1263,40 @@ bar_window_name(char *s, ssize_t sz, struct ws_win *cur_focus) } void +bar_urgent(char *s, ssize_t sz) +{ + XWMHints *wmh = NULL; + struct ws_win *win; + int i, j, got_some = 0; + char a[32], b[8]; + + if (urgent_enabled == 0) + return; + + a[0] = '\0'; + for (i = 0; i < ScreenCount(display); i++) + for (j = 0; j < SWM_WS_MAX; j++) + TAILQ_FOREACH(win, &screens[i].ws[j].winlist, entry) { + wmh = XGetWMHints(display, win->id); + if (wmh == NULL) + continue; + + if (wmh->flags & XUrgencyHint) { + snprintf(b, sizeof b, "%d ", j + 1); + strlcat(a, b, sizeof a); + got_some = 1; + } + XFree(wmh); + } + + if (got_some) { + strlcat(s, a, sz); + strlcat(s, " ", sz); + } else + strlcat(s, " ", sz); +} + +void bar_update(void) { time_t tmt; @@ -1247,7 +1308,6 @@ bar_update(void) char cn[SWM_BAR_MAX]; char loc[SWM_BAR_MAX]; char *b; - char *stack = ""; if (bar_enabled == 0) return; @@ -1280,15 +1340,13 @@ bar_update(void) TAILQ_FOREACH(r, &screens[i].rl, entry) { strlcpy(cn, "", sizeof cn); if (r && r->ws) { + bar_urgent(cn, sizeof cn); bar_class_name(cn, sizeof cn, r->ws->focus); bar_window_name(cn, sizeof cn, r->ws->focus); } - if (stack_enabled) - stack = r->ws->cur_layout->name; - snprintf(loc, sizeof loc, "%d:%d %s %s%s %s %s", - x++, r->ws->idx + 1, stack, s, cn, bar_ext, + x++, r->ws->idx + 1, r->ws->stacker, s, cn, bar_ext, bar_vertext); bar_print(r, loc); } @@ -2414,6 +2472,7 @@ stack_config(struct swm_region *r, union arg *args) if (args->id != SWM_ARG_ID_STACKINIT) stack(); + bar_update(); } void @@ -2440,6 +2499,7 @@ stack(void) { g.h -= bar_height; } r->ws->cur_layout->l_stack(r->ws, &g); + r->ws->cur_layout->l_string(r->ws); /* save r so we can track region changes */ r->ws->old_r = r; } @@ -4409,15 +4469,17 @@ enum { SWM_S_BAR_DELAY, SWM_S_BAR_ENABLED, SWM_S_BAR_BORDER_WIDTH, SWM_S_STACK_ENABLED, SWM_S_CLOCK_ENABLED, SWM_S_CLOCK_FORMAT, SWM_S_CYCLE_EMPTY, SWM_S_CYCLE_VISIBLE, SWM_S_SS_ENABLED, SWM_S_TERM_WIDTH, SWM_S_TITLE_CLASS_ENABLED, - SWM_S_TITLE_NAME_ENABLED, SWM_S_WINDOW_NAME_ENABLED, + SWM_S_TITLE_NAME_ENABLED, SWM_S_WINDOW_NAME_ENABLED, SWM_S_URGENT_ENABLED, SWM_S_FOCUS_MODE, SWM_S_DISABLE_BORDER, SWM_S_BORDER_WIDTH, SWM_S_BAR_FONT, SWM_S_BAR_ACTION, SWM_S_SPAWN_TERM, - SWM_S_SS_APP, SWM_S_DIALOG_RATIO, SWM_S_BAR_AT_BOTTOM + SWM_S_SS_APP, SWM_S_DIALOG_RATIO, SWM_S_BAR_AT_BOTTOM, + SWM_S_VERBOSE_LAYOUT }; int setconfvalue(char *selector, char *value, int flags) { + int i; switch (flags) { case SWM_S_BAR_DELAY: bar_delay = atoi(value); @@ -4465,6 +4527,9 @@ setconfvalue(char *selector, char *value, int flags) case SWM_S_TITLE_NAME_ENABLED: title_name_enabled = atoi(value); break; + case SWM_S_URGENT_ENABLED: + urgent_enabled = atoi(value); + break; case SWM_S_FOCUS_MODE: if (!strcmp(value, "default")) focus_mode = SWM_FOCUS_DEFAULT; @@ -4503,6 +4568,15 @@ setconfvalue(char *selector, char *value, int flags) if (dialog_ratio > 1.0 || dialog_ratio <= .3) dialog_ratio = .6; break; + case SWM_S_VERBOSE_LAYOUT: + verbose_layout = atoi(value); + for (i = 0; layouts[i].l_stack != NULL; i++) { + if (verbose_layout) + layouts[i].l_string = fancy_stacker; + else + layouts[i].l_string = plain_stacker; + } + break; default: return (1); } @@ -4694,6 +4768,7 @@ struct config_option configopt[] = { { "cycle_empty", setconfvalue, SWM_S_CYCLE_EMPTY }, { "cycle_visible", setconfvalue, SWM_S_CYCLE_VISIBLE }, { "dialog_ratio", setconfvalue, SWM_S_DIALOG_RATIO }, + { "verbose_layout", setconfvalue, SWM_S_VERBOSE_LAYOUT }, { "modkey", setconfmodkey, 0 }, { "program", setconfspawn, 0 }, { "quirk", setconfquirk, 0 }, @@ -4702,6 +4777,7 @@ struct config_option configopt[] = { { "screenshot_enabled", setconfvalue, SWM_S_SS_ENABLED }, { "screenshot_app", setconfvalue, SWM_S_SS_APP }, { "window_name_enabled", setconfvalue, SWM_S_WINDOW_NAME_ENABLED }, + { "urgent_enabled", setconfvalue, SWM_S_URGENT_ENABLED }, { "term_width", setconfvalue, SWM_S_TERM_WIDTH }, { "title_class_enabled", setconfvalue, SWM_S_TITLE_CLASS_ENABLED }, { "title_name_enabled", setconfvalue, SWM_S_TITLE_NAME_ENABLED }, @@ -5985,6 +6061,7 @@ setup_screens(void) layouts[k].l_config(ws, SWM_ARG_ID_STACKINIT); ws->cur_layout = &layouts[0]; + ws->cur_layout->l_string(ws); } scan_xrandr(i);