[PATCH weston] xwm: set the shell_surface's title

Giulio Camuffo giuliocamuffo at gmail.com
Wed Sep 11 07:15:46 PDT 2013


add a new function pointer to the weston_shell_interface struct that
shells will set accordingly.
---
 src/compositor.h              |  2 ++
 src/shell.c                   | 11 +++++++++--
 src/xwayland/window-manager.c |  8 ++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/compositor.h b/src/compositor.h
index 891db0e..6c12757 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -107,6 +107,8 @@ struct weston_shell_interface {
 	int (*move)(struct shell_surface *shsurf, struct weston_seat *ws);
 	int (*resize)(struct shell_surface *shsurf,
 		      struct weston_seat *ws, uint32_t edges);
+	void (*set_title)(struct shell_surface *shsurf,
+	                  const char *title);
 
 };
 
diff --git a/src/shell.c b/src/shell.c
index dc15bfa..ea4315a 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -1595,13 +1595,19 @@ shell_surface_pong(struct wl_client *client, struct wl_resource *resource,
 }
 
 static void
+set_title(struct shell_surface *shsurf, const char *title)
+{
+	free(shsurf->title);
+	shsurf->title = strdup(title);
+}
+
+static void
 shell_surface_set_title(struct wl_client *client,
 			struct wl_resource *resource, const char *title)
 {
 	struct shell_surface *shsurf = wl_resource_get_user_data(resource);
 
-	free(shsurf->title);
-	shsurf->title = strdup(title);
+	set_title(shsurf, title);
 }
 
 static void
@@ -4583,6 +4589,7 @@ module_init(struct weston_compositor *ec,
 	ec->shell_interface.set_xwayland = set_xwayland;
 	ec->shell_interface.move = surface_move;
 	ec->shell_interface.resize = surface_resize;
+	ec->shell_interface.set_title = set_title;
 
 	wl_list_init(&shell->input_panel.surfaces);
 
diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index 4c7256e..14bc0a3 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -337,6 +337,8 @@ static void
 weston_wm_window_read_properties(struct weston_wm_window *window)
 {
 	struct weston_wm *wm = window->wm;
+	struct weston_shell_interface *shell_interface =
+		&wm->server->compositor->shell_interface;
 
 #define F(field) offsetof(struct weston_wm_window, field)
 	const struct {
@@ -431,6 +433,9 @@ weston_wm_window_read_properties(struct weston_wm_window *window)
 		}
 		free(reply);
 	}
+
+	if (window->shsurf && window->name)
+		shell_interface->set_title(window->shsurf, window->name);
 }
 
 static void
@@ -1913,6 +1918,9 @@ xserver_map_shell_surface(struct weston_wm *wm,
 						      window->surface,
 						      &shell_client);
 
+	if (window->name)
+		shell_interface->set_title(window->shsurf, window->name);
+
 	if (window->fullscreen) {
 		window->saved_width = window->width;
 		window->saved_height = window->height;
-- 
1.8.4



More information about the wayland-devel mailing list