Make show_marks configurable

Introduce a config directive "show_marks [yes|no]" to en- or disable drawing marks on window decorations.
To not change the look & feel of existing configurations, the default is "no".
This commit is contained in:
Ingo Bürk 2015-03-29 00:26:49 +01:00
parent 2af1a80028
commit 245a29e233
7 changed files with 41 additions and 6 deletions

View File

@ -1006,6 +1006,24 @@ focus::
none::
The window will neither be focused, nor be marked urgent.
=== Drawing marks on window decoration
If activated, marks on windows are drawn in their window decoration. However,
any mark starting with an underscore in its name (+_+) will not be drawn even if
this option is activated.
The default for this option is +no+.
*Syntax*:
-------------------
show_marks [yes|no]
-------------------
*Example*:
--------------
show_marks yes
--------------
== Configuring i3bar
The bar at the bottom of your monitor is drawn by a separate process called
@ -1886,6 +1904,8 @@ The additional +--toggle+ option will remove the mark if the window already has
this mark, add it if the window has none or replace the current mark if it has
another mark.
Refer to +show_marks+ if you want marks to be shown in the window decoration.
*Syntax*:
------------------------------
mark [--toggle] identifier

View File

@ -179,6 +179,10 @@ struct Config {
FOWA_NONE
} focus_on_window_activation;
/** Specifies whether or not marks should be displayed in the window
* decoration. Marks starting with a "_" will be ignored either way. */
bool show_marks;
/** The default border style for new windows. */
border_style_t default_border;

View File

@ -52,6 +52,7 @@ CFGFUN(force_xinerama, const char *value);
CFGFUN(fake_outputs, const char *outputs);
CFGFUN(force_display_urgency_hint, const long duration_ms);
CFGFUN(focus_on_window_activation, const char *mode);
CFGFUN(show_marks, const char *value);
CFGFUN(hide_edge_borders, const char *borders);
CFGFUN(assign, const char *workspace);
CFGFUN(ipc_socket, const char *path);

View File

@ -39,6 +39,7 @@ state INITIAL:
'fake_outputs', 'fake-outputs' -> FAKE_OUTPUTS
'force_display_urgency_hint' -> FORCE_DISPLAY_URGENCY_HINT
'focus_on_window_activation' -> FOCUS_ON_WINDOW_ACTIVATION
'show_marks' -> SHOW_MARKS
'workspace' -> WORKSPACE
'ipc_socket', 'ipc-socket' -> IPC_SOCKET
'restart_state' -> RESTART_STATE
@ -205,6 +206,11 @@ state FORCE_DISPLAY_URGENCY_HINT:
duration_ms = number
-> FORCE_DISPLAY_URGENCY_HINT_MS
# show_marks
state SHOW_MARKS:
value = word
-> call cfg_show_marks($value)
state FORCE_DISPLAY_URGENCY_HINT_MS:
'ms'
->

View File

@ -346,6 +346,10 @@ CFGFUN(focus_on_window_activation, const char *mode) {
DLOG("Set new focus_on_window_activation mode = %i", config.focus_on_window_activation);
}
CFGFUN(show_marks, const char *value) {
config.show_marks = eval_boolstr(value);
}
CFGFUN(workspace, const char *workspace, const char *output) {
DLOG("Assigning workspace \"%s\" to output \"%s\"\n", workspace, output);
/* Check for earlier assignments of the same workspace so that we

10
src/x.c
View File

@ -534,16 +534,16 @@ void x_draw_decoration(Con *con) {
int indent_px = (indent_level * 5) * indent_mult;
int mark_width = 0;
if (con->mark != NULL && (con->mark)[0] != '_') {
if (config.show_marks && con->mark != NULL && (con->mark)[0] != '_') {
char *formatted_mark;
sasprintf(&formatted_mark, "[%s]", con->mark);
i3String *mark = i3string_from_utf8(formatted_mark);
FREE(formatted_mark);
mark_width = predict_text_width(mark) + logical_px(2);
mark_width = predict_text_width(mark);
draw_text(mark, parent->pixmap, parent->pm_gc,
con->deco_rect.x + con->deco_rect.width - mark_width,
con->deco_rect.y + text_offset_y, mark_width - logical_px(2));
con->deco_rect.x + con->deco_rect.width - mark_width - logical_px(2),
con->deco_rect.y + text_offset_y, mark_width);
I3STRING_FREE(mark);
}
@ -551,7 +551,7 @@ void x_draw_decoration(Con *con) {
draw_text(win->name,
parent->pixmap, parent->pm_gc,
con->deco_rect.x + logical_px(2) + indent_px, con->deco_rect.y + text_offset_y,
con->deco_rect.width - logical_px(2) - indent_px - mark_width);
con->deco_rect.width - logical_px(2) - indent_px - mark_width - logical_px(2));
after_title:
/* Since we dont clip the text at all, it might in some cases be painted

View File

@ -433,7 +433,7 @@ client.focused #4c7899 #285577 #ffffff #2e9ef4
EOT
my $expected_all_tokens = <<'EOT';
ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', 'bar', 'font', 'mode', 'floating_minimum_size', 'floating_maximum_size', 'floating_modifier', 'default_orientation', 'workspace_layout', 'new_window', 'new_float', 'hide_edge_borders', 'for_window', 'assign', 'focus_follows_mouse', 'mouse_warping', 'force_focus_wrapping', 'force_xinerama', 'force-xinerama', 'workspace_auto_back_and_forth', 'fake_outputs', 'fake-outputs', 'force_display_urgency_hint', 'focus_on_window_activation', 'workspace', 'ipc_socket', 'ipc-socket', 'restart_state', 'popup_during_fullscreen', 'exec_always', 'exec', 'client.background', 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent', 'client.placeholder'
ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'bindsym', 'bindcode', 'bind', 'bar', 'font', 'mode', 'floating_minimum_size', 'floating_maximum_size', 'floating_modifier', 'default_orientation', 'workspace_layout', 'new_window', 'new_float', 'hide_edge_borders', 'for_window', 'assign', 'focus_follows_mouse', 'mouse_warping', 'force_focus_wrapping', 'force_xinerama', 'force-xinerama', 'workspace_auto_back_and_forth', 'fake_outputs', 'fake-outputs', 'force_display_urgency_hint', 'focus_on_window_activation', 'show_marks', 'workspace', 'ipc_socket', 'ipc-socket', 'restart_state', 'popup_during_fullscreen', 'exec_always', 'exec', 'client.background', 'client.focused_inactive', 'client.focused', 'client.unfocused', 'client.urgent', 'client.placeholder'
EOT
my $expected_end = <<'EOT';