From: John Lindgren Date: Thu, 3 Oct 2024 11:31:29 +0000 (-0400) Subject: ssd: limit icon size to ~85% of window_button_width X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=db3aab77fef5ba4ad98e53cc9e1c2908751dedc3;p=proto%2Flabwc.git 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. --- diff --git a/src/ssd/ssd-titlebar.c b/src/ssd/ssd-titlebar.c index b3a72b35..c63bd5f9 100644 --- a/src/ssd/ssd-titlebar.c +++ b/src/ssd/ssd-titlebar.c @@ -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;