[PATCH 1/2] shell: Implement the probe_area request on wl_shell_surface

Rob Bradford rob at robster.org.uk
Wed Feb 29 11:15:20 PST 2012


From: Rob Bradford <rob at linux.intel.com>

---
 src/shell.c |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 67 insertions(+), 1 deletions(-)

diff --git a/src/shell.c b/src/shell.c
index a28302b..c6108c3 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -631,6 +631,71 @@ shell_surface_set_popup(struct wl_client *client,
 	shsurf->popup.y = y;
 }
 
+
+static void
+shell_surface_probe_area(struct wl_client *client,
+			 struct wl_resource *resource,
+			 int x,
+			 int y,
+			 int w,
+			 int h)
+{
+	struct shell_surface *shsurf = resource->data;
+	struct {
+		struct {
+			int x;
+			int y;
+		} tl, br;
+	} orig, new;
+
+	int output_w, output_h;
+
+	int new_x, new_y, new_w, new_h;
+
+	output_w = shsurf->surface->output->current->width;
+	output_h = shsurf->surface->output->current->height;
+
+	/* orig and new are in global co-ordinates */
+	orig.tl.x = shsurf->surface->geometry.x + x;
+	orig.tl.y = shsurf->surface->geometry.y + y;
+	orig.br.x = orig.tl.x + w;
+	orig.br.y = orig.tl.y + h;
+
+	new = orig;
+
+	/* Clamp the top left so it is inside */
+	if (orig.tl.x < 0)
+	  new.tl.x = 0;
+	if (orig.tl.y < 0)
+	  new.tl.y = 0;
+	if (orig.tl.x > output_w)
+	  new.tl.x = output_w;
+	if (orig.tl.y > output_h)
+	  new.tl.y = output_h;
+
+	/* Clamp the bottom right so it is inside */
+	if (orig.br.x < 0)
+	  new.br.x = 0;
+	if (orig.br.y < 0)
+	  new.br.y = 0;
+	if (orig.br.x > output_w)
+	  new.br.x = output_w;
+	if (orig.br.y > output_h)
+	  new.br.y = output_h;
+
+	/* Translate back into relative co-ordinates */
+	new_x = new.tl.x - shsurf->surface->geometry.x;
+	new_y = new.tl.y - shsurf->surface->geometry.y;
+	new_w = new.br.x - new.tl.x;
+	new_h = new.br.y - new.tl.y;
+
+	wl_resource_post_event(resource,
+			       WL_SHELL_SURFACE_VISIBLE_AREA,
+			       new_x, new_y,
+			       new_w, new_h);
+
+}
+
 static const struct wl_shell_surface_interface shell_surface_implementation = {
 	shell_surface_move,
 	shell_surface_resize,
@@ -638,7 +703,8 @@ static const struct wl_shell_surface_interface shell_surface_implementation = {
 	shell_surface_set_transient,
 	shell_surface_set_fullscreen,
 	shell_surface_set_popup,
-	shell_surface_set_maximized
+	shell_surface_set_maximized,
+	shell_surface_probe_area,
 };
 
 static void
-- 
1.7.7.6



More information about the wayland-devel mailing list