[mutter] x11-display: Clean up GdkDisplay opening
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] x11-display: Clean up GdkDisplay opening
- Date: Mon, 19 Sep 2022 15:12:28 +0000 (UTC)
commit b8cdc91c19f7450a92826368a5c4f3f32d356d3c
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Sat May 28 23:39:30 2022 +0200
x11-display: Clean up GdkDisplay opening
It exposed unnecessary public and private API, and used a global static
variable instead of a return value, none which was necessary. Remove
both API and use a return value for communicating to the caller.
This doesn't remove a public symbol, lets do that for GNOME 44.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
src/x11/meta-x11-display-private.h | 2 --
src/x11/meta-x11-display.c | 51 ++++++++++++++++++--------------------
2 files changed, 24 insertions(+), 29 deletions(-)
---
diff --git a/src/x11/meta-x11-display-private.h b/src/x11/meta-x11-display-private.h
index 9158387d69..4e30b0c548 100644
--- a/src/x11/meta-x11-display-private.h
+++ b/src/x11/meta-x11-display-private.h
@@ -251,6 +251,4 @@ void meta_x11_display_set_input_focus (MetaX11Display *x11_display,
MetaDisplay * meta_x11_display_get_display (MetaX11Display *x11_display);
-const gchar * meta_x11_get_display_name (void);
-
#endif /* META_X11_DISPLAY_PRIVATE_H */
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index 76e0b077b0..1f8353eb45 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -80,8 +80,6 @@ typedef struct _MetaX11DisplayLogicalMonitorData
int xinerama_index;
} MetaX11DisplayLogicalMonitorData;
-static GdkDisplay *prepared_gdk_display = NULL;
-
static char *get_screen_name (Display *xdisplay,
int number);
@@ -985,27 +983,24 @@ set_work_area_hint (MetaDisplay *display,
g_free (data);
}
-const gchar *
-meta_x11_get_display_name (void)
+static const char *
+get_display_name (MetaDisplay *display)
{
#ifdef HAVE_WAYLAND
- if (meta_is_wayland_compositor ())
- {
- MetaWaylandCompositor *compositor;
-
- compositor = meta_wayland_compositor_get_default ();
+ MetaContext *context = meta_display_get_context (display);
+ MetaWaylandCompositor *compositor =
+ meta_context_get_wayland_compositor (context);
- return meta_wayland_get_private_xwayland_display_name (compositor);
- }
+ if (compositor)
+ return meta_wayland_get_private_xwayland_display_name (compositor);
else
#endif
- {
- return g_getenv ("DISPLAY");
- }
+ return g_getenv ("DISPLAY");
}
-gboolean
-meta_x11_init_gdk_display (GError **error)
+static GdkDisplay *
+open_gdk_display (MetaDisplay *display,
+ GError **error)
{
const char *xdisplay_name;
GdkDisplay *gdk_display;
@@ -1014,12 +1009,12 @@ meta_x11_init_gdk_display (GError **error)
const char *old_no_at_bridge;
Display *xdisplay;
- xdisplay_name = meta_x11_get_display_name ();
+ xdisplay_name = get_display_name (display);
if (!xdisplay_name)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Unable to open display, DISPLAY not set");
- return FALSE;
+ return NULL;
}
gdk_set_allowed_backends ("x11");
@@ -1036,7 +1031,7 @@ meta_x11_init_gdk_display (GError **error)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Failed to initialize gtk");
- return FALSE;
+ return NULL;
}
old_no_at_bridge = g_getenv ("NO_AT_BRIDGE");
@@ -1054,8 +1049,7 @@ meta_x11_init_gdk_display (GError **error)
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Failed to initialize GDK");
-
- return FALSE;
+ return NULL;
}
if (gdk_backend_env)
@@ -1085,12 +1079,16 @@ meta_x11_init_gdk_display (GError **error)
gdk_display_close (gdk_display);
- return FALSE;
+ return NULL;
}
- prepared_gdk_display = gdk_display;
+ return gdk_display;
+}
- return TRUE;
+gboolean
+meta_x11_init_gdk_display (GError **error)
+{
+ return !!open_gdk_display (meta_get_display (), error);
}
static void
@@ -1151,11 +1149,10 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
};
Atom atoms[G_N_ELEMENTS(atom_names)];
- if (!meta_x11_init_gdk_display (error))
+ gdk_display = open_gdk_display (display, error);
+ if (!gdk_display)
return NULL;
- g_assert (prepared_gdk_display);
- gdk_display = g_steal_pointer (&prepared_gdk_display);
xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display);
XSynchronize (xdisplay, meta_context_is_x11_sync (context));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]