Commit 82ff17de authored by Nick Diego Yamane's avatar Nick Diego Yamane Committed by Commit Bot

exo: Fix cast linux builds

Restrict extended-drag extension to OS_CHROMEOS as it depends directly
into some ash components, which are not included in cast product builds.

R=oshima@chromium.org, spang@chromium.org

Bug: 1099418, 1146150
Change-Id: I5269825917ce9343e438aaabb9b11f560187ac0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521694
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824949}
parent ffad4ce0
......@@ -33,10 +33,6 @@ static_library("exo") {
"display.h",
"drag_drop_operation.cc",
"drag_drop_operation.h",
"extended_drag_offer.cc",
"extended_drag_offer.h",
"extended_drag_source.cc",
"extended_drag_source.h",
"frame_sink_resource_manager.cc",
"frame_sink_resource_manager.h",
"input_trace.h",
......@@ -139,6 +135,10 @@ static_library("exo") {
"client_controlled_accelerators.h",
"client_controlled_shell_surface.cc",
"client_controlled_shell_surface.h",
"extended_drag_offer.cc",
"extended_drag_offer.h",
"extended_drag_source.cc",
"extended_drag_source.h",
"gamepad.cc",
"gamepad.h",
"gamepad_observer.h",
......
......@@ -10,7 +10,6 @@
#include "base/threading/sequenced_task_runner_handle.h"
#include "components/exo/data_offer.h"
#include "components/exo/data_source.h"
#include "components/exo/extended_drag_source.h"
#include "components/exo/seat.h"
#include "components/exo/surface.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
......@@ -29,6 +28,7 @@
#if defined(OS_CHROMEOS)
#include "ash/drag_drop/drag_drop_controller.h"
#include "components/exo/extended_drag_source.h"
#endif // defined(OS_CHROMEOS)
namespace exo {
......@@ -88,10 +88,9 @@ base::WeakPtr<DragDropOperation> DragDropOperation::Create(
Surface* origin,
Surface* icon,
const gfx::PointF& drag_start_point,
ui::mojom::DragEventSource event_source,
ExtendedDragSource* extended_drag_source) {
ui::mojom::DragEventSource event_source) {
auto* dnd_op = new DragDropOperation(source, origin, icon, drag_start_point,
event_source, extended_drag_source);
event_source);
return dnd_op->weak_ptr_factory_.GetWeakPtr();
}
......@@ -99,15 +98,13 @@ DragDropOperation::DragDropOperation(DataSource* source,
Surface* origin,
Surface* icon,
const gfx::PointF& drag_start_point,
ui::mojom::DragEventSource event_source,
ExtendedDragSource* extended_drag_source)
ui::mojom::DragEventSource event_source)
: SurfaceTreeHost("ExoDragDropOperation"),
source_(std::make_unique<ScopedDataSource>(source, this)),
origin_(std::make_unique<ScopedSurface>(origin, this)),
drag_start_point_(drag_start_point),
os_exchange_data_(std::make_unique<ui::OSExchangeData>()),
event_source_(event_source),
extended_drag_source_(extended_drag_source) {
event_source_(event_source) {
aura::Window* root_window = origin_->get()->window()->GetRootWindow();
DCHECK(root_window);
#if defined(OS_CHROMEOS)
......@@ -123,13 +120,14 @@ DragDropOperation::DragDropOperation(DataSource* source,
drag_drop_controller_->AddObserver(this);
if (extended_drag_source_) {
#if defined(OS_CHROMEOS)
extended_drag_source_ = ExtendedDragSource::Get();
if (extended_drag_source_) {
drag_drop_controller_->set_toplevel_window_drag_delegate(
extended_drag_source_);
#endif
extended_drag_source_->AddObserver(this);
}
#endif
if (icon)
icon_ = std::make_unique<ScopedSurface>(icon, this);
......@@ -169,10 +167,10 @@ DragDropOperation::~DragDropOperation() {
if (drag_drop_controller_->IsDragDropInProgress() && started_by_this_object_)
drag_drop_controller_->DragCancel();
if (extended_drag_source_) {
extended_drag_source_->RemoveObserver(this);
extended_drag_source_ = nullptr;
}
#if defined(OS_CHROMEOS)
if (extended_drag_source_)
ResetExtendedDragSource();
#endif
}
void DragDropOperation::AbortIfPending() {
......@@ -348,17 +346,19 @@ void DragDropOperation::OnDragActionsChanged(int actions) {
source_->get()->Action(dnd_action);
}
#endif
void DragDropOperation::OnExtendedDragSourceDestroying(
ExtendedDragSource* source) {
ResetExtendedDragSource();
}
void DragDropOperation::ResetExtendedDragSource() {
DCHECK(extended_drag_source_);
extended_drag_source_->RemoveObserver(this);
#if defined(OS_CHROMEOS)
drag_drop_controller_->set_toplevel_window_drag_delegate(nullptr);
#endif
extended_drag_source_ = nullptr;
}
#endif
void DragDropOperation::OnSurfaceDestroying(Surface* surface) {
DCHECK(surface == origin_->get() || surface == icon_->get());
......
......@@ -8,7 +8,6 @@
#include "components/exo/data_device.h"
#include "components/exo/data_offer_observer.h"
#include "components/exo/data_source_observer.h"
#include "components/exo/extended_drag_source.h"
#include "components/exo/surface_observer.h"
#include "components/exo/surface_tree_host.h"
#include "components/exo/wm_helper.h"
......@@ -16,6 +15,10 @@
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-forward.h"
#include "ui/gfx/geometry/point_f.h"
#if defined(OS_CHROMEOS)
#include "components/exo/extended_drag_source.h"
#endif
namespace ash {
class DragDropController;
} // namespace ash
......@@ -35,7 +38,6 @@ class CopyOutputResult;
}
namespace exo {
class ExtendedDragSource;
class ScopedDataSource;
// This class represents an ongoing drag-drop operation started by an exo
......@@ -46,8 +48,10 @@ class ScopedDataSource;
class DragDropOperation : public DataSourceObserver,
public SurfaceTreeHost,
public SurfaceObserver,
public aura::client::DragDropClientObserver,
public ExtendedDragSource::Observer {
#if defined(OS_CHROMEOS)
public ExtendedDragSource::Observer,
#endif
public aura::client::DragDropClientObserver {
public:
// Create an operation for a drag-drop originating from a wayland app.
static base::WeakPtr<DragDropOperation> Create(
......@@ -55,8 +59,7 @@ class DragDropOperation : public DataSourceObserver,
Surface* origin,
Surface* icon,
const gfx::PointF& drag_start_point,
ui::mojom::DragEventSource event_source,
ExtendedDragSource* extended_drag_source);
ui::mojom::DragEventSource event_source);
// Abort the operation if it hasn't been started yet, otherwise do nothing.
void AbortIfPending();
......@@ -75,10 +78,10 @@ class DragDropOperation : public DataSourceObserver,
void OnDragEnded() override;
#if defined(OS_CHROMEOS)
void OnDragActionsChanged(int actions) override;
#endif
// ExtendedDragSource::Observer:
void OnExtendedDragSourceDestroying(ExtendedDragSource* source) override;
#endif
private:
// A private constructor and destructor are used to prevent anyone else from
......@@ -87,8 +90,7 @@ class DragDropOperation : public DataSourceObserver,
Surface* origin,
Surface* icon,
const gfx::PointF& drag_start_point,
ui::mojom::DragEventSource event_source,
ExtendedDragSource* extended_drag_source);
ui::mojom::DragEventSource event_source);
~DragDropOperation() override;
void CaptureDragIcon();
......@@ -105,7 +107,9 @@ class DragDropOperation : public DataSourceObserver,
// directly. Use ScheduleStartDragDropOperation instead.
void StartDragDropOperation();
void ResetSource();
#if defined(OS_CHROMEOS)
void ResetExtendedDragSource();
#endif
std::unique_ptr<ScopedDataSource> source_;
std::unique_ptr<ScopedSurface> icon_;
......@@ -134,7 +138,9 @@ class DragDropOperation : public DataSourceObserver,
ui::mojom::DragEventSource event_source_;
#if defined(OS_CHROMEOS)
ExtendedDragSource* extended_drag_source_;
#endif
base::WeakPtrFactory<DragDropOperation> weak_ptr_factory_{this};
......
......@@ -105,7 +105,7 @@ TEST_F(DragDropOperationTest, DeleteDuringDragging) {
auto operation = DragDropOperation::Create(
data_source.get(), origin_surface.get(), icon_surface.get(),
gfx::PointF(), ui::mojom::DragEventSource::kMouse, nullptr);
gfx::PointF(), ui::mojom::DragEventSource::kMouse);
icon_surface->Commit();
base::RunLoop run_loop;
......
......@@ -9,12 +9,12 @@
#include "ash/shell.h"
#include "ash/wm/toplevel_window_event_handler.h"
#include "base/check.h"
#include "base/check_op.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/optional.h"
#include "components/exo/data_source.h"
#include "components/exo/seat.h"
#include "components/exo/surface.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window_observer.h"
......@@ -33,6 +33,9 @@
namespace exo {
// static
ExtendedDragSource* ExtendedDragSource::instance_ = nullptr;
// Internal representation of a toplevel window, backed by an Exo shell surface,
// which is being dragged. It supports both already mapped/visible windows as
// well as newly created ones (i.e: not added to a root window yet), in which
......@@ -97,16 +100,20 @@ class ExtendedDragSource::DraggedWindowHolder : public aura::WindowObserver {
aura::Window* toplevel_window_ = nullptr;
};
ExtendedDragSource::ExtendedDragSource(Seat* seat,
DataSource* source,
Delegate* delegate)
: seat_(seat), source_(source), delegate_(delegate) {
DCHECK(seat_);
// static
ExtendedDragSource* ExtendedDragSource::Get() {
return instance_;
}
ExtendedDragSource::ExtendedDragSource(DataSource* source, Delegate* delegate)
: source_(source), delegate_(delegate) {
DCHECK(source_);
DCHECK(delegate_);
seat_->set_extended_drag_source(this);
source_->AddObserver(this);
DCHECK(!instance_);
instance_ = this;
}
ExtendedDragSource::~ExtendedDragSource() {
......@@ -114,9 +121,11 @@ ExtendedDragSource::~ExtendedDragSource() {
for (auto& observer : observers_)
observer.OnExtendedDragSourceDestroying(this);
seat_->set_extended_drag_source(nullptr);
if (source_)
source_->RemoveObserver(this);
DCHECK_EQ(instance_, this);
instance_ = nullptr;
}
void ExtendedDragSource::AddObserver(Observer* observer) {
......
......@@ -33,7 +33,6 @@ class LocatedEvent;
namespace exo {
class DataSource;
class Seat;
class Surface;
class ExtendedDragSource : public DataSourceObserver,
......@@ -60,7 +59,9 @@ class ExtendedDragSource : public DataSourceObserver,
virtual ~Observer() = default;
};
ExtendedDragSource(Seat* seat, DataSource* source, Delegate* delegate);
static ExtendedDragSource* Get();
ExtendedDragSource(DataSource* source, Delegate* delegate);
ExtendedDragSource(const ExtendedDragSource&) = delete;
ExtendedDragSource& operator=(const ExtendedDragSource&) = delete;
~ExtendedDragSource() override;
......@@ -96,7 +97,8 @@ class ExtendedDragSource : public DataSourceObserver,
gfx::Point CalculateOrigin(aura::Window* target) const;
void Cleanup();
Seat* const seat_;
static ExtendedDragSource* instance_;
DataSource* source_ = nullptr;
// Created and destroyed at wayland/zcr_extended_drag.cc and its lifetime is
......
......@@ -114,11 +114,10 @@ class ExtendedDragSourceTest : public test::ExoTestBase {
seat_ = std::make_unique<Seat>();
data_source_ = std::make_unique<DataSource>(new TestDataSourceDelegate);
extended_drag_source_ =
std::make_unique<ExtendedDragSource>(seat_.get(), data_source_.get(),
new TestExtendedDragSourceDelegate(
/*allow_drop_no_target=*/true,
/*lock_cursor=*/true));
extended_drag_source_ = std::make_unique<ExtendedDragSource>(
data_source_.get(), new TestExtendedDragSourceDelegate(
/*allow_drop_no_target=*/true,
/*lock_cursor=*/true));
}
void TearDown() override {
......
......@@ -20,7 +20,6 @@
#include "base/task/post_task.h"
#include "components/exo/data_source.h"
#include "components/exo/drag_drop_operation.h"
#include "components/exo/extended_drag_source.h"
#include "components/exo/mime_utils.h"
#include "components/exo/seat_observer.h"
#include "components/exo/shell_surface_util.h"
......@@ -111,9 +110,8 @@ void Seat::StartDrag(DataSource* source,
Surface* icon,
ui::mojom::DragEventSource event_source) {
// DragDropOperation manages its own lifetime.
drag_drop_operation_ =
DragDropOperation::Create(source, origin, icon, last_pointer_location_,
event_source, extended_drag_source_);
drag_drop_operation_ = DragDropOperation::Create(
source, origin, icon, last_pointer_location_, event_source);
}
void Seat::SetLastPointerLocation(const gfx::PointF& last_pointer_location) {
......
......@@ -31,7 +31,6 @@ class KeyEvent;
namespace exo {
class DragDropOperation;
class ExtendedDragSource;
class ScopedDataSource;
class SeatObserver;
class Surface;
......@@ -116,11 +115,6 @@ class Seat : public aura::client::FocusChangeObserver,
void OnKeyboardLayoutNameChanged(const std::string& layout_name) override;
#endif
void set_extended_drag_source(ExtendedDragSource* extended_drag_source) {
DCHECK(!extended_drag_source || !extended_drag_source_);
extended_drag_source_ = extended_drag_source;
}
void set_physical_code_for_currently_processing_event_for_testing(
ui::DomCode physical_code_for_currently_processing_event) {
physical_code_for_currently_processing_event_ =
......@@ -190,8 +184,6 @@ class Seat : public aura::client::FocusChangeObserver,
std::unique_ptr<XkbTracker> xkb_tracker_;
#endif // defined(OS_CHROMEOS)
ExtendedDragSource* extended_drag_source_ = nullptr;
base::WeakPtrFactory<Seat> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(Seat);
......
......@@ -49,8 +49,6 @@ source_set("wayland") {
"zaura_shell.h",
"zcr_alpha_compositing.cc",
"zcr_alpha_compositing.h",
"zcr_extended_drag.cc",
"zcr_extended_drag.h",
"zcr_secure_output.cc",
"zcr_secure_output.h",
"zcr_stylus.cc",
......@@ -156,6 +154,8 @@ source_set("wayland") {
"zcr_color_space.h",
"zcr_cursor_shapes.cc",
"zcr_cursor_shapes.h",
"zcr_extended_drag.cc",
"zcr_extended_drag.h",
"zcr_gaming_input.cc",
"zcr_gaming_input.h",
"zcr_keyboard_configuration.cc",
......
......@@ -16,7 +16,6 @@
#include "components/exo/display.h"
#include "components/exo/extended_drag_offer.h"
#include "components/exo/extended_drag_source.h"
#include "components/exo/seat.h"
#include "components/exo/surface.h"
#include "components/exo/wayland/server_util.h"
#include "ui/gfx/geometry/vector2d.h"
......@@ -144,7 +143,6 @@ void extended_drag_get_extended_drag_source(wl_client* client,
uint32_t id,
wl_resource* data_source_resource,
uint32_t settings) {
Display* display = GetUserDataAs<Display>(resource);
DataSource* source = GetUserDataAs<DataSource>(data_source_resource);
wl_resource* extended_drag_source_resource =
......@@ -154,9 +152,8 @@ void extended_drag_get_extended_drag_source(wl_client* client,
SetImplementation(extended_drag_source_resource,
&extended_drag_source_implementation,
std::make_unique<ExtendedDragSource>(
display->seat(), source,
new ZcrExtendedDragSourceDelegate(
extended_drag_source_resource, settings)));
source, new ZcrExtendedDragSourceDelegate(
extended_drag_source_resource, settings)));
}
void extended_drag_get_extended_drag_offer(wl_client* client,
......
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