]> git.mdlowis.com Git - proto/labwc.git/commitdiff
img: apply padding around window icon only horizontally
authortokyo4j <hrak1529@gmail.com>
Sat, 4 Jan 2025 07:50:21 +0000 (16:50 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 4 Jan 2025 08:32:02 +0000 (08:32 +0000)
16dbdc64 changed the padding around the app icon in the titlebar to be
applied both vertically and horizontally rather than only horizontally
because it was more natural from a developer's perspective, but some users
complained about the smaller icons in certain configurations.

So let's undo the change in 16dbdc64 and apply the icon padding only
horizontally for now.

We can add configurations for the icon padding (or icon size independent
from window.button.{width,height}?) later.

include/img/img.h
src/img/img-svg.c
src/img/img.c
src/ssd/ssd-part.c
src/ssd/ssd-titlebar.c

index fafe9353f8295a81ed172fadcf262688500e129f..c3d1e7614a8c9e049e91bbc5e0677d8f63808514 100644 (file)
@@ -61,11 +61,11 @@ void lab_img_add_modifier(struct lab_img *img, lab_img_modifier_func_t modifier)
  * @img: source image
  * @width: width of the created buffer
  * @height: height of the created buffer
- * @padding: padding around the rendered image in the buffer
+ * @padding_x: horizontal padding around the rendered image in the buffer
  * @scale: scale of the created buffer
  */
 struct lab_data_buffer *lab_img_render(struct lab_img *img,
-       int width, int height, int padding, double scale);
+       int width, int height, int padding_x, double scale);
 
 /**
  * lab_img_destroy() - destroy lab_img
index 4900e2cc2039c9cea8246ff445c281381e37c66d..b7274d0f5aadeb6d6d37b79d0e127379472af330 100644 (file)
@@ -36,7 +36,7 @@ img_svg_load(const char *filename)
 }
 
 struct lab_data_buffer *
-img_svg_render(RsvgHandle *svg, int w, int h, int padding, double scale)
+img_svg_render(RsvgHandle *svg, int w, int h, int padding_x, double scale)
 {
        struct lab_data_buffer *buffer = buffer_create_cairo(w, h, scale);
        cairo_surface_t *image = buffer->surface;
@@ -44,10 +44,10 @@ img_svg_render(RsvgHandle *svg, int w, int h, int padding, double scale)
        GError *err = NULL;
 
        RsvgRectangle viewport = {
-               .x = padding,
-               .y = padding,
-               .width = w - 2 * padding,
-               .height = h - 2 * padding,
+               .x = padding_x,
+               .y = 0,
+               .width = w - 2 * padding_x,
+               .height = h,
        };
        rsvg_handle_render_document(svg, cr, &viewport, &err);
        if (err) {
index 7874c20d1edc632cb71f1929a72d1cdee9d19d50..57cb26bc90d16a42e6ddacac0d907ef499aa812d 100644 (file)
@@ -119,7 +119,7 @@ lab_img_add_modifier(struct lab_img *img,  lab_img_modifier_func_t modifier)
  */
 static struct lab_data_buffer *
 render_cairo_surface(cairo_surface_t *surface, int width, int height,
-       int padding, double scale)
+       int padding_x, double scale)
 {
        assert(surface);
        int src_w = cairo_image_surface_get_width(surface);
@@ -130,10 +130,10 @@ render_cairo_surface(cairo_surface_t *surface, int width, int height,
        cairo_t *cairo = cairo_create(buffer->surface);
 
        struct wlr_box container = {
-               .x = padding,
-               .y = padding,
-               .width = width - 2 * padding,
-               .height = height - 2 * padding,
+               .x = padding_x,
+               .y = 0,
+               .width = width - 2 * padding_x,
+               .height = height,
        };
 
        struct wlr_box dst_box = box_fit_within(src_w, src_h, &container);
index fc4d6139f67575d7fa9059848c92c83c2ae8d08f..fba803e311dfd6968803cab47d15e8dde2a9e438 100644 (file)
@@ -107,7 +107,7 @@ add_scene_button(struct wl_list *part_list, enum ssd_part_type type,
                struct ssd_part *icon_part = add_scene_part(part_list, type);
                struct scaled_img_buffer *img_buffer = scaled_img_buffer_create(
                        parent, imgs[state_set], rc.theme->window_button_width,
-                       rc.theme->window_button_height, /* padding */ 0);
+                       rc.theme->window_button_height, /* padding_x */ 0);
                assert(img_buffer);
                icon_part->node = &img_buffer->scene_buffer->node;
                wlr_scene_node_set_enabled(icon_part->node, false);
index dbad3010e619961557ac4df6750202dab4b66557..46ba2e21963a7cb8c31d5f19305480dec9aa48ea 100644 (file)
@@ -597,7 +597,7 @@ ssd_update_window_icon(struct ssd *ssd)
         */
        int icon_padding = theme->window_button_width / 10;
        int icon_size = MIN(theme->window_button_width - 2 * icon_padding,
-               theme->window_button_height - 2 * icon_padding);
+               theme->window_button_height);
 
        /*
         * Load/render icons at the max scale of any usable output (at