Commit b6e8f135 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

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

When use_x11 && use_ozone are set to true at the same
time, the compiler throws an error about multiple definitions
of the Create() method for Clipboard.

Thus, to fix that, create a separate source file for
is_linux case that will choose what Clipboard impl 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: I3a32b261ec01fd2a751127b5abda1147575b8e18
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2247760
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779210}
parent 9d1610a2
......@@ -115,13 +115,15 @@ jumbo_component("clipboard") {
if (use_aura) {
# Linux clipboard implementations.
if (is_desktop_linux && !is_chromecast) {
sources += [ "clipboard_linux.cc" ]
if (use_ozone) {
sources += [
"clipboard_ozone.cc",
"clipboard_ozone.h",
]
deps += [ "//ui/base" ]
} else if (use_x11) {
}
if (use_x11) {
sources += [
"clipboard_x11.cc",
"clipboard_x11.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/base/clipboard/clipboard.h"
#if defined(USE_OZONE)
#include "ui/base/clipboard/clipboard_ozone.h"
#include "ui/base/ui_base_features.h"
#endif
#if defined(USE_X11)
#include "ui/base/clipboard/clipboard_x11.h"
#endif
namespace ui {
// Clipboard factory method.
Clipboard* Clipboard::Create() {
#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform())
return new ClipboardOzone();
#endif
#if defined(USE_X11)
return new ClipboardX11();
#else
NOTREACHED();
return nullptr;
#endif
}
} // namespace ui
......@@ -15,6 +15,7 @@
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/clipboard/clipboard_buffer.h"
#include "ui/base/clipboard/clipboard_constants.h"
......@@ -294,6 +295,8 @@ class ClipboardOzone::AsyncClipboardOzone {
DISALLOW_COPY_AND_ASSIGN(AsyncClipboardOzone);
};
// Uses the factory in the clipboard_linux otherwise.
#if defined(OS_CHROMEOS) || !defined(OS_LINUX)
// Clipboard factory method.
Clipboard* Clipboard::Create() {
// linux-chromeos uses non-backed clipboard by default, but supports ozone x11
......@@ -306,6 +309,7 @@ Clipboard* Clipboard::Create() {
#endif
return new ClipboardOzone;
}
#endif
// ClipboardOzone implementation.
ClipboardOzone::ClipboardOzone() {
......
......@@ -46,6 +46,7 @@
#endif
#if defined(USE_X11)
#include "ui/base/ui_base_features.h"
#include "ui/events/platform/platform_event_source.h"
#endif
......@@ -67,7 +68,8 @@ class ClipboardTest : public PlatformTest {
void SetUp() override {
PlatformTest::SetUp();
#if defined(USE_X11)
event_source_ = ClipboardTraits::GetEventSource();
if (!features::IsUsingOzonePlatform())
event_source_ = ClipboardTraits::GetEventSource();
#endif
clipboard_ = ClipboardTraits::Create();
}
......
......@@ -511,12 +511,6 @@ bool ClipboardX11::X11Details::DispatchXEvent(x11::Event* x11_event) {
return false;
}
///////////////////////////////////////////////////////////////////////////////
// Clipboard factory method.
Clipboard* Clipboard::Create() {
return new ClipboardX11;
}
///////////////////////////////////////////////////////////////////////////////
// ClipboardX11
......
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