]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xwayland: Honor size increments from WM_SIZE_HINTS
authorJohn Lindgren <john@jlindgren.net>
Sun, 20 Mar 2022 19:45:55 +0000 (15:45 -0400)
committerJohan Malm <jgm323@gmail.com>
Mon, 21 Mar 2022 09:38:05 +0000 (09:38 +0000)
src/xwayland.c

index 3b5680e7f1bc75d250e1c969c9b72d6196213a12..7d625497370e9c7cd23f66a4c1ece39faa01ce83 100644 (file)
@@ -181,9 +181,26 @@ handle_set_class(struct wl_listener *listener, void *data)
        view_update_app_id(view);
 }
 
+static int
+round_to_increment(int val, int base, int inc) {
+       if (base < 0 || inc <= 0)
+               return val;
+       return base + (val - base + inc / 2) / inc * inc;
+}
+
 static void
 configure(struct view *view, struct wlr_box geo)
 {
+       // honor size increments from WM_SIZE_HINTS
+       struct wlr_xwayland_surface_size_hints *hints =
+               view->xwayland_surface->size_hints;
+       if (hints) {
+               geo.width = round_to_increment(geo.width,
+                       hints->base_width, hints->width_inc);
+               geo.height = round_to_increment(geo.height,
+                       hints->base_height, hints->height_inc);
+       }
+
        view->pending_move_resize.update_x = geo.x != view->x;
        view->pending_move_resize.update_y = geo.y != view->y;
        view->pending_move_resize.x = geo.x;