window, desktop-shell: deal with output unplug on client side

when output is removed, weston-desktop-shell should destroy panel
and background surface on destroyed output.

Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index d864a65..4e7a815 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -95,6 +95,7 @@
 
 struct output {
 	struct wl_output *output;
+	uint32_t server_output_id;
 	struct wl_list link;
 
 	struct panel *panel;
@@ -1213,6 +1214,7 @@
 
 	output->output =
 		display_bind(desktop->display, id, &wl_output_interface, 2);
+	output->server_output_id = id;
 
 	wl_output_add_listener(output->output, &output_listener, output);
 
@@ -1242,6 +1244,23 @@
 }
 
 static void
+global_handler_remove(struct display *display, uint32_t id,
+	       const char *interface, uint32_t version, void *data)
+{
+	struct desktop *desktop = data;
+	struct output *output;
+
+	if (!strcmp(interface, "wl_output")) {
+		wl_list_for_each(output, &desktop->outputs, link) {
+			if (output->server_output_id == id) {
+				output_destroy(output);
+				break;
+			}
+		}
+	}
+}
+
+static void
 panel_add_launchers(struct panel *panel, struct desktop *desktop)
 {
 	struct weston_config_section *s;
@@ -1298,6 +1317,7 @@
 
 	display_set_user_data(desktop.display, &desktop);
 	display_set_global_handler(desktop.display, global_handler);
+	display_set_global_handler_remove(desktop.display, global_handler_remove);
 
 	/* Create panel and background for outputs processed before the shell
 	 * global interface was processed */