Commit 6ecb48f9 authored by Sergey Kipet's avatar Sergey Kipet Committed by Commit Bot

libgtkui: Fix linkage when building Chrome for Ozone/Wayland

Since recently, Chrome started to fail while building for the Ozone/Wayland
backend. The libgtkui::GtkEventLoopX11::GetInstance() symbol is now considered
as undefined by the linker, if the target is configured to run on Wayland.

CL fixes the link-time error by moving the X11-related code of the library
(particularly, inside the gtk_ui.cc source file) under the newly introduced
USE_GTK_EVENT_LOOP_X11 conditional compilation flag where checking on whether
a target platform is Ozone/X11 is performed.

Test: configure Chrome browser for running on Wayland and build the target.

Bug: 1011277
Change-Id: I0236f92e05c2525cd72e2643ecd4772c059e27ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1843972
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703854}
parent 79e67a4e
...@@ -115,6 +115,8 @@ jumbo_component("libgtkui") { ...@@ -115,6 +115,8 @@ jumbo_component("libgtkui") {
"gtk_event_loop_x11.h", "gtk_event_loop_x11.h",
] ]
defines += [ "USE_GTK_EVENT_LOOP_X11" ]
deps += [ deps += [
"//ui/events/platform/x11", "//ui/events/platform/x11",
"//ui/gfx/x", "//ui/gfx/x",
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/libgtkui/gtk_event_loop_x11.h"
#include "chrome/browser/ui/libgtkui/gtk_key_bindings_handler.h" #include "chrome/browser/ui/libgtkui/gtk_key_bindings_handler.h"
#include "chrome/browser/ui/libgtkui/gtk_util.h" #include "chrome/browser/ui/libgtkui/gtk_util.h"
#include "chrome/browser/ui/libgtkui/input_method_context_impl_gtk.h" #include "chrome/browser/ui/libgtkui/input_method_context_impl_gtk.h"
...@@ -72,6 +71,10 @@ ...@@ -72,6 +71,10 @@
#include "chrome/browser/ui/libgtkui/settings_provider_gsettings.h" #include "chrome/browser/ui/libgtkui/settings_provider_gsettings.h"
#endif #endif
#if defined(USE_GTK_EVENT_LOOP_X11)
#include "chrome/browser/ui/libgtkui/gtk_event_loop_x11.h"
#endif
#if defined(USE_X11) #if defined(USE_X11)
#include "ui/gfx/x/x11.h" // nogncheck #include "ui/gfx/x/x11.h" // nogncheck
#include "ui/gfx/x/x11_types.h" // nogncheck #include "ui/gfx/x/x11_types.h" // nogncheck
...@@ -323,6 +326,19 @@ views::LinuxUI::WindowFrameAction GetDefaultMiddleClickAction() { ...@@ -323,6 +326,19 @@ views::LinuxUI::WindowFrameAction GetDefaultMiddleClickAction() {
} }
} }
#if defined(USE_GTK_EVENT_LOOP_X11)
bool ShouldCreateGtkEventLoopX11() {
#if defined(USE_OZONE)
// TODO(crbug.com/1002674): This is a temporary layering violation, supported
// during X11 migration to Ozone.
std::string ozone_platform{ui::OzonePlatform::GetPlatformName()};
return ozone_platform == "x11";
#else
return true;
#endif
}
#endif // defined(USE_GTK_EVENT_LOOP_X11)
} // namespace } // namespace
GtkUi::GtkUi() { GtkUi::GtkUi() {
...@@ -403,8 +419,11 @@ void GtkUi::Initialize() { ...@@ -403,8 +419,11 @@ void GtkUi::Initialize() {
indicators_count = 0; indicators_count = 0;
// Instantiate the singleton instance of GtkEventLoopX11. #if defined(USE_GTK_EVENT_LOOP_X11)
GtkEventLoopX11::GetInstance(); if (ShouldCreateGtkEventLoopX11())
// Instantiate the singleton instance of GtkEventLoopX11.
GtkEventLoopX11::GetInstance();
#endif
} }
bool GtkUi::GetTint(int id, color_utils::HSL* tint) const { bool GtkUi::GetTint(int id, color_utils::HSL* tint) const {
......
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