osd: add osd.window-switcher.item.icon.size

This allows users to make the icon in window switcher bigger (or smaller)
than the font size, which enables more Openbox-like appearance.

Example configuration:
  osd.window-switcher.item.icon.size: 50

This commit also makes the icon smaller than the font size if the width
allocated with <windowSwitcher><fields><field width=""> is smaller than
that.
This commit is contained in:
tokyo4j 2025-04-01 16:53:15 +09:00 committed by Johan Malm
parent d8bd8c5a3e
commit 6a04c5f0dd
5 changed files with 28 additions and 4 deletions

View file

@ -542,6 +542,7 @@ theme_builtin(struct theme *theme, struct server *server)
theme->osd_window_switcher_item_padding_x = 10;
theme->osd_window_switcher_item_padding_y = 1;
theme->osd_window_switcher_item_active_border_width = 2;
theme->osd_window_switcher_item_icon_size = -1;
/* inherit settings in post_processing() if not set elsewhere */
theme->osd_window_switcher_preview_border_width = INT_MIN;
@ -879,6 +880,11 @@ entry(struct theme *theme, const char *key, const char *value)
get_int_if_positive(
value, "osd.window-switcher.item.active.border.width");
}
if (match_glob(key, "osd.window-switcher.item.icon.size")) {
theme->osd_window_switcher_item_icon_size =
get_int_if_positive(
value, "osd.window-switcher.item.icon.size");
}
if (match_glob(key, "osd.window-switcher.preview.border.width")) {
theme->osd_window_switcher_preview_border_width =
get_int_if_positive(
@ -1380,7 +1386,13 @@ post_processing(struct theme *theme)
theme->menu_header_height = font_height(&rc.font_menuheader)
+ 2 * theme->menu_items_padding_y;
theme->osd_window_switcher_item_height = font_height(&rc.font_osd)
int osd_font_height = font_height(&rc.font_osd);
if (theme->osd_window_switcher_item_icon_size <= 0) {
theme->osd_window_switcher_item_icon_size = osd_font_height;
}
int osd_field_height =
MAX(osd_font_height, theme->osd_window_switcher_item_icon_size);
theme->osd_window_switcher_item_height = osd_field_height
+ 2 * theme->osd_window_switcher_item_padding_y
+ 2 * theme->osd_window_switcher_item_active_border_width;