focus-manager: Make groups "refcounted"
Rather than unconditionally removing a focus root in remove_group(), decrement a counter that add_group() increments, and only actually remove a focus root when the counter drops to 0. https://bugzilla.gnome.org/show_bug.cgi?id=682243
This commit is contained in:
parent
4254fa3d38
commit
94c1d5a18c
@ -180,10 +180,13 @@ void
|
|||||||
st_focus_manager_add_group (StFocusManager *manager,
|
st_focus_manager_add_group (StFocusManager *manager,
|
||||||
StWidget *root)
|
StWidget *root)
|
||||||
{
|
{
|
||||||
|
gpointer count_p = g_hash_table_lookup (manager->priv->groups, root);
|
||||||
|
int count = count_p ? GPOINTER_TO_INT (count_p) : 0;
|
||||||
|
|
||||||
g_signal_connect (root, "destroy",
|
g_signal_connect (root, "destroy",
|
||||||
G_CALLBACK (remove_destroyed_group),
|
G_CALLBACK (remove_destroyed_group),
|
||||||
manager);
|
manager);
|
||||||
g_hash_table_insert (manager->priv->groups, root, GINT_TO_POINTER (1));
|
g_hash_table_insert (manager->priv->groups, root, GINT_TO_POINTER (++count));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -197,7 +200,15 @@ void
|
|||||||
st_focus_manager_remove_group (StFocusManager *manager,
|
st_focus_manager_remove_group (StFocusManager *manager,
|
||||||
StWidget *root)
|
StWidget *root)
|
||||||
{
|
{
|
||||||
g_hash_table_remove (manager->priv->groups, root);
|
gpointer count_p = g_hash_table_lookup (manager->priv->groups, root);
|
||||||
|
int count = count_p ? GPOINTER_TO_INT (count_p) : 0;
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
return;
|
||||||
|
if (count == 1)
|
||||||
|
g_hash_table_remove (manager->priv->groups, root);
|
||||||
|
else
|
||||||
|
g_hash_table_insert (manager->priv->groups, root, GINT_TO_POINTER(--count));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user