From 89053cc6f772ab3715ed775b8aba234a6a6a5ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 25 Feb 2021 21:03:54 +0100 Subject: [PATCH] display: Make meta_display_open() report errors Instead of just exit():ing, report the error, so the caller can decide how to deal with the error. Part-of: --- src/core/display-private.h | 2 +- src/core/display.c | 16 +++++++++------- src/core/main.c | 9 +++++++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/core/display-private.h b/src/core/display-private.h index 3d690fcb6..6008de05f 100644 --- a/src/core/display-private.h +++ b/src/core/display-private.h @@ -260,7 +260,7 @@ struct _MetaDisplayClass (time2) != 0) \ ) -gboolean meta_display_open (void); +gboolean meta_display_open (GError **error); void meta_display_manage_all_xwindows (MetaDisplay *display); void meta_display_unmanage_windows (MetaDisplay *display, diff --git a/src/core/display.c b/src/core/display.c index 5cdfce5ee..0ce0e1c0a 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -798,9 +798,8 @@ meta_display_shutdown_x11 (MetaDisplay *display) * has a window manager. */ gboolean -meta_display_open (void) +meta_display_open (GError **error) { - GError *error = NULL; MetaDisplay *display; int i; guint32 timestamp; @@ -902,8 +901,11 @@ meta_display_open (void) else #endif { - if (!meta_display_init_x11_display (display, &error)) - g_error ("Failed to init X11 display: %s", error->message); + if (!meta_display_init_x11_display (display, error)) + { + g_object_unref (display); + return FALSE; + } timestamp = display->x11_display->timestamp; } @@ -917,10 +919,10 @@ meta_display_open (void) display->x11_display->atom__NET_ACTIVE_WINDOW, &old_active_xwindow); - if (!meta_compositor_do_manage (display->compositor, &error)) + if (!meta_compositor_do_manage (display->compositor, error)) { - g_error ("Compositor failed to manage display: %s", - error->message); + g_object_unref (display); + return FALSE; } if (display->x11_display) diff --git a/src/core/main.c b/src/core/main.c index 76d3ef5df..888753732 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -850,6 +850,8 @@ meta_register_with_session (void) void meta_start (void) { + g_autoptr (GError) error = NULL; + meta_prefs_init (); #ifdef HAVE_WAYLAND @@ -857,8 +859,11 @@ meta_start (void) meta_backend_init_wayland (meta_get_backend ()); #endif - if (!meta_display_open ()) - meta_exit (META_EXIT_ERROR); + if (!meta_display_open (&error)) + { + g_warning ("Failed to open display: %s", error->message); + meta_exit (META_EXIT_ERROR); + } } void