Commit 57bfb02f authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

X11 and Ozone: fix use_x11 && use_x11 build for desktop_screen

When use_x11 && use_ozone are set to true at the same
time, compiler throws an error about multiple definitions
of the CreateDesktopScreen.

Thus, to fix that, create a separate source file for
is_linux case that will choose what DesktopScreen to
use based on the IsUsingOzonePlatform feature flag.

Please note that this is a temp solution and it will
be removed once use_x11 goes away.

Please note that it's impossible to build use_x11 && use_ozone without
some hacks in PlatformCursor code. The changes to that are on their
way to upstream.

Bug: 1085700
Change-Id: I8710809572cc82d514ee64af1fe9a6a1eff73cd9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2247719Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#779213}
parent 2968d615
...@@ -784,7 +784,8 @@ jumbo_component("views") { ...@@ -784,7 +784,8 @@ jumbo_component("views") {
"widget/desktop_aura/desktop_window_tree_host_win.cc", "widget/desktop_aura/desktop_window_tree_host_win.cc",
] ]
deps += [ "//ui/events:dom_keyboard_layout" ] deps += [ "//ui/events:dom_keyboard_layout" ]
} else if (use_ozone) { }
if (use_ozone) {
public += [ "widget/desktop_aura/desktop_screen_ozone.h" ] public += [ "widget/desktop_aura/desktop_screen_ozone.h" ]
sources += [ sources += [
"widget/desktop_aura/desktop_drag_drop_client_ozone.cc", "widget/desktop_aura/desktop_drag_drop_client_ozone.cc",
...@@ -796,6 +797,7 @@ jumbo_component("views") { ...@@ -796,6 +797,7 @@ jumbo_component("views") {
public += [ "widget/desktop_aura/desktop_window_tree_host_linux.h" ] public += [ "widget/desktop_aura/desktop_window_tree_host_linux.h" ]
sources += [ sources += [
"style/platform_style_linux.cc", "style/platform_style_linux.cc",
"widget/desktop_aura/desktop_screen_linux.cc",
"widget/desktop_aura/desktop_window_tree_host_linux.cc", "widget/desktop_aura/desktop_window_tree_host_linux.cc",
"widget/desktop_aura/window_event_filter_linux.cc", "widget/desktop_aura/window_event_filter_linux.cc",
"widget/desktop_aura/window_event_filter_linux.h", "widget/desktop_aura/window_event_filter_linux.h",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/widget/desktop_aura/desktop_screen.h"
#if defined(USE_X11)
#include "ui/views/widget/desktop_aura/desktop_screen_x11.h"
#endif
#if defined(USE_OZONE)
#include "ui/base/ui_base_features.h"
#include "ui/views/widget/desktop_aura/desktop_screen_ozone.h"
#endif
namespace views {
display::Screen* CreateDesktopScreen() {
#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform())
return new DesktopScreenOzone();
#endif
#if defined(USE_X11)
auto* screen = new DesktopScreenX11();
screen->Init();
return screen;
#else
NOTREACHED();
return nullptr;
#endif
}
} // namespace views
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ui/views/widget/desktop_aura/desktop_screen_ozone.h" #include "ui/views/widget/desktop_aura/desktop_screen_ozone.h"
#include "build/build_config.h"
#include "ui/aura/screen_ozone.h" #include "ui/aura/screen_ozone.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h" #include "ui/views/widget/desktop_aura/desktop_screen.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h"
...@@ -22,8 +23,13 @@ gfx::NativeWindow DesktopScreenOzone::GetNativeWindowFromAcceleratedWidget( ...@@ -22,8 +23,13 @@ gfx::NativeWindow DesktopScreenOzone::GetNativeWindowFromAcceleratedWidget(
widget); widget);
} }
// To avoid multiple definitions when use_x11 && use_ozone is true, disable this
// factory method for OS_LINUX as Linux has a factory method that decides what
// screen to use based on IsUsingOzonePlatform feature flag.
#if !defined(OS_LINUX)
display::Screen* CreateDesktopScreen() { display::Screen* CreateDesktopScreen() {
return new DesktopScreenOzone(); return new DesktopScreenOzone();
} }
#endif
} // namespace views } // namespace views
...@@ -178,12 +178,4 @@ float DesktopScreenX11::GetXDisplayScaleFactor() const { ...@@ -178,12 +178,4 @@ float DesktopScreenX11::GetXDisplayScaleFactor() const {
: 1.0f; : 1.0f;
} }
////////////////////////////////////////////////////////////////////////////////
display::Screen* CreateDesktopScreen() {
auto* screen = new DesktopScreenX11;
screen->Init();
return screen;
}
} // namespace views } // namespace views
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