We don't want the application to fight with the user when manually
resizing a window.

v2: Re-enable sync when a new resize operation is started

Signed-off-by: Louis-Francis Ratté-Boulianne <l...@collabora.com>
---
 xwayland/window-manager.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index a0ff6b62..1f3bcdac 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -173,6 +173,7 @@ struct weston_wm_window {
        int delete_window;
        int maximized_vert;
        int maximized_horz;
+       int resizing;
        int64_t sync_request_serial;
        int configure_pending;
        int sync_disabled;
@@ -701,6 +702,11 @@ weston_wm_handle_configure_request(struct weston_wm *wm, 
xcb_generic_event_t *ev
                return;
        }
 
+       if (window->frame && window->resizing) {
+               wm_log("Ignore configure request while resizing window\n");
+               return;
+       }
+
        if (configure_request->value_mask & XCB_CONFIG_WINDOW_WIDTH)
                window->width = configure_request->width;
        if (configure_request->value_mask & XCB_CONFIG_WINDOW_HEIGHT)
@@ -1671,9 +1677,13 @@ weston_wm_window_handle_moveresize(struct 
weston_wm_window *window,
        case _NET_WM_MOVERESIZE_SIZE_BOTTOM:
        case _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT:
        case _NET_WM_MOVERESIZE_SIZE_LEFT:
+               if (!window->resizing)
+                       window->sync_disabled = 0;
+               window->resizing = 1;
                xwayland_interface->resize(window->shsurf, pointer, 
map[detail]);
                break;
        case _NET_WM_MOVERESIZE_CANCEL:
+               window->resizing = 0;
                break;
        }
 }
@@ -2106,6 +2116,10 @@ weston_wm_handle_button(struct weston_wm *wm, 
xcb_generic_event_t *event)
                WL_POINTER_BUTTON_STATE_RELEASED;
        button_id = button->detail == 1 ? BTN_LEFT : BTN_RIGHT;
 
+       if (window->resizing && button_id == BTN_LEFT &&
+           button_state == WL_POINTER_BUTTON_STATE_PRESSED)
+               window->resizing = 0;
+
        if (button_state == WL_POINTER_BUTTON_STATE_PRESSED) {
                if (button->time - window->last_button_time <= 
DOUBLE_CLICK_PERIOD) {
                        double_click = 1;
@@ -2143,8 +2157,12 @@ weston_wm_handle_button(struct weston_wm *wm, 
xcb_generic_event_t *event)
        }
 
        if (frame_status(window->frame) & FRAME_STATUS_RESIZE) {
-               if (pointer && weston_wm_window_is_resizable(window))
+               if (pointer && weston_wm_window_is_resizable(window)) {
+                       if (!window->resizing)
+                               window->sync_disabled = 0;
+                       window->resizing = 1;
                        xwayland_interface->resize(window->shsurf, pointer, 
location);
+               }
                frame_status_clear(window->frame, FRAME_STATUS_RESIZE);
        }
 
-- 
2.13.0

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to