[weston,v2,6/8] xwm: Ignore configure request while the user is resizing

Submitted by Louis-Francis Ratté-Boulianne on Nov. 13, 2017, 9:20 p.m.

Details

Message ID 20171113212056.18397-7-lfrb@collabora.com
State New
Headers show
Series "Implement NET_WM_SYNC_REQUEST basic support" ( rev: 2 ) in Wayland

Not browsing as part of any series.

Commit Message

Louis-Francis Ratté-Boulianne Nov. 13, 2017, 9:20 p.m.
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 <lfrb@collabora.com>
---
 xwayland/window-manager.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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);
 	}