Add new bar.binding_mode_indicator configuration.
i3 current behavior hides the binding mode indicator when workspace buttons are disabled. This patch adds a new configuration for i3bar called 'binding_mode_indicator' which acts like the workspace_buttons. It is now possible to configure i3bar to hide the workspace buttons and keep showing the binding mode indicator. This should make the hide workspace buttons configuration more convenient for those who are heavily using binding modes. Default value for binding_mode_indicator is true.
This commit is contained in:
committed by
Michael Stapelberg
parent
97b086efd9
commit
7098ef602b
@ -23,7 +23,8 @@ typedef struct config_t {
|
||||
position_t position;
|
||||
int verbose;
|
||||
struct xcb_color_strings_t colors;
|
||||
int disable_ws;
|
||||
bool disable_binding_mode_indicator;
|
||||
bool disable_ws;
|
||||
char *bar_id;
|
||||
char *command;
|
||||
char *fontname;
|
||||
|
@ -193,6 +193,12 @@ static int config_string_cb(void *params_, const unsigned char *val, unsigned in
|
||||
*
|
||||
*/
|
||||
static int config_boolean_cb(void *params_, int val) {
|
||||
if (!strcmp(cur_key, "binding_mode_indicator")) {
|
||||
DLOG("binding_mode_indicator = %d\n", val);
|
||||
config.disable_binding_mode_indicator = !val;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp(cur_key, "workspace_buttons")) {
|
||||
DLOG("workspace_buttons = %d\n", val);
|
||||
config.disable_ws = !val;
|
||||
|
127
i3bar/src/xcb.c
127
i3bar/src/xcb.c
@ -1670,72 +1670,71 @@ void draw_bars(bool unhide) {
|
||||
MIN(outputs_walk->rect.w - traypx - 4, statusline_width), font.height + 2);
|
||||
}
|
||||
|
||||
if (config.disable_ws) {
|
||||
continue;
|
||||
if (!config.disable_ws) {
|
||||
i3_ws *ws_walk;
|
||||
TAILQ_FOREACH(ws_walk, outputs_walk->workspaces, tailq) {
|
||||
DLOG("Drawing Button for WS %s at x = %d, len = %d\n",
|
||||
i3string_as_utf8(ws_walk->name), i, ws_walk->name_width);
|
||||
uint32_t fg_color = colors.inactive_ws_fg;
|
||||
uint32_t bg_color = colors.inactive_ws_bg;
|
||||
uint32_t border_color = colors.inactive_ws_border;
|
||||
if (ws_walk->visible) {
|
||||
if (!ws_walk->focused) {
|
||||
fg_color = colors.active_ws_fg;
|
||||
bg_color = colors.active_ws_bg;
|
||||
border_color = colors.active_ws_border;
|
||||
} else {
|
||||
fg_color = colors.focus_ws_fg;
|
||||
bg_color = colors.focus_ws_bg;
|
||||
border_color = colors.focus_ws_border;
|
||||
if (last_urgent_ws && strcmp(i3string_as_utf8(ws_walk->name),
|
||||
last_urgent_ws) == 0)
|
||||
walks_away = false;
|
||||
}
|
||||
}
|
||||
if (ws_walk->urgent) {
|
||||
DLOG("WS %s is urgent!\n", i3string_as_utf8(ws_walk->name));
|
||||
fg_color = colors.urgent_ws_fg;
|
||||
bg_color = colors.urgent_ws_bg;
|
||||
border_color = colors.urgent_ws_border;
|
||||
unhide = true;
|
||||
if (!ws_walk->focused) {
|
||||
FREE(last_urgent_ws);
|
||||
last_urgent_ws = sstrdup(i3string_as_utf8(ws_walk->name));
|
||||
}
|
||||
}
|
||||
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND;
|
||||
uint32_t vals_border[] = { border_color, border_color };
|
||||
xcb_change_gc(xcb_connection,
|
||||
outputs_walk->bargc,
|
||||
mask,
|
||||
vals_border);
|
||||
xcb_rectangle_t rect_border = { i, 1, ws_walk->name_width + 10, font.height + 4 };
|
||||
xcb_poly_fill_rectangle(xcb_connection,
|
||||
outputs_walk->buffer,
|
||||
outputs_walk->bargc,
|
||||
1,
|
||||
&rect_border);
|
||||
uint32_t vals[] = { bg_color, bg_color };
|
||||
xcb_change_gc(xcb_connection,
|
||||
outputs_walk->bargc,
|
||||
mask,
|
||||
vals);
|
||||
xcb_rectangle_t rect = { i + 1, 2, ws_walk->name_width + 8, font.height + 2 };
|
||||
xcb_poly_fill_rectangle(xcb_connection,
|
||||
outputs_walk->buffer,
|
||||
outputs_walk->bargc,
|
||||
1,
|
||||
&rect);
|
||||
set_font_colors(outputs_walk->bargc, fg_color, bg_color);
|
||||
draw_text(ws_walk->name, outputs_walk->buffer, outputs_walk->bargc,
|
||||
i + 5, 3, ws_walk->name_width);
|
||||
i += 10 + ws_walk->name_width + 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
i3_ws *ws_walk;
|
||||
|
||||
TAILQ_FOREACH(ws_walk, outputs_walk->workspaces, tailq) {
|
||||
DLOG("Drawing Button for WS %s at x = %d, len = %d\n", i3string_as_utf8(ws_walk->name), i, ws_walk->name_width);
|
||||
uint32_t fg_color = colors.inactive_ws_fg;
|
||||
uint32_t bg_color = colors.inactive_ws_bg;
|
||||
uint32_t border_color = colors.inactive_ws_border;
|
||||
if (ws_walk->visible) {
|
||||
if (!ws_walk->focused) {
|
||||
fg_color = colors.active_ws_fg;
|
||||
bg_color = colors.active_ws_bg;
|
||||
border_color = colors.active_ws_border;
|
||||
} else {
|
||||
fg_color = colors.focus_ws_fg;
|
||||
bg_color = colors.focus_ws_bg;
|
||||
border_color = colors.focus_ws_border;
|
||||
if (last_urgent_ws && strcmp(i3string_as_utf8(ws_walk->name), last_urgent_ws) == 0)
|
||||
walks_away = false;
|
||||
}
|
||||
}
|
||||
if (ws_walk->urgent) {
|
||||
DLOG("WS %s is urgent!\n", i3string_as_utf8(ws_walk->name));
|
||||
fg_color = colors.urgent_ws_fg;
|
||||
bg_color = colors.urgent_ws_bg;
|
||||
border_color = colors.urgent_ws_border;
|
||||
unhide = true;
|
||||
if (!ws_walk->focused) {
|
||||
FREE(last_urgent_ws);
|
||||
last_urgent_ws = sstrdup(i3string_as_utf8(ws_walk->name));
|
||||
}
|
||||
}
|
||||
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND;
|
||||
uint32_t vals_border[] = { border_color, border_color };
|
||||
xcb_change_gc(xcb_connection,
|
||||
outputs_walk->bargc,
|
||||
mask,
|
||||
vals_border);
|
||||
xcb_rectangle_t rect_border = { i, 1, ws_walk->name_width + 10, font.height + 4 };
|
||||
xcb_poly_fill_rectangle(xcb_connection,
|
||||
outputs_walk->buffer,
|
||||
outputs_walk->bargc,
|
||||
1,
|
||||
&rect_border);
|
||||
uint32_t vals[] = { bg_color, bg_color };
|
||||
xcb_change_gc(xcb_connection,
|
||||
outputs_walk->bargc,
|
||||
mask,
|
||||
vals);
|
||||
xcb_rectangle_t rect = { i + 1, 2, ws_walk->name_width + 8, font.height + 2 };
|
||||
xcb_poly_fill_rectangle(xcb_connection,
|
||||
outputs_walk->buffer,
|
||||
outputs_walk->bargc,
|
||||
1,
|
||||
&rect);
|
||||
set_font_colors(outputs_walk->bargc, fg_color, bg_color);
|
||||
draw_text(ws_walk->name, outputs_walk->buffer, outputs_walk->bargc, i + 5, 3, ws_walk->name_width);
|
||||
i += 10 + ws_walk->name_width + 1;
|
||||
|
||||
}
|
||||
|
||||
if (binding.name) {
|
||||
|
||||
if (binding.name && !config.disable_binding_mode_indicator) {
|
||||
uint32_t fg_color = colors.urgent_ws_fg;
|
||||
uint32_t bg_color = colors.urgent_ws_bg;
|
||||
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND;
|
||||
|
Reference in New Issue
Block a user