]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view: fix bug in view_snap_to_edge()
authorJohan Malm <jgm323@gmail.com>
Fri, 7 Jan 2022 20:53:48 +0000 (20:53 +0000)
committerJohan Malm <jgm323@gmail.com>
Fri, 7 Jan 2022 20:53:48 +0000 (20:53 +0000)
Use view_move() and view_move_resize() correctly.

view_move_resize() should only be used when the view actually changes
width and/or height, otherwise the serials might cause a delay in moving
xdg-shell clients.

Issue #201

include/labwc.h
src/view.c

index 9749223b4e2addcf15ab86b9a32afb5188dce96e..2ab577f8d12b3c6aa243b2cc93f9da7a088f2ab0 100644 (file)
@@ -368,6 +368,15 @@ void view_subsurface_create(struct view *view,
 void view_set_activated(struct view *view, bool activated);
 void view_close(struct view *view);
 struct border view_border(struct view *view);
+
+/**
+ * view_move_resize - resize and move view
+ * @view: view to be resized and moved
+ * @geo: the new geometry
+ * NOTE: Only use this when the view actually changes width and/or height
+ * otherwise the serials might cause a delay in moving xdg-shell clients.
+ * For move only, use view_move()
+ */
 void view_move_resize(struct view *view, struct wlr_box geo);
 void view_move(struct view *view, double x, double y);
 void view_minimize(struct view *view, bool minimized);
index fe4099da45eadb566d41f9c2a1b81998bfff6f41..0ea556c8bde76fbaaefede4a909dcf577fba27c3 100644 (file)
@@ -25,21 +25,24 @@ view_close(struct view *view)
 }
 
 void
-view_move_resize(struct view *view, struct wlr_box geo)
+view_move(struct view *view, double x, double y)
 {
-       if (view->impl->configure) {
-               view->impl->configure(view, geo);
+       if (view->impl->move) {
+               view->impl->move(view, x, y);
        }
-       ssd_update_title(view);
        view_discover_output(view);
 }
 
 void
-view_move(struct view *view, double x, double y)
+view_move_resize(struct view *view, struct wlr_box geo)
 {
-       if (view->impl->move) {
-               view->impl->move(view, x, y);
+       if (view->w == geo.width && view->h == geo.height) {
+               wlr_log(WLR_ERROR, "use view_move() if not resizing");
+       }
+       if (view->impl->configure) {
+               view->impl->configure(view, geo);
        }
+       ssd_update_title(view);
        view_discover_output(view);
 }
 
@@ -602,7 +605,12 @@ view_snap_to_edge(struct view *view, const char *direction)
                        view_edge_invert(edge));
        }
 
-       view_move_resize(view, dst);
+       if (view->w == dst.width && view->h == dst.height) {
+               /* move horizontally/vertically without changing size */
+               view_move(view, dst.x, dst.y);
+       } else {
+               view_move_resize(view, dst);
+       }
 }
 
 const char *