meta_display_list_windows: Exclude override-redirect

Don't include override-redirect windows in the list return by
meta_display_list_windows(), since we almost never want to handle
them when considering "all window" for the display. Add a separate
meta_display_list_all_windows() that includes override-redirect
windows.

http://bugzilla.gnome.org/show_bug.cgi?id=582639
This commit is contained in:
Owen W. Taylor 2009-06-15 15:32:23 -04:00
parent fd27647440
commit 00d955eb40
10 changed files with 59 additions and 33 deletions

View File

@ -766,7 +766,7 @@ meta_invalidate_default_icons (void)
if (display == NULL)
return; /* We can validly be called before the display is opened. */
windows = meta_display_list_windows (display);
windows = meta_display_list_windows (display, META_LIST_DEFAULT);
for (l = windows; l != NULL; l = l->next)
{
MetaWindow *window = (MetaWindow*)l->data;

View File

@ -253,7 +253,7 @@ meta_window_present_delete_dialog (MetaWindow *window, guint32 timestamp)
* mutter-dialog
*/
windows = meta_display_list_windows (window->display);
windows = meta_display_list_windows (window->display, META_LIST_DEFAULT);
tmp = windows;
while (tmp != NULL)
{

View File

@ -61,6 +61,10 @@ typedef void (* MetaWindowPingFunc) (MetaDisplay *display,
guint32 timestamp,
gpointer user_data);
typedef enum {
META_LIST_DEFAULT = 0, /* normal windows */
META_LIST_INCLUDE_OVERRIDE_REDIRECT = 1 << 0, /* normal and O-R */
} MetaListWindowsFlags;
#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
#define _NET_WM_STATE_ADD 1 /* add/set property */
@ -366,7 +370,8 @@ void meta_display_unregister_x_window (MetaDisplay *display,
gboolean meta_display_xwindow_is_a_no_focus_window (MetaDisplay *display,
Window xwindow);
GSList* meta_display_list_windows (MetaDisplay *display);
GSList* meta_display_list_windows (MetaDisplay *display,
MetaListWindowsFlags flags);
MetaDisplay* meta_display_for_x_display (Display *xdisplay);
MetaDisplay* meta_get_display (void);

View File

@ -812,15 +812,6 @@ meta_display_open (void)
return TRUE;
}
static void
listify_func (gpointer key, gpointer value, gpointer data)
{
GSList **listp;
listp = data;
*listp = g_slist_prepend (*listp, value);
}
static gint
ptrcmp (gconstpointer a, gconstpointer b)
{
@ -832,17 +823,38 @@ ptrcmp (gconstpointer a, gconstpointer b)
return 0;
}
/**
* meta_display_list_windows:
* @display: a #MetaDisplay
* @flags: options for listing
*
* Lists windows for the display, the @flags parameter for
* now determines whether override-redirect windows will be
* included.
*
* Return value: (transfer container): the list of windows.
*/
GSList*
meta_display_list_windows (MetaDisplay *display)
meta_display_list_windows (MetaDisplay *display,
MetaListWindowsFlags flags)
{
GSList *winlist;
GSList *tmp;
GSList *prev;
GHashTableIter iter;
gpointer key, value;
winlist = NULL;
g_hash_table_foreach (display->window_ids,
listify_func,
&winlist);
g_hash_table_iter_init (&iter, display->window_ids);
while (g_hash_table_iter_next (&iter, &key, &value))
{
MetaWindow *window = value;
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
@ -3931,7 +3943,7 @@ meta_display_queue_retheme_all_windows (MetaDisplay *display)
GSList* windows;
GSList *tmp;
windows = meta_display_list_windows (display);
windows = meta_display_list_windows (display, META_LIST_DEFAULT);
tmp = windows;
while (tmp != NULL)
{
@ -4441,7 +4453,7 @@ meta_display_get_tab_list (MetaDisplay *display,
GSList *tmp;
MetaWindow *l_window;
tmp = meta_display_list_windows (display);
tmp = meta_display_list_windows (display, META_LIST_DEFAULT);
/* Go through all windows */
while (tmp != NULL)
@ -4824,7 +4836,8 @@ meta_display_unmanage_windows_for_screen (MetaDisplay *display,
GSList *tmp;
GSList *winlist;
winlist = meta_display_list_windows (display);
winlist = meta_display_list_windows (display,
META_LIST_INCLUDE_OVERRIDE_REDIRECT);
winlist = g_slist_sort (winlist, meta_display_stack_cmp);
/* Unmanage all windows */
@ -4916,7 +4929,7 @@ prefs_changed_callback (MetaPreference pref,
GSList *windows;
GSList *tmp;
windows = meta_display_list_windows (display);
windows = meta_display_list_windows (display, META_LIST_DEFAULT);
/* Ungrab all */
tmp = windows;
@ -5018,7 +5031,7 @@ sanity_check_timestamps (MetaDisplay *display,
display->last_user_time, timestamp);
display->last_user_time = timestamp;
windows = meta_display_list_windows (display);
windows = meta_display_list_windows (display, META_LIST_DEFAULT);
tmp = windows;
while (tmp != NULL)
{

View File

@ -460,7 +460,7 @@ regrab_key_bindings (MetaDisplay *display)
tmp = tmp->next;
}
windows = meta_display_list_windows (display);
windows = meta_display_list_windows (display, META_LIST_DEFAULT);
tmp = windows;
while (tmp != NULL)
{

View File

@ -839,7 +839,7 @@ meta_window_place (MetaWindow *window,
GSList *all_windows;
GSList *tmp;
all_windows = meta_display_list_windows (window->display);
all_windows = meta_display_list_windows (window->display, META_LIST_DEFAULT);
tmp = all_windows;
while (tmp != NULL)

View File

@ -934,7 +934,8 @@ meta_screen_composite_all_windows (MetaScreen *screen)
if (!display->compositor)
return;
windows = meta_display_list_windows (display);
windows = meta_display_list_windows (display,
META_LIST_INCLUDE_OVERRIDE_REDIRECT);
for (tmp = windows; tmp != NULL; tmp = tmp->next)
meta_compositor_add_window (display->compositor, tmp->data);
g_slist_free (windows);
@ -2476,7 +2477,7 @@ queue_windows_showing (MetaScreen *screen)
* active_workspace's window list, because the active_workspace's
* window list may not contain the on_all_workspace windows.
*/
windows = meta_display_list_windows (screen->display);
windows = meta_display_list_windows (screen->display, META_LIST_DEFAULT);
tmp = windows;
while (tmp != NULL)

View File

@ -889,7 +889,7 @@ save_state (void)
fprintf (outfile, "<mutter_session id=\"%s\">\n",
client_id);
windows = meta_display_list_windows (meta_get_display ());
windows = meta_display_list_windows (meta_get_display (), META_LIST_DEFAULT);
stack_position = 0;
windows = g_slist_sort (windows, meta_display_stack_cmp);
@ -1768,7 +1768,7 @@ warn_about_lame_clients_and_finish_interact (gboolean shutdown)
GSList *tmp;
GSList *columns = NULL;
windows = meta_display_list_windows (meta_get_display ());
windows = meta_display_list_windows (meta_get_display (), META_LIST_DEFAULT);
tmp = windows;
while (tmp != NULL)
{

View File

@ -4440,7 +4440,7 @@ get_modal_transient (MetaWindow *window)
*/
modal_transient = window;
windows = meta_display_list_windows (window->display);
windows = meta_display_list_windows (window->display, META_LIST_DEFAULT);
tmp = windows;
while (tmp != NULL)
{
@ -8157,7 +8157,7 @@ meta_window_foreach_transient (MetaWindow *window,
GSList *windows;
GSList *tmp;
windows = meta_display_list_windows (window->display);
windows = meta_display_list_windows (window->display, META_LIST_DEFAULT);
tmp = windows;
while (tmp != NULL)

View File

@ -620,8 +620,14 @@ meta_workspace_update_window_hints (MetaWorkspace *workspace)
}
}
/* get windows contained on workspace, including workspace->windows
* and also sticky windows.
/**
* meta_workspace_list_windows:
* @display: a #MetaDisplay
*
* Gets windows contained on the workspace, including workspace->windows
* and also sticky windows. Override-redirect windows are not included.
*
* Return value: (transfer container): the list of windows.
*/
GList*
meta_workspace_list_windows (MetaWorkspace *workspace)
@ -630,7 +636,8 @@ meta_workspace_list_windows (MetaWorkspace *workspace)
GSList *tmp;
GList *workspace_windows;
display_windows = meta_display_list_windows (workspace->screen->display);
display_windows = meta_display_list_windows (workspace->screen->display,
META_LIST_DEFAULT);
workspace_windows = NULL;
tmp = display_windows;