OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ | 5 #ifndef ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ |
6 #define ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ | 6 #define ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "ash/display/display_controller.h" |
11 #include "base/callback.h" | 12 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "ui/aura/client/window_move_client.h" | 15 #include "ui/aura/client/window_move_client.h" |
15 #include "ui/base/events/event_handler.h" | 16 #include "ui/base/events/event_handler.h" |
16 #include "ui/gfx/point.h" | 17 #include "ui/gfx/point.h" |
17 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
18 | 19 |
19 namespace aura { | 20 namespace aura { |
20 class Window; | 21 class Window; |
21 } | 22 } |
22 | 23 |
23 namespace ui { | 24 namespace ui { |
24 class LocatedEvent; | 25 class LocatedEvent; |
25 } | 26 } |
26 | 27 |
27 namespace ash { | 28 namespace ash { |
28 | 29 |
29 class WindowResizer; | 30 class WindowResizer; |
30 | 31 |
31 class ASH_EXPORT ToplevelWindowEventHandler | 32 class ASH_EXPORT ToplevelWindowEventHandler |
32 : public ui::EventHandler, | 33 : public ui::EventHandler, |
33 public aura::client::WindowMoveClient { | 34 public aura::client::WindowMoveClient, |
| 35 public DisplayController::Observer { |
34 public: | 36 public: |
35 explicit ToplevelWindowEventHandler(aura::Window* owner); | 37 explicit ToplevelWindowEventHandler(aura::Window* owner); |
36 virtual ~ToplevelWindowEventHandler(); | 38 virtual ~ToplevelWindowEventHandler(); |
37 | 39 |
38 // Overridden from ui::EventHandler: | 40 // Overridden from ui::EventHandler: |
39 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | 41 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
40 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 42 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
41 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 43 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
42 virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | 44 virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* event) OVERRIDE; |
43 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 45 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
44 | 46 |
45 // Overridden form aura::client::WindowMoveClient: | 47 // Overridden form aura::client::WindowMoveClient: |
46 virtual void RunMoveLoop(aura::Window* source, | 48 virtual aura::client::WindowMoveResult RunMoveLoop( |
47 const gfx::Point& drag_offset) OVERRIDE; | 49 aura::Window* source, |
| 50 const gfx::Point& drag_offset) OVERRIDE; |
48 virtual void EndMoveLoop() OVERRIDE; | 51 virtual void EndMoveLoop() OVERRIDE; |
49 | 52 |
| 53 // Overridden form ash::DisplayController::Observer: |
| 54 virtual void OnDisplayConfigurationChanging() OVERRIDE; |
| 55 |
50 protected: | 56 protected: |
51 // Creates a new WindowResizer. | 57 // Creates a new WindowResizer. |
52 virtual WindowResizer* CreateWindowResizer(aura::Window* window, | 58 virtual WindowResizer* CreateWindowResizer(aura::Window* window, |
53 const gfx::Point& point_in_parent, | 59 const gfx::Point& point_in_parent, |
54 int window_component); | 60 int window_component); |
55 | 61 |
56 private: | 62 private: |
57 class ScopedWindowResizer; | 63 class ScopedWindowResizer; |
58 | 64 |
59 enum DragCompletionStatus { | 65 enum DragCompletionStatus { |
(...skipping 19 matching lines...) Expand all Loading... |
79 // Called for mouse exits to hide window resize shadows. | 85 // Called for mouse exits to hide window resize shadows. |
80 // Return value is returned by OnMouseEvent() above. | 86 // Return value is returned by OnMouseEvent() above. |
81 bool HandleMouseExited(aura::Window* target, ui::LocatedEvent* event); | 87 bool HandleMouseExited(aura::Window* target, ui::LocatedEvent* event); |
82 | 88 |
83 // Invoked from ScopedWindowResizer if the window is destroyed. | 89 // Invoked from ScopedWindowResizer if the window is destroyed. |
84 void ResizerWindowDestroyed(); | 90 void ResizerWindowDestroyed(); |
85 | 91 |
86 // Are we running a nested message loop from RunMoveLoop(). | 92 // Are we running a nested message loop from RunMoveLoop(). |
87 bool in_move_loop_; | 93 bool in_move_loop_; |
88 | 94 |
| 95 // Was the move operation cancelled? Used only when the nested loop |
| 96 // is used to move a window. |
| 97 bool move_cancelled_; |
| 98 |
89 // Is a gesture-resize in progress? | 99 // Is a gesture-resize in progress? |
90 bool in_gesture_resize_; | 100 bool in_gesture_resize_; |
91 | 101 |
92 scoped_ptr<ScopedWindowResizer> window_resizer_; | 102 scoped_ptr<ScopedWindowResizer> window_resizer_; |
93 | 103 |
94 base::Closure quit_closure_; | 104 base::Closure quit_closure_; |
95 | 105 |
96 DISALLOW_COPY_AND_ASSIGN(ToplevelWindowEventHandler); | 106 DISALLOW_COPY_AND_ASSIGN(ToplevelWindowEventHandler); |
97 }; | 107 }; |
98 | 108 |
99 } // namespace aura | 109 } // namespace aura |
100 | 110 |
101 #endif // ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ | 111 #endif // ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ |
OLD | NEW |