ssd: limit icon size to ~85% of window_button_width

This ensures that the icon doesn't push right up to the window edge
(or left-aligned title) when using a large font or narrow button width.
In the default config (with 10pt font), it makes no difference since
the limiting factor on the icon size is the titlebar height anyway.

I spent way too much time over-thinking how to compute the padding.
I think 2px on each side is reasonable (and it should be equal on each
side), so window_button_width/10 (rounded down) should be fine.
Eventually the padding should probably be configurable anyway.
This commit is contained in:
John Lindgren 2024-10-03 07:31:29 -04:00 committed by Johan Malm
parent f347408949
commit db3aab77fe

View file

@ -654,7 +654,16 @@ ssd_update_window_icon(struct ssd *ssd)
struct theme *theme = ssd->view->server->theme;
int icon_size = MIN(theme->window_button_width,
/*
* Ensure a small amount of horizontal padding within the button
* area (2px on each side with the default 26px button width).
* A new theme setting could be added to configure this. Using
* an existing setting (padding.width or window.button.spacing)
* was considered, but these settings have distinct purposes
* already and are zero by default.
*/
int hpad = theme->window_button_width / 10;
int icon_size = MIN(theme->window_button_width - 2 * hpad,
theme->title_height - 2 * theme->padding_height);
/* TODO: take into account output scales */
int icon_scale = 1;