sway-border-width.diff (4057B)
1 diff --git a/include/sway/commands.h b/include/sway/commands.h 2 index 5210d3ba..f04144eb 100644 3 --- a/include/sway/commands.h 4 +++ b/include/sway/commands.h 5 @@ -246,6 +246,8 @@ sway_cmd bar_colors_cmd_statusline; 6 sway_cmd bar_colors_cmd_focused_statusline; 7 sway_cmd bar_colors_cmd_urgent_workspace; 8 9 +sway_cmd bar_cmd_border_width; 10 + 11 sway_cmd input_cmd_seat; 12 sway_cmd input_cmd_accel_profile; 13 sway_cmd input_cmd_calibration_matrix; 14 diff --git a/include/sway/config.h b/include/sway/config.h 15 index bb770c6f..c20194a0 100644 16 --- a/include/sway/config.h 17 +++ b/include/sway/config.h 18 @@ -405,6 +405,8 @@ struct bar_config { 19 list_t *tray_outputs; // char * 20 int tray_padding; 21 #endif 22 + 23 + int border_width; 24 }; 25 26 struct bar_binding { 27 diff --git a/include/swaybar/config.h b/include/swaybar/config.h 28 index 361acd99..05f93884 100644 29 --- a/include/swaybar/config.h 30 +++ b/include/swaybar/config.h 31 @@ -75,6 +75,8 @@ struct swaybar_config { 32 list_t *tray_outputs; // char * 33 int tray_padding; 34 #endif 35 + 36 + int border_width; 37 }; 38 39 #if HAVE_TRAY 40 diff --git a/sway/commands/bar/height.c b/sway/commands/bar/height.c 41 index 945eb707..2aeeb626 100644 42 --- a/sway/commands/bar/height.c 43 +++ b/sway/commands/bar/height.c 44 @@ -18,3 +18,21 @@ struct cmd_results *bar_cmd_height(int argc, char **argv) { 45 height, config->current_bar->id); 46 return cmd_results_new(CMD_SUCCESS, NULL); 47 } 48 + 49 +// I can't add a new file in a diff so just stuff my function here 50 +struct cmd_results *bar_cmd_border_width(int argc, char **argv) { 51 + struct cmd_results *error = NULL; 52 + if ((error = checkarg(argc, "border_width", EXPECTED_EQUAL_TO, 1))) { 53 + return error; 54 + } 55 + int border_width = atoi(argv[0]); 56 + if (border_width < 0) { 57 + return cmd_results_new(CMD_INVALID, 58 + "Invalid border_width value: %s", argv[0]); 59 + } 60 + config->current_bar->border_width = border_width; 61 + sway_log(SWAY_DEBUG, "Setting border_width to %d on bar: %s", 62 + border_width, config->current_bar->id); 63 + return cmd_results_new(CMD_SUCCESS, NULL); 64 +} 65 + 66 diff --git a/swaybar/config.c b/swaybar/config.c 67 index 55bfcb72..056d3845 100644 68 --- a/swaybar/config.c 69 +++ b/swaybar/config.c 70 @@ -81,6 +81,8 @@ struct swaybar_config *init_config(void) { 71 wl_list_init(&config->tray_bindings); 72 #endif 73 74 + config->border_width = 1; 75 + 76 return config; 77 } 78 79 diff --git a/swaybar/render.c b/swaybar/render.c 80 index 45faefa9..33d6efa6 100644 81 --- a/swaybar/render.c 82 +++ b/swaybar/render.c 83 @@ -21,7 +21,6 @@ 84 85 static const int WS_HORIZONTAL_PADDING = 5; 86 static const double WS_VERTICAL_PADDING = 1.5; 87 -static const double BORDER_WIDTH = 1; 88 89 struct render_context { 90 cairo_t *cairo; 91 @@ -432,7 +431,7 @@ static uint32_t predict_workspace_button_length(cairo_t *cairo, 92 93 int ws_vertical_padding = WS_VERTICAL_PADDING; 94 int ws_horizontal_padding = WS_HORIZONTAL_PADDING; 95 - int border_width = BORDER_WIDTH; 96 + int border_width = config->border_width; 97 98 uint32_t ideal_height = ws_vertical_padding * 2 + text_height 99 + border_width * 2; 100 @@ -481,7 +480,7 @@ static uint32_t predict_binding_mode_indicator_length(cairo_t *cairo, 101 102 int ws_vertical_padding = WS_VERTICAL_PADDING; 103 int ws_horizontal_padding = WS_HORIZONTAL_PADDING; 104 - int border_width = BORDER_WIDTH; 105 + int border_width = config->border_width; 106 107 uint32_t ideal_height = text_height + ws_vertical_padding * 2 108 + border_width * 2; 109 @@ -558,7 +557,7 @@ static uint32_t render_binding_mode_indicator(struct render_context *ctx, 110 111 int ws_vertical_padding = WS_VERTICAL_PADDING; 112 int ws_horizontal_padding = WS_HORIZONTAL_PADDING; 113 - int border_width = BORDER_WIDTH; 114 + int border_width = config->border_width; 115 116 uint32_t ideal_height = text_height + ws_vertical_padding * 2 117 + border_width * 2; 118 @@ -638,7 +637,7 @@ static uint32_t render_workspace_button(struct render_context *ctx, 119 120 int ws_vertical_padding = WS_VERTICAL_PADDING; 121 int ws_horizontal_padding = WS_HORIZONTAL_PADDING; 122 - int border_width = BORDER_WIDTH; 123 + int border_width = config->border_width; 124 125 uint32_t ideal_height = ws_vertical_padding * 2 + text_height 126 + border_width * 2;