clutter/context: Create a StageManager when constructed
Instead of delegating that to StageManager.get_default and add a private getter for it. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
This commit is contained in:
parent
914787294f
commit
0d93f805d4
9 changed files with 27 additions and 32 deletions
|
@ -38,8 +38,10 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "clutter/clutter-accessibility-private.h"
|
||||
#include "clutter/clutter-context-private.h"
|
||||
#include "clutter/clutter-stage-manager-accessible-private.h"
|
||||
#include "clutter/clutter.h"
|
||||
#include "clutter/clutter-private.h"
|
||||
|
||||
#define DEFAULT_PASSWORD_CHAR '*'
|
||||
|
||||
|
@ -76,8 +78,12 @@ clutter_accessibility_init (ClutterAccessibility *accessibility)
|
|||
static AtkObject*
|
||||
clutter_accessibility_get_root (void)
|
||||
{
|
||||
ClutterContext *context = _clutter_context_get_default ();
|
||||
ClutterStageManager *stage_manager =
|
||||
clutter_context_get_stage_manager (context);
|
||||
|
||||
if (!root)
|
||||
root = clutter_stage_manager_accessible_new ();
|
||||
root = clutter_stage_manager_accessible_new (stage_manager);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "clutter/clutter-context.h"
|
||||
#include "clutter-stage-manager-private.h"
|
||||
|
||||
struct _ClutterContext
|
||||
{
|
||||
|
@ -45,3 +46,5 @@ struct _ClutterContext
|
|||
|
||||
gboolean show_fps;
|
||||
};
|
||||
|
||||
ClutterStageManager * clutter_context_get_stage_manager (ClutterContext *context);
|
||||
|
|
|
@ -276,6 +276,8 @@ clutter_context_new (ClutterBackendConstructor backend_constructor,
|
|||
_clutter_settings_set_backend (context->settings,
|
||||
context->backend);
|
||||
|
||||
context->stage_manager = g_object_new (CLUTTER_TYPE_STAGE_MANAGER, NULL);
|
||||
|
||||
context->events_queue =
|
||||
g_async_queue_new_full ((GDestroyNotify) clutter_event_free);
|
||||
context->last_repaint_id = 1;
|
||||
|
@ -370,3 +372,9 @@ clutter_get_accessibility_enabled (void)
|
|||
{
|
||||
return clutter_enable_accessibility;
|
||||
}
|
||||
|
||||
ClutterStageManager *
|
||||
clutter_context_get_stage_manager (ClutterContext *context)
|
||||
{
|
||||
return context->stage_manager;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "clutter-backend.h"
|
||||
#include "clutter-stage-manager-private.h"
|
||||
#include "clutter-settings.h"
|
||||
#include "cogl-pango/cogl-pango.h"
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <atk/atk.h>
|
||||
|
||||
#include "clutter/clutter-macros.h"
|
||||
#include "clutter/clutter-stage-manager-private.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -34,6 +35,6 @@ G_DECLARE_FINAL_TYPE (ClutterStageManagerAccessible,
|
|||
STAGE_MANAGER_ACCESSIBLE,
|
||||
AtkGObjectAccessible)
|
||||
|
||||
AtkObject * clutter_stage_manager_accessible_new (void);
|
||||
AtkObject * clutter_stage_manager_accessible_new (ClutterStageManager *stage_manager);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
#include "clutter/clutter-actor.h"
|
||||
#include "clutter/clutter-stage-private.h"
|
||||
#include "clutter/clutter-stage-manager-private.h"
|
||||
|
||||
struct _ClutterStageManagerAccessible {
|
||||
AtkGObjectAccessible parent;
|
||||
|
@ -59,16 +58,14 @@ clutter_stage_manager_accessible_init (ClutterStageManagerAccessible *manager_ac
|
|||
* Return value: the newly created #AtkObject
|
||||
*/
|
||||
AtkObject*
|
||||
clutter_stage_manager_accessible_new (void)
|
||||
clutter_stage_manager_accessible_new (ClutterStageManager *stage_manager)
|
||||
{
|
||||
GObject *object = NULL;
|
||||
AtkObject *accessible = NULL;
|
||||
ClutterStageManager *stage_manager = NULL;
|
||||
|
||||
object = g_object_new (CLUTTER_TYPE_STAGE_MANAGER_ACCESSIBLE, NULL);
|
||||
|
||||
accessible = ATK_OBJECT (object);
|
||||
stage_manager = clutter_stage_manager_get_default ();
|
||||
|
||||
atk_object_initialize (accessible, stage_manager);
|
||||
|
||||
|
|
|
@ -36,8 +36,6 @@ G_DECLARE_FINAL_TYPE (ClutterStageManager,
|
|||
STAGE_MANAGER,
|
||||
GObject)
|
||||
|
||||
ClutterStageManager * clutter_stage_manager_get_default (void);
|
||||
|
||||
const GSList * clutter_stage_manager_peek_stages (ClutterStageManager *stage_manager);
|
||||
|
||||
void _clutter_stage_manager_add_stage (ClutterStageManager *stage_manager,
|
||||
|
|
|
@ -80,25 +80,6 @@ clutter_stage_manager_init (ClutterStageManager *stage_manager)
|
|||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_stage_manager_get_default:
|
||||
*
|
||||
* Returns the default #ClutterStageManager.
|
||||
*
|
||||
* Return value: (transfer none): the default stage manager instance. The returned
|
||||
* object is owned by Clutter and you should not reference or unreference it.
|
||||
*/
|
||||
ClutterStageManager *
|
||||
clutter_stage_manager_get_default (void)
|
||||
{
|
||||
ClutterContext *context = _clutter_context_get_default ();
|
||||
|
||||
if (G_UNLIKELY (context->stage_manager == NULL))
|
||||
context->stage_manager = g_object_new (CLUTTER_TYPE_STAGE_MANAGER, NULL);
|
||||
|
||||
return context->stage_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_stage_manager_peek_stages:
|
||||
* @stage_manager: a #ClutterStageManager
|
||||
|
|
|
@ -1147,9 +1147,9 @@ static void
|
|||
clutter_stage_constructed (GObject *gobject)
|
||||
{
|
||||
ClutterStage *self = CLUTTER_STAGE (gobject);
|
||||
ClutterStageManager *stage_manager;
|
||||
|
||||
stage_manager = clutter_stage_manager_get_default ();
|
||||
ClutterContext *context = _clutter_context_get_default ();
|
||||
ClutterStageManager *stage_manager =
|
||||
clutter_context_get_stage_manager (context);
|
||||
|
||||
/* this will take care to sinking the floating reference */
|
||||
_clutter_stage_manager_add_stage (stage_manager, self);
|
||||
|
@ -1220,6 +1220,7 @@ clutter_stage_dispose (GObject *object)
|
|||
{
|
||||
ClutterStage *stage = CLUTTER_STAGE (object);
|
||||
ClutterStagePrivate *priv = clutter_stage_get_instance_private (stage);
|
||||
ClutterContext *context;
|
||||
ClutterStageManager *stage_manager;
|
||||
|
||||
clutter_actor_hide (CLUTTER_ACTOR (object));
|
||||
|
@ -1244,7 +1245,8 @@ clutter_stage_dispose (GObject *object)
|
|||
priv->pending_relayouts = NULL;
|
||||
|
||||
/* this will release the reference on the stage */
|
||||
stage_manager = clutter_stage_manager_get_default ();
|
||||
context = _clutter_context_get_default ();
|
||||
stage_manager = clutter_context_get_stage_manager (context);
|
||||
_clutter_stage_manager_remove_stage (stage_manager, stage);
|
||||
|
||||
g_hash_table_remove_all (priv->pointer_devices);
|
||||
|
|
Loading…
Reference in a new issue