From 7ca28e09746f3f1a6b240a8c1a416dd4ad6c8ff6 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 11 Dec 2015 14:23:38 +0000 Subject: [PATCH] Add internal constructor function for each backend We're going to use it to create an instance of each backend without using the get_type() function. --- clutter/egl/clutter-backend-eglnative.c | 8 ++++++-- clutter/egl/clutter-backend-eglnative.h | 6 ++++-- clutter/gdk/clutter-backend-gdk.c | 7 ++++++- clutter/gdk/clutter-backend-gdk.h | 6 ++++-- clutter/mir/clutter-backend-mir.c | 8 ++++++-- clutter/mir/clutter-backend-mir.h | 9 +++++---- clutter/osx/clutter-backend-osx.c | 6 ++++++ clutter/osx/clutter-backend-osx.h | 2 ++ clutter/wayland/clutter-backend-wayland.c | 8 ++++++-- clutter/wayland/clutter-backend-wayland.h | 6 ++++-- clutter/win32/clutter-backend-win32.c | 6 ++++++ clutter/win32/clutter-backend-win32.h | 2 ++ clutter/x11/clutter-backend-x11.c | 8 ++++++-- clutter/x11/clutter-backend-x11.h | 6 ++++-- 14 files changed, 67 insertions(+), 21 deletions(-) diff --git a/clutter/egl/clutter-backend-eglnative.c b/clutter/egl/clutter-backend-eglnative.c index 1eccd31d9..fe2a2cde0 100644 --- a/clutter/egl/clutter-backend-eglnative.c +++ b/clutter/egl/clutter-backend-eglnative.c @@ -55,8 +55,6 @@ #include "clutter-stage-eglnative.h" -#define clutter_backend_egl_native_get_type _clutter_backend_egl_native_get_type - G_DEFINE_TYPE (ClutterBackendEglNative, clutter_backend_egl_native, CLUTTER_TYPE_BACKEND); #ifdef COGL_HAS_EGL_PLATFORM_KMS_SUPPORT @@ -115,6 +113,12 @@ clutter_backend_egl_native_init (ClutterBackendEglNative *backend_egl_native) backend_egl_native->event_timer = g_timer_new (); } +ClutterBackend * +clutter_backend_egl_native_new (void) +{ + return g_object_new (CLUTTER_TYPE_BACKEND_EGL_NATIVE, NULL); +} + /** * clutter_eglx_display: * diff --git a/clutter/egl/clutter-backend-eglnative.h b/clutter/egl/clutter-backend-eglnative.h index 4178f3c14..78fce148d 100644 --- a/clutter/egl/clutter-backend-eglnative.h +++ b/clutter/egl/clutter-backend-eglnative.h @@ -37,7 +37,7 @@ G_BEGIN_DECLS -#define CLUTTER_TYPE_BACKEND_EGL_NATIVE (_clutter_backend_egl_native_get_type ()) +#define CLUTTER_TYPE_BACKEND_EGL_NATIVE (clutter_backend_egl_native_get_type ()) #define CLUTTER_BACKEND_EGL_NATIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND_EGL_NATIVE, ClutterBackendEglNative)) #define CLUTTER_IS_BACKEND_EGL_NATIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND_EGL_NATIVE)) #define CLUTTER_BACKEND_EGL_NATIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND_EGL_NATIVE, ClutterBackendEglNativeClass)) @@ -66,7 +66,9 @@ struct _ClutterBackendEglNativeClass ClutterBackendClass parent_class; }; -GType _clutter_backend_egl_native_get_type (void) G_GNUC_CONST; +GType clutter_backend_egl_native_get_type (void) G_GNUC_CONST; + +ClutterBackend *clutter_backend_egl_new (void); G_END_DECLS diff --git a/clutter/gdk/clutter-backend-gdk.c b/clutter/gdk/clutter-backend-gdk.c index d257c001a..25c687b99 100644 --- a/clutter/gdk/clutter-backend-gdk.c +++ b/clutter/gdk/clutter-backend-gdk.c @@ -77,7 +77,6 @@ #include "clutter-private.h" #include "clutter-settings-private.h" -#define clutter_backend_gdk_get_type _clutter_backend_gdk_get_type G_DEFINE_TYPE (ClutterBackendGdk, clutter_backend_gdk, CLUTTER_TYPE_BACKEND); /* global for pre init setup calls */ @@ -396,6 +395,12 @@ clutter_backend_gdk_init (ClutterBackendGdk *backend_gdk) _clutter_set_sync_to_vblank (FALSE); } +ClutterBackend * +clutter_backend_gdk_new (void) +{ + return g_object_new (CLUTTER_TYPE_BACKEND_GDK, NULL); +} + /** * clutter_gdk_get_default_display: * diff --git a/clutter/gdk/clutter-backend-gdk.h b/clutter/gdk/clutter-backend-gdk.h index fb5411315..3b8bc3497 100644 --- a/clutter/gdk/clutter-backend-gdk.h +++ b/clutter/gdk/clutter-backend-gdk.h @@ -33,7 +33,7 @@ G_BEGIN_DECLS -#define CLUTTER_TYPE_BACKEND_GDK (_clutter_backend_gdk_get_type ()) +#define CLUTTER_TYPE_BACKEND_GDK (clutter_backend_gdk_get_type ()) #define CLUTTER_BACKEND_GDK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND_GDK, ClutterBackendGdk)) #define CLUTTER_IS_BACKEND_GDK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND_GDK)) #define CLUTTER_BACKEND_GDK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND_GDK, ClutterBackendGdkClass)) @@ -60,7 +60,9 @@ struct _ClutterBackendGdkClass /* nothing here, for now */ }; -GType _clutter_backend_gdk_get_type (void) G_GNUC_CONST; +GType clutter_backend_gdk_get_type (void) G_GNUC_CONST; + +ClutterBackend *clutter_backend_gdk_new (void); void _clutter_backend_gdk_events_init (ClutterBackend *backend); diff --git a/clutter/mir/clutter-backend-mir.c b/clutter/mir/clutter-backend-mir.c index 019ef71d7..16706beb1 100644 --- a/clutter/mir/clutter-backend-mir.c +++ b/clutter/mir/clutter-backend-mir.c @@ -37,8 +37,6 @@ #include "mir/clutter-stage-mir.h" #include "mir/clutter-mir.h" -#define clutter_backend_mir_get_type _clutter_backend_mir_get_type - G_DEFINE_TYPE (ClutterBackendMir, clutter_backend_mir, CLUTTER_TYPE_BACKEND); static MirConnection *_foreign_connection = NULL; @@ -173,6 +171,12 @@ clutter_backend_mir_class_init (ClutterBackendMirClass *klass) backend_class->get_display = clutter_backend_mir_get_display; } +ClutterBackend * +clutter_backend_mir_new (void) +{ + return g_object_new (CLUTTER_TYPE_BACKEND_MIR, NULL); +} + /** * clutter_mir_set_connection: * @connection: pointer to a mir connection diff --git a/clutter/mir/clutter-backend-mir.h b/clutter/mir/clutter-backend-mir.h index beecf8a5d..e3aba7712 100644 --- a/clutter/mir/clutter-backend-mir.h +++ b/clutter/mir/clutter-backend-mir.h @@ -30,7 +30,7 @@ G_BEGIN_DECLS -#define CLUTTER_TYPE_BACKEND_MIR (_clutter_backend_mir_get_type ()) +#define CLUTTER_TYPE_BACKEND_MIR (clutter_backend_mir_get_type ()) #define CLUTTER_BACKEND_MIR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND_MIR, ClutterBackendMir)) #define CLUTTER_IS_BACKEND_MIR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND_MIR)) #define CLUTTER_BACKEND_MIR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND_MIR, ClutterBackendMirClass)) @@ -45,10 +45,11 @@ struct _ClutterBackendMirClass ClutterBackendClass parent_class; }; -GType _clutter_backend_mir_get_type (void) G_GNUC_CONST; +GType clutter_backend_mir_get_type (void) G_GNUC_CONST; -void -_clutter_events_mir_init (ClutterBackend *backend); +ClutterBackend *clutter_backend_mir_new (void); + +void _clutter_events_mir_init (ClutterBackend *backend); G_END_DECLS diff --git a/clutter/osx/clutter-backend-osx.c b/clutter/osx/clutter-backend-osx.c index 90f5e6c17..6b6aaec11 100644 --- a/clutter/osx/clutter-backend-osx.c +++ b/clutter/osx/clutter-backend-osx.c @@ -245,3 +245,9 @@ clutter_backend_osx_class_init (ClutterBackendOSXClass *klass) backend_class->create_context = clutter_backend_osx_create_context; backend_class->ensure_context = clutter_backend_osx_ensure_context; } + +ClutterBackend * +clutter_backend_osx_new (void) +{ + return g_object_new (CLUTTER_TYPE_BACKEND_OSX, NULL); +} diff --git a/clutter/osx/clutter-backend-osx.h b/clutter/osx/clutter-backend-osx.h index cef4e0e72..b3e13d8e4 100644 --- a/clutter/osx/clutter-backend-osx.h +++ b/clutter/osx/clutter-backend-osx.h @@ -69,6 +69,8 @@ void _clutter_backend_osx_events_init (ClutterBackend *backend); void _clutter_event_osx_put (NSEvent *nsevent, ClutterStage *wrapper); +ClutterBackend *clutter_backend_osx_new (void); + G_END_DECLS #endif /* __CLUTTER_BACKEND_OSX_H__ */ diff --git a/clutter/wayland/clutter-backend-wayland.c b/clutter/wayland/clutter-backend-wayland.c index dcc7c65a1..281b1a905 100644 --- a/clutter/wayland/clutter-backend-wayland.c +++ b/clutter/wayland/clutter-backend-wayland.c @@ -56,8 +56,6 @@ #include #include -#define clutter_backend_wayland_get_type _clutter_backend_wayland_get_type - G_DEFINE_TYPE (ClutterBackendWayland, clutter_backend_wayland, CLUTTER_TYPE_BACKEND); static struct wl_display *_foreign_display = NULL; @@ -322,6 +320,12 @@ clutter_backend_wayland_init (ClutterBackendWayland *backend_wayland) { } +ClutterBackend * +clutter_backend_wayland_new (void) +{ + return g_object_new (CLUTTER_TYPE_BACKEND_WAYLAND, NULL); +} + /** * clutter_wayland_set_display * @display: pointer to a wayland display diff --git a/clutter/wayland/clutter-backend-wayland.h b/clutter/wayland/clutter-backend-wayland.h index b916e5345..ba7a25329 100644 --- a/clutter/wayland/clutter-backend-wayland.h +++ b/clutter/wayland/clutter-backend-wayland.h @@ -36,7 +36,7 @@ G_BEGIN_DECLS -#define CLUTTER_TYPE_BACKEND_WAYLAND (_clutter_backend_wayland_get_type ()) +#define CLUTTER_TYPE_BACKEND_WAYLAND (clutter_backend_wayland_get_type ()) #define CLUTTER_BACKEND_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND_WAYLAND, ClutterBackendWayland)) #define CLUTTER_IS_BACKEND_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND_WAYLAND)) #define CLUTTER_BACKEND_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND_WAYLAND, ClutterBackendWaylandClass)) @@ -51,7 +51,9 @@ struct _ClutterBackendWaylandClass ClutterBackendClass parent_class; }; -GType _clutter_backend_wayland_get_type (void) G_GNUC_CONST; +GType clutter_backend_wayland_get_type (void) G_GNUC_CONST; + +ClutterBackend *clutter_backend_wayland_new (void); G_END_DECLS diff --git a/clutter/win32/clutter-backend-win32.c b/clutter/win32/clutter-backend-win32.c index fc7c6042b..1811c7396 100644 --- a/clutter/win32/clutter-backend-win32.c +++ b/clutter/win32/clutter-backend-win32.c @@ -239,3 +239,9 @@ DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved) return TRUE; } + +ClutterBackend * +clutter_backend_win32_new (void) +{ + return g_object_new (CLUTTER_TYPE_BACKEND_WIN32, NULL); +} diff --git a/clutter/win32/clutter-backend-win32.h b/clutter/win32/clutter-backend-win32.h index da5ac9c17..3981ed3d0 100644 --- a/clutter/win32/clutter-backend-win32.h +++ b/clutter/win32/clutter-backend-win32.h @@ -72,6 +72,8 @@ clutter_backend_win32_get_features (ClutterBackend *backend); HCURSOR _clutter_backend_win32_get_invisible_cursor (ClutterBackend *backend); +ClutterBackend *clutter_backend_win32_new (void); + G_END_DECLS #endif /* __CLUTTER_BACKEND_WIN32_H__ */ diff --git a/clutter/x11/clutter-backend-x11.c b/clutter/x11/clutter-backend-x11.c index 3f18a76f4..91be18c85 100644 --- a/clutter/x11/clutter-backend-x11.c +++ b/clutter/x11/clutter-backend-x11.c @@ -65,8 +65,6 @@ #include "clutter-private.h" #include "clutter-settings-private.h" -#define clutter_backend_x11_get_type _clutter_backend_x11_get_type - G_DEFINE_TYPE (ClutterBackendX11, clutter_backend_x11, CLUTTER_TYPE_BACKEND) GType @@ -853,6 +851,12 @@ clutter_backend_x11_init (ClutterBackendX11 *backend_x11) backend_x11->last_event_time = CurrentTime; } +ClutterBackend * +clutter_backend_x11_new (void) +{ + return g_object_new (CLUTTER_TYPE_BACKEND_X11, NULL); +} + static int error_handler(Display *xdpy, XErrorEvent *error) diff --git a/clutter/x11/clutter-backend-x11.h b/clutter/x11/clutter-backend-x11.h index 2ffe2f6e3..98a4589f4 100644 --- a/clutter/x11/clutter-backend-x11.h +++ b/clutter/x11/clutter-backend-x11.h @@ -36,7 +36,7 @@ G_BEGIN_DECLS -#define CLUTTER_TYPE_BACKEND_X11 (_clutter_backend_x11_get_type ()) +#define CLUTTER_TYPE_BACKEND_X11 (clutter_backend_x11_get_type ()) #define CLUTTER_BACKEND_X11(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND_X11, ClutterBackendX11)) #define CLUTTER_IS_BACKEND_X11(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND_X11)) #define CLUTTER_BACKEND_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND_X11, ClutterBackendX11Class)) @@ -116,7 +116,9 @@ struct _ClutterBackendX11Class ClutterBackendClass parent_class; }; -GType _clutter_backend_x11_get_type (void) G_GNUC_CONST; +GType clutter_backend_x11_get_type (void) G_GNUC_CONST; + +ClutterBackend *clutter_backend_x11_new (void); void _clutter_backend_x11_events_init (ClutterBackend *backend);