OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_OVERVIEW_WINDOW_SELECTOR_H_ | 5 #ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "ui/aura/window_observer.h" | 16 #include "ui/aura/window_observer.h" |
17 #include "ui/aura/window_tracker.h" | |
18 #include "ui/events/event_handler.h" | |
19 #include "ui/gfx/display_observer.h" | |
20 #include "ui/gfx/rect.h" | |
flackr
2014/05/15 21:28:14
This doesn't seem to be used directly.
| |
17 #include "ui/wm/public/activation_change_observer.h" | 21 #include "ui/wm/public/activation_change_observer.h" |
18 | 22 |
19 namespace aura { | 23 namespace aura { |
20 class RootWindow; | 24 class RootWindow; |
25 class Window; | |
26 namespace client { | |
27 class CursorClient; | |
28 } // namespace client | |
29 } // namespace aura | |
30 | |
31 namespace ui { | |
32 class LocatedEvent; | |
33 } | |
34 | |
35 namespace views { | |
36 class Widget; | |
21 } | 37 } |
22 | 38 |
23 namespace ash { | 39 namespace ash { |
24 class WindowOverview; | |
25 class WindowSelectorDelegate; | 40 class WindowSelectorDelegate; |
26 class WindowSelectorItem; | 41 class WindowSelectorItem; |
27 class WindowSelectorTest; | 42 class WindowSelectorTest; |
28 | 43 |
29 // The WindowSelector allows selecting a window by clicking or tapping on it | 44 // The WindowSelector shows a grid of all of your windows, allowing to select |
30 // (entering Overview Mode). | 45 // one by clicking or tapping on it. |
31 class ASH_EXPORT WindowSelector | 46 class ASH_EXPORT WindowSelector |
32 : public aura::WindowObserver, | 47 : public ui::EventHandler, |
48 public gfx::DisplayObserver, | |
49 public aura::WindowObserver, | |
33 public aura::client::ActivationChangeObserver { | 50 public aura::client::ActivationChangeObserver { |
34 public: | 51 public: |
35 typedef std::vector<aura::Window*> WindowList; | 52 typedef std::vector<aura::Window*> WindowList; |
53 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; | |
36 | 54 |
37 WindowSelector(const WindowList& windows, | 55 WindowSelector(const WindowList& windows, |
38 WindowSelectorDelegate* delegate); | 56 WindowSelectorDelegate* delegate); |
39 virtual ~WindowSelector(); | 57 virtual ~WindowSelector(); |
40 | 58 |
41 // Choose |window| from the available windows to select. | 59 // Choose |window| from the available windows to select. |
42 void SelectWindow(aura::Window* window); | 60 void SelectWindow(aura::Window* window); |
43 | 61 |
44 // Cancels window selection. | 62 // Cancels window selection. |
45 void CancelSelection(); | 63 void CancelSelection(); |
46 | 64 |
65 // ui::EventHandler: | |
66 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | |
67 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | |
68 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | |
69 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | |
70 | |
71 // gfx::DisplayObserver: | |
72 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; | |
73 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; | |
74 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; | |
75 | |
47 // aura::WindowObserver: | 76 // aura::WindowObserver: |
48 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; | 77 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; |
49 virtual void OnWindowBoundsChanged(aura::Window* window, | 78 virtual void OnWindowBoundsChanged(aura::Window* window, |
50 const gfx::Rect& old_bounds, | 79 const gfx::Rect& old_bounds, |
51 const gfx::Rect& new_bounds) OVERRIDE; | 80 const gfx::Rect& new_bounds) OVERRIDE; |
52 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 81 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
53 | 82 |
54 // Overridden from aura::client::ActivationChangeObserver: | 83 // Overridden from aura::client::ActivationChangeObserver: |
flackr
2014/05/15 21:28:14
nit: Can you change this to match the override com
| |
55 virtual void OnWindowActivated(aura::Window* gained_active, | 84 virtual void OnWindowActivated(aura::Window* gained_active, |
56 aura::Window* lost_active) OVERRIDE; | 85 aura::Window* lost_active) OVERRIDE; |
57 virtual void OnAttemptToReactivateWindow( | 86 virtual void OnAttemptToReactivateWindow( |
58 aura::Window* request_active, | 87 aura::Window* request_active, |
59 aura::Window* actual_active) OVERRIDE; | 88 aura::Window* actual_active) OVERRIDE; |
60 | 89 |
61 private: | 90 private: |
62 friend class WindowSelectorTest; | 91 friend class WindowSelectorTest; |
63 | 92 |
64 // Begins positioning windows such that all windows are visible on the screen. | 93 // Begins positioning windows such that all windows are visible on the screen. |
65 void StartOverview(); | 94 void StartOverview(); |
66 | 95 |
96 // Position all of the windows based on the current selection mode. | |
97 void PositionWindows(bool animate); | |
98 // Position all of the windows from |root_window| on |root_window|. | |
99 void PositionWindowsFromRoot(aura::Window* root_window, bool animate); | |
100 | |
67 // Resets the stored window from RemoveFocusAndSetRestoreWindow to NULL. If | 101 // Resets the stored window from RemoveFocusAndSetRestoreWindow to NULL. If |
102 // Hide and track all hidden windows not in overview. | |
103 void HideAndTrackNonOverviewWindows(); | |
104 | |
68 // |focus|, restores focus to the stored window. | 105 // |focus|, restores focus to the stored window. |
69 void ResetFocusRestoreWindow(bool focus); | 106 void ResetFocusRestoreWindow(bool focus); |
70 | 107 |
108 // Returns the target of |event| or NULL if the event is not targeted at | |
109 // any of the windows in the selector. | |
110 aura::Window* GetEventTarget(ui::LocatedEvent* event); | |
111 | |
112 // Returns the top-level window selected by targeting |window| or NULL if | |
113 // no overview window was found for |window|. | |
114 aura::Window* GetTargetedWindow(aura::Window* window); | |
115 | |
71 // The collection of items in the overview wrapped by a helper class which | 116 // The collection of items in the overview wrapped by a helper class which |
72 // restores their state and helps transform them to other root windows. | 117 // restores their state and helps transform them to other root windows. |
73 ScopedVector<WindowSelectorItem> windows_; | 118 ScopedVector<WindowSelectorItem> windows_; |
74 | 119 |
75 // Tracks observed windows. | 120 // Tracks observed windows. |
76 std::set<aura::Window*> observed_windows_; | 121 std::set<aura::Window*> observed_windows_; |
77 | 122 |
78 scoped_ptr<WindowOverview> window_overview_; | |
79 | |
80 // Weak pointer to the selector delegate which will be called when a | 123 // Weak pointer to the selector delegate which will be called when a |
81 // selection is made. | 124 // selection is made. |
82 WindowSelectorDelegate* delegate_; | 125 WindowSelectorDelegate* delegate_; |
83 | 126 |
84 // A weak pointer to the window which was focused on beginning window | 127 // A weak pointer to the window which was focused on beginning window |
85 // selection. If window selection is canceled the focus should be restored to | 128 // selection. If window selection is canceled the focus should be restored to |
86 // this window. | 129 // this window. |
87 aura::Window* restore_focus_window_; | 130 aura::Window* restore_focus_window_; |
88 | 131 |
89 // True when performing operations that may cause window activations. This is | 132 // True when performing operations that may cause window activations. This is |
90 // used to prevent handling the resulting expected activation. | 133 // used to prevent handling the resulting expected activation. |
91 bool ignore_activations_; | 134 bool ignore_activations_; |
92 | 135 |
136 // The cursor client used to lock the current cursor during overview. | |
137 aura::client::CursorClient* cursor_client_; | |
138 | |
139 // Widget indicating which window is currently selected. | |
140 scoped_ptr<views::Widget> selection_widget_; | |
141 | |
142 // Index of the currently selected window. This is used to determine when the | |
143 // selection changes rows and use a different animation. | |
144 size_t selection_index_; | |
145 | |
146 // The time when overview was started. | |
147 base::Time overview_start_time_; | |
148 | |
149 // Tracks windows which were hidden because they were not part of the | |
150 // overview. | |
151 aura::WindowTracker hidden_windows_; | |
152 | |
93 DISALLOW_COPY_AND_ASSIGN(WindowSelector); | 153 DISALLOW_COPY_AND_ASSIGN(WindowSelector); |
94 }; | 154 }; |
95 | 155 |
96 } // namespace ash | 156 } // namespace ash |
97 | 157 |
98 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 158 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
OLD | NEW |