wayland/keyboard: Cleanup resource list management

Initialize on init(), unlink and reinitialize the list headers on
disable() so that any delayed resource destruction doesn't affect future
state.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
This commit is contained in:
Jonas Ådahl 2016-09-21 11:30:02 +08:00
parent 312f215fc3
commit 578e527869

View File

@ -608,9 +608,6 @@ meta_wayland_keyboard_enable (MetaWaylandKeyboard *keyboard)
MetaBackend *backend = meta_get_backend ();
GSettingsSchema *schema;
wl_list_init (&keyboard->resource_list);
wl_list_init (&keyboard->focus_resource_list);
keyboard->settings = g_settings_new ("org.gnome.desktop.peripherals.keyboard");
g_signal_connect (keyboard->settings, "changed",
G_CALLBACK (settings_changed), keyboard);
@ -672,7 +669,10 @@ meta_wayland_keyboard_disable (MetaWaylandKeyboard *keyboard)
meta_wayland_keyboard_set_focus (keyboard, NULL);
meta_wayland_xkb_info_destroy (&keyboard->xkb_info);
/* XXX: What about keyboard->resource_list? */
wl_list_remove (&keyboard->resource_list);
wl_list_init (&keyboard->resource_list);
wl_list_remove (&keyboard->focus_resource_list);
wl_list_init (&keyboard->focus_resource_list);
g_clear_object (&keyboard->settings);
if (keyboard->gsd_settings)
@ -963,6 +963,9 @@ meta_wayland_keyboard_end_grab (MetaWaylandKeyboard *keyboard)
static void
meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard)
{
wl_list_init (&keyboard->resource_list);
wl_list_init (&keyboard->focus_resource_list);
meta_wayland_xkb_info_init (&keyboard->xkb_info);
keyboard->default_grab.interface = &default_keyboard_grab_interface;