[PATCH 6/6] compositor: introduce internal shell_surface helpers

Tiago Vignatti tiago.vignatti at intel.com
Mon Apr 16 07:31:45 PDT 2012


We're able now to create shell_surfaces inside Weston. This makes possible the
glue needed between shell and xserver-launcher.

Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
---
 src/compositor.h       |   24 +++++++++++++++++++++++-
 src/shell.c            |    8 +++++---
 src/xserver-launcher.c |   13 +++++++++++++
 3 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/src/compositor.h b/src/compositor.h
index f2860b6..be01a9f 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -42,6 +42,7 @@ struct weston_transform {
 };
 
 struct weston_surface;
+struct shell_surface;
 struct weston_input_device;
 
 struct weston_mode {
@@ -152,6 +153,27 @@ struct weston_spring {
 	uint32_t timestamp;
 };
 
+struct weston_shell_surface {
+	void *shell;			/* either desktop or tablet */
+	void (*create_shell_surface) (void *shell,
+				      struct weston_surface *surface,
+				      struct shell_surface **ret);
+
+	/* shell_surface operations */
+	void (*set_toplevel)(struct shell_surface *shsurf);
+	void (*set_transiant)(struct shell_surface *shsurf,
+			      struct shell_surface *pshsurf,
+			      int x, int y, uint32_t flags);
+	void (*set_fullscreen)(struct shell_surface *shsurf,
+			       struct weston_output *output,
+			       uint32_t method, uint32_t framerate);
+	void (*set_maximized)(struct shell_surface *shsurf,
+			      struct weston_output *output);
+	void (*set_popup)(struct shell_surface *shsurf,
+			  struct shell_surface *pshsurf,
+			  int32_t x, int32_t y);
+};
+
 enum {
 	WESTON_COMPOSITOR_ACTIVE,
 	WESTON_COMPOSITOR_IDLE,		/* shell->unlock called on activity */
@@ -168,7 +190,7 @@ struct weston_layer {
 struct weston_compositor {
 	struct wl_shm *shm;
 	struct wl_signal destroy_signal;
-	void *shell;			/* either desktop or tablet */
+	struct weston_shell_surface shell_surface;
 
 	EGLDisplay display;
 	EGLContext context;
diff --git a/src/shell.c b/src/shell.c
index 6026a6c..165f152 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -36,8 +36,6 @@
 #include "desktop-shell-server-protocol.h"
 #include "../shared/config-parser.h"
 
-struct shell_surface;
-
 struct desktop_shell {
 	struct weston_compositor *compositor;
 
@@ -957,7 +955,7 @@ create_shell_surface(void *shell, struct weston_surface *surface,
 	}
 
 	surface->configure = shell_surface_configure;
-	surface->compositor->shell = shell;
+	surface->compositor->shell_surface.shell = shell;
 	shsurf->shell = (struct desktop_shell *) shell;
 	shsurf->saved_position_valid = false;
 	shsurf->surface = surface;
@@ -966,6 +964,7 @@ create_shell_surface(void *shell, struct weston_surface *surface,
 	shsurf->fullscreen.black_surface = NULL;
 	wl_list_init(&shsurf->fullscreen.transform.link);
 
+	wl_signal_init(&shsurf->resource.destroy_signal);
 	shsurf->surface_destroy_listener.notify = shell_handle_surface_destroy;
 	wl_signal_add(&surface->surface.resource.destroy_signal,
 		      &shsurf->surface_destroy_listener);
@@ -2274,6 +2273,9 @@ shell_init(struct weston_compositor *ec)
 	shell->unlock_listener.notify = unlock;
 	wl_signal_add(&ec->unlock_signal, &shell->unlock_listener);
 
+	ec->shell_surface.create_shell_surface = create_shell_surface;
+	ec->shell_surface.set_toplevel = set_toplevel;
+
 	wl_list_init(&shell->backgrounds);
 	wl_list_init(&shell->panels);
 	wl_list_init(&shell->screensaver.surfaces);
diff --git a/src/xserver-launcher.c b/src/xserver-launcher.c
index 639a188..50b8d25 100644
--- a/src/xserver-launcher.c
+++ b/src/xserver-launcher.c
@@ -118,6 +118,7 @@ struct weston_wm {
 struct weston_wm_window {
 	xcb_window_t id;
 	struct weston_surface *surface;
+	struct shell_surface *shsurf;
 	struct wl_listener surface_destroy_listener;
 	char *class;
 	char *name;
@@ -612,6 +613,8 @@ weston_wm_handle_map_notify(struct weston_wm *wm, xcb_generic_event_t *event)
 	xcb_get_property_cookie_t cookie[ARRAY_LENGTH(props)];
 	xcb_get_property_reply_t *reply;
 	struct weston_wm_window *window;
+	struct weston_shell_surface shell_surface =
+		wm->server->compositor->shell_surface;
 	void *p;
 	uint32_t *xid;
 	xcb_atom_t *atom;
@@ -672,6 +675,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);
+
+	if (shell_surface.set_toplevel)
+		shell_surface.set_toplevel(window->shsurf);
 }
 
 static const size_t incr_chunk_size = 64 * 1024;
@@ -1517,6 +1523,8 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
 	struct weston_wm *wm = wxs->wm;
 	struct wl_surface *surface = surface_resource->data;
 	struct weston_wm_window *window;
+	struct weston_shell_surface shell_surface =
+		wxs->compositor->shell_surface;
 
 	if (client != wxs->client)
 		return;
@@ -1533,6 +1541,11 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
 	window->surface_destroy_listener.notify = surface_destroy;
 	wl_signal_add(&surface->resource.destroy_signal,
 		      &window->surface_destroy_listener);
+
+	if (shell_surface.create_shell_surface)
+		shell_surface.create_shell_surface(shell_surface.shell,
+						   window->surface,
+						   &window->shsurf);
 }
 
 static const struct xserver_interface xserver_implementation = {
-- 
1.7.5.4



More information about the wayland-devel mailing list