From 27f36a8eddcf71c33b9fd0b5f80521896b2d71f9 Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Wed, 31 Aug 2022 03:31:52 -0400 Subject: [PATCH] Only set GDK_BACKEND to "x11" if GDK_BACKEND is unset and XDG_SESSION_TYPE is not "wayland" (#1811) * Only set GDK_BACKEND to "x11" if GDK_BACKEND is unset and XDG_SESSION_TYPE is not "wayland" * GDK_BACKEND should only be set if XDG_SESSION_TYPE is unset, "unspecified" or "x11" --- v2/internal/frontend/desktop/linux/frontend.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/v2/internal/frontend/desktop/linux/frontend.go b/v2/internal/frontend/desktop/linux/frontend.go index 4f697c19a..433795173 100644 --- a/v2/internal/frontend/desktop/linux/frontend.go +++ b/v2/internal/frontend/desktop/linux/frontend.go @@ -58,8 +58,10 @@ func init() { func NewFrontend(ctx context.Context, appoptions *options.App, myLogger *logger.Logger, appBindings *binding.Bindings, dispatcher frontend.Dispatcher) *Frontend { - // Set GDK_BACKEND=x11 to prevent warnings - _ = os.Setenv("GDK_BACKEND", "x11") + // Set GDK_BACKEND=x11 if currently unset and XDG_SESSION_TYPE is unset, unspecified or x11 to prevent warnings + if os.Getenv("GDK_BACKEND") == "" && (os.Getenv("XDG_SESSION_TYPE") == "" || os.Getenv("XDG_SESSION_TYPE") == "unspecified" || os.Getenv("XDG_SESSION_TYPE") == "x11") { + _ = os.Setenv("GDK_BACKEND", "x11") + } result := &Frontend{ frontendOptions: appoptions,