Skip to content

Commit

Permalink
ozone: //ui/base: clean up from USE_X11 1/*
Browse files Browse the repository at this point in the history
This is another CL that removes USE_X11 define and
gn arg usage from //ui/base and also removes
IsUsingOzonePlatform condition as it's no longer
needed as it always resolves to true.

Please note that //ui/base used to have
//ui/base/x in public_deps. That resulted in other
components implicitly depending on the //ui/base/x
as well. However, after it was deleted, it was
required to fix deps in //remoting/host,
//components/viz/service and //chrome/test/chromedriver.

Changes:
1) Moved hit_tests_x11 to //ui/platform_window/x11
2) Moved os_exhange_data_provider_x11 to //ui/platform_window/x11
3) Fixed deps
4) //ui/base:ui_base_unittests no longer includes //ui/base/x:unittests.
Instead, the //ui/base/x:unittests target is included in
//ui/platform_window/x11:x11_unittests and these base x11 unittests
run as part of x11_unittests.

Bug: 1096425
Change-Id: If0ec32b8a9e91bc36f284266cd29dd42236ea780
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3263824
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
Reviewed-by: Joe Downing <joedow@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/main@{#938809}
  • Loading branch information
msisov authored and Chromium LUCI CQ committed Nov 5, 2021
1 parent d996f66 commit 2b98fed
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 173 deletions.
5 changes: 4 additions & 1 deletion chrome/test/chromedriver/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ source_set("lib") {
# engine.
if (ozone_platform_x11) {
sources += [ "keycode_text_conversion_x.cc" ]
deps += [ "//ui/gfx/x" ]
deps += [
"//ui/base/x",
"//ui/gfx/x",
]
}
}

Expand Down
1 change: 1 addition & 0 deletions components/viz/service/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ viz_source_set("gpu_service_dependencies") {
libs = [ "xshmfence" ]

deps += [
"//ui/base/x",
"//ui/events/platform/x11",
"//ui/gfx/x",
]
Expand Down
1 change: 1 addition & 0 deletions remoting/host/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ static_library("common") {
]
deps += [
"//remoting/host/linux:x11",
"//ui/base/x",
"//ui/events/platform/x11",
"//ui/gfx/x",
]
Expand Down
59 changes: 10 additions & 49 deletions ui/base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,6 @@ source_set("hit_test") {
"hit_test.cc",
"hit_test.h",
]

if (use_x11 || use_ozone) {
sources += [
"hit_test_x11.cc",
"hit_test_x11.h",
]
}

deps = [ "//base" ]
}

component("base") {
Expand Down Expand Up @@ -500,25 +491,6 @@ component("base") {
deps += [ "//ui/events" ]
}

if ((is_linux || is_chromeos) && (use_x11 || ozone_platform_x11)) {
public_deps += [ "//ui/base/x" ]

# X11 drag and drop wants to use common drag and drop types.
allow_circular_includes_from = [ "//ui/base/x" ]

if (!is_chromeos_ash) {
# These files/deps aren't used in ChromeOS.
sources += [
"dragdrop/os_exchange_data_provider_x11.cc",
"dragdrop/os_exchange_data_provider_x11.h",
]
deps += [
"//ui/events/platform/x11",
"//ui/gfx/x",
]
}
}

if (use_aura && (is_linux || is_chromeos)) {
sources += [ "resource/resource_bundle_auralinux.cc" ]
}
Expand Down Expand Up @@ -1071,20 +1043,17 @@ test("ui_base_unittests") {
]
}
if ((is_linux || is_chromeos_lacros) && use_aura) {
sources += [ "dragdrop/os_exchange_data_provider_non_backed_unittest.cc" ]

if (use_x11 || use_ozone) {
sources += [ "ime/linux/input_method_auralinux_unittest.cc" ]
deps += [
"//ui/base/ime/init",
"//ui/base/ime/linux",
]
}
if (!use_x11) {
sources += [ "ime/input_method_minimal_unittest.cc" ]
}
sources += [
"dragdrop/os_exchange_data_provider_non_backed_unittest.cc",
"ime/input_method_minimal_unittest.cc",
"ime/linux/input_method_auralinux_unittest.cc",
]
deps += [
"//ui/base/ime/init",
"//ui/base/ime/linux",
]
}
if (use_x11) {
if (is_linux && !is_chromecast && !is_chromeos_lacros) {
sources += [ "ime/linux/composition_text_util_pango_unittest.cc" ]
}
if (is_chromeos_ash || use_ozone) {
Expand Down Expand Up @@ -1138,14 +1107,6 @@ test("ui_base_unittests") {
configs += [ "//build/config/linux/pangocairo" ]
}

if (use_x11) {
deps += [
"//ui/base/x:unittests",
"//ui/events/platform/x11",
"//ui/gfx/x",
]
}

if (is_mac) {
deps += [
":ui_unittests_framework",
Expand Down
39 changes: 6 additions & 33 deletions ui/base/dragdrop/os_exchange_data_provider_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@
#include "build/build_config.h"

#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA)
#include "ui/base/dragdrop/os_exchange_data_provider_non_backed.h"
#include "ui/base/ui_base_features.h"
#if defined(USE_OZONE)
#include "ui/base/dragdrop/os_exchange_data_provider_factory_ozone.h"
#endif // defined(USE_OZONE)
#if defined(USE_X11)
#include "ui/base/dragdrop/os_exchange_data_provider_x11.h"
#endif // defined(USE_X11)
#include "ui/base/dragdrop/os_exchange_data_provider_non_backed.h"
#elif defined(OS_APPLE)
#include "ui/base/dragdrop/os_exchange_data_provider_builder_mac.h"
#elif defined(OS_WIN)
Expand All @@ -24,40 +18,19 @@

namespace ui {

namespace {

// static
std::unique_ptr<OSExchangeDataProvider>
OSExchangeDataProviderFactory::CreateProvider() {
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
std::unique_ptr<OSExchangeDataProvider> CreateProviderForLinux() {
#if defined(USE_OZONE)
// The instance can be nullptr in tests that do not instantiate the platform,
// or on platforms that do not implement specific drag'n'drop. For them,
// falling back to the Aura provider should be fine.
if (OSExchangeDataProviderFactoryOzone::Instance()) {
auto provider =
OSExchangeDataProviderFactoryOzone::Instance()->CreateProvider();
if (auto* factory = OSExchangeDataProviderFactoryOzone::Instance()) {
auto provider = factory->CreateProvider();
if (provider)
return provider;
}
#endif // defined(USE_OZONE)
// non-Ozone X11 is never expected to reach this.
DCHECK(features::IsUsingOzonePlatform());
return std::make_unique<OSExchangeDataProviderNonBacked>();
}
#endif // defined(USE_LINUX)

} // namespace

// static
std::unique_ptr<OSExchangeDataProvider>
OSExchangeDataProviderFactory::CreateProvider() {
#if defined(OS_LINUX) || defined(OS_CHROMEOS)
if (features::IsUsingOzonePlatform())
return CreateProviderForLinux();
#if defined(USE_X11)
return std::make_unique<OSExchangeDataProviderX11>();
#endif // defined(USE_X11)
NOTREACHED();
return nullptr;
#elif defined(OS_APPLE)
return BuildOSExchangeDataProviderMac();
#elif defined(OS_WIN)
Expand Down
12 changes: 1 addition & 11 deletions ui/base/idle/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,13 @@ component("idle") {

if (is_linux) {
sources += [ "idle_linux.cc" ]
deps += [ "//ui/display" ]
if (use_dbus) {
deps += [ "//dbus" ]
defines += [ "USE_DBUS" ]
}
}

if (use_x11 && !is_chromeos_ash) {
deps += [ "//ui/base/x" ]
}

if (use_ozone) {
deps += [
"//ui/base:features",
"//ui/display",
]
}

if (is_android) {
deps += [ "//ui/base:ui_base_jni_headers" ]
sources -= [ "idle.cc" ]
Expand Down
53 changes: 11 additions & 42 deletions ui/base/idle/idle_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "base/notreached.h"
#include "ui/base/idle/idle.h"
#include "ui/base/idle/idle_internal.h"
#include "ui/display/screen.h"

#if defined(USE_DBUS)
#include "base/bind.h"
Expand All @@ -20,16 +21,6 @@
#include "dbus/object_proxy.h"
#endif

#if defined(USE_X11)
#include "ui/base/x/x11_idle_query.h"
#include "ui/base/x/x11_screensaver.h"
#endif

#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h"
#include "ui/display/screen.h"
#endif

namespace ui {

#if defined(USE_DBUS)
Expand Down Expand Up @@ -224,22 +215,11 @@ DBusScreenSaverWatcher* GetDBusScreenSaverWatcher() {
#endif // defined(USE_DBUS)

int CalculateIdleTime() {
#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform()) {
auto* const screen = display::Screen::GetScreen();
// The screen can be nullptr in tests.
if (!screen)
return 0;
return screen->CalculateIdleTime().InSeconds();
}
#endif
#if defined(USE_X11)
IdleQueryX11 idle_query;
return idle_query.IdleTime();
#else
NOTIMPLEMENTED_LOG_ONCE();
return 0;
#endif
auto* const screen = display::Screen::GetScreen();
// The screen can be nullptr in tests.
if (!screen)
return 0;
return screen->CalculateIdleTime().InSeconds();
}

bool CheckIdleStateIsLocked() {
Expand All @@ -252,22 +232,11 @@ bool CheckIdleStateIsLocked() {
return lock_state == DBusScreenSaverWatcher::LockState::kLocked;
#endif

#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform()) {
auto* const screen = display::Screen::GetScreen();
// The screen can be nullptr in tests.
if (!screen)
return false;
return screen->IsScreenSaverActive();
}
#endif
#if defined(USE_X11)
// Usually the screensaver is used to lock the screen.
return IsXScreensaverActive();
#else
NOTIMPLEMENTED_LOG_ONCE();
return false;
#endif
auto* const screen = display::Screen::GetScreen();
// The screen can be nullptr in tests.
if (!screen)
return false;
return screen->IsScreenSaverActive();
}

} // namespace ui
21 changes: 3 additions & 18 deletions ui/base/ime/init/input_method_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@
#include "ui/base/ime/win/input_method_win_tsf.h"
#elif defined(OS_APPLE)
#include "ui/base/ime/mac/input_method_mac.h"
#elif defined(USE_X11) || defined(USE_OZONE)
#if defined(USE_X11)
#include "ui/base/ime/linux/input_method_auralinux.h"
#endif // defined(USE_X11)
#if defined(USE_OZONE)
#elif defined(USE_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#endif // defined(USE_OZONE)
#else
#include "ui/base/ime/input_method_minimal.h"
#endif
Expand Down Expand Up @@ -67,18 +62,8 @@ std::unique_ptr<InputMethod> CreateInputMethod(
return std::make_unique<InputMethodWinImm32>(delegate, widget);
#elif defined(OS_APPLE)
return std::make_unique<InputMethodMac>(delegate);
#elif defined(USE_X11) || defined(USE_OZONE)
#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform()) {
return ui::OzonePlatform::GetInstance()->CreateInputMethod(delegate,
widget);
}
#endif // defined(USE_OZONE)
#if defined(USE_X11)
return std::make_unique<ui::InputMethodAuraLinux>(delegate);
#endif // defined(USE_X11)
NOTREACHED();
return nullptr;
#elif defined(USE_OZONE)
return ui::OzonePlatform::GetInstance()->CreateInputMethod(delegate, widget);
#else
return std::make_unique<InputMethodMinimal>(delegate);
#endif
Expand Down
3 changes: 2 additions & 1 deletion ui/base/x/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import("//build/config/linux/gtk/gtk.gni")
import("//build/config/ozone.gni")
import("//build/config/ui.gni")

assert(use_x11 || ozone_platform_x11)
assert(ozone_platform_x11)

component("x") {
output_name = "ui_base_x"
Expand Down Expand Up @@ -107,6 +107,7 @@ component("x") {
]
public_deps += [ "//ui/base/dragdrop/mojom:mojom_shared" ]
deps += [
"//ui/base",
"//ui/base/dragdrop:types",
"//ui/base/dragdrop/mojom",
]
Expand Down
1 change: 1 addition & 0 deletions ui/gtk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ component("gtk") {
"x/gtk_ui_platform_x11.h",
]
deps += [
"//ui/base/x",
"//ui/events/platform/x11",
"//ui/gfx/x",
"//ui/platform_window/x11",
Expand Down
2 changes: 1 addition & 1 deletion ui/ozone/platform/x11/ozone_platform_x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
#include "ui/base/dragdrop/os_exchange_data_provider_non_backed.h"
#include "ui/base/ime/ash/input_method_ash.h"
#else
#include "ui/base/dragdrop/os_exchange_data_provider_x11.h"
#include "ui/base/ime/linux/input_method_auralinux.h"
#include "ui/platform_window/x11/os_exchange_data_provider_x11.h"
#endif

namespace ui {
Expand Down
7 changes: 7 additions & 0 deletions ui/platform_window/x11/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ component("x11") {
"//ui/base",
"//ui/base:hit_test",
"//ui/base:wm_role_names",
"//ui/base/clipboard:clipboard_types",
"//ui/base/data_transfer_policy",
"//ui/base/dragdrop:types",
"//ui/base/dragdrop/mojom",
"//ui/base/x",
Expand All @@ -36,6 +38,10 @@ component("x11") {
defines = [ "X11_WINDOW_IMPLEMENTATION" ]

sources = [
"hit_test_x11.cc",
"hit_test_x11.h",
"os_exchange_data_provider_x11.cc",
"os_exchange_data_provider_x11.h",
"x11_topmost_window_finder.cc",
"x11_topmost_window_finder.h",
"x11_window.cc",
Expand Down Expand Up @@ -80,6 +86,7 @@ test("x11_unittests") {
"//ui/base/dragdrop:types",
"//ui/base/x",
"//ui/base/x:test_support",
"//ui/base/x:unittests",
"//ui/events:test_support",
"//ui/events/platform/x11",
"//ui/events/x",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/base/hit_test_x11.h"
#include "ui/platform_window/x11/hit_test_x11.h"

#include "ui/base/hit_test.h"

Expand Down
Loading

0 comments on commit 2b98fed

Please sign in to comment.