st/focus-manager: Mark as final type
Nothing can derive this type. Also squeeze in a macro usage for cleanup Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3508>
This commit is contained in:
parent
7aee2ca854
commit
31119228a8
@ -31,24 +31,22 @@
|
|||||||
|
|
||||||
#include "st-focus-manager.h"
|
#include "st-focus-manager.h"
|
||||||
|
|
||||||
struct _StFocusManagerPrivate
|
typedef struct _StFocusManager
|
||||||
{
|
{
|
||||||
|
GObject parent;
|
||||||
|
|
||||||
ClutterStage *stage;
|
ClutterStage *stage;
|
||||||
GHashTable *groups;
|
GHashTable *groups;
|
||||||
};
|
} StFocusManager;
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (StFocusManager, st_focus_manager, G_TYPE_OBJECT)
|
G_DEFINE_FINAL_TYPE (StFocusManager, st_focus_manager, G_TYPE_OBJECT)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
st_focus_manager_dispose (GObject *object)
|
st_focus_manager_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
StFocusManager *manager = ST_FOCUS_MANAGER (object);
|
StFocusManager *manager = ST_FOCUS_MANAGER (object);
|
||||||
|
|
||||||
if (manager->priv->groups)
|
g_clear_pointer (&manager->groups, g_hash_table_destroy);
|
||||||
{
|
|
||||||
g_hash_table_destroy (manager->priv->groups);
|
|
||||||
manager->priv->groups = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (st_focus_manager_parent_class)->dispose (object);
|
G_OBJECT_CLASS (st_focus_manager_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
@ -64,8 +62,7 @@ st_focus_manager_class_init (StFocusManagerClass *klass)
|
|||||||
static void
|
static void
|
||||||
st_focus_manager_init (StFocusManager *manager)
|
st_focus_manager_init (StFocusManager *manager)
|
||||||
{
|
{
|
||||||
manager->priv = st_focus_manager_get_instance_private (manager);
|
manager->groups = g_hash_table_new (NULL, NULL);
|
||||||
manager->priv->groups = g_hash_table_new (NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -117,7 +114,7 @@ st_focus_manager_stage_event (ClutterActor *stage,
|
|||||||
|
|
||||||
for (group = focused; group != stage; group = clutter_actor_get_parent (group))
|
for (group = focused; group != stage; group = clutter_actor_get_parent (group))
|
||||||
{
|
{
|
||||||
if (g_hash_table_lookup (manager->priv->groups, group))
|
if (g_hash_table_lookup (manager->groups, group))
|
||||||
{
|
{
|
||||||
return st_widget_navigate_focus (ST_WIDGET (group), focused,
|
return st_widget_navigate_focus (ST_WIDGET (group), focused,
|
||||||
direction, wrap_around);
|
direction, wrap_around);
|
||||||
@ -143,7 +140,7 @@ st_focus_manager_get_for_stage (ClutterStage *stage)
|
|||||||
if (!manager)
|
if (!manager)
|
||||||
{
|
{
|
||||||
manager = g_object_new (ST_TYPE_FOCUS_MANAGER, NULL);
|
manager = g_object_new (ST_TYPE_FOCUS_MANAGER, NULL);
|
||||||
manager->priv->stage = stage;
|
manager->stage = stage;
|
||||||
g_object_set_data_full (G_OBJECT (stage), "st-focus-manager",
|
g_object_set_data_full (G_OBJECT (stage), "st-focus-manager",
|
||||||
manager, g_object_unref);
|
manager, g_object_unref);
|
||||||
|
|
||||||
@ -176,13 +173,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);
|
gpointer count_p = g_hash_table_lookup (manager->groups, root);
|
||||||
int count = count_p ? GPOINTER_TO_INT (count_p) : 0;
|
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 (++count));
|
g_hash_table_insert (manager->groups, root, GINT_TO_POINTER (++count));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,15 +193,15 @@ void
|
|||||||
st_focus_manager_remove_group (StFocusManager *manager,
|
st_focus_manager_remove_group (StFocusManager *manager,
|
||||||
StWidget *root)
|
StWidget *root)
|
||||||
{
|
{
|
||||||
gpointer count_p = g_hash_table_lookup (manager->priv->groups, root);
|
gpointer count_p = g_hash_table_lookup (manager->groups, root);
|
||||||
int count = count_p ? GPOINTER_TO_INT (count_p) : 0;
|
int count = count_p ? GPOINTER_TO_INT (count_p) : 0;
|
||||||
|
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
g_hash_table_remove (manager->priv->groups, root);
|
g_hash_table_remove (manager->groups, root);
|
||||||
else
|
else
|
||||||
g_hash_table_insert (manager->priv->groups, root, GINT_TO_POINTER(--count));
|
g_hash_table_insert (manager->groups, root, GINT_TO_POINTER(--count));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -224,7 +221,7 @@ st_focus_manager_get_group (StFocusManager *manager,
|
|||||||
{
|
{
|
||||||
ClutterActor *actor = CLUTTER_ACTOR (widget);
|
ClutterActor *actor = CLUTTER_ACTOR (widget);
|
||||||
|
|
||||||
while (actor && !g_hash_table_lookup (manager->priv->groups, actor))
|
while (actor && !g_hash_table_lookup (manager->groups, actor))
|
||||||
actor = clutter_actor_get_parent (actor);
|
actor = clutter_actor_get_parent (actor);
|
||||||
|
|
||||||
return ST_WIDGET (actor);
|
return ST_WIDGET (actor);
|
||||||
@ -249,6 +246,6 @@ st_focus_manager_navigate_from_event (StFocusManager *manager,
|
|||||||
if (clutter_event_type (event) != CLUTTER_KEY_PRESS)
|
if (clutter_event_type (event) != CLUTTER_KEY_PRESS)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return st_focus_manager_stage_event (CLUTTER_ACTOR (manager->priv->stage),
|
return st_focus_manager_stage_event (CLUTTER_ACTOR (manager->stage),
|
||||||
event, manager);
|
event, manager);
|
||||||
}
|
}
|
||||||
|
@ -33,20 +33,6 @@ G_BEGIN_DECLS
|
|||||||
G_DECLARE_FINAL_TYPE (StFocusManager, st_focus_manager, ST, FOCUS_MANAGER, GObject)
|
G_DECLARE_FINAL_TYPE (StFocusManager, st_focus_manager, ST, FOCUS_MANAGER, GObject)
|
||||||
|
|
||||||
typedef struct _StFocusManager StFocusManager;
|
typedef struct _StFocusManager StFocusManager;
|
||||||
typedef struct _StFocusManagerPrivate StFocusManagerPrivate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* StFocusManager:
|
|
||||||
*
|
|
||||||
* The #StFocusManager struct contains only private data
|
|
||||||
*/
|
|
||||||
struct _StFocusManager
|
|
||||||
{
|
|
||||||
/*< private >*/
|
|
||||||
GObject parent_instance;
|
|
||||||
|
|
||||||
StFocusManagerPrivate *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
StFocusManager *st_focus_manager_get_for_stage (ClutterStage *stage);
|
StFocusManager *st_focus_manager_get_for_stage (ClutterStage *stage);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user