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.
This commit is contained in:
Emmanuele Bassi 2015-12-11 14:23:38 +00:00
parent 407d7ca436
commit 7ca28e0974
14 changed files with 67 additions and 21 deletions

View File

@ -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:
*

View File

@ -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

View File

@ -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:
*

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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__ */

View File

@ -56,8 +56,6 @@
#include <cogl/cogl.h>
#include <cogl/cogl-wayland-client.h>
#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

View File

@ -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

View File

@ -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);
}

View File

@ -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__ */

View File

@ -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)

View File

@ -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);