[mutter/gnome-42] x11-display: Unset GDK_BACKEND environment variable
- From: Robert Mader <rmader src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gnome-42] x11-display: Unset GDK_BACKEND environment variable
- Date: Wed, 10 Aug 2022 11:23:07 +0000 (UTC)
commit 453cae800368fd3d9dcc56f8473755a151a5d6be
Author: Michel Dänzer <mdaenzer redhat com>
Date: Wed Jul 6 17:38:55 2022 +0200
x11-display: Unset GDK_BACKEND environment variable
mutter needs GDK to use the x11 backend. It already calls
gdk_set_allowed_backends ("x11") for this purpose; however, if
GDK_BACKEND=wayland (or any other non-x11 backend possibly) happened to
be in the environment, GDK would fail to initialize at all. This would
result in mutter not registering as X11 window manager, and all X11
clients hanging.
Big thanks to Olivier Fourdan for figuring this out!
v2:
* Restore original value of GDK_BACKEND environment variable after
initializing GDK.
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=2022283
Bug: https://bugs.debian.org/1008992
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2496>
(cherry picked from commit 23526a99c7bfc48ef6e13637be93ad8783b6aacb)
src/x11/meta-x11-display.c | 8 ++++++++
1 file changed, 8 insertions(+)
---
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index 9a2f02e9e4..51a7a3b753 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -1028,6 +1028,7 @@ meta_x11_init_gdk_display (GError **error)
{
const char *xdisplay_name;
GdkDisplay *gdk_display;
+ const char *gdk_backend_env = NULL;
const char *gdk_gl_env = NULL;
const char *old_no_at_bridge;
Display *xdisplay;
@@ -1042,6 +1043,10 @@ meta_x11_init_gdk_display (GError **error)
gdk_set_allowed_backends ("x11");
+ gdk_backend_env = g_getenv ("GDK_BACKEND");
+ /* GDK would fail to initialize with e.g. GDK_BACKEND=wayland */
+ g_unsetenv ("GDK_BACKEND");
+
gdk_gl_env = g_getenv ("GDK_GL");
g_setenv ("GDK_GL", "disable", TRUE);
@@ -1072,6 +1077,9 @@ meta_x11_init_gdk_display (GError **error)
return FALSE;
}
+ if (gdk_backend_env)
+ g_setenv("GDK_BACKEND", gdk_backend_env, TRUE);
+
if (gdk_gl_env)
g_setenv("GDK_GL", gdk_gl_env, TRUE);
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]