]> git.mdlowis.com Git - proto/labwc.git/commitdiff
ssd: limit icon size to ~85% of window_button_width
authorJohn Lindgren <john@jlindgren.net>
Thu, 3 Oct 2024 11:31:29 +0000 (07:31 -0400)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 3 Oct 2024 20:17:21 +0000 (21:17 +0100)
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.

src/ssd/ssd-titlebar.c

index b3a72b35d157097ffd30af4168d6467eaaa2c7c4..c63bd5f9f44d3be210128a50c5eb5c74ed92c067 100644 (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;