Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Unified Diff: services/ui/ws/drag_controller.h

Issue 2376583003: mus: Keep track of the drag cursor during DnD operations. (Closed)
Patch Set: style Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/ws/BUILD.gn ('k') | services/ui/ws/drag_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/drag_controller.h
diff --git a/services/ui/ws/drag_controller.h b/services/ui/ws/drag_controller.h
index 3b781a44a2ebb43d2732ace7123f3f62b912b5e7..3862051d709903b368878a25628188d0df8a8ebb 100644
--- a/services/ui/ws/drag_controller.h
+++ b/services/ui/ws/drag_controller.h
@@ -5,6 +5,9 @@
#ifndef SERVICES_UI_WS_DRAG_CONTROLLER_H_
#define SERVICES_UI_WS_DRAG_CONTROLLER_H_
+#include <map>
+#include <set>
+
#include "base/memory/weak_ptr.h"
#include "services/ui/common/types.h"
#include "services/ui/ws/ids.h"
@@ -17,23 +20,33 @@ namespace test {
class DragControllerTestApi;
}
+class DragCursorUpdater;
class DragSource;
class DragTargetConnection;
+// A single ui::mojom::kDropEffect operation.
+using DropEffect = uint32_t;
sky 2016/09/28 20:02:38 Nice! Thanks!
+
+// A bitmask of ui::mojom::kDropEffect operations.
+using DropEffectBitmask = uint32_t;
+
// 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 DragController : public ServerWindowObserver {
public:
- DragController(DragSource* source,
+ DragController(DragCursorUpdater* cursor_updater,
+ DragSource* source,
ServerWindow* source_window,
DragTargetConnection* source_connection,
int32_t drag_pointer,
mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data,
- uint32_t drag_operations);
+ DropEffectBitmask drag_operations);
~DragController() override;
+ int32_t current_cursor() const { return current_cursor_; }
+
// Cancels the current drag, ie, due to the user pressing Escape.
void Cancel();
@@ -52,7 +65,7 @@ class DragController : public ServerWindowObserver {
// Notifies all windows we messaged that the drag is finished, and then tell
// |source| the result.
- void MessageDragCompleted(bool success, uint32_t action_taken);
+ void MessageDragCompleted(bool success, DropEffect action_taken);
// Returns the number of events on |window|. A value of 1 means that there's
// a single event outstanding that we're waiting for a response from the
@@ -64,6 +77,14 @@ class DragController : public ServerWindowObserver {
// and release ServerWindow observers correctly.
void SetCurrentTargetWindow(ServerWindow* current_target);
+ // Updates the possible cursor effects for |window|. |bitmask| is a
+ // bitmask of the current valid drag operations.
+ void SetWindowDropOperations(ServerWindow* window, DropEffectBitmask bitmask);
+
+ // Returns the ui::mojom::Cursor for the window |bitmask|, adjusted for types
+ // that the drag source allows.
+ int32_t CursorForEffectBitmask(DropEffectBitmask bitmask);
+
// Ensure that |window| has an entry in |window_state_| and that we're an
// observer.
void EnsureWindowObserved(ServerWindow* window);
@@ -76,8 +97,8 @@ class DragController : public ServerWindowObserver {
void OnRespondToOperation(ServerWindow* window);
// Callback methods.
- void OnDragStatusCompleted(const WindowId& id, uint32_t bitmask);
- void OnDragDropCompleted(const WindowId& id, uint32_t action);
+ void OnDragStatusCompleted(const WindowId& id, DropEffectBitmask bitmask);
+ void OnDragDropCompleted(const WindowId& id, DropEffect action);
// ServerWindowObserver:
void OnWindowDestroying(ServerWindow* window) override;
@@ -85,12 +106,18 @@ class DragController : public ServerWindowObserver {
// Our owner.
DragSource* source_;
+ // Object to notify about all cursor changes.
+ DragCursorUpdater* cursor_updater_;
+
// A bit-field of acceptable drag operations offered by the source.
- const uint32_t drag_operations_;
+ const DropEffectBitmask drag_operations_;
// Only act on pointer events that meet this id.
const int32_t drag_pointer_id_;
+ // The current mouse cursor during the drag.
+ int32_t current_cursor_;
+
// Sending OnDragOver() to our |source_| destroys us; there is a period where
// we have to continue to exist, but not process any more pointer events.
bool waiting_for_final_drop_response_ = false;
« no previous file with comments | « services/ui/ws/BUILD.gn ('k') | services/ui/ws/drag_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698