[mutter/wip/nielsdg/use-g-declare-interface: 153/156] clutter: StageWindow: Use G_DECLARE_INTERFACE()



commit 3efd4d9b0321b4247dfa413d960f316e4925f95d
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Tue Jan 8 13:51:47 2019 +0100

    clutter: StageWindow: Use G_DECLARE_INTERFACE()
    
    It cuts away a bit of the GObject boilerplate, gives us support for
    `g_autoptr`, and removes the typedef hack inside clutter-stage-window.c.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/380

 clutter/clutter/clutter-stage-window.c    | 38 ++++++++++++++-----------------
 clutter/clutter/clutter-stage-window.h    | 26 +++++----------------
 clutter/clutter/clutter-stage.c           |  8 +++----
 clutter/clutter/cogl/clutter-stage-cogl.c |  5 ++--
 clutter/clutter/x11/clutter-stage-x11.c   | 10 ++++----
 src/backends/native/meta-stage-native.c   |  4 ++--
 src/backends/x11/meta-stage-x11-nested.c  |  6 ++---
 7 files changed, 41 insertions(+), 56 deletions(-)
---
diff --git a/clutter/clutter/clutter-stage-window.c b/clutter/clutter/clutter-stage-window.c
index 1786c7842..e8fa976a7 100644
--- a/clutter/clutter/clutter-stage-window.c
+++ b/clutter/clutter/clutter-stage-window.c
@@ -14,10 +14,6 @@
  * #ClutterStage actor, abstracting away the specifics of the windowing system.
  */
 
-#define clutter_stage_window_get_type   _clutter_stage_window_get_type
-
-typedef ClutterStageWindowIface ClutterStageWindowInterface;
-
 G_DEFINE_INTERFACE (ClutterStageWindow, clutter_stage_window, G_TYPE_OBJECT);
 
 static void
@@ -60,7 +56,7 @@ void
 _clutter_stage_window_set_title (ClutterStageWindow *window,
                                  const gchar        *title)
 {
-  ClutterStageWindowIface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
+  ClutterStageWindowInterface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
 
   if (iface->set_title)
     iface->set_title (window, title);
@@ -70,7 +66,7 @@ void
 _clutter_stage_window_set_fullscreen (ClutterStageWindow *window,
                                       gboolean            is_fullscreen)
 {
-  ClutterStageWindowIface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
+  ClutterStageWindowInterface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
 
   if (iface->set_fullscreen)
     iface->set_fullscreen (window, is_fullscreen);
@@ -80,7 +76,7 @@ void
 _clutter_stage_window_set_cursor_visible (ClutterStageWindow *window,
                                           gboolean            is_visible)
 {
-  ClutterStageWindowIface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
+  ClutterStageWindowInterface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
 
   if (iface->set_cursor_visible)
     iface->set_cursor_visible (window, is_visible);
@@ -138,7 +134,7 @@ void
 _clutter_stage_window_schedule_update  (ClutterStageWindow *window,
                                         int                 sync_delay)
 {
-  ClutterStageWindowIface *iface;
+  ClutterStageWindowInterface *iface;
 
   g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
 
@@ -163,7 +159,7 @@ _clutter_stage_window_schedule_update  (ClutterStageWindow *window,
 gint64
 _clutter_stage_window_get_update_time (ClutterStageWindow *window)
 {
-  ClutterStageWindowIface *iface;
+  ClutterStageWindowInterface *iface;
 
   g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), 0);
 
@@ -186,7 +182,7 @@ _clutter_stage_window_get_update_time (ClutterStageWindow *window)
 void
 _clutter_stage_window_clear_update_time (ClutterStageWindow *window)
 {
-  ClutterStageWindowIface *iface;
+  ClutterStageWindowInterface *iface;
 
   g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
 
@@ -204,7 +200,7 @@ void
 _clutter_stage_window_add_redraw_clip (ClutterStageWindow    *window,
                                        cairo_rectangle_int_t *stage_clip)
 {
-  ClutterStageWindowIface *iface;
+  ClutterStageWindowInterface *iface;
 
   g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
 
@@ -224,7 +220,7 @@ _clutter_stage_window_add_redraw_clip (ClutterStageWindow    *window,
 gboolean
 _clutter_stage_window_has_redraw_clips (ClutterStageWindow *window)
 {
-  ClutterStageWindowIface *iface;
+  ClutterStageWindowInterface *iface;
 
   g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
 
@@ -246,7 +242,7 @@ _clutter_stage_window_has_redraw_clips (ClutterStageWindow *window)
 gboolean
 _clutter_stage_window_ignoring_redraw_clips (ClutterStageWindow *window)
 {
-  ClutterStageWindowIface *iface;
+  ClutterStageWindowInterface *iface;
 
   g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
 
@@ -261,7 +257,7 @@ gboolean
 _clutter_stage_window_get_redraw_clip_bounds (ClutterStageWindow    *window,
                                               cairo_rectangle_int_t *stage_clip)
 {
-  ClutterStageWindowIface *iface;
+  ClutterStageWindowInterface *iface;
 
   g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
 
@@ -276,7 +272,7 @@ void
 _clutter_stage_window_set_accept_focus (ClutterStageWindow *window,
                                         gboolean            accept_focus)
 {
-  ClutterStageWindowIface *iface;
+  ClutterStageWindowInterface *iface;
 
   g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
 
@@ -288,7 +284,7 @@ _clutter_stage_window_set_accept_focus (ClutterStageWindow *window,
 void
 _clutter_stage_window_redraw (ClutterStageWindow *window)
 {
-  ClutterStageWindowIface *iface;
+  ClutterStageWindowInterface *iface;
 
   g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
 
@@ -303,7 +299,7 @@ _clutter_stage_window_get_dirty_pixel (ClutterStageWindow *window,
                                        ClutterStageView   *view,
                                        int *x, int *y)
 {
-  ClutterStageWindowIface *iface;
+  ClutterStageWindowInterface *iface;
 
   *x = 0;
   *y = 0;
@@ -318,7 +314,7 @@ _clutter_stage_window_get_dirty_pixel (ClutterStageWindow *window,
 gboolean
 _clutter_stage_window_can_clip_redraws (ClutterStageWindow *window)
 {
-  ClutterStageWindowIface *iface;
+  ClutterStageWindowInterface *iface;
 
   g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
 
@@ -332,7 +328,7 @@ _clutter_stage_window_can_clip_redraws (ClutterStageWindow *window)
 GList *
 _clutter_stage_window_get_views (ClutterStageWindow *window)
 {
-  ClutterStageWindowIface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
+  ClutterStageWindowInterface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
 
   return iface->get_views (window);
 }
@@ -340,7 +336,7 @@ _clutter_stage_window_get_views (ClutterStageWindow *window)
 void
 _clutter_stage_window_finish_frame (ClutterStageWindow *window)
 {
-  ClutterStageWindowIface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
+  ClutterStageWindowInterface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
 
   if (iface->finish_frame)
     iface->finish_frame (window);
@@ -349,7 +345,7 @@ _clutter_stage_window_finish_frame (ClutterStageWindow *window)
 int64_t
 _clutter_stage_window_get_frame_counter (ClutterStageWindow *window)
 {
-  ClutterStageWindowIface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
+  ClutterStageWindowInterface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
 
   if (iface->get_frame_counter)
     return iface->get_frame_counter (window);
diff --git a/clutter/clutter/clutter-stage-window.h b/clutter/clutter/clutter-stage-window.h
index 50a54108f..9f337fa44 100644
--- a/clutter/clutter/clutter-stage-window.h
+++ b/clutter/clutter/clutter-stage-window.h
@@ -7,30 +7,19 @@
 
 G_BEGIN_DECLS
 
-#define CLUTTER_TYPE_STAGE_WINDOW               (_clutter_stage_window_get_type ())
-#define CLUTTER_STAGE_WINDOW(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
CLUTTER_TYPE_STAGE_WINDOW, ClutterStageWindow))
-#define CLUTTER_IS_STAGE_WINDOW(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
CLUTTER_TYPE_STAGE_WINDOW))
-#define CLUTTER_STAGE_WINDOW_GET_IFACE(obj)     (G_TYPE_INSTANCE_GET_INTERFACE ((obj), 
CLUTTER_TYPE_STAGE_WINDOW, ClutterStageWindowIface))
+#define CLUTTER_TYPE_STAGE_WINDOW (clutter_stage_window_get_type ())
+G_DECLARE_INTERFACE (ClutterStageWindow, clutter_stage_window,
+                     CLUTTER, STAGE_WINDOW,
+                     GObject)
 
 /*
- * ClutterStageWindow: (skip)
- *
- * #ClutterStageWindow is an opaque structure
- * whose members should not be accessed directly
- *
- * Since: 0.8
- */
-typedef struct _ClutterStageWindow      ClutterStageWindow; /* dummy */
-typedef struct _ClutterStageWindowIface ClutterStageWindowIface;
-
-/*
- * ClutterStageWindowIface: (skip)
+ * ClutterStageWindowInterface: (skip)
  *
  * The interface implemented by backends for stage windows
  *
  * Since: 0.8
  */
-struct _ClutterStageWindowIface
+struct _ClutterStageWindowInterface
 {
   /*< private >*/
   GTypeInterface parent_iface;
@@ -88,9 +77,6 @@ struct _ClutterStageWindowIface
   void              (* finish_frame)            (ClutterStageWindow *stage_window);
 };
 
-CLUTTER_EXPORT
-GType _clutter_stage_window_get_type (void) G_GNUC_CONST;
-
 ClutterActor *    _clutter_stage_window_get_wrapper        (ClutterStageWindow *window);
 
 void              _clutter_stage_window_set_title          (ClutterStageWindow *window,
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 04367b0ee..7030d77fa 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -2742,7 +2742,7 @@ clutter_stage_set_fullscreen (ClutterStage *stage,
   if (priv->is_fullscreen != fullscreen)
     {
       ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
-      ClutterStageWindowIface *iface;
+      ClutterStageWindowInterface *iface;
 
       iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
 
@@ -2807,7 +2807,7 @@ clutter_stage_set_user_resizable (ClutterStage *stage,
       && priv->is_user_resizable != resizable)
     {
       ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
-      ClutterStageWindowIface *iface;
+      ClutterStageWindowInterface *iface;
 
       iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
       if (iface->set_user_resizable)
@@ -2856,7 +2856,7 @@ clutter_stage_show_cursor (ClutterStage *stage)
   if (!priv->is_cursor_visible)
     {
       ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
-      ClutterStageWindowIface *iface;
+      ClutterStageWindowInterface *iface;
 
       iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
       if (iface->set_cursor_visible)
@@ -2889,7 +2889,7 @@ clutter_stage_hide_cursor (ClutterStage *stage)
   if (priv->is_cursor_visible)
     {
       ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
-      ClutterStageWindowIface *iface;
+      ClutterStageWindowInterface *iface;
 
       iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
       if (iface->set_cursor_visible)
diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c
index ad9dec304..b313c9a10 100644
--- a/clutter/clutter/cogl/clutter-stage-cogl.c
+++ b/clutter/clutter/cogl/clutter-stage-cogl.c
@@ -60,7 +60,8 @@ typedef struct _ClutterStageViewCoglPrivate
 G_DEFINE_TYPE_WITH_PRIVATE (ClutterStageViewCogl, clutter_stage_view_cogl,
                             CLUTTER_TYPE_STAGE_VIEW)
 
-static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
+static void
+clutter_stage_window_iface_init (ClutterStageWindowInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (ClutterStageCogl,
                          _clutter_stage_cogl,
@@ -994,7 +995,7 @@ clutter_stage_cogl_get_dirty_pixel (ClutterStageWindow *stage_window,
 }
 
 static void
-clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
+clutter_stage_window_iface_init (ClutterStageWindowInterface *iface)
 {
   iface->realize = clutter_stage_cogl_realize;
   iface->unrealize = clutter_stage_cogl_unrealize;
diff --git a/clutter/clutter/x11/clutter-stage-x11.c b/clutter/clutter/x11/clutter-stage-x11.c
index 62a67708e..087bd6742 100644
--- a/clutter/clutter/x11/clutter-stage-x11.c
+++ b/clutter/clutter/x11/clutter-stage-x11.c
@@ -49,10 +49,12 @@
 
 #define STAGE_X11_IS_MAPPED(s)  ((((ClutterStageX11 *) (s))->wm_state & STAGE_X11_WITHDRAWN) == 0)
 
-static ClutterStageWindowIface *clutter_stage_window_parent_iface = NULL;
+static ClutterStageWindowInterface *clutter_stage_window_parent_iface = NULL;
 
-static void clutter_stage_window_iface_init     (ClutterStageWindowIface     *iface);
-static void clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface);
+static void
+clutter_stage_window_iface_init (ClutterStageWindowInterface *iface);
+static void
+clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface);
 
 static ClutterStageCogl *clutter_x11_get_stage_window_from_window (Window win);
 
@@ -972,7 +974,7 @@ clutter_stage_x11_init (ClutterStageX11 *stage)
 }
 
 static void
-clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
+clutter_stage_window_iface_init (ClutterStageWindowInterface *iface)
 {
   clutter_stage_window_parent_iface = g_type_interface_peek_parent (iface);
 
diff --git a/src/backends/native/meta-stage-native.c b/src/backends/native/meta-stage-native.c
index 2463781dc..c8afa752c 100644
--- a/src/backends/native/meta-stage-native.c
+++ b/src/backends/native/meta-stage-native.c
@@ -45,7 +45,7 @@ struct _MetaStageNative
 };
 
 static void
-clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
+clutter_stage_window_iface_init (ClutterStageWindowInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (MetaStageNative, meta_stage_native,
                          CLUTTER_TYPE_STAGE_COGL,
@@ -219,7 +219,7 @@ meta_stage_native_class_init (MetaStageNativeClass *klass)
 }
 
 static void
-clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
+clutter_stage_window_iface_init (ClutterStageWindowInterface *iface)
 {
   iface->can_clip_redraws = meta_stage_native_can_clip_redraws;
   iface->get_geometry = meta_stage_native_get_geometry;
diff --git a/src/backends/x11/meta-stage-x11-nested.c b/src/backends/x11/meta-stage-x11-nested.c
index f77e13ade..02fef1e55 100644
--- a/src/backends/x11/meta-stage-x11-nested.c
+++ b/src/backends/x11/meta-stage-x11-nested.c
@@ -35,7 +35,7 @@
 #include "backends/x11/nested/meta-renderer-x11-nested.h"
 #include "clutter/clutter-mutter.h"
 
-static ClutterStageWindowIface *clutter_stage_window_parent_iface = NULL;
+static ClutterStageWindowInterface *clutter_stage_window_parent_iface = NULL;
 
 struct _MetaStageX11Nested
 {
@@ -45,7 +45,7 @@ struct _MetaStageX11Nested
 };
 
 static void
-clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
+clutter_stage_window_iface_init (ClutterStageWindowInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (MetaStageX11Nested, meta_stage_x11_nested,
                          CLUTTER_TYPE_STAGE_X11,
@@ -350,7 +350,7 @@ meta_stage_x11_nested_class_init (MetaStageX11NestedClass *klass)
 }
 
 static void
-clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
+clutter_stage_window_iface_init (ClutterStageWindowInterface *iface)
 {
   clutter_stage_window_parent_iface = g_type_interface_peek_parent (iface);
 


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