[weston 3/8] xwm: Don't resize windows if the application have these hints

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


If the minimum and maximum size hints are equal, that means the
application doesn't want the window manager to allow resizing.

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

diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index 02a7c252..b78175b3 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -964,6 +964,15 @@ weston_wm_window_set_net_wm_state(struct weston_wm_window *window)
 			    i, property);
 }
 
+static inline bool
+weston_wm_window_is_resizable(struct weston_wm_window *window)
+{
+	return (window->size_hints.min_width <= 0 ||
+	        window->size_hints.min_height <= 0 ||
+		window->size_hints.min_width != window->size_hints.max_width ||
+		window->size_hints.min_height != window->size_hints.max_height);
+}
+
 static void
 weston_wm_window_create_frame(struct weston_wm_window *window)
 {
@@ -972,7 +981,8 @@ weston_wm_window_create_frame(struct weston_wm_window *window)
 	int x, y, width, height;
 	int buttons = FRAME_BUTTON_CLOSE;
 
-	if (window->decorate & MWM_DECOR_MAXIMIZE)
+	if (window->decorate & MWM_DECOR_MAXIMIZE &&
+	    weston_wm_window_is_resizable(window))
 		buttons |= FRAME_BUTTON_MAXIMIZE;
 
 	window->frame = frame_create(window->wm->theme,
@@ -2137,7 +2147,7 @@ weston_wm_handle_button(struct weston_wm *wm, xcb_generic_event_t *event)
 	}
 
 	if (frame_status(window->frame) & FRAME_STATUS_RESIZE) {
-		if (pointer)
+		if (pointer && weston_wm_window_is_resizable(window))
 			xwayland_interface->resize(window->shsurf, pointer, location);
 		frame_status_clear(window->frame, FRAME_STATUS_RESIZE);
 	}
@@ -2178,8 +2188,10 @@ weston_wm_handle_motion(struct weston_wm *wm, xcb_generic_event_t *event)
 	if (frame_status(window->frame) & FRAME_STATUS_REPAINT)
 		weston_wm_window_schedule_repaint(window);
 
-	cursor = get_cursor_for_location(location);
-	weston_wm_window_set_cursor(wm, window->frame_id, cursor);
+	if (weston_wm_window_is_resizable(window)) {
+		cursor = get_cursor_for_location(location);
+		weston_wm_window_set_cursor(wm, window->frame_id, cursor);
+	}
 }
 
 static void
@@ -2199,8 +2211,10 @@ weston_wm_handle_enter(struct weston_wm *wm, xcb_generic_event_t *event)
 	if (frame_status(window->frame) & FRAME_STATUS_REPAINT)
 		weston_wm_window_schedule_repaint(window);
 
-	cursor = get_cursor_for_location(location);
-	weston_wm_window_set_cursor(wm, window->frame_id, cursor);
+	if (weston_wm_window_is_resizable(window)) {
+		cursor = get_cursor_for_location(location);
+		weston_wm_window_set_cursor(wm, window->frame_id, cursor);
+	}
 }
 
 static void
-- 
2.12.2



More information about the wayland-devel mailing list