]> git.mdlowis.com Git - proto/labwc.git/commitdiff
ssd: don't update ssd if view width is too small
authortokyo4j <hrak1529@gmail.com>
Sat, 27 Apr 2024 09:15:53 +0000 (18:15 +0900)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 28 Apr 2024 08:20:24 +0000 (10:20 +0200)
Clients can ignore the requsted geometry and negative widths could be
passed to `wlr_scene_rect_set_size()` in `ssd_titlebar_update()` or in
`ssd_border_update()`.

src/ssd/ssd.c

index 518602a6a3d19124d750ca04f47c9b3090f95259..9c96ef7bcd63dc67d85de9e0cf75ff5805324dab 100644 (file)
@@ -229,6 +229,16 @@ ssd_update_geometry(struct ssd *ssd)
        int eff_width = current.width;
        int eff_height = view_effective_height(ssd->view, /* use_pending */ false);
 
+       if (eff_width > 0 && eff_width < LAB_MIN_VIEW_WIDTH) {
+               /*
+                * Prevent negative values in calculations like
+                * `width - SSD_BUTTON_WIDTH * SSD_BUTTON_COUNT`
+                */
+               wlr_log(WLR_ERROR,
+                       "view width is smaller than its minimal value");
+               return;
+       }
+
        if (eff_width == cached.width && eff_height == cached.height) {
                if (current.x != cached.x || current.y != cached.y) {
                        /* Dynamically resize extents based on position and usable_area */