xrandr --output <output> --primary
-------------------------
+=== Tray padding
+
+The tray is shown on the right-hand side of the bar. By default, a padding of 2
+pixels is used for the upper, lower and right-hand side of the tray area and
+between the individual icons.
+
+*Syntax*:
+-------------------------
+tray_padding <px> [px]
+-------------------------
+
+*Example*:
+-------------------------
+# Obey Fitts's law
+tray_padding 0
+-------------------------
+
=== Font
Specifies the font to be used in the bar. See <<fonts>>.
char *fontname;
i3String *separator_symbol;
char *tray_output;
+ int tray_padding;
int num_outputs;
char **outputs;
return 0;
}
+ if (!strcmp(cur_key, "tray_padding")) {
+ DLOG("tray_padding = %lld\n", val);
+ config.tray_padding = val;
+ return 1;
+ }
+
return 0;
}
/* Additional offset between the tray and the statusline, if the tray is not empty */
static const int tray_loff_px = 2;
-/* Padding around the tray icons */
-static const int tray_spacing_px = 2;
-
/* Vertical offset between the bar and a separator */
static const int sep_voff_px = 4;
TAILQ_FOREACH_REVERSE(trayclient, trayclients, tc_head, tailq) {
if (!trayclient->mapped)
continue;
- tray_width += icon_size + logical_px(tray_spacing_px);
+ tray_width += icon_size + logical_px(config.tray_padding);
}
if (tray_width > 0)
tray_width += logical_px(tray_loff_px);
clients++;
DLOG("Configuring tray window %08x to x=%d\n",
- trayclient->win, output->rect.w - (clients * (icon_size + logical_px(tray_spacing_px))));
- uint32_t x = output->rect.w - (clients * (icon_size + logical_px(tray_spacing_px)));
+ trayclient->win, output->rect.w - (clients * (icon_size + logical_px(config.tray_padding))));
+ uint32_t x = output->rect.w - (clients * (icon_size + logical_px(config.tray_padding)));
xcb_configure_window(xcb_connection,
trayclient->win,
XCB_CONFIG_WINDOW_X,
xcb_reparent_window(xcb_connection,
client,
output->bar,
- output->rect.w - icon_size - logical_px(tray_spacing_px),
- logical_px(tray_spacing_px));
+ output->rect.w - icon_size - logical_px(config.tray_padding),
+ logical_px(config.tray_padding));
/* We reconfigure the window to use a reasonable size. The systray
* specification explicitly says:
* Tray icons may be assigned any size by the system tray, and
continue;
xcb_rectangle_t rect;
- rect.x = output->rect.w - (clients * (icon_size + logical_px(tray_spacing_px)));
- rect.y = logical_px(tray_spacing_px);
+ rect.x = output->rect.w - (clients * (icon_size + logical_px(config.tray_padding)));
+ rect.y = logical_px(config.tray_padding);
rect.width = icon_size;
rect.height = icon_size;
set_font(&font);
DLOG("Calculated font height: %d\n", font.height);
bar_height = font.height + 2 * logical_px(ws_voff_px);
- icon_size = bar_height - 2 * logical_px(tray_spacing_px);
+ icon_size = bar_height - 2 * logical_px(config.tray_padding);
if (config.separator_symbol)
separator_symbol_width = predict_text_width(config.separator_symbol);
* disables the tray (it’s enabled by default). */
char *tray_output;
+ /* Padding around the tray icons. */
+ int tray_padding;
+
/** Path to the i3 IPC socket. This option is discouraged since programs
* can find out the path by looking for the I3_SOCKET_PATH property on the
* root window! */
CFGFUN(bar_color, const char *colorclass, const char *border, const char *background, const char *text);
CFGFUN(bar_socket_path, const char *socket_path);
CFGFUN(bar_tray_output, const char *output);
+CFGFUN(bar_tray_padding, const long spacing_px);
CFGFUN(bar_color_single, const char *colorclass, const char *color);
CFGFUN(bar_status_command, const char *command);
CFGFUN(bar_binding_mode_indicator, const char *value);
'position' -> BAR_POSITION
'output' -> BAR_OUTPUT
'tray_output' -> BAR_TRAY_OUTPUT
+ 'tray_padding' -> BAR_TRAY_PADDING
'font' -> BAR_FONT
'separator_symbol' -> BAR_SEPARATOR_SYMBOL
'binding_mode_indicator' -> BAR_BINDING_MODE_INDICATOR
output = word
-> call cfg_bar_tray_output($output); BAR
+state BAR_TRAY_PADDING:
+ padding_px = number
+ -> BAR_TRAY_PADDING_PX
+
+state BAR_TRAY_PADDING_PX:
+ 'px'
+ ->
+ end
+ -> call cfg_bar_tray_padding(&padding_px); BAR
+
state BAR_FONT:
font = string
-> call cfg_bar_font($font); BAR
current_bar.tray_output = sstrdup(output);
}
+CFGFUN(bar_tray_padding, const long padding_px) {
+ current_bar.tray_padding = padding_px;
+}
+
CFGFUN(bar_color_single, const char *colorclass, const char *color) {
if (strcmp(colorclass, "background") == 0)
current_bar.colors.background = sstrdup(color);
CFGFUN(bar_start) {
TAILQ_INIT(&(current_bar.bar_bindings));
+ current_bar.tray_padding = 2;
}
CFGFUN(bar_finish) {
} while (0)
YSTR_IF_SET(tray_output);
+
+ ystr("tray_padding");
+ y(integer, config->tray_padding);
+
YSTR_IF_SET(socket_path);
ystr("mode");
ok($bar_config->{binding_mode_indicator}, 'mode indicator enabled per default');
is($bar_config->{mode}, 'dock', 'dock mode by default');
is($bar_config->{position}, 'bottom', 'position bottom by default');
+is($bar_config->{tray_padding}, 2, 'tray_padding ok');
#####################################################################
# ensure that reloading cleans up the old bar configs
tray_output LVDS1
tray_output HDMI2
+ tray_padding 0
position top
mode dock
font Terminus
is($bar_config->{position}, 'top', 'position top');
is_deeply($bar_config->{outputs}, [ 'HDMI1', 'HDMI2' ], 'outputs ok');
is($bar_config->{tray_output}, 'HDMI2', 'tray_output ok');
+is($bar_config->{tray_padding}, 0, 'tray_padding ok');
is($bar_config->{font}, 'Terminus', 'font ok');
is($bar_config->{socket_path}, '/tmp/foobar', 'socket_path ok');
is_deeply($bar_config->{colors},
$expected = <<'EOT';
cfg_bar_start()
cfg_bar_output(LVDS-1)
-ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'i3bar_command', 'status_command', 'socket_path', 'mode', 'hidden_state', 'id', 'modifier', 'wheel_up_cmd', 'wheel_down_cmd', 'bindsym', 'position', 'output', 'tray_output', 'font', 'separator_symbol', 'binding_mode_indicator', 'workspace_buttons', 'strip_workspace_numbers', 'verbose', 'colors', '}'
+ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'i3bar_command', 'status_command', 'socket_path', 'mode', 'hidden_state', 'id', 'modifier', 'wheel_up_cmd', 'wheel_down_cmd', 'bindsym', 'position', 'output', 'tray_output', 'tray_padding', 'font', 'separator_symbol', 'binding_mode_indicator', 'workspace_buttons', 'strip_workspace_numbers', 'verbose', 'colors', '}'
ERROR: CONFIG: (in file <stdin>)
ERROR: CONFIG: Line 1: bar {
ERROR: CONFIG: Line 2: output LVDS-1