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 0091a3aab5
commit ace0521cba
4 changed files with 63 additions and 12 deletions

View File

@ -367,6 +367,7 @@ gboolean meta_display_xwindow_is_a_no_focus_window (MetaDisplay *display,
Window xwindow); Window xwindow);
GSList* meta_display_list_windows (MetaDisplay *display); GSList* meta_display_list_windows (MetaDisplay *display);
GSList* meta_display_list_all_windows (MetaDisplay *display);
MetaDisplay* meta_display_for_x_display (Display *xdisplay); MetaDisplay* meta_display_for_x_display (Display *xdisplay);
MetaDisplay* meta_get_display (void); MetaDisplay* meta_get_display (void);

View File

@ -812,13 +812,19 @@ meta_display_open (void)
return TRUE; return TRUE;
} }
typedef struct {
GSList *winlist;
gboolean include_override_redirect;
} ListifyClosure;
static void static void
listify_func (gpointer key, gpointer value, gpointer data) listify_func (gpointer key, gpointer value, gpointer data)
{ {
GSList **listp; ListifyClosure *closure = data;
MetaWindow *window = value;
listp = data; if (closure->include_override_redirect || !window->override_redirect)
*listp = g_slist_prepend (*listp, value); closure->winlist = g_slist_prepend (closure->winlist, window);
} }
static gint static gint
@ -832,17 +838,21 @@ ptrcmp (gconstpointer a, gconstpointer b)
return 0; return 0;
} }
GSList* static GSList*
meta_display_list_windows (MetaDisplay *display) list_windows (MetaDisplay *display,
gboolean include_override_redirect)
{ {
ListifyClosure closure;
GSList *winlist; GSList *winlist;
GSList *tmp; GSList *tmp;
GSList *prev; GSList *prev;
winlist = NULL; closure.winlist = NULL;
closure.include_override_redirect = include_override_redirect;
g_hash_table_foreach (display->window_ids, g_hash_table_foreach (display->window_ids,
listify_func, listify_func,
&winlist); &closure);
winlist = closure.winlist;
/* Uniquify the list, since both frame windows and plain /* Uniquify the list, since both frame windows and plain
* windows are in the hash * windows are in the hash
@ -883,6 +893,40 @@ meta_display_list_windows (MetaDisplay *display)
return winlist; return winlist;
} }
/**
* meta_display_list_windows:
* @display: a #MetaDisplay
*
* Lists windows for the display, excluding override-redirect
* windows.
*
* Return value: (transfer container): the list of windows.
*/
GSList*
meta_display_list_windows (MetaDisplay *display)
{
return list_windows (display, FALSE);
}
/**
* meta_display_list_all_windows:
* @display: a #MetaDisplay
*
* Lists windows for the display, including override-redirect
* windows. You usually want to use meta_display_list_windows()
* instead, since override-redirect windows are by definition
* outside the scope of window management. This function is most
* useful if you are interested in how things are displayed on
* the screen.
*
* Return value: (transfer container): the list of windows.
*/
GSList*
meta_display_list_all_windows (MetaDisplay *display)
{
return list_windows (display, TRUE);
}
void void
meta_display_close (MetaDisplay *display, meta_display_close (MetaDisplay *display,
guint32 timestamp) guint32 timestamp)
@ -4824,7 +4868,7 @@ meta_display_unmanage_windows_for_screen (MetaDisplay *display,
GSList *tmp; GSList *tmp;
GSList *winlist; GSList *winlist;
winlist = meta_display_list_windows (display); winlist = meta_display_list_all_windows (display);
winlist = g_slist_sort (winlist, meta_display_stack_cmp); winlist = g_slist_sort (winlist, meta_display_stack_cmp);
/* Unmanage all windows */ /* Unmanage all windows */

View File

@ -934,7 +934,7 @@ meta_screen_composite_all_windows (MetaScreen *screen)
if (!display->compositor) if (!display->compositor)
return; return;
windows = meta_display_list_windows (display); windows = meta_display_list_all_windows (display);
for (tmp = windows; tmp != NULL; tmp = tmp->next) for (tmp = windows; tmp != NULL; tmp = tmp->next)
meta_compositor_add_window (display->compositor, tmp->data); meta_compositor_add_window (display->compositor, tmp->data);
g_slist_free (windows); g_slist_free (windows);

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_display_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* GList*
meta_workspace_list_windows (MetaWorkspace *workspace) meta_workspace_list_windows (MetaWorkspace *workspace)