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
This commit is contained in:
Niels De Graef 2019-01-08 13:51:47 +01:00 committed by Jonas Ådahl
parent f9e33a89fd
commit b67394dcd1
7 changed files with 43 additions and 56 deletions

View File

@ -14,10 +14,6 @@
* #ClutterStage actor, abstracting away the specifics of the windowing system. * #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); G_DEFINE_INTERFACE (ClutterStageWindow, clutter_stage_window, G_TYPE_OBJECT);
static void static void
@ -60,7 +56,7 @@ void
_clutter_stage_window_set_title (ClutterStageWindow *window, _clutter_stage_window_set_title (ClutterStageWindow *window,
const gchar *title) const gchar *title)
{ {
ClutterStageWindowIface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window); ClutterStageWindowInterface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
if (iface->set_title) if (iface->set_title)
iface->set_title (window, title); iface->set_title (window, title);
@ -70,7 +66,7 @@ void
_clutter_stage_window_set_fullscreen (ClutterStageWindow *window, _clutter_stage_window_set_fullscreen (ClutterStageWindow *window,
gboolean is_fullscreen) gboolean is_fullscreen)
{ {
ClutterStageWindowIface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window); ClutterStageWindowInterface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
if (iface->set_fullscreen) if (iface->set_fullscreen)
iface->set_fullscreen (window, is_fullscreen); iface->set_fullscreen (window, is_fullscreen);
@ -80,7 +76,7 @@ void
_clutter_stage_window_set_cursor_visible (ClutterStageWindow *window, _clutter_stage_window_set_cursor_visible (ClutterStageWindow *window,
gboolean is_visible) gboolean is_visible)
{ {
ClutterStageWindowIface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window); ClutterStageWindowInterface *iface = CLUTTER_STAGE_WINDOW_GET_IFACE (window);
if (iface->set_cursor_visible) if (iface->set_cursor_visible)
iface->set_cursor_visible (window, is_visible); iface->set_cursor_visible (window, is_visible);
@ -138,7 +134,7 @@ void
_clutter_stage_window_schedule_update (ClutterStageWindow *window, _clutter_stage_window_schedule_update (ClutterStageWindow *window,
int sync_delay) int sync_delay)
{ {
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window)); g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
@ -163,7 +159,7 @@ _clutter_stage_window_schedule_update (ClutterStageWindow *window,
gint64 gint64
_clutter_stage_window_get_update_time (ClutterStageWindow *window) _clutter_stage_window_get_update_time (ClutterStageWindow *window)
{ {
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), 0); g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), 0);
@ -186,7 +182,7 @@ _clutter_stage_window_get_update_time (ClutterStageWindow *window)
void void
_clutter_stage_window_clear_update_time (ClutterStageWindow *window) _clutter_stage_window_clear_update_time (ClutterStageWindow *window)
{ {
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window)); g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
@ -204,7 +200,7 @@ void
_clutter_stage_window_add_redraw_clip (ClutterStageWindow *window, _clutter_stage_window_add_redraw_clip (ClutterStageWindow *window,
cairo_rectangle_int_t *stage_clip) cairo_rectangle_int_t *stage_clip)
{ {
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window)); g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
@ -224,7 +220,7 @@ _clutter_stage_window_add_redraw_clip (ClutterStageWindow *window,
gboolean gboolean
_clutter_stage_window_has_redraw_clips (ClutterStageWindow *window) _clutter_stage_window_has_redraw_clips (ClutterStageWindow *window)
{ {
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE); g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
@ -246,7 +242,7 @@ _clutter_stage_window_has_redraw_clips (ClutterStageWindow *window)
gboolean gboolean
_clutter_stage_window_ignoring_redraw_clips (ClutterStageWindow *window) _clutter_stage_window_ignoring_redraw_clips (ClutterStageWindow *window)
{ {
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE); 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, _clutter_stage_window_get_redraw_clip_bounds (ClutterStageWindow *window,
cairo_rectangle_int_t *stage_clip) cairo_rectangle_int_t *stage_clip)
{ {
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE); g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
@ -276,7 +272,7 @@ void
_clutter_stage_window_set_accept_focus (ClutterStageWindow *window, _clutter_stage_window_set_accept_focus (ClutterStageWindow *window,
gboolean accept_focus) gboolean accept_focus)
{ {
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window)); g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
@ -288,7 +284,7 @@ _clutter_stage_window_set_accept_focus (ClutterStageWindow *window,
void void
_clutter_stage_window_redraw (ClutterStageWindow *window) _clutter_stage_window_redraw (ClutterStageWindow *window)
{ {
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window)); g_return_if_fail (CLUTTER_IS_STAGE_WINDOW (window));
@ -303,7 +299,7 @@ _clutter_stage_window_get_dirty_pixel (ClutterStageWindow *window,
ClutterStageView *view, ClutterStageView *view,
int *x, int *y) int *x, int *y)
{ {
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
*x = 0; *x = 0;
*y = 0; *y = 0;
@ -318,7 +314,7 @@ _clutter_stage_window_get_dirty_pixel (ClutterStageWindow *window,
gboolean gboolean
_clutter_stage_window_can_clip_redraws (ClutterStageWindow *window) _clutter_stage_window_can_clip_redraws (ClutterStageWindow *window)
{ {
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE); g_return_val_if_fail (CLUTTER_IS_STAGE_WINDOW (window), FALSE);
@ -332,7 +328,7 @@ _clutter_stage_window_can_clip_redraws (ClutterStageWindow *window)
GList * GList *
_clutter_stage_window_get_views (ClutterStageWindow *window) _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); return iface->get_views (window);
} }
@ -340,7 +336,7 @@ _clutter_stage_window_get_views (ClutterStageWindow *window)
void void
_clutter_stage_window_finish_frame (ClutterStageWindow *window) _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) if (iface->finish_frame)
iface->finish_frame (window); iface->finish_frame (window);
@ -349,7 +345,7 @@ _clutter_stage_window_finish_frame (ClutterStageWindow *window)
int64_t int64_t
_clutter_stage_window_get_frame_counter (ClutterStageWindow *window) _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) if (iface->get_frame_counter)
return iface->get_frame_counter (window); return iface->get_frame_counter (window);

View File

@ -7,30 +7,21 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#define CLUTTER_TYPE_STAGE_WINDOW (_clutter_stage_window_get_type ()) #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)) CLUTTER_EXPORT
#define CLUTTER_STAGE_WINDOW_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), CLUTTER_TYPE_STAGE_WINDOW, ClutterStageWindowIface)) G_DECLARE_INTERFACE (ClutterStageWindow, clutter_stage_window,
CLUTTER, STAGE_WINDOW,
GObject)
/* /*
* ClutterStageWindow: (skip) * ClutterStageWindowInterface: (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)
* *
* The interface implemented by backends for stage windows * The interface implemented by backends for stage windows
* *
* Since: 0.8 * Since: 0.8
*/ */
struct _ClutterStageWindowIface struct _ClutterStageWindowInterface
{ {
/*< private >*/ /*< private >*/
GTypeInterface parent_iface; GTypeInterface parent_iface;
@ -88,9 +79,6 @@ struct _ClutterStageWindowIface
void (* finish_frame) (ClutterStageWindow *stage_window); 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); ClutterActor * _clutter_stage_window_get_wrapper (ClutterStageWindow *window);
void _clutter_stage_window_set_title (ClutterStageWindow *window, void _clutter_stage_window_set_title (ClutterStageWindow *window,

View File

@ -2742,7 +2742,7 @@ clutter_stage_set_fullscreen (ClutterStage *stage,
if (priv->is_fullscreen != fullscreen) if (priv->is_fullscreen != fullscreen)
{ {
ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl); ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl); iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
@ -2807,7 +2807,7 @@ clutter_stage_set_user_resizable (ClutterStage *stage,
&& priv->is_user_resizable != resizable) && priv->is_user_resizable != resizable)
{ {
ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl); ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl); iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
if (iface->set_user_resizable) if (iface->set_user_resizable)
@ -2856,7 +2856,7 @@ clutter_stage_show_cursor (ClutterStage *stage)
if (!priv->is_cursor_visible) if (!priv->is_cursor_visible)
{ {
ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl); ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl); iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
if (iface->set_cursor_visible) if (iface->set_cursor_visible)
@ -2889,7 +2889,7 @@ clutter_stage_hide_cursor (ClutterStage *stage)
if (priv->is_cursor_visible) if (priv->is_cursor_visible)
{ {
ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl); ClutterStageWindow *impl = CLUTTER_STAGE_WINDOW (priv->impl);
ClutterStageWindowIface *iface; ClutterStageWindowInterface *iface;
iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl); iface = CLUTTER_STAGE_WINDOW_GET_IFACE (impl);
if (iface->set_cursor_visible) if (iface->set_cursor_visible)

View File

@ -60,7 +60,8 @@ typedef struct _ClutterStageViewCoglPrivate
G_DEFINE_TYPE_WITH_PRIVATE (ClutterStageViewCogl, clutter_stage_view_cogl, G_DEFINE_TYPE_WITH_PRIVATE (ClutterStageViewCogl, clutter_stage_view_cogl,
CLUTTER_TYPE_STAGE_VIEW) 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, G_DEFINE_TYPE_WITH_CODE (ClutterStageCogl,
_clutter_stage_cogl, _clutter_stage_cogl,
@ -994,7 +995,7 @@ clutter_stage_cogl_get_dirty_pixel (ClutterStageWindow *stage_window,
} }
static void static void
clutter_stage_window_iface_init (ClutterStageWindowIface *iface) clutter_stage_window_iface_init (ClutterStageWindowInterface *iface)
{ {
iface->realize = clutter_stage_cogl_realize; iface->realize = clutter_stage_cogl_realize;
iface->unrealize = clutter_stage_cogl_unrealize; iface->unrealize = clutter_stage_cogl_unrealize;

View File

@ -49,10 +49,12 @@
#define STAGE_X11_IS_MAPPED(s) ((((ClutterStageX11 *) (s))->wm_state & STAGE_X11_WITHDRAWN) == 0) #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
static void clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface); 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); static ClutterStageCogl *clutter_x11_get_stage_window_from_window (Window win);
@ -972,7 +974,7 @@ clutter_stage_x11_init (ClutterStageX11 *stage)
} }
static void 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); clutter_stage_window_parent_iface = g_type_interface_peek_parent (iface);

View File

@ -45,7 +45,7 @@ struct _MetaStageNative
}; };
static void 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, G_DEFINE_TYPE_WITH_CODE (MetaStageNative, meta_stage_native,
CLUTTER_TYPE_STAGE_COGL, CLUTTER_TYPE_STAGE_COGL,
@ -219,7 +219,7 @@ meta_stage_native_class_init (MetaStageNativeClass *klass)
} }
static void 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->can_clip_redraws = meta_stage_native_can_clip_redraws;
iface->get_geometry = meta_stage_native_get_geometry; iface->get_geometry = meta_stage_native_get_geometry;

View File

@ -35,7 +35,7 @@
#include "backends/x11/nested/meta-renderer-x11-nested.h" #include "backends/x11/nested/meta-renderer-x11-nested.h"
#include "clutter/clutter-mutter.h" #include "clutter/clutter-mutter.h"
static ClutterStageWindowIface *clutter_stage_window_parent_iface = NULL; static ClutterStageWindowInterface *clutter_stage_window_parent_iface = NULL;
struct _MetaStageX11Nested struct _MetaStageX11Nested
{ {
@ -45,7 +45,7 @@ struct _MetaStageX11Nested
}; };
static void 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, G_DEFINE_TYPE_WITH_CODE (MetaStageX11Nested, meta_stage_x11_nested,
CLUTTER_TYPE_STAGE_X11, CLUTTER_TYPE_STAGE_X11,
@ -350,7 +350,7 @@ meta_stage_x11_nested_class_init (MetaStageX11NestedClass *klass)
} }
static void 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); clutter_stage_window_parent_iface = g_type_interface_peek_parent (iface);