OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_VIEWS_MUS_DROP_TARGET_MUS_H_ |
| 6 #define UI_VIEWS_MUS_DROP_TARGET_MUS_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <memory> |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/macros.h" |
| 14 #include "services/ui/public/cpp/window_drop_target.h" |
| 15 #include "ui/aura/window_observer.h" |
| 16 |
| 17 namespace aura { |
| 18 class RootWindow; |
| 19 class Window; |
| 20 |
| 21 namespace client { |
| 22 class DragDropDelegate; |
| 23 } |
| 24 } |
| 25 |
| 26 namespace ui { |
| 27 class DropTargetEvent; |
| 28 class OSExchangeData; |
| 29 } |
| 30 |
| 31 namespace views { |
| 32 |
| 33 // An adapter class which takes signals from mus' WindowDropTarget, performs |
| 34 // targeting on the underlying aura::Window tree, and dispatches them to the |
| 35 // aura DragDropDelegate of the targeted aura::Window. |
| 36 class DropTargetMus : public ui::WindowDropTarget, public aura::WindowObserver { |
| 37 public: |
| 38 explicit DropTargetMus(aura::Window* root_window); |
| 39 ~DropTargetMus() override; |
| 40 |
| 41 private: |
| 42 // Common functionality for the WindowDropTarget methods to translate from |
| 43 // mus data types to Aura ones. This method takes in mus messages and |
| 44 // performs the common tasks of keeping track of which aura window (along |
| 45 // with enter/leave messages at that layer), doing coordinate translation, |
| 46 // and creation of ui layer event objects that get dispatched to aura/views. |
| 47 void Translate(uint32_t key_state, |
| 48 const gfx::Point& screen_location, |
| 49 uint32_t effect_bitmask, |
| 50 std::unique_ptr<ui::DropTargetEvent>* event, |
| 51 aura::client::DragDropDelegate** delegate); |
| 52 |
| 53 void NotifyDragExited(); |
| 54 |
| 55 // Overridden from ui::WindowDropTarget: |
| 56 void OnDragDropStart( |
| 57 std::map<std::string, std::vector<uint8_t>> mime_data) override; |
| 58 uint32_t OnDragEnter(uint32_t key_state, |
| 59 const gfx::Point& position, |
| 60 uint32_t effect_bitmask) override; |
| 61 uint32_t OnDragOver(uint32_t key_state, |
| 62 const gfx::Point& position, |
| 63 uint32_t effect_bitmask) override; |
| 64 void OnDragLeave() override; |
| 65 uint32_t OnCompleteDrop(uint32_t key_state, |
| 66 const gfx::Point& position, |
| 67 uint32_t effect_bitmask) override; |
| 68 void OnDragDropDone() override; |
| 69 |
| 70 // Overridden from aura::WindowObserver: |
| 71 void OnWindowDestroyed(aura::Window* window) override; |
| 72 |
| 73 // The root window associated with this drop target. |
| 74 aura::Window* root_window_; |
| 75 |
| 76 // The Aura window that is currently under the cursor. We need to manually |
| 77 // keep track of this because mus will only call our drag enter method once |
| 78 // when the user enters the associated mus::Window. But inside mus there |
| 79 // could be multiple aura windows, so we need to generate drag enter events |
| 80 // for them. |
| 81 aura::Window* target_window_; |
| 82 |
| 83 // The entire drag data payload. We receive this during the drag enter event |
| 84 // and cache it so we don't send this multiple times. We reset this value on |
| 85 // leave or drop. |
| 86 std::unique_ptr<ui::OSExchangeData> os_exchange_data_; |
| 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(DropTargetMus); |
| 89 }; |
| 90 |
| 91 } // namespace views |
| 92 |
| 93 #endif // UI_VIEWS_MUS_DROP_TARGET_MUS_H_ |
OLD | NEW |