[PATCH weston 3/3] shell: constrain resize grabs so titlebars don't go under the panel

Jonny Lamb jonny.lamb at collabora.co.uk
Wed Aug 20 01:37:02 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=80228
---
 desktop-shell/shell.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 9cb81d5..b9d5f39 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -1758,6 +1758,30 @@ struct weston_resize_grab {
 };
 
 static void
+constrain_resize_grab(struct weston_pointer_grab *grab,
+		      int32_t *width, int32_t *height)
+{
+	struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
+	struct shell_surface *shsurf = resize->base.shsurf;
+
+	int32_t height_difference;
+
+	height_difference = *height - shsurf->geometry.height;
+
+	/* we're only trying to make sure titlebars don't go under the panel */
+	if (shsurf->shell->panel_position == DESKTOP_SHELL_PANEL_POSITION_TOP &&
+	    resize->edges & WL_SHELL_SURFACE_RESIZE_TOP &&
+	    height_difference > 0) {
+		int32_t top;
+
+		top = shsurf->view->geometry.y - height_difference;
+
+		if (top < 0)
+			*height = shsurf->geometry.height;
+	}
+}
+
+static void
 resize_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
 		   wl_fixed_t x, wl_fixed_t y)
 {
@@ -1793,6 +1817,8 @@ resize_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
 		height += wl_fixed_to_int(to_y - from_y);
 	}
 
+	constrain_resize_grab(grab, &width, &height);
+
 	shsurf->client->send_configure(shsurf->surface, width, height);
 }
 
-- 
2.1.0.rc1



More information about the wayland-devel mailing list