[PATCH weston 07/11] shell: Initialize workspace state for new outputs

Jonas Ådahl jadahl at gmail.com
Sat Jan 26 06:33:37 PST 2013


Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---
 src/compositor.c |    3 +++
 src/compositor.h |    1 +
 src/shell.c      |   17 +++++++++++++++++
 3 files changed, 21 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index cd11f6b..207a216 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2905,6 +2905,8 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c,
 	output->global =
 		wl_display_add_global(c->wl_display, &wl_output_interface,
 				      output, bind_output);
+
+	wl_signal_emit(&c->output_created_signal, output);
 }
 
 static void
@@ -2961,6 +2963,7 @@ weston_compositor_init(struct weston_compositor *ec,
 	wl_signal_init(&ec->show_input_panel_signal);
 	wl_signal_init(&ec->hide_input_panel_signal);
 	wl_signal_init(&ec->seat_created_signal);
+	wl_signal_init(&ec->output_created_signal);
 	ec->launcher_sock = weston_environment_get_fd("WESTON_LAUNCHER_SOCK");
 
 	ec->output_id_pool = 0;
diff --git a/src/compositor.h b/src/compositor.h
index 544cf33..57d7442 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -291,6 +291,7 @@ struct weston_compositor {
 	struct wl_signal hide_input_panel_signal;
 
 	struct wl_signal seat_created_signal;
+	struct wl_signal output_created_signal;
 
 	struct wl_event_loop *input_loop;
 	struct wl_event_source *input_loop_source;
diff --git a/src/shell.c b/src/shell.c
index 45e70f0..be4cf0a 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -122,6 +122,8 @@ struct desktop_shell {
 	struct weston_surface *lock_surface;
 	struct wl_listener lock_surface_listener;
 
+	struct wl_listener output_create_listener;
+
 	struct {
 		struct hash_table *table;
 		unsigned int default_num;
@@ -3952,6 +3954,17 @@ init_output_workspaces(struct desktop_shell *shell,
 
 	return 0;
 }
+
+static void
+handle_output_create(struct wl_listener *listener, void *data)
+{
+	struct weston_output *output = data;
+
+	if (init_output_workspaces(output->compositor->shell_interface.shell,
+				   data) != 0)
+		abort();
+}
+
 static void
 destroy_workspace_container(void *element, void *data)
 {
@@ -4089,6 +4102,10 @@ module_init(struct weston_compositor *ec)
 	ec->shell_interface.move = surface_move;
 	ec->shell_interface.resize = surface_resize;
 
+	shell->output_create_listener.notify = handle_output_create;
+	wl_signal_add(&ec->output_created_signal,
+		      &shell->output_create_listener);
+
 	wl_list_init(&shell->input_panel.surfaces);
 
 	weston_layer_init(&shell->fullscreen_layer, &ec->cursor_layer.link);
-- 
1.7.10.4



More information about the wayland-devel mailing list