Chromium Code Reviews| Index: services/ui/ws/current_drag_operation.h |
| diff --git a/services/ui/ws/current_drag_operation.h b/services/ui/ws/current_drag_operation.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c2263cd5eabe8eac54d0a21bcc6165cdb7fd1cb2 |
| --- /dev/null |
| +++ b/services/ui/ws/current_drag_operation.h |
| @@ -0,0 +1,99 @@ |
| +// Copyright 2016 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. |
| + |
| +#ifndef SERVICES_UI_WS_CURRENT_DRAG_OPERATION_H_ |
| +#define SERVICES_UI_WS_CURRENT_DRAG_OPERATION_H_ |
| + |
| +#include <deque> |
| + |
| +#include "base/memory/weak_ptr.h" |
| +#include "services/ui/common/types.h" |
| +#include "services/ui/ws/ids.h" |
| +#include "services/ui/ws/server_window_observer.h" |
| + |
| +namespace ui { |
| +namespace ws { |
| + |
| +namespace test { |
| +class CurrentDragOperationTestApi; |
| +} |
| + |
| +class CurrentDragOperationSource; |
| + |
| +// Represents all the data around the current ongoing drag operation. |
| +// |
| +// There should only be one instance of this class per userid. The |
| +// WindowManagerState's EventDispatcher creates and owns this instance. |
| +class CurrentDragOperation : public ServerWindowObserver { |
|
sky
2016/09/06 21:11:27
Is 'current' really helpful in this context? Is ju
|
| + public: |
| + CurrentDragOperation(CurrentDragOperationSource* source, |
| + ServerWindow* window, |
| + mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data, |
| + uint32_t drag_operations); |
| + ~CurrentDragOperation() override; |
| + |
| + // Cancels the current drag, ie, due to the user pressing Escape. |
| + void DispatchCancel(); |
|
sky
2016/09/06 21:11:27
I would just call this Cancel().
|
| + |
| + // Responds to a pointer move/release event. |
| + void DispatchLocatedEvent(const ui::LocatedEvent& event, |
| + ServerWindow* current_target); |
| + |
| + private: |
| + friend class test::CurrentDragOperationTestApi; |
| + enum DragEventType { TYPE_ENTER, TYPE_OVER, TYPE_LEAVE, TYPE_DROP }; |
|
sky
2016/09/06 21:11:27
enum class, and nuke TYPE_?
|
| + struct Operation; |
| + |
| + // Notifies all windows we messaged that the drag is finished, and then tell |
| + // |source| the result. |
| + void MessageDragCompleted(bool success); |
| + |
| + size_t GetSizeOfQueueForWindow(ServerWindow* window); |
|
sky
2016/09/06 21:11:27
Description.
|
| + |
| + void QueueEvent(ServerWindow* window, |
| + DragEventType type, |
| + uint32_t key_state, |
| + gfx::Point position); |
| + void RemoveQueueFront(ServerWindow* window); |
| + void DispatchFrontOfWindowQueue(ServerWindow* window, |
| + std::deque<Operation>* queue); |
| + |
| + // Callback methods. |
| + void OnDragStatusCompleted(const WindowId& id, uint32_t bitmask); |
| + void OnDragDropCompleted(const WindowId& id, uint32_t bitmask); |
| + |
| + // ServerWindowObserver: |
| + void OnWindowDestroying(ServerWindow* window) override; |
| + |
| + // Our owner. |
| + CurrentDragOperationSource* source_ = nullptr; |
| + |
| + uint32_t drag_operations_; |
|
sky
2016/09/06 21:11:27
const?
|
| + |
| + bool waiting_for_final_drop_response_ = false; |
| + |
| + ServerWindow* source_window_ = nullptr; |
| + ServerWindow* current_target_window_ = nullptr; |
| + |
| + // A list of the offered mime types. |
| + mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data_; |
| + |
| + // Event queues for each window. If a vector is empty, there are no |
| + // operations going on. If a vector has one operation, we're waiting on a |
| + // response for that operation from the client. Every operation past the |
| + // first is queued. |
| + std::map<ServerWindow*, std::deque<Operation>> current_window_state_; |
|
sky
2016/09/06 21:11:27
window_operations_?
|
| + |
| + // A set of ServerWindows* which have received the PerformOnDragStart() call. |
| + std::set<ServerWindow*> called_on_drag_start_; |
| + |
| + base::WeakPtrFactory<CurrentDragOperation> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CurrentDragOperation); |
| +}; |
| + |
| +} // namespace ws |
| +} // namespace ui |
| + |
| +#endif // SERVICES_UI_WS_CURRENT_DRAG_OPERATION_H_ |