[PATCH] compositor: Calculate resizing direction

Benjamin Franzke benjaminfranzke at googlemail.com
Tue Feb 1 07:30:31 PST 2011


This applies to resizes initiated by the compositor.
---
 compositor/compositor.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/compositor/compositor.c b/compositor/compositor.c
index 9d7c330..365344a 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -772,6 +772,7 @@ notify_button(struct wl_input_device *device,
 		(struct wlsc_compositor *) device->compositor;
 
 	surface = (struct wlsc_surface *) device->pointer_focus;
+	uint32_t edges = 0;
 
 	if (state && surface && device->grab == NULL) {
 		wlsc_surface_raise(surface);
@@ -794,11 +795,22 @@ notify_button(struct wl_input_device *device,
 			   (struct wl_shell *) &compositor->shell,
 			   &surface->surface, device, time);
 	else if (state && surface && button == BTN_MIDDLE &&
-		 (wd->modifier_state & MODIFIER_SUPER))
+		 (wd->modifier_state & MODIFIER_SUPER)) {
+
+		if ((device->grab_x - surface->x) < surface->width / 2)
+			edges |= WL_SHELL_RESIZE_LEFT;
+		else
+			edges |= WL_SHELL_RESIZE_RIGHT;
+
+		if ((device->grab_y - surface->y) < surface->height / 2)
+			edges |= WL_SHELL_RESIZE_TOP;
+		else
+			edges |= WL_SHELL_RESIZE_BOTTOM;
+
 		shell_resize(NULL,
 			     (struct wl_shell *) &compositor->shell,
-			     &surface->surface, device, time,
-			     WL_SHELL_RESIZE_BOTTOM_RIGHT);
+			     &surface->surface, device, time, edges);
+	}
 
 	if (device->grab)
 		device->grab->interface->button(device->grab, time,
-- 
1.7.3.4



More information about the wayland-devel mailing list