[PATCH 5/7] shell: update position of surfaces with type none on map()

Ander Conselvan de Oliveira ander.conselvan.de.oliveira at intel.com
Wed Feb 15 07:02:56 PST 2012


Needed for implementing drag'n'drop icons. When a drag starts, the
compositor will position the top-left corner of the client supplied
icon surface at the cursor hotspot. On the first attach to that
surface, the client may want to reposition it but shell->map did not
take sx and sy parameters.

This changes shell->map interface to take sx and sy parameters and
change dekstop shell implementation to update the position of a
surface of type none according to those parameters. Since a surface
of type none won't actually be mapped, the effect of this change is
only visible for surfaces that are made visible by the compositor.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
---
 src/compositor.c   |    2 +-
 src/compositor.h   |    2 +-
 src/shell.c        |    8 ++++++--
 src/tablet-shell.c |    2 +-
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 31e26d8..13ee927 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1176,7 +1176,7 @@ surface_attach(struct wl_client *client,
 		       &es->buffer_destroy_listener.link);
 
 	if (es->visual == WESTON_NONE_VISUAL) {
-		shell->map(shell, es, buffer->width, buffer->height);
+		shell->map(shell, es, buffer->width, buffer->height, sx, sy);
 	} else if (sx != 0 || sy != 0 ||
 		   es->geometry.width != buffer->width ||
 		   es->geometry.height != buffer->height) {
diff --git a/src/compositor.h b/src/compositor.h
index 6c10805..c47f24b 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -130,7 +130,7 @@ struct weston_shell {
 	void (*lock)(struct weston_shell *shell);
 	void (*unlock)(struct weston_shell *shell);
 	void (*map)(struct weston_shell *shell, struct weston_surface *surface,
-		    int32_t width, int32_t height);
+		    int32_t width, int32_t height, int32_t sx, int32_t sy);
 	void (*configure)(struct weston_shell *shell,
 			  struct weston_surface *surface,
 			  GLfloat x, GLfloat y, int32_t width, int32_t height);
diff --git a/src/shell.c b/src/shell.c
index d48633e..d9ba168 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -1267,8 +1267,8 @@ center_on_output(struct weston_surface *surface, struct weston_output *output)
 }
 
 static void
-map(struct weston_shell *base,
-    struct weston_surface *surface, int32_t width, int32_t height)
+map(struct weston_shell *base, struct weston_surface *surface,
+    int32_t width, int32_t height, int32_t sx, int32_t sy)
 {
 	struct wl_shell *shell = container_of(base, struct wl_shell, shell);
 	struct weston_compositor *compositor = shell->compositor;
@@ -1308,6 +1308,10 @@ map(struct weston_shell *base,
 		break;
 	case SHELL_SURFACE_POPUP:
 		shell_map_popup(shsurf, shsurf->popup.time);
+	case SHELL_SURFACE_NONE:
+		weston_surface_set_position(surface,
+					    surface->geometry.x + sx,
+					    surface->geometry.y + sy);
 		break;
 	default:
 		;
diff --git a/src/tablet-shell.c b/src/tablet-shell.c
index 48784f6..2c325db 100644
--- a/src/tablet-shell.c
+++ b/src/tablet-shell.c
@@ -105,7 +105,7 @@ tablet_shell_set_state(struct tablet_shell *shell, int state)
 
 static void
 tablet_shell_map(struct weston_shell *base, struct weston_surface *surface,
-		       int32_t width, int32_t height)
+		       int32_t width, int32_t height, int32_t sx, int32_t sy)
 {
 	struct tablet_shell *shell =
 		container_of(base, struct tablet_shell, shell);
-- 
1.7.4.1



More information about the wayland-devel mailing list