Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7594)

Unified Diff: chrome/browser/ui/libgtkui/gtk_ui.cc

Issue 2762723003: Gtk3: Whitelist X11 backend (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/libgtkui/gtk_util.h » ('j') | chrome/browser/ui/libgtkui/gtk_util.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/libgtkui/gtk_ui.cc
diff --git a/chrome/browser/ui/libgtkui/gtk_ui.cc b/chrome/browser/ui/libgtkui/gtk_ui.cc
index 06e2f94bd4893bdff66a6bd539a0cf30b5c09a94..dd59476a70333754846827023d83ff534227c372 100644
--- a/chrome/browser/ui/libgtkui/gtk_ui.cc
+++ b/chrome/browser/ui/libgtkui/gtk_ui.cc
@@ -4,9 +4,10 @@
#include "chrome/browser/ui/libgtkui/gtk_ui.h"
+#include <X11/Xcursor/Xcursor.h>
+#include <dlfcn.h>
#include <math.h>
#include <pango/pango.h>
-#include <X11/Xcursor/Xcursor.h>
#include <cmath>
#include <set>
@@ -376,6 +377,19 @@ SkColor GetToolbarTopSeparatorColor(SkColor header_fg,
} // namespace
GtkUi::GtkUi() : middle_click_action_(GetDefaultMiddleClickAction()) {
+#if GTK_MAJOR_VERSION > 2
+ // Force Gtk to use Xwayland if it would have used wayland. libgtkui assumes
+ // the use of X11 (eg. X11InputMethodContextImplGtk) and will crash under
+ // other backends.
+ // TODO(thomasanderson): Change this logic once Wayland support is added.
+ static auto* _gdk_set_allowed_backends =
+ reinterpret_cast<void (*)(const gchar*)>(
+ dlsym(GetGdkSharedLibrary(), "gdk_set_allowed_backends"));
+ if (GtkVersionCheck(3, 10))
+ DCHECK(_gdk_set_allowed_backends);
+ if (_gdk_set_allowed_backends)
+ _gdk_set_allowed_backends("x11");
+#endif
GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess());
#if GTK_MAJOR_VERSION == 2
native_theme_ = NativeThemeGtk2::instance();
« no previous file with comments | « no previous file | chrome/browser/ui/libgtkui/gtk_util.h » ('j') | chrome/browser/ui/libgtkui/gtk_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698