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

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Tue Apr 11 20:53:02 UTC 2017


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

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
---
 xwayland/window-manager.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index bea3cc68..3ee76027 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)
@@ -1672,9 +1678,11 @@ 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:
+		window->resizing = 1;
 		xwayland_interface->resize(window->shsurf, pointer, map[detail]);
 		break;
 	case _NET_WM_MOVERESIZE_CANCEL:
+		window->resizing = 0;
 		break;
 	}
 }
@@ -2110,6 +2118,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;
@@ -2147,8 +2159,10 @@ 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)) {
+			window->resizing = 1;
 			xwayland_interface->resize(window->shsurf, pointer, location);
+		}
 		frame_status_clear(window->frame, FRAME_STATUS_RESIZE);
 	}
 
-- 
2.12.2



More information about the wayland-devel mailing list