aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/render.c
diff options
context:
space:
mode:
authorLibravatar Connor E <38229097+c-edw@users.noreply.github.com>2018-11-17 16:11:28 +0000
committerLibravatar Connor E <38229097+c-edw@users.noreply.github.com>2018-11-17 16:11:28 +0000
commit4bd46fb079fb5a32ee6eb2b297de273b261a9c71 (patch)
tree81dfd95a863ae17de78a6c69a14dd5698c6de862 /swaybar/render.c
parentMerge pull request #3046 from tokyovigilante/relative-transform (diff)
downloadsway-4bd46fb079fb5a32ee6eb2b297de273b261a9c71.tar.gz
sway-4bd46fb079fb5a32ee6eb2b297de273b261a9c71.tar.zst
sway-4bd46fb079fb5a32ee6eb2b297de273b261a9c71.zip
Implement strip_workspace_name.
Diffstat (limited to 'swaybar/render.c')
-rw-r--r--swaybar/render.c22
1 files changed, 2 insertions, 20 deletions
diff --git a/swaybar/render.c b/swaybar/render.c
index 4ebf922e..8269a840 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -342,19 +342,6 @@ static uint32_t render_binding_mode_indicator(cairo_t *cairo,
342 return output->height; 342 return output->height;
343} 343}
344 344
345static const char *strip_workspace_number(const char *ws_name) {
346 size_t len = strlen(ws_name);
347 for (size_t i = 0; i < len; ++i) {
348 if (ws_name[i] < '0' || ws_name[i] > '9') {
349 if (':' == ws_name[i] && i < len - 1 && i > 0) {
350 return ws_name + i + 1;
351 }
352 return ws_name;
353 }
354 }
355 return ws_name;
356}
357
358static enum hotspot_event_handling workspace_hotspot_callback(struct swaybar_output *output, 345static enum hotspot_event_handling workspace_hotspot_callback(struct swaybar_output *output,
359 int x, int y, enum x11_button button, void *data) { 346 int x, int y, enum x11_button button, void *data) {
360 if (button != LEFT) { 347 if (button != LEFT) {
@@ -368,11 +355,6 @@ static uint32_t render_workspace_button(cairo_t *cairo,
368 struct swaybar_output *output, 355 struct swaybar_output *output,
369 struct swaybar_workspace *ws, double *x) { 356 struct swaybar_workspace *ws, double *x) {
370 struct swaybar_config *config = output->bar->config; 357 struct swaybar_config *config = output->bar->config;
371 const char *name = ws->name;
372 if (config->strip_workspace_numbers) {
373 name = strip_workspace_number(ws->name);
374 }
375
376 struct box_colors box_colors; 358 struct box_colors box_colors;
377 if (ws->urgent) { 359 if (ws->urgent) {
378 box_colors = config->colors.urgent_workspace; 360 box_colors = config->colors.urgent_workspace;
@@ -388,7 +370,7 @@ static uint32_t render_workspace_button(cairo_t *cairo,
388 370
389 int text_width, text_height; 371 int text_width, text_height;
390 get_text_size(cairo, config->font, &text_width, &text_height, NULL, 372 get_text_size(cairo, config->font, &text_width, &text_height, NULL,
391 output->scale, config->pango_markup, "%s", name); 373 output->scale, config->pango_markup, "%s", ws->label);
392 374
393 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale; 375 int ws_vertical_padding = WS_VERTICAL_PADDING * output->scale;
394 int ws_horizontal_padding = WS_HORIZONTAL_PADDING * output->scale; 376 int ws_horizontal_padding = WS_HORIZONTAL_PADDING * output->scale;
@@ -421,7 +403,7 @@ static uint32_t render_workspace_button(cairo_t *cairo,
421 cairo_set_source_u32(cairo, box_colors.text); 403 cairo_set_source_u32(cairo, box_colors.text);
422 cairo_move_to(cairo, *x + width / 2 - text_width / 2, (int)floor(text_y)); 404 cairo_move_to(cairo, *x + width / 2 - text_width / 2, (int)floor(text_y));
423 pango_printf(cairo, config->font, output->scale, config->pango_markup, 405 pango_printf(cairo, config->font, output->scale, config->pango_markup,
424 "%s", name); 406 "%s", ws->label);
425 407
426 struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot)); 408 struct swaybar_hotspot *hotspot = calloc(1, sizeof(struct swaybar_hotspot));
427 hotspot->x = *x; 409 hotspot->x = *x;