]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xdg: Eliminate redundant update_x/update_y flags
authorJohn Lindgren <john@jlindgren.net>
Wed, 8 Feb 2023 21:14:06 +0000 (16:14 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Wed, 8 Feb 2023 22:22:10 +0000 (22:22 +0000)
struct view's pending_move_resize.update_x/update_y flags appear to
be redundant, since we can easily determine whether x/y have been
update via a simple comparison in handle_commit().

The only corner case I can think of where this change might affect
behavior, is if xdg_toplevel_view_move() is called while a resize
is still pending (e.g. after xdg_toplevel_view_configure() but
before handle_commit()). This corner case will be addressed in the
following commit.

include/view.h
src/xdg.c

index 0d3e5e0f71ea3648f6c3b209153e24ad769e95b0..719209bd37b6a3315f06294e56f91021f45b1c1c 100644 (file)
@@ -65,7 +65,6 @@ struct view {
        struct wlr_box natural_geometry;
 
        struct view_pending_move_resize {
-               bool update_x, update_y;
                int x, y;
                uint32_t width, height;
                uint32_t configure_serial;
index 0f5e8b527a0a48e5e97decc36c8542574639844a..426b9b9ec1291d6b33b5d00819cbcf2049ef4ca1 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -76,12 +76,12 @@ handle_commit(struct wl_listener *listener, void *data)
 
        uint32_t serial = view->pending_move_resize.configure_serial;
        if (serial > 0 && serial >= xdg_surface->current.configure_serial) {
-               if (view->pending_move_resize.update_x) {
+               if (view->x != view->pending_move_resize.x) {
                        update_required = true;
                        view->x = view->pending_move_resize.x +
                                view->pending_move_resize.width - size.width;
                }
-               if (view->pending_move_resize.update_y) {
+               if (view->y != view->pending_move_resize.y) {
                        update_required = true;
                        view->y = view->pending_move_resize.y +
                                view->pending_move_resize.height - size.height;
@@ -205,8 +205,6 @@ xdg_toplevel_view_configure(struct view *view, struct wlr_box geo)
 {
        view_adjust_size(view, &geo.width, &geo.height);
 
-       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;
        view->pending_move_resize.y = geo.y;
        view->pending_move_resize.width = geo.width;