| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <map> |
| 6 |
| 5 #include "ash/ash_export.h" | 7 #include "ash/ash_export.h" |
| 6 #include "ash/common/pointer_watcher_delegate.h" | 8 #include "ash/common/pointer_watcher_delegate.h" |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 8 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 9 #include "ui/events/event_handler.h" | 11 #include "ui/events/event_handler.h" |
| 10 | 12 |
| 11 namespace gfx { | 13 namespace gfx { |
| 12 class Point; | 14 class Point; |
| 13 } | 15 } |
| 14 | 16 |
| 15 namespace ui { | 17 namespace ui { |
| 16 class LocatedEvent; | 18 class LocatedEvent; |
| 17 } | 19 } |
| 18 | 20 |
| 19 namespace views { | 21 namespace views { |
| 20 class Widget; | 22 class Widget; |
| 21 } | 23 } |
| 22 | 24 |
| 23 namespace ash { | 25 namespace ash { |
| 24 | 26 |
| 25 // Support for PointerWatchers in non-mus ash, implemented with a pre-target | 27 // Support for PointerWatchers in non-mus ash, implemented with a pre-target |
| 26 // EventHandler on the Shell. | 28 // EventHandler on the Shell. |
| 27 class ASH_EXPORT PointerWatcherDelegateAura : public PointerWatcherDelegate, | 29 class ASH_EXPORT PointerWatcherDelegateAura : public PointerWatcherDelegate, |
| 28 public ui::EventHandler { | 30 public ui::EventHandler { |
| 29 public: | 31 public: |
| 30 PointerWatcherDelegateAura(); | 32 PointerWatcherDelegateAura(); |
| 31 ~PointerWatcherDelegateAura() override; | 33 ~PointerWatcherDelegateAura() override; |
| 32 | 34 |
| 33 // PointerWatcherDelegate: | 35 // PointerWatcherDelegate: |
| 34 void AddPointerWatcher(views::PointerWatcher* watcher) override; | 36 void AddPointerWatcher(views::PointerWatcher* watcher, |
| 37 bool wants_moves = false) override; |
| 35 void RemovePointerWatcher(views::PointerWatcher* watcher) override; | 38 void RemovePointerWatcher(views::PointerWatcher* watcher) override; |
| 36 | 39 |
| 37 // ui::EventHandler: | 40 // ui::EventHandler: |
| 38 void OnMouseEvent(ui::MouseEvent* event) override; | 41 void OnMouseEvent(ui::MouseEvent* event) override; |
| 39 void OnTouchEvent(ui::TouchEvent* event) override; | 42 void OnTouchEvent(ui::TouchEvent* event) override; |
| 40 | 43 |
| 41 private: | 44 private: |
| 42 gfx::Point GetLocationInScreen(const ui::LocatedEvent& event) const; | 45 gfx::Point GetLocationInScreen(const ui::LocatedEvent& event) const; |
| 43 views::Widget* GetTargetWidget(const ui::LocatedEvent& event) const; | 46 views::Widget* GetTargetWidget(const ui::LocatedEvent& event) const; |
| 44 | 47 |
| 45 // Must be empty on destruction. | 48 // Must be empty on destruction. |
| 46 base::ObserverList<views::PointerWatcher, true> pointer_watchers_; | 49 base::ObserverList<views::PointerWatcher, true> pointer_watchers_; |
| 47 | 50 |
| 51 // Map stores the pointer watchers that want mouse move events. |
| 52 std::map<views::PointerWatcher*, bool> wants_moves_map_; |
| 53 |
| 48 DISALLOW_COPY_AND_ASSIGN(PointerWatcherDelegateAura); | 54 DISALLOW_COPY_AND_ASSIGN(PointerWatcherDelegateAura); |
| 49 }; | 55 }; |
| 50 | 56 |
| 51 } // namespace ash | 57 } // namespace ash |
| OLD | NEW |