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>
struct output {
struct wl_output *output;
struct output {
struct wl_output *output;
+ uint32_t server_output_id;
struct wl_list link;
struct panel *panel;
struct wl_list link;
struct panel *panel;
output->output =
display_bind(desktop->display, id, &wl_output_interface, 2);
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);
wl_output_add_listener(output->output, &output_listener, output);
+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;
panel_add_launchers(struct panel *panel, struct desktop *desktop)
{
struct weston_config_section *s;
display_set_user_data(desktop.display, &desktop);
display_set_global_handler(desktop.display, global_handler);
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 */
/* Create panel and background for outputs processed before the shell
* global interface was processed */
display_output_handler_t output_configure_handler;
display_global_handler_t global_handler;
display_output_handler_t output_configure_handler;
display_global_handler_t global_handler;
+ display_global_handler_t global_handler_remove;
struct output {
struct display *display;
struct wl_output *output;
struct output {
struct display *display;
struct wl_output *output;
+ uint32_t server_output_id;
struct rectangle allocation;
struct wl_list link;
int transform;
struct rectangle allocation;
struct wl_list link;
int transform;
output->scale = 1;
output->output =
wl_registry_bind(d->registry, id, &wl_output_interface, 2);
output->scale = 1;
output->output =
wl_registry_bind(d->registry, id, &wl_output_interface, 2);
+ output->server_output_id = id;
wl_list_insert(d->output_list.prev, &output->link);
wl_output_add_listener(output->output, &output_listener, output);
wl_list_insert(d->output_list.prev, &output->link);
wl_output_add_listener(output->output, &output_listener, output);
+static void
+display_destroy_output(struct display *d, uint32_t id)
+{
+ struct output *output;
+
+ wl_list_for_each(output, &d->output_list, link) {
+ if (output->server_output_id == id) {
+ output_destroy(output);
+ break;
+ }
+ }
+}
+
void
display_set_global_handler(struct display *display,
display_global_handler_t handler)
void
display_set_global_handler(struct display *display,
display_global_handler_t handler)
+display_set_global_handler_remove(struct display *display,
+ display_global_handler_t remove_handler)
+{
+ display->global_handler_remove = remove_handler;
+ if (!remove_handler)
+ return;
+}
+
+void
display_set_output_configure_handler(struct display *display,
display_output_handler_t handler)
{
display_set_output_configure_handler(struct display *display,
display_output_handler_t handler)
{
if (global->name != name)
continue;
if (global->name != name)
continue;
- /* XXX: Should destroy bound globals, and call
- * the counterpart of display::global_handler
- */
+ if (strcmp(global->interface, "wl_output") == 0)
+ display_destroy_output(d, name);
+
+ /* XXX: Should destroy remaining bound globals */
+
+ if (d->global_handler_remove)
+ d->global_handler_remove(d, name, global->interface,
+ global->version, d->user_data);
+
wl_list_remove(&global->link);
free(global->interface);
free(global);
wl_list_remove(&global->link);
free(global->interface);
free(global);
void
display_set_global_handler(struct display *display,
display_global_handler_t handler);
void
display_set_global_handler(struct display *display,
display_global_handler_t handler);
+void
+display_set_global_handler_remove(struct display *display,
+ display_global_handler_t remove_handler);
void *
display_bind(struct display *display, uint32_t name,
const struct wl_interface *interface, uint32_t version);
void *
display_bind(struct display *display, uint32_t name,
const struct wl_interface *interface, uint32_t version);