theme: add option osd.window-switcher.padding

Fixes: issue #969
This commit is contained in:
Johan Malm 2023-06-29 21:29:43 +01:00 committed by Johan Malm
parent fe8cdd7f8b
commit 55bf79c3fe
5 changed files with 24 additions and 6 deletions

View file

@ -141,7 +141,7 @@ elements are not listed here, but are supported.
Border color of on-screen-display Border color of on-screen-display
*osd.border.width* *osd.border.width*
Border width of on-screen-display Border width of on-screen-display. Inherits *border.width* if not set.
*osd.label.text.color* *osd.label.text.color*
Text color of on-screen-display Text color of on-screen-display
@ -149,6 +149,11 @@ elements are not listed here, but are supported.
*osd.window-switcher.width* *osd.window-switcher.width*
Width of window switcher in pixels. Default is 600. Width of window switcher in pixels. Default is 600.
*osd.window-switcher.padding*
Padding of window switcher in pixels. This is the space between the
window-switcher border and its items. Inherits *osd.border.width* if
not set.
*osd.window-switcher.item.padding.x* *osd.window-switcher.item.padding.x*
Horizontal padding of window switcher entries in pixels. Horizontal padding of window switcher entries in pixels.
Default is 10. Default is 10.

View file

@ -54,5 +54,6 @@ osd.border.width: 1
osd.label.text.color: #000000 osd.label.text.color: #000000
osd.window-switcher.width: 600 osd.window-switcher.width: 600
osd.window-switcher.padding: 1
osd.window-switcher.item.padding.x: 10 osd.window-switcher.item.padding.x: 10
osd.window-switcher.item.padding.y: 6 osd.window-switcher.item.padding.y: 6

View file

@ -68,6 +68,7 @@ struct theme {
float osd_label_text_color[4]; float osd_label_text_color[4];
int osd_window_switcher_width; int osd_window_switcher_width;
int osd_window_switcher_padding;
int osd_window_switcher_item_padding_x; int osd_window_switcher_item_padding_x;
int osd_window_switcher_item_padding_y; int osd_window_switcher_item_padding_y;

View file

@ -78,6 +78,7 @@ get_osd_height(struct wl_list *node_list)
/* Add OSD border width */ /* Add OSD border width */
height += 2 * rc.theme->osd_border_width; height += 2 * rc.theme->osd_border_width;
height += 2 * rc.theme->osd_window_switcher_padding;
return height; return height;
} }
@ -316,7 +317,7 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
pango_cairo_update_layout(cairo, layout); pango_cairo_update_layout(cairo, layout);
int y = theme->osd_border_width; int y = theme->osd_border_width + theme->osd_window_switcher_padding;
/* Draw workspace indicator */ /* Draw workspace indicator */
if (show_workspace) { if (show_workspace) {
@ -342,7 +343,8 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
* Subtract 4x border-width to allow for both the OSD border and the * Subtract 4x border-width to allow for both the OSD border and the
* item border. This is the width of the area available for text fields. * item border. This is the width of the area available for text fields.
*/ */
int available_width = w - 4 * theme->osd_border_width; int available_width = w - 4 * theme->osd_border_width
- 2 * theme->osd_window_switcher_padding;
/* Draw text for each node */ /* Draw text for each node */
wl_list_for_each_reverse(node, node_list, link) { wl_list_for_each_reverse(node, node_list, link) {
@ -374,7 +376,8 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
*/ */
y += theme->osd_border_width; y += theme->osd_border_width;
int x = theme->osd_window_switcher_item_padding_x int x = theme->osd_window_switcher_item_padding_x
+ 2 * theme->osd_border_width; + 2 * theme->osd_border_width
+ theme->osd_window_switcher_padding;
int nr_fields = wl_list_length(&rc.window_switcher.fields); int nr_fields = wl_list_length(&rc.window_switcher.fields);
struct window_switcher_field *field; struct window_switcher_field *field;
@ -408,10 +411,11 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
if (view == cycle_view) { if (view == cycle_view) {
/* Highlight current window */ /* Highlight current window */
struct wlr_fbox fbox = { struct wlr_fbox fbox = {
.x = theme->osd_border_width, .x = theme->osd_border_width + theme->osd_window_switcher_padding,
.y = y - theme->osd_border_width, .y = y - theme->osd_border_width,
.width = theme->osd_window_switcher_width .width = theme->osd_window_switcher_width
- 2 * theme->osd_border_width, - 2 * theme->osd_border_width
- 2 * theme->osd_window_switcher_padding,
.height = theme->osd_window_switcher_item_height .height = theme->osd_window_switcher_item_height
+ 2 * theme->osd_border_width, + 2 * theme->osd_border_width,
}; };

View file

@ -141,6 +141,7 @@ theme_builtin(struct theme *theme)
parse_hexstr("#888888", theme->menu_separator_color); parse_hexstr("#888888", theme->menu_separator_color);
theme->osd_window_switcher_width = 600; theme->osd_window_switcher_width = 600;
theme->osd_window_switcher_padding = INT_MIN;
theme->osd_window_switcher_item_padding_x = 10; theme->osd_window_switcher_item_padding_x = 10;
theme->osd_window_switcher_item_padding_y = 6; theme->osd_window_switcher_item_padding_y = 6;
@ -311,6 +312,9 @@ entry(struct theme *theme, const char *key, const char *value)
if (match_glob(key, "osd.window-switcher.width")) { if (match_glob(key, "osd.window-switcher.width")) {
theme->osd_window_switcher_width = atoi(value); theme->osd_window_switcher_width = atoi(value);
} }
if (match_glob(key, "osd.window-switcher.padding")) {
theme->osd_window_switcher_padding = atoi(value);
}
if (match_glob(key, "osd.window-switcher.item.padding.x")) { if (match_glob(key, "osd.window-switcher.item.padding.x")) {
theme->osd_window_switcher_item_padding_x = atoi(value); theme->osd_window_switcher_item_padding_x = atoi(value);
} }
@ -554,6 +558,9 @@ post_processing(struct theme *theme)
if (theme->osd_border_width == INT_MIN) { if (theme->osd_border_width == INT_MIN) {
theme->osd_border_width = theme->border_width; theme->osd_border_width = theme->border_width;
} }
if (theme->osd_window_switcher_padding == INT_MIN) {
theme->osd_window_switcher_padding = theme->osd_border_width;
}
if (theme->osd_label_text_color[0] == FLT_MIN) { if (theme->osd_label_text_color[0] == FLT_MIN) {
memcpy(theme->osd_label_text_color, memcpy(theme->osd_label_text_color,
theme->window_active_label_text_color, theme->window_active_label_text_color,