| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef UI_VIEWS_EVENT_MONITOR_H_ | 5 #ifndef UI_VIEWS_EVENT_MONITOR_H_ |
| 6 #define UI_VIEWS_EVENT_MONITOR_H_ | 6 #define UI_VIEWS_EVENT_MONITOR_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include <memory> |
| 9 |
| 9 #include "ui/gfx/geometry/point.h" | 10 #include "ui/gfx/geometry/point.h" |
| 10 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
| 11 #include "ui/views/views_export.h" | 12 #include "ui/views/views_export.h" |
| 12 | 13 |
| 13 namespace ui { | 14 namespace ui { |
| 14 class EventHandler; | 15 class EventHandler; |
| 15 } | 16 } |
| 16 | 17 |
| 17 namespace views { | 18 namespace views { |
| 18 | 19 |
| 19 // RAII-style class that forwards events to |event_handler| before they are | 20 // RAII-style class that forwards events to |event_handler| before they are |
| 20 // dispatched. | 21 // dispatched. |
| 21 class VIEWS_EXPORT EventMonitor { | 22 class VIEWS_EXPORT EventMonitor { |
| 22 public: | 23 public: |
| 23 virtual ~EventMonitor() {} | 24 virtual ~EventMonitor() {} |
| 24 | 25 |
| 25 // Create an instance for monitoring application events. | 26 // Create an instance for monitoring application events. |
| 26 // Events will be forwarded to |event_handler| before they are dispatched to | 27 // Events will be forwarded to |event_handler| before they are dispatched to |
| 27 // the application. | 28 // the application. |
| 28 static scoped_ptr<EventMonitor> CreateApplicationMonitor( | 29 static std::unique_ptr<EventMonitor> CreateApplicationMonitor( |
| 29 ui::EventHandler* event_handler); | 30 ui::EventHandler* event_handler); |
| 30 | 31 |
| 31 // Create an instance for monitoring events on a specific window. | 32 // Create an instance for monitoring events on a specific window. |
| 32 // Events will be forwarded to |event_handler| before they are dispatched to | 33 // Events will be forwarded to |event_handler| before they are dispatched to |
| 33 // |target_window|. | 34 // |target_window|. |
| 34 // The EventMonitor instance must be destroyed before |target_window|. | 35 // The EventMonitor instance must be destroyed before |target_window|. |
| 35 static scoped_ptr<EventMonitor> CreateWindowMonitor( | 36 static std::unique_ptr<EventMonitor> CreateWindowMonitor( |
| 36 ui::EventHandler* event_handler, | 37 ui::EventHandler* event_handler, |
| 37 gfx::NativeWindow target_window); | 38 gfx::NativeWindow target_window); |
| 38 | 39 |
| 39 // Returns the last mouse location seen in a mouse event in screen | 40 // Returns the last mouse location seen in a mouse event in screen |
| 40 // coordinates. | 41 // coordinates. |
| 41 static gfx::Point GetLastMouseLocation(); | 42 static gfx::Point GetLastMouseLocation(); |
| 42 }; | 43 }; |
| 43 | 44 |
| 44 } // namespace views | 45 } // namespace views |
| 45 | 46 |
| 46 #endif // UI_VIEWS_EVENT_MONITOR_H_ | 47 #endif // UI_VIEWS_EVENT_MONITOR_H_ |
| OLD | NEW |