| Index: services/ui/public/cpp/window_tree_client.cc
|
| diff --git a/services/ui/public/cpp/window_tree_client.cc b/services/ui/public/cpp/window_tree_client.cc
|
| index a997f0b8ab785b7e1027240576a4fe8dab415c5f..0ea883964023621aef3b516cb816d582820e6b71 100644
|
| --- a/services/ui/public/cpp/window_tree_client.cc
|
| +++ b/services/ui/public/cpp/window_tree_client.cc
|
| @@ -16,6 +16,7 @@
|
| #include "services/ui/common/util.h"
|
| #include "services/ui/public/cpp/in_flight_change.h"
|
| #include "services/ui/public/cpp/input_event_handler.h"
|
| +#include "services/ui/public/cpp/window_drop_target.h"
|
| #include "services/ui/public/cpp/window_manager_delegate.h"
|
| #include "services/ui/public/cpp/window_observer.h"
|
| #include "services/ui/public/cpp/window_private.h"
|
| @@ -644,6 +645,24 @@ void WindowTreeClient::StopPointerWatcher() {
|
| has_pointer_watcher_ = false;
|
| }
|
|
|
| +void WindowTreeClient::PerformDragDrop(
|
| + Window* window,
|
| + const std::map<std::string, std::vector<uint8_t>>& drag_data,
|
| + int drag_operation,
|
| + const gfx::Point& cursor_location,
|
| + const SkBitmap& bitmap,
|
| + const base::Callback<void(bool)>& callback) {
|
| + DCHECK(on_current_drag_finished_.is_null());
|
| + on_current_drag_finished_ = callback;
|
| +
|
| + current_drag_change_ =
|
| + ScheduleInFlightChange(base::MakeUnique<InFlightDragChange>(window));
|
| + tree_->PerformDragDrop(
|
| + current_drag_change_, window->server_id(),
|
| + mojo::Map<mojo::String, mojo::Array<uint8_t>>::From(drag_data),
|
| + drag_operation, cursor_location, bitmap);
|
| +}
|
| +
|
| void WindowTreeClient::PerformWindowMove(
|
| Window* window,
|
| ui::mojom::MoveLoopSource source,
|
| @@ -652,8 +671,8 @@ void WindowTreeClient::PerformWindowMove(
|
| DCHECK(on_current_move_finished_.is_null());
|
| on_current_move_finished_ = callback;
|
|
|
| - current_move_loop_change_ = ScheduleInFlightChange(
|
| - base::MakeUnique<InFlightMoveLoopChange>(window));
|
| + current_move_loop_change_ =
|
| + ScheduleInFlightChange(base::MakeUnique<InFlightDragChange>(window));
|
| // Tell the window manager to take over moving us.
|
| tree_->PerformWindowMove(current_move_loop_change_, window->server_id(),
|
| source, cursor_location);
|
| @@ -711,6 +730,11 @@ void WindowTreeClient::RemoveObserver(WindowTreeClientObserver* observer) {
|
| observers_.RemoveObserver(observer);
|
| }
|
|
|
| +void WindowTreeClient::SetCanAcceptDrags(Id window_id, bool can_accept_drags) {
|
| + DCHECK(tree_);
|
| + tree_->SetCanAcceptDrags(window_id, can_accept_drags);
|
| +}
|
| +
|
| void WindowTreeClient::SetCanAcceptEvents(Id window_id,
|
| bool can_accept_events) {
|
| DCHECK(tree_);
|
| @@ -1052,6 +1076,85 @@ void WindowTreeClient::OnWindowPredefinedCursorChanged(
|
| WindowPrivate(window).LocalSetPredefinedCursor(cursor);
|
| }
|
|
|
| +void WindowTreeClient::OnDragEnter(
|
| + Id window_id,
|
| + mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data,
|
| + uint32_t key_state,
|
| + const gfx::Point& position,
|
| + uint32_t effect_bitmask,
|
| + const OnDragEnterCallback& callback) {
|
| + Window* window = GetWindowByServerId(window_id);
|
| + if (!window) {
|
| + callback.Run(mojom::kDropEffectNone);
|
| + return;
|
| + }
|
| +
|
| + WindowDropTarget* target = window->drop_target();
|
| + if (!target) {
|
| + callback.Run(mojom::kDropEffectNone);
|
| + return;
|
| + }
|
| +
|
| + uint32_t ret = target->OnDragEnter(
|
| + mime_data.To<std::map<std::string, std::vector<uint8_t>>>(), key_state,
|
| + position, effect_bitmask);
|
| + callback.Run(ret);
|
| +}
|
| +
|
| +void WindowTreeClient::OnDragOver(Id window_id,
|
| + uint32_t key_state,
|
| + const gfx::Point& position,
|
| + uint32_t effect_bitmask,
|
| + const OnDragOverCallback& callback) {
|
| + Window* window = GetWindowByServerId(window_id);
|
| + if (!window) {
|
| + callback.Run(mojom::kDropEffectNone);
|
| + return;
|
| + }
|
| +
|
| + WindowDropTarget* target = window->drop_target();
|
| + if (!target) {
|
| + callback.Run(mojom::kDropEffectNone);
|
| + return;
|
| + }
|
| +
|
| + uint32_t ret = target->OnDragOver(key_state, position, effect_bitmask);
|
| + callback.Run(ret);
|
| +}
|
| +
|
| +void WindowTreeClient::OnDragLeave(Id window_id) {
|
| + Window* window = GetWindowByServerId(window_id);
|
| + if (!window)
|
| + return;
|
| +
|
| + WindowDropTarget* target = window->drop_target();
|
| + if (!target)
|
| + return;
|
| +
|
| + target->OnDragLeave();
|
| +}
|
| +
|
| +void WindowTreeClient::OnDragDrop(Id window_id,
|
| + uint32_t key_state,
|
| + const gfx::Point& position,
|
| + uint32_t effect_bitmask,
|
| + const OnDragDropCallback& callback) {
|
| + Window* window = GetWindowByServerId(window_id);
|
| + if (!window) {
|
| + callback.Run(mojom::kDropEffectNone);
|
| + return;
|
| + }
|
| +
|
| + WindowDropTarget* target = window->drop_target();
|
| + if (!target) {
|
| + callback.Run(mojom::kDropEffectNone);
|
| + return;
|
| + }
|
| +
|
| + uint32_t ret = target->OnDragDrop(key_state, position, effect_bitmask);
|
| + callback.Run(ret);
|
| +}
|
| +
|
| void WindowTreeClient::OnChangeCompleted(uint32_t change_id, bool success) {
|
| std::unique_ptr<InFlightChange> change(std::move(in_flight_map_[change_id]));
|
| in_flight_map_.erase(change_id);
|
| @@ -1074,6 +1177,12 @@ void WindowTreeClient::OnChangeCompleted(uint32_t change_id, bool success) {
|
| on_current_move_finished_.Run(success);
|
| on_current_move_finished_.Reset();
|
| }
|
| +
|
| + if (change_id == current_drag_change_) {
|
| + current_drag_change_ = 0;
|
| + on_current_drag_finished_.Run(success);
|
| + on_current_drag_finished_.Reset();
|
| + }
|
| }
|
|
|
| void WindowTreeClient::GetWindowManager(
|
|
|