clutter: Use G_DECLARE_DERIVABLE_TYPE for ClutterDeviceManager

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
This commit is contained in:
Carlos Garnacho 2019-03-26 15:38:37 +01:00 committed by Jonas Ådahl
parent 829d9c863c
commit 54101b1948
3 changed files with 32 additions and 40 deletions

View File

@ -50,7 +50,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterConstraint, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterContainer, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterContainer, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDeformEffect, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDeformEffect, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDesaturateEffect, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDesaturateEffect, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDeviceManager, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDragAction, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDragAction, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDropAction, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterDropAction, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterEffect, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterEffect, g_object_unref)

View File

@ -106,7 +106,8 @@ clutter_device_manager_set_property (GObject *gobject,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
ClutterDeviceManagerPrivate *priv = CLUTTER_DEVICE_MANAGER (gobject)->priv; ClutterDeviceManager *self = CLUTTER_DEVICE_MANAGER (gobject);
ClutterDeviceManagerPrivate *priv = clutter_device_manager_get_instance_private (self);
switch (prop_id) switch (prop_id)
{ {
@ -125,7 +126,8 @@ clutter_device_manager_get_property (GObject *gobject,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
ClutterDeviceManagerPrivate *priv = CLUTTER_DEVICE_MANAGER (gobject)->priv; ClutterDeviceManager *self = CLUTTER_DEVICE_MANAGER (gobject);
ClutterDeviceManagerPrivate *priv = clutter_device_manager_get_instance_private (self);
switch (prop_id) switch (prop_id)
{ {
@ -309,7 +311,6 @@ clutter_device_manager_class_init (ClutterDeviceManagerClass *klass)
static void static void
clutter_device_manager_init (ClutterDeviceManager *self) clutter_device_manager_init (ClutterDeviceManager *self)
{ {
self->priv = clutter_device_manager_get_instance_private (self);
} }
/** /**
@ -552,9 +553,11 @@ _clutter_device_manager_update_devices (ClutterDeviceManager *device_manager)
ClutterBackend * ClutterBackend *
_clutter_device_manager_get_backend (ClutterDeviceManager *manager) _clutter_device_manager_get_backend (ClutterDeviceManager *manager)
{ {
ClutterDeviceManagerPrivate *priv = clutter_device_manager_get_instance_private (manager);
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (manager), NULL); g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (manager), NULL);
return manager->priv->backend; return priv->backend;
} }
/** /**
@ -623,13 +626,14 @@ clutter_device_manager_set_kbd_a11y_settings (ClutterDeviceManager *device_man
ClutterKbdA11ySettings *settings) ClutterKbdA11ySettings *settings)
{ {
ClutterDeviceManagerClass *manager_class; ClutterDeviceManagerClass *manager_class;
ClutterDeviceManagerPrivate *priv = clutter_device_manager_get_instance_private (device_manager);
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager)); g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
if (are_kbd_a11y_settings_equal (&device_manager->priv->kbd_a11y_settings, settings)) if (are_kbd_a11y_settings_equal (&priv->kbd_a11y_settings, settings))
return; return;
device_manager->priv->kbd_a11y_settings = *settings; priv->kbd_a11y_settings = *settings;
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager); manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
if (manager_class->apply_kbd_a11y_settings) if (manager_class->apply_kbd_a11y_settings)
@ -640,9 +644,11 @@ void
clutter_device_manager_get_kbd_a11y_settings (ClutterDeviceManager *device_manager, clutter_device_manager_get_kbd_a11y_settings (ClutterDeviceManager *device_manager,
ClutterKbdA11ySettings *settings) ClutterKbdA11ySettings *settings)
{ {
ClutterDeviceManagerPrivate *priv = clutter_device_manager_get_instance_private (device_manager);
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager)); g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
*settings = device_manager->priv->kbd_a11y_settings; *settings = priv->kbd_a11y_settings;
} }
static gboolean static gboolean
@ -685,17 +691,20 @@ void
clutter_device_manager_set_pointer_a11y_settings (ClutterDeviceManager *device_manager, clutter_device_manager_set_pointer_a11y_settings (ClutterDeviceManager *device_manager,
ClutterPointerA11ySettings *settings) ClutterPointerA11ySettings *settings)
{ {
ClutterDeviceManagerPrivate *priv =
clutter_device_manager_get_instance_private (device_manager);
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager)); g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
if (are_pointer_a11y_settings_equal (&device_manager->priv->pointer_a11y_settings, settings)) if (are_pointer_a11y_settings_equal (&priv->pointer_a11y_settings, settings))
return; return;
if (device_manager->priv->pointer_a11y_settings.controls == 0 && settings->controls != 0) if (priv->pointer_a11y_settings.controls == 0 && settings->controls != 0)
clutter_device_manager_enable_pointer_a11y (device_manager); clutter_device_manager_enable_pointer_a11y (device_manager);
else if (device_manager->priv->pointer_a11y_settings.controls != 0 && settings->controls == 0) else if (priv->pointer_a11y_settings.controls != 0 && settings->controls == 0)
clutter_device_manager_disable_pointer_a11y (device_manager); clutter_device_manager_disable_pointer_a11y (device_manager);
device_manager->priv->pointer_a11y_settings = *settings; priv->pointer_a11y_settings = *settings;
} }
/** /**
@ -709,9 +718,12 @@ void
clutter_device_manager_get_pointer_a11y_settings (ClutterDeviceManager *device_manager, clutter_device_manager_get_pointer_a11y_settings (ClutterDeviceManager *device_manager,
ClutterPointerA11ySettings *settings) ClutterPointerA11ySettings *settings)
{ {
ClutterDeviceManagerPrivate *priv =
clutter_device_manager_get_instance_private (device_manager);
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager)); g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
*settings = device_manager->priv->pointer_a11y_settings; *settings = priv->pointer_a11y_settings;
} }
/** /**
@ -725,7 +737,10 @@ void
clutter_device_manager_set_pointer_a11y_dwell_click_type (ClutterDeviceManager *device_manager, clutter_device_manager_set_pointer_a11y_dwell_click_type (ClutterDeviceManager *device_manager,
ClutterPointerA11yDwellClickType click_type) ClutterPointerA11yDwellClickType click_type)
{ {
ClutterDeviceManagerPrivate *priv =
clutter_device_manager_get_instance_private (device_manager);
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager)); g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
device_manager->priv->pointer_a11y_settings.dwell_click_type = click_type; priv->pointer_a11y_settings.dwell_click_type = click_type;
} }

View File

@ -34,15 +34,11 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define CLUTTER_TYPE_DEVICE_MANAGER (clutter_device_manager_get_type ()) #define CLUTTER_TYPE_DEVICE_MANAGER (clutter_device_manager_get_type ())
#define CLUTTER_DEVICE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_DEVICE_MANAGER, ClutterDeviceManager)) CLUTTER_EXPORT
#define CLUTTER_IS_DEVICE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_DEVICE_MANAGER)) G_DECLARE_DERIVABLE_TYPE (ClutterDeviceManager, clutter_device_manager,
#define CLUTTER_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_DEVICE_MANAGER, ClutterDeviceManagerClass)) CLUTTER, DEVICE_MANAGER, GObject)
#define CLUTTER_IS_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_DEVICE_MANAGER))
#define CLUTTER_DEVICE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_DEVICE_MANAGER, ClutterDeviceManagerClass))
typedef struct _ClutterDeviceManager ClutterDeviceManager;
typedef struct _ClutterDeviceManagerPrivate ClutterDeviceManagerPrivate; typedef struct _ClutterDeviceManagerPrivate ClutterDeviceManagerPrivate;
typedef struct _ClutterDeviceManagerClass ClutterDeviceManagerClass;
/** /**
* ClutterVirtualDeviceType: * ClutterVirtualDeviceType:
@ -94,21 +90,6 @@ typedef struct _ClutterPointerA11ySettings
gint dwell_threshold; gint dwell_threshold;
} ClutterPointerA11ySettings; } ClutterPointerA11ySettings;
/**
* ClutterDeviceManager:
*
* The #ClutterDeviceManager structure contains only private data
*
* Since: 1.2
*/
struct _ClutterDeviceManager
{
/*< private >*/
GObject parent_instance;
ClutterDeviceManagerPrivate *priv;
};
/** /**
* ClutterDeviceManagerClass: * ClutterDeviceManagerClass:
* *
@ -146,9 +127,6 @@ struct _ClutterDeviceManagerClass
gpointer _padding[6]; gpointer _padding[6];
}; };
CLUTTER_EXPORT
GType clutter_device_manager_get_type (void) G_GNUC_CONST;
CLUTTER_EXPORT CLUTTER_EXPORT
ClutterDeviceManager *clutter_device_manager_get_default (void); ClutterDeviceManager *clutter_device_manager_get_default (void);
CLUTTER_EXPORT CLUTTER_EXPORT