[mutter/wip/carlosg/input-in-backends: 32/48] clutter: Use G_DECLARE_DERIVABLE_TYPE for ClutterDeviceManager



commit 54101b1948472096cabdfbff7df9cc3cac89338b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 26 15:38:37 2019 +0100

    clutter: Use G_DECLARE_DERIVABLE_TYPE for ClutterDeviceManager
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/672

 clutter/clutter/clutter-autocleanups.h   |  1 -
 clutter/clutter/clutter-device-manager.c | 41 ++++++++++++++++++++++----------
 clutter/clutter/clutter-device-manager.h | 32 ++++---------------------
 3 files changed, 33 insertions(+), 41 deletions(-)
---
diff --git a/clutter/clutter/clutter-autocleanups.h b/clutter/clutter/clutter-autocleanups.h
index dfb371541..0a68c0505 100644
--- a/clutter/clutter/clutter-autocleanups.h
+++ b/clutter/clutter/clutter-autocleanups.h
@@ -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 (ClutterDeformEffect, 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 (ClutterDropAction, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterEffect, g_object_unref)
diff --git a/clutter/clutter/clutter-device-manager.c b/clutter/clutter/clutter-device-manager.c
index 39dcf2bce..b2e73772f 100644
--- a/clutter/clutter/clutter-device-manager.c
+++ b/clutter/clutter/clutter-device-manager.c
@@ -106,7 +106,8 @@ clutter_device_manager_set_property (GObject      *gobject,
                                      const GValue *value,
                                      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)
     {
@@ -125,7 +126,8 @@ clutter_device_manager_get_property (GObject    *gobject,
                                      GValue     *value,
                                      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)
     {
@@ -309,7 +311,6 @@ clutter_device_manager_class_init (ClutterDeviceManagerClass *klass)
 static void
 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 *
 _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);
 
-  return manager->priv->backend;
+  return priv->backend;
 }
 
 /**
@@ -623,13 +626,14 @@ clutter_device_manager_set_kbd_a11y_settings (ClutterDeviceManager   *device_man
                                               ClutterKbdA11ySettings *settings)
 {
   ClutterDeviceManagerClass *manager_class;
+  ClutterDeviceManagerPrivate *priv = clutter_device_manager_get_instance_private (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;
 
-  device_manager->priv->kbd_a11y_settings = *settings;
+  priv->kbd_a11y_settings = *settings;
 
   manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
   if (manager_class->apply_kbd_a11y_settings)
@@ -640,9 +644,11 @@ void
 clutter_device_manager_get_kbd_a11y_settings (ClutterDeviceManager   *device_manager,
                                               ClutterKbdA11ySettings *settings)
 {
+  ClutterDeviceManagerPrivate *priv = clutter_device_manager_get_instance_private (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
@@ -685,17 +691,20 @@ void
 clutter_device_manager_set_pointer_a11y_settings (ClutterDeviceManager       *device_manager,
                                                   ClutterPointerA11ySettings *settings)
 {
+  ClutterDeviceManagerPrivate *priv =
+    clutter_device_manager_get_instance_private (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;
 
-  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);
-  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);
 
-  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,
                                                   ClutterPointerA11ySettings *settings)
 {
+  ClutterDeviceManagerPrivate *priv =
+    clutter_device_manager_get_instance_private (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,
                                                           ClutterPointerA11yDwellClickType  click_type)
 {
+  ClutterDeviceManagerPrivate *priv =
+    clutter_device_manager_get_instance_private (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;
 }
diff --git a/clutter/clutter/clutter-device-manager.h b/clutter/clutter/clutter-device-manager.h
index 5fbd3952b..2927f1296 100644
--- a/clutter/clutter/clutter-device-manager.h
+++ b/clutter/clutter/clutter-device-manager.h
@@ -33,16 +33,12 @@
 
 G_BEGIN_DECLS
 
-#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))
-#define CLUTTER_IS_DEVICE_MANAGER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
CLUTTER_TYPE_DEVICE_MANAGER))
-#define CLUTTER_DEVICE_MANAGER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), 
CLUTTER_TYPE_DEVICE_MANAGER, ClutterDeviceManagerClass))
-#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;
+#define CLUTTER_TYPE_DEVICE_MANAGER (clutter_device_manager_get_type ())
+CLUTTER_EXPORT
+G_DECLARE_DERIVABLE_TYPE (ClutterDeviceManager, clutter_device_manager,
+                          CLUTTER, DEVICE_MANAGER, GObject)
+
 typedef struct _ClutterDeviceManagerPrivate     ClutterDeviceManagerPrivate;
-typedef struct _ClutterDeviceManagerClass       ClutterDeviceManagerClass;
 
 /**
  * ClutterVirtualDeviceType:
@@ -94,21 +90,6 @@ typedef struct _ClutterPointerA11ySettings
   gint dwell_threshold;
 } ClutterPointerA11ySettings;
 
-/**
- * ClutterDeviceManager:
- *
- * The #ClutterDeviceManager structure contains only private data
- *
- * Since: 1.2
- */
-struct _ClutterDeviceManager
-{
-  /*< private >*/
-  GObject parent_instance;
-
-  ClutterDeviceManagerPrivate *priv;
-};
-
 /**
  * ClutterDeviceManagerClass:
  *
@@ -146,9 +127,6 @@ struct _ClutterDeviceManagerClass
   gpointer _padding[6];
 };
 
-CLUTTER_EXPORT
-GType clutter_device_manager_get_type (void) G_GNUC_CONST;
-
 CLUTTER_EXPORT
 ClutterDeviceManager *clutter_device_manager_get_default     (void);
 CLUTTER_EXPORT


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]