diff --git a/ChangeLog b/ChangeLog index eb248885e..779284db7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,7 +13,9 @@ 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 + (remove_window_from_group): change cached_group to group + (meta_window_group_leader_changed): call meta_window_compute_group + instead of meta_window_get_group 2003-05-29 Rob Adams diff --git a/src/group.c b/src/group.c index ab35cd262..a1e61c2a4 100644 --- a/src/group.c +++ b/src/group.c @@ -105,67 +105,72 @@ meta_window_get_group (MetaWindow *window) { if (window->unmanaging) return NULL; + + if (window->group == NULL) + meta_window_compute_group (window); - 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 */ + + group = NULL; + + if (window->display->groups_by_leader) { - MetaGroup *group; - - /* use window->xwindow if no window->xgroup_leader */ - - group = NULL; - - if (window->display->groups_by_leader) - { - if (window->xgroup_leader != None) - group = g_hash_table_lookup (window->display->groups_by_leader, - &window->xgroup_leader); - else - group = g_hash_table_lookup (window->display->groups_by_leader, - &window->xwindow); - } - - if (group != NULL) - { - window->cached_group = group; - group->refcount += 1; - } + if (window->xgroup_leader != None) + group = g_hash_table_lookup (window->display->groups_by_leader, + &window->xgroup_leader); else - { - if (window->xgroup_leader != None) - group = meta_group_new (window->display, - window->xgroup_leader); - else - group = meta_group_new (window->display, - window->xwindow); + group = g_hash_table_lookup (window->display->groups_by_leader, + &window->xwindow); + } + + if (group != NULL) + { + window->group = group; + group->refcount += 1; + } + else + { + if (window->xgroup_leader != None) + group = meta_group_new (window->display, + window->xgroup_leader); + else + group = meta_group_new (window->display, + window->xwindow); - window->cached_group = group; - } - - window->cached_group->windows = g_slist_prepend (window->cached_group->windows, - window); - - meta_topic (META_DEBUG_GROUPS, - "Adding %s to group with leader 0x%lx\n", - window->desc, group->group_leader); + window->group = group; } - return window->cached_group; + 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); + } 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; } } @@ -173,7 +178,7 @@ void meta_window_group_leader_changed (MetaWindow *window) { remove_window_from_group (window); - meta_window_get_group (window); + meta_window_compute_group (window); } void @@ -255,4 +260,5 @@ meta_group_property_notify (MetaGroup *group, event->xproperty.atom); return TRUE; + } diff --git a/src/group.h b/src/group.h index 6639839a9..3f1425b5b 100644 --- a/src/group.h +++ b/src/group.h @@ -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); diff --git a/src/window.c b/src/window.c index 7b65e95eb..76e66ea30 100644 --- a/src/window.c +++ b/src/window.c @@ -347,6 +347,10 @@ meta_window_new (MetaDisplay *display, window->display = display; window->workspaces = NULL; + /* assign the window to its group, or create a new group if needed + */ + meta_window_compute_group (window); + #ifdef HAVE_XSYNC window->update_counter = None; #endif @@ -490,7 +494,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; @@ -536,7 +540,7 @@ meta_window_new (MetaDisplay *display, update_role (window); update_net_wm_type (window); meta_window_update_icon_now (window); - + if (window->initially_iconic) { /* WM_HINTS said minimized */ diff --git a/src/window.h b/src/window.h index 2c331d847..2b6a8fa0c 100644 --- a/src/window.h +++ b/src/window.h @@ -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)