Commit ae53c074 authored by Tom Anderson's avatar Tom Anderson Committed by Chromium LUCI CQ

Override GDK_BACKEND in GTK initialization

GDK_BACKEND gets set by chrome-remote-desktop [1].  GDK_BACKEND takes
precedence over gdk_set_allowed_backends() [2], so this means weston
sessions (which inherit GDK_BACKEND) will incorrectly try to use X11,
which won't work.  To avoid this, manually set GDK_BACKEND during GTK
initialization.

[1] https://source.chromium.org/chromium/chromium/src/+/master:remoting/host/linux/linux_me2me_host.py;drc=be48a068a67faa7f3bc2ea0d03529d62319f06fb;l=461
[2] https://gitlab.gnome.org/GNOME/gtk/blob/3.24.5/gdk/gdkdisplaymanager.c#L441

BUG=None
R=nickdiego

Change-Id: I5ae6cae1511e4a7215098a0c291d735303a1827f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586184
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarNick Yamane <nickdiego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#835870}
parent db9c5f91
......@@ -7,6 +7,7 @@
#include <gtk/gtk.h>
#include "base/check.h"
#include "base/environment.h"
#include "ui/base/x/x11_util.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/native_widget_types.h"
......@@ -32,6 +33,9 @@ GtkUiDelegateX11::GtkUiDelegateX11(x11::Connection* connection)
: connection_(connection) {
DCHECK(connection_);
gdk_set_allowed_backends("x11");
// GDK_BACKEND takes precedence over gdk_set_allowed_backends(), so override
// it to ensure we get the x11 backend.
base::Environment::Create()->SetVar("GDK_BACKEND", "x11");
x11::InitXlib();
}
......
......@@ -10,6 +10,7 @@
#include <memory>
#include "base/bind.h"
#include "base/environment.h"
#include "base/logging.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
......@@ -29,6 +30,9 @@ GtkUiDelegateWayland::GtkUiDelegateWayland(WaylandConnection* connection)
: connection_(connection) {
DCHECK(connection_);
gdk_set_allowed_backends("wayland");
// GDK_BACKEND takes precedence over gdk_set_allowed_backends(), so override
// it to ensure we get the wayland backend.
base::Environment::Create()->SetVar("GDK_BACKEND", "wayland");
}
GtkUiDelegateWayland::~GtkUiDelegateWayland() = default;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment