Commit 3a9de35a authored by Thomas Wood's avatar Thomas Wood Committed by Matthias Clasen

gdk: Implement GInitable on GdkDisplayManager

Add GInitable interface with a default implementation that always
succeeds. This allows backends to override the GInitable implementation
and add their own checks to determine if the backend can be loaded.  If
a backend cannot be loaded, GDK can attempt to load the next available
backend.

Since backends may need to read any relevant options (such as the
display flag) to determine if they can be created successfully, this
patch also removes calls that attempt to create the display manager
before the options have been parsed.

https://bugzilla.gnome.org/show_bug.cgi?id=694465
parent 75f4f7a4
......@@ -275,9 +275,6 @@ gdk_pre_parse_libgtk_only (void)
else if (g_str_equal (rendering_mode, "recording"))
_gdk_rendering_mode = GDK_RENDERING_MODE_RECORDING;
}
/* Do any setup particular to the windowing system */
gdk_display_manager_get ();
}
......
......@@ -125,7 +125,24 @@ static void gdk_display_manager_get_property (GObject *object,
static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (GdkDisplayManager, gdk_display_manager, G_TYPE_OBJECT)
static void g_initable_iface_init (GInitableIface *iface);
G_DEFINE_TYPE_WITH_CODE (GdkDisplayManager, gdk_display_manager, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, g_initable_iface_init))
static gboolean
gdk_display_manager_initable_init (GInitable *initable,
GCancellable *cancellable,
GError **error)
{
return TRUE;
}
static void
g_initable_iface_init (GInitableIface *iface)
{
iface->init = gdk_display_manager_initable_init;
}
static void
gdk_display_manager_class_init (GdkDisplayManagerClass *klass)
......@@ -236,33 +253,31 @@ gdk_display_manager_get (void)
backend = g_getenv ("GDK_BACKEND");
#ifdef GDK_WINDOWING_QUARTZ
if (backend == NULL || strcmp (backend, "quartz") == 0)
manager = g_object_new (gdk_quartz_display_manager_get_type (), NULL);
else
manager = g_initable_new (gdk_quartz_display_manager_get_type (), NULL, NULL, NULL);
#endif
#ifdef GDK_WINDOWING_WIN32
if (backend == NULL || strcmp (backend, "win32") == 0)
manager = g_object_new (gdk_win32_display_manager_get_type (), NULL);
else
if (!manager && (backend == NULL || strcmp (backend, "win32") == 0))
manager = g_initable_new (gdk_win32_display_manager_get_type (), NULL, NULL, NULL);
#endif
#ifdef GDK_WINDOWING_X11
if (backend == NULL || strcmp (backend, "x11") == 0)
manager = g_object_new (gdk_x11_display_manager_get_type (), NULL);
else
if (!manager && (backend == NULL || strcmp (backend, "x11") == 0))
manager = g_initable_new (gdk_x11_display_manager_get_type (), NULL, NULL, NULL);
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (backend == NULL || strcmp (backend, "wayland") == 0)
manager = g_object_new (gdk_wayland_display_manager_get_type (), NULL);
else
if (!manager && (backend == NULL || strcmp (backend, "wayland") == 0))
manager = g_initable_new (gdk_wayland_display_manager_get_type (), NULL, NULL, NULL);
#endif
#ifdef GDK_WINDOWING_BROADWAY
if (backend == NULL || strcmp (backend, "broadway") == 0)
manager = g_object_new (gdk_broadway_display_manager_get_type (), NULL);
else
if (!manager && (backend == NULL || strcmp (backend, "broadway") == 0))
manager = g_initable_new (gdk_broadway_display_manager_get_type (), NULL, NULL, NULL);
#endif
if (backend != NULL)
g_error ("Unsupported GDK backend: %s", backend);
else
g_error ("No GDK backend found");
if (!manager)
{
if (backend != NULL)
g_error ("Unsupported GDK backend: %s", backend);
else
g_error ("No GDK backend found");
}
}
return manager;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment