|
|
@ -75,6 +75,7 @@ char *output, *status_command;
|
|
|
|
struct registry *registry;
|
|
|
|
struct registry *registry;
|
|
|
|
struct window *window;
|
|
|
|
struct window *window;
|
|
|
|
bool dirty = true;
|
|
|
|
bool dirty = true;
|
|
|
|
|
|
|
|
char *separator_symbol = NULL;
|
|
|
|
typedef enum {UNDEF, TEXT, I3BAR} command_protocol;
|
|
|
|
typedef enum {UNDEF, TEXT, I3BAR} command_protocol;
|
|
|
|
command_protocol protocol = UNDEF;
|
|
|
|
command_protocol protocol = UNDEF;
|
|
|
|
|
|
|
|
|
|
|
@ -289,7 +290,7 @@ void bar_ipc_init(int outputi, const char *bar_id) {
|
|
|
|
json_object *bar_config = json_tokener_parse(res);
|
|
|
|
json_object *bar_config = json_tokener_parse(res);
|
|
|
|
json_object *tray_output, *mode, *hidden_state, *position, *_status_command;
|
|
|
|
json_object *tray_output, *mode, *hidden_state, *position, *_status_command;
|
|
|
|
json_object *font, *bar_height, *workspace_buttons, *strip_workspace_numbers;
|
|
|
|
json_object *font, *bar_height, *workspace_buttons, *strip_workspace_numbers;
|
|
|
|
json_object *binding_mode_indicator, *verbose, *_colors;
|
|
|
|
json_object *binding_mode_indicator, *verbose, *_colors, *sep_symbol;
|
|
|
|
json_object_object_get_ex(bar_config, "tray_output", &tray_output);
|
|
|
|
json_object_object_get_ex(bar_config, "tray_output", &tray_output);
|
|
|
|
json_object_object_get_ex(bar_config, "mode", &mode);
|
|
|
|
json_object_object_get_ex(bar_config, "mode", &mode);
|
|
|
|
json_object_object_get_ex(bar_config, "hidden_state", &hidden_state);
|
|
|
|
json_object_object_get_ex(bar_config, "hidden_state", &hidden_state);
|
|
|
@ -301,6 +302,7 @@ void bar_ipc_init(int outputi, const char *bar_id) {
|
|
|
|
json_object_object_get_ex(bar_config, "strip_workspace_numbers", &strip_workspace_numbers);
|
|
|
|
json_object_object_get_ex(bar_config, "strip_workspace_numbers", &strip_workspace_numbers);
|
|
|
|
json_object_object_get_ex(bar_config, "binding_mode_indicator", &binding_mode_indicator);
|
|
|
|
json_object_object_get_ex(bar_config, "binding_mode_indicator", &binding_mode_indicator);
|
|
|
|
json_object_object_get_ex(bar_config, "verbose", &verbose);
|
|
|
|
json_object_object_get_ex(bar_config, "verbose", &verbose);
|
|
|
|
|
|
|
|
json_object_object_get_ex(bar_config, "separator_symbol", &sep_symbol);
|
|
|
|
json_object_object_get_ex(bar_config, "colors", &_colors);
|
|
|
|
json_object_object_get_ex(bar_config, "colors", &_colors);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: More of these options
|
|
|
|
// TODO: More of these options
|
|
|
@ -317,6 +319,10 @@ void bar_ipc_init(int outputi, const char *bar_id) {
|
|
|
|
window->font = parse_font(json_object_get_string(font));
|
|
|
|
window->font = parse_font(json_object_get_string(font));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sep_symbol) {
|
|
|
|
|
|
|
|
separator_symbol = strdup(json_object_get_string(sep_symbol));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (bar_height) {
|
|
|
|
if (bar_height) {
|
|
|
|
int width, height;
|
|
|
|
int width, height;
|
|
|
|
get_text_size(window, &width, &height, "Test string for measuring purposes");
|
|
|
|
get_text_size(window, &width, &height, "Test string for measuring purposes");
|
|
|
@ -438,7 +444,7 @@ void render_sharp_line(cairo_t *cairo, uint32_t color, double x, double y, doubl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void render_block(struct status_block *block, double *x, bool edge) {
|
|
|
|
void render_block(struct status_block *block, double *x, bool edge) {
|
|
|
|
int width, height;
|
|
|
|
int width, height, sep_width;
|
|
|
|
get_text_size(window, &width, &height, "%s", block->full_text);
|
|
|
|
get_text_size(window, &width, &height, "%s", block->full_text);
|
|
|
|
|
|
|
|
|
|
|
|
int textwidth = width;
|
|
|
|
int textwidth = width;
|
|
|
@ -462,6 +468,13 @@ void render_block(struct status_block *block, double *x, bool edge) {
|
|
|
|
|
|
|
|
|
|
|
|
// Add separator
|
|
|
|
// Add separator
|
|
|
|
if (!edge) {
|
|
|
|
if (!edge) {
|
|
|
|
|
|
|
|
if (separator_symbol) {
|
|
|
|
|
|
|
|
get_text_size(window, &sep_width, &height, "%s", separator_symbol);
|
|
|
|
|
|
|
|
if (sep_width > block->separator_block_width) {
|
|
|
|
|
|
|
|
block->separator_block_width = sep_width + margin * 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
*x -= block->separator_block_width;
|
|
|
|
*x -= block->separator_block_width;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
*x -= margin;
|
|
|
|
*x -= margin;
|
|
|
@ -535,15 +548,24 @@ void render_block(struct status_block *block, double *x, bool edge) {
|
|
|
|
pos += block->border_right;
|
|
|
|
pos += block->border_right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sway_log(L_DEBUG, "%s", separator_symbol);
|
|
|
|
|
|
|
|
|
|
|
|
// render separator
|
|
|
|
// render separator
|
|
|
|
// TODO: Handle custom separator
|
|
|
|
|
|
|
|
if (!edge && block->separator) {
|
|
|
|
if (!edge && block->separator) {
|
|
|
|
cairo_set_source_u32(window->cairo, colors.separator);
|
|
|
|
cairo_set_source_u32(window->cairo, colors.separator);
|
|
|
|
|
|
|
|
if (separator_symbol) {
|
|
|
|
|
|
|
|
offset = pos + (block->separator_block_width - sep_width) / 2;
|
|
|
|
|
|
|
|
cairo_move_to(window->cairo, offset, margin);
|
|
|
|
|
|
|
|
pango_printf(window, "%s", separator_symbol);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
cairo_set_line_width(window->cairo, 1);
|
|
|
|
cairo_set_line_width(window->cairo, 1);
|
|
|
|
cairo_move_to(window->cairo, pos + block->separator_block_width/2, margin);
|
|
|
|
cairo_move_to(window->cairo, pos + block->separator_block_width/2,
|
|
|
|
cairo_line_to(window->cairo, pos + block->separator_block_width/2, window->height - margin);
|
|
|
|
margin);
|
|
|
|
|
|
|
|
cairo_line_to(window->cairo, pos + block->separator_block_width/2,
|
|
|
|
|
|
|
|
window->height - margin);
|
|
|
|
cairo_stroke(window->cairo);
|
|
|
|
cairo_stroke(window->cairo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|