Precompute groups to guarantee that meta_group_list_windows always returns

2003-06-04  Rob Adams  <robadams@ucla.edu>

	Precompute groups to guarantee that meta_group_list_windows always
	returns the correct list of windows.  See Bug #96973

	* src/window.h: change cached_group variable to group

	* src/window.c (meta_window_new): change cached_group to group and
	call meta_window_compute_group

	* src/groups.c (meta_window_get_group): simply return
	window->group rather than computing it and returning
	window->cached_group
	(meta_window_compute_group): new function computes window->group.
	Designed to be called once from meta_window_new
	(remove_window_from_group): change cached_group to group
This commit is contained in:
Rob Adams 2003-06-04 16:45:47 +00:00 committed by Rob Adams
parent f87a8c212f
commit bf965f8465
5 changed files with 73 additions and 47 deletions

View File

@ -1,3 +1,20 @@
2003-06-04 Rob Adams <robadams@ucla.edu>
Precompute groups to guarantee that meta_group_list_windows always
returns the correct list of windows. See Bug #96973
* src/window.h: change cached_group variable to group
* src/window.c (meta_window_new): change cached_group to group and
call meta_window_compute_group
* src/groups.c (meta_window_get_group): simply return
window->group rather than computing it and returning
window->cached_group
(meta_window_compute_group): new function computes window->group.
Designed to be called once from meta_window_new
(remove_window_from_group): change cached_group to group
2003-05-29 Rob Adams <robadams@ucla.edu>
Use a new property _METACITY_SENTINEL to eliminate a race

View File

@ -103,11 +103,17 @@ meta_group_unref (MetaGroup *group)
MetaGroup*
meta_window_get_group (MetaWindow *window)
{
g_assert (window->group != NULL);
if (window->unmanaging)
return NULL;
if (window->cached_group == NULL)
{
return window->group;
}
void
meta_window_compute_group (MetaWindow* window)
{
MetaGroup *group;
/* use window->xwindow if no window->xgroup_leader */
@ -126,7 +132,7 @@ meta_window_get_group (MetaWindow *window)
if (group != NULL)
{
window->cached_group = group;
window->group = group;
group->refcount += 1;
}
else
@ -138,34 +144,32 @@ meta_window_get_group (MetaWindow *window)
group = meta_group_new (window->display,
window->xwindow);
window->cached_group = group;
window->group = group;
}
window->cached_group->windows = g_slist_prepend (window->cached_group->windows,
window->group->windows = g_slist_prepend (window->group->windows,
window);
meta_topic (META_DEBUG_GROUPS,
"Adding %s to group with leader 0x%lx\n",
window->desc, group->group_leader);
}
return window->cached_group;
}
static void
remove_window_from_group (MetaWindow *window)
{
if (window->cached_group != NULL)
if (window->group != NULL)
{
meta_topic (META_DEBUG_GROUPS,
"Removing %s from group with leader 0x%lx\n",
window->desc, window->cached_group->group_leader);
window->desc, window->group->group_leader);
window->cached_group->windows =
g_slist_remove (window->cached_group->windows,
window->group->windows =
g_slist_remove (window->group->windows,
window);
meta_group_unref (window->cached_group);
window->cached_group = NULL;
meta_group_unref (window->group);
window->group = NULL;
}
}

View File

@ -26,6 +26,7 @@
/* note, can return NULL */
MetaGroup* meta_window_get_group (MetaWindow *window);
void meta_window_compute_group (MetaWindow* window);
void meta_window_shutdown_group (MetaWindow *window);
void meta_window_group_leader_changed (MetaWindow *window);

View File

@ -490,7 +490,7 @@ meta_window_new (MetaDisplay *display,
window->top_strut = 0;
window->bottom_strut = 0;
window->cached_group = NULL;
window->group = NULL;
window->using_net_wm_name = FALSE;
window->using_net_wm_icon_name = FALSE;
@ -692,6 +692,10 @@ meta_window_new (MetaDisplay *display,
}
}
/* assign the window to its group, or create a new group if needed
*/
meta_window_compute_group (window);
/* Maximize windows if they are too big for their work
* area (bit of a hack here). Assume undecorated windows
* probably don't intend to be maximized.

View File

@ -284,7 +284,7 @@ struct _MetaWindow
int dialog_pipe;
/* maintained by group.c */
MetaGroup *cached_group;
MetaGroup *group;
};
#define META_WINDOW_ALLOWS_MOVE(w) ((w)->has_move_func && !(w)->maximized && !(w)->fullscreen)