diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c index b424dee70..76e0b077b 100644 --- a/src/x11/meta-x11-display.c +++ b/src/x11/meta-x11-display.c @@ -1009,6 +1009,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; @@ -1023,6 +1024,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); @@ -1053,6 +1058,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