[PATCH 2/6 weston] xserver: glue it with shell_surface

Tiago Vignatti tiago.vignatti at intel.com
Tue Apr 3 06:58:00 PDT 2012


Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
---
 src/Makefile.am        |    4 +++-
 src/shell.c            |   17 +++++++++++++++--
 src/shell.h            |   34 ++++++++++++++++++++++++++++++++++
 src/xserver-launcher.c |   14 ++++++++++++++
 4 files changed, 66 insertions(+), 3 deletions(-)
 create mode 100644 src/shell.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 048e58f..afd8dcd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,7 +36,8 @@ xserver_launcher_sources =			\
 	xserver-protocol.c			\
 	xserver-server-protocol.h		\
 	hash.c					\
-	hash.h
+	hash.h					\
+	$(desktop_shell_la_SOURCES)
 endif
 
 moduledir = @libdir@/weston
@@ -96,6 +97,7 @@ desktop_shell_la_LIBADD = $(COMPOSITOR_LIBS)	\
 desktop_shell_la_CFLAGS = $(GCC_CFLAGS)
 desktop_shell_la_SOURCES =			\
 	shell.c					\
+	shell.h					\
 	desktop-shell-protocol.c		\
 	desktop-shell-server-protocol.h
 endif
diff --git a/src/shell.c b/src/shell.c
index 46fa370..80b3c11 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -33,6 +33,7 @@
 
 #include <wayland-server.h>
 #include "compositor.h"
+#include "shell.h"
 #include "desktop-shell-server-protocol.h"
 #include "../shared/config-parser.h"
 
@@ -421,7 +422,7 @@ reset_shell_surface_type(struct shell_surface *surface)
 	return 0;
 }
 
-static void
+void
 shell_surface_set_toplevel(struct wl_client *client,
 			   struct wl_resource *resource)
 
@@ -814,10 +815,22 @@ get_shell_surface(struct weston_surface *surface)
 	return NULL;
 }
 
+struct wl_resource *
+shell_get_shell_surface_resource(struct weston_surface *weston_surface)
+{
+	struct shell_surface *shsurf;
+
+	if (!weston_surface)
+		return NULL;
+
+	shsurf = get_shell_surface(weston_surface);
+	return &shsurf->resource;
+}
+
 static void
 shell_surface_configure(struct weston_surface *, int32_t, int32_t);
 
-static void
+void
 shell_get_shell_surface(struct wl_client *client,
 			struct wl_resource *resource,
 			uint32_t id,
diff --git a/src/shell.h b/src/shell.h
new file mode 100644
index 0000000..222e327
--- /dev/null
+++ b/src/shell.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  The copyright holders make
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+struct wl_resource *
+shell_get_shell_surface_resource(struct weston_surface *weston_surface);
+
+void
+shell_surface_set_toplevel(struct wl_client *client,
+                           struct wl_resource *resource);
+
+void
+shell_get_shell_surface(struct wl_client *client,
+                        struct wl_resource *resource,
+                        uint32_t id,
+                        struct wl_resource *surface_resource);
diff --git a/src/xserver-launcher.c b/src/xserver-launcher.c
index 4fda42f..91f827b 100644
--- a/src/xserver-launcher.c
+++ b/src/xserver-launcher.c
@@ -38,6 +38,7 @@
 #include <wayland-server.h>
 
 #include "compositor.h"
+#include "shell.h"
 #include "xserver-server-protocol.h"
 #include "hash.h"
 
@@ -115,6 +116,7 @@ struct weston_wm {
 
 struct weston_wm_window {
 	xcb_window_t id;
+	struct wl_client *client;
 	struct weston_surface *surface;
 	struct wl_listener surface_destroy_listener;
 	char *class;
@@ -611,6 +613,7 @@ weston_wm_handle_map_notify(struct weston_wm *wm, xcb_generic_event_t *event)
 	uint32_t *xid;
 	xcb_atom_t *atom;
 	uint32_t i;
+	struct wl_resource *shsurf_resource;
 
 	fprintf(stderr, "XCB_MAP_NOTIFY (window %d)\n", map_notify->window);
 
@@ -667,6 +670,9 @@ weston_wm_handle_map_notify(struct weston_wm *wm, xcb_generic_event_t *event)
 		window->id, window->name, window->class,
 		window->transient_for ? window->transient_for->id : 0);
 	weston_wm_activate(wm, window, XCB_TIME_CURRENT_TIME);
+
+	shsurf_resource = shell_get_shell_surface_resource(window->surface);
+	shell_surface_set_toplevel(window->client, shsurf_resource);
 }
 
 static const size_t incr_chunk_size = 64 * 1024;
@@ -1529,9 +1535,17 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
 	fprintf(stderr, "set_window_id %d for surface %p\n", id, surface);
 
 	window->surface = (struct weston_surface *) surface;
+	window->client = client;
 	window->surface_destroy_listener.func = surface_destroy;
 	wl_list_insert(surface->resource.destroy_listener_list.prev,
 		       &window->surface_destroy_listener.link);
+
+	/* Given that we're stealing the same client call to create
+	 * shell_surface, the id here follows X11 convention i.e, using big
+	 * integers (drawable.id). This is different from Wayland style but
+	 * seems to work -- we remark that it might be dangerous though. TODO:
+	 * create a testing for it on the protocol. */
+	shell_get_shell_surface(client, resource, id, surface_resource);
 }
 
 static const struct xserver_interface xserver_implementation = {
-- 
1.7.5.4



More information about the wayland-devel mailing list