display: include wayland clients in the tab list

Make sure that meta_display_list_windows() returns wayland windows
too, by keeping a separate hash for wayland clients.
This fixes a crash in the alt-tab code of gnome-shell.

Reviewed by drago01 in IRC.
This commit is contained in:
Giovanni Campagna 2013-09-16 11:24:01 +02:00
parent 42a5f4f479
commit 514fec7275
3 changed files with 38 additions and 0 deletions

View File

@ -154,6 +154,7 @@ struct _MetaDisplay
GSList *screens;
MetaScreen *active_screen;
GHashTable *xids;
GHashTable *wayland_windows;
int error_traps;
int (* error_trap_handler) (Display *display,
XErrorEvent *error);
@ -380,6 +381,11 @@ void meta_display_register_x_window (MetaDisplay *display,
void meta_display_unregister_x_window (MetaDisplay *display,
Window xwindow);
void meta_display_register_wayland_window (MetaDisplay *display,
MetaWindow *window);
void meta_display_unregister_wayland_window (MetaDisplay *display,
MetaWindow *window);
#ifdef HAVE_XSYNC
MetaWindow* meta_display_lookup_sync_alarm (MetaDisplay *display,
XSyncAlarm alarm);

View File

@ -607,6 +607,7 @@ meta_display_open (void)
the_display->xids = g_hash_table_new (meta_unsigned_long_hash,
meta_unsigned_long_equal);
the_display->wayland_windows = g_hash_table_new (NULL, NULL);
i = 0;
while (i < N_IGNORED_CROSSING_SERIALS)
@ -1048,6 +1049,19 @@ meta_display_list_windows (MetaDisplay *display,
winlist = g_slist_prepend (winlist, window);
}
g_hash_table_iter_init (&iter, display->wayland_windows);
while (g_hash_table_iter_next (&iter, &key, &value))
{
MetaWindow *window = value;
if (!META_IS_WINDOW (window))
continue;
if (!window->override_redirect ||
(flags & META_LIST_INCLUDE_OVERRIDE_REDIRECT) != 0)
winlist = g_slist_prepend (winlist, window);
}
/* Uniquify the list, since both frame windows and plain
* windows are in the hash
*/
@ -3864,6 +3878,20 @@ meta_display_unregister_x_window (MetaDisplay *display,
remove_pending_pings_for_window (display, xwindow);
}
void
meta_display_register_wayland_window (MetaDisplay *display,
MetaWindow *window)
{
g_hash_table_add (display->wayland_windows, window);
}
void
meta_display_unregister_wayland_window (MetaDisplay *display,
MetaWindow *window)
{
g_hash_table_remove (display->wayland_windows, window);
}
#ifdef HAVE_XSYNC
/* We store sync alarms in the window ID hash table, because they are
* just more types of XIDs in the same global space, but we have

View File

@ -1060,6 +1060,8 @@ meta_window_new_shared (MetaDisplay *display,
meta_window_update_shape_region_x11 (window);
meta_window_update_input_region_x11 (window);
}
else
meta_display_register_wayland_window (display, window);
/* assign the window to its group, or create a new group if needed
*/
@ -2050,6 +2052,8 @@ meta_window_unmanage (MetaWindow *window,
meta_error_trap_pop (window->display);
}
else
meta_display_unregister_wayland_window (window->display, window);
if (window->surface)
meta_wayland_surface_free (window->surface);