uint32_t focus_ws_bg;
uint32_t focus_ws_fg;
uint32_t focus_ws_border;
+ uint32_t binding_mode_bg;
+ uint32_t binding_mode_fg;
+ uint32_t binding_mode_border;
};
struct xcb_colors_t colors;
/* 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);
PARSE_COLOR(focus_ws_border, "#4c7899");
#undef PARSE_COLOR
+#define PARSE_COLOR_FALLBACK(name, fallback) \
+ do { \
+ colors.name = new_colors->name ? get_colorpixel(new_colors->name) : colors.fallback; \
+ } while (0)
+
+ /* For the binding mode indicator colors, we don't hardcode a default.
+ * Instead, we fall back to urgent_ws_* colors. */
+ PARSE_COLOR_FALLBACK(binding_mode_fg, urgent_ws_fg);
+ PARSE_COLOR_FALLBACK(binding_mode_bg, urgent_ws_bg);
+ PARSE_COLOR_FALLBACK(binding_mode_border, urgent_ws_border);
+#undef PARSE_COLOR_FALLBACK
+
init_tray_colors();
xcb_flush(xcb_connection);
}
x = original_x;
}
+ /* If a custom command was specified for this mouse button, it overrides
+ * the default behavior. */
+ binding_t *binding;
+ TAILQ_FOREACH(binding, &(config.bindings), bindings) {
+ if (binding->input_code != event->detail)
+ continue;
+
+ i3_send_msg(I3_IPC_MESSAGE_TYPE_COMMAND, binding->command);
+ return;
+ }
+
if (cur_ws == NULL) {
DLOG("No workspace active?\n");
return;
}
-
switch (event->detail) {
case 4:
/* Mouse wheel up. We select the previous ws, if any.
* If there is no more workspace, don’t even send the workspace
* command, otherwise (with workspace auto_back_and_forth) we’d end
* up on the wrong workspace. */
-
- /* If `wheel_up_cmd [COMMAND]` was specified, it should override
- * the default behavior */
- if (config.wheel_up_cmd) {
- i3_send_msg(I3_IPC_MESSAGE_TYPE_COMMAND, config.wheel_up_cmd);
- return;
- }
-
if (cur_ws == TAILQ_FIRST(walk->workspaces))
return;
* If there is no more workspace, don’t even send the workspace
* command, otherwise (with workspace auto_back_and_forth) we’d end
* up on the wrong workspace. */
-
- /* if `wheel_down_cmd [COMMAND]` was specified, it should override
- * the default behavior */
- if (config.wheel_down_cmd) {
- i3_send_msg(I3_IPC_MESSAGE_TYPE_COMMAND, config.wheel_down_cmd);
- return;
- }
-
if (cur_ws == TAILQ_LAST(walk->workspaces, ws_head))
return;
}
const size_t len = namelen + strlen("workspace \"\"") + 1;
- char *buffer = scalloc(len + num_quotes);
+ char *buffer = scalloc(len + num_quotes, 1);
strncpy(buffer, "workspace \"", strlen("workspace \""));
size_t inpos, outpos;
for (inpos = 0, outpos = strlen("workspace \"");
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
values);
/* send the XEMBED_EMBEDDED_NOTIFY message */
- void *event = scalloc(32);
+ void *event = scalloc(32, 1);
xcb_client_message_event_t *ev = event;
ev->response_type = XCB_CLIENT_MESSAGE;
ev->window = client;
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);
"i3bar\0i3bar\0");
char *name;
- if (asprintf(&name, "i3bar for output %s", walk->name) == -1)
- err(EXIT_FAILURE, "asprintf()");
+ sasprintf(&name, "i3bar for output %s", walk->name);
xcb_void_cookie_t name_cookie;
name_cookie = xcb_change_property(xcb_connection,
XCB_PROP_MODE_REPLACE,
if (binding.name && !config.disable_binding_mode_indicator) {
workspace_width += logical_px(ws_spacing_px);
- uint32_t fg_color = colors.urgent_ws_fg;
- uint32_t bg_color = colors.urgent_ws_bg;
+ uint32_t fg_color = colors.binding_mode_fg;
+ uint32_t bg_color = colors.binding_mode_bg;
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND;
- uint32_t vals_border[] = {colors.urgent_ws_border, colors.urgent_ws_border};
+ uint32_t vals_border[] = {colors.binding_mode_border, colors.binding_mode_border};
xcb_change_gc(xcb_connection,
outputs_walk->bargc,
mask,