Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: ash/wm/overview/window_selector.h

Issue 260883005: Separated alt-tab window cycle from overview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/wm/public/activation_change_observer.h" 17 #include "ui/wm/public/activation_change_observer.h"
18 18
19 namespace aura { 19 namespace aura {
20 class RootWindow; 20 class RootWindow;
21 } 21 }
22 22
23 namespace ui {
24 class EventHandler;
25 }
26
27 namespace ash { 23 namespace ash {
28 class ScopedShowWindow; 24 class ScopedShowWindow;
29 class WindowOverview; 25 class WindowOverview;
30 class WindowSelectorDelegate; 26 class WindowSelectorDelegate;
31 class WindowSelectorItem; 27 class WindowSelectorItem;
32 class WindowSelectorTest; 28 class WindowSelectorTest;
33 29
34 // The WindowSelector allows selecting a window by alt-tabbing (CYCLE mode) or 30 // The WindowSelector allows selecting a window by alt-tabbing (CYCLE mode) or
35 // by clicking or tapping on it (OVERVIEW mode). A WindowOverview will be shown 31 // by clicking or tapping on it (OVERVIEW mode). A WindowOverview will be shown
36 // in OVERVIEW mode or if the user lingers on a window while alt tabbing. 32 // in OVERVIEW mode or if the user lingers on a window while alt tabbing.
37 class ASH_EXPORT WindowSelector 33 class ASH_EXPORT WindowSelector
38 : public aura::WindowObserver, 34 : public aura::WindowObserver,
39 public aura::client::ActivationChangeObserver { 35 public aura::client::ActivationChangeObserver {
40 public: 36 public:
41 enum Direction { 37 enum Direction {
42 FORWARD, 38 FORWARD,
43 BACKWARD 39 BACKWARD
44 }; 40 };
45 enum Mode {
46 CYCLE,
47 OVERVIEW
48 };
49 41
50 typedef std::vector<aura::Window*> WindowList; 42 typedef std::vector<aura::Window*> WindowList;
51 43
52 WindowSelector(const WindowList& windows, 44 WindowSelector(const WindowList& windows,
53 Mode mode,
54 WindowSelectorDelegate* delegate); 45 WindowSelectorDelegate* delegate);
55 virtual ~WindowSelector(); 46 virtual ~WindowSelector();
56 47
57 // Step to the next window in |direction|.
58 void Step(Direction direction);
59
60 // Choose the currently selected window. 48 // Choose the currently selected window.
61 void SelectWindow(); 49 void SelectWindow();
62 50
63 // Choose |window| from the available windows to select. 51 // Choose |window| from the available windows to select.
64 void SelectWindow(aura::Window* window); 52 void SelectWindow(aura::Window* window);
65 53
66 // Cancels window selection. 54 // Cancels window selection.
67 void CancelSelection(); 55 void CancelSelection();
68 56
69 Mode mode() { return mode_; }
70
71 // aura::WindowObserver: 57 // aura::WindowObserver:
72 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; 58 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE;
73 virtual void OnWindowBoundsChanged(aura::Window* window, 59 virtual void OnWindowBoundsChanged(aura::Window* window,
74 const gfx::Rect& old_bounds, 60 const gfx::Rect& old_bounds,
75 const gfx::Rect& new_bounds) OVERRIDE; 61 const gfx::Rect& new_bounds) OVERRIDE;
76 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; 62 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
77 63
78 // Overridden from aura::client::ActivationChangeObserver: 64 // Overridden from aura::client::ActivationChangeObserver:
79 virtual void OnWindowActivated(aura::Window* gained_active, 65 virtual void OnWindowActivated(aura::Window* gained_active,
80 aura::Window* lost_active) OVERRIDE; 66 aura::Window* lost_active) OVERRIDE;
(...skipping 11 matching lines...) Expand all
92 // |focus|, restores focus to the stored window. 78 // |focus|, restores focus to the stored window.
93 void ResetFocusRestoreWindow(bool focus); 79 void ResetFocusRestoreWindow(bool focus);
94 80
95 // The collection of items in the overview wrapped by a helper class which 81 // The collection of items in the overview wrapped by a helper class which
96 // restores their state and helps transform them to other root windows. 82 // restores their state and helps transform them to other root windows.
97 ScopedVector<WindowSelectorItem> windows_; 83 ScopedVector<WindowSelectorItem> windows_;
98 84
99 // Tracks observed windows. 85 // Tracks observed windows.
100 std::set<aura::Window*> observed_windows_; 86 std::set<aura::Window*> observed_windows_;
101 87
102 // The window selection mode.
103 Mode mode_;
104
105 // An event handler listening for the release of the alt key during alt-tab
106 // cycling.
107 scoped_ptr<ui::EventHandler> event_handler_;
108
109 // The currently selected window being shown (temporarily brought to the front
110 // of the stacking order and made visible).
111 scoped_ptr<ScopedShowWindow> showing_window_;
112
113 scoped_ptr<WindowOverview> window_overview_; 88 scoped_ptr<WindowOverview> window_overview_;
114 89
115 // The time when window cycling was started. 90 // The time when window cycling was started.
116 base::Time cycle_start_time_; 91 base::Time cycle_start_time_;
117 92
118 // Weak pointer to the selector delegate which will be called when a 93 // Weak pointer to the selector delegate which will be called when a
119 // selection is made. 94 // selection is made.
120 WindowSelectorDelegate* delegate_; 95 WindowSelectorDelegate* delegate_;
121 96
122 // Index of the currently selected window if the mode is CYCLE. 97 // Index of the currently selected window if the mode is CYCLE.
123 size_t selected_window_; 98 size_t selected_window_;
124 99
125 // A weak pointer to the window which was focused on beginning window 100 // A weak pointer to the window which was focused on beginning window
126 // selection. If window selection is canceled the focus should be restored to 101 // selection. If window selection is canceled the focus should be restored to
127 // this window. 102 // this window.
128 aura::Window* restore_focus_window_; 103 aura::Window* restore_focus_window_;
129 104
130 // True when performing operations that may cause window activations. This is 105 // True when performing operations that may cause window activations. This is
131 // used to prevent handling the resulting expected activation. 106 // used to prevent handling the resulting expected activation.
132 bool ignore_activations_; 107 bool ignore_activations_;
133 108
134 DISALLOW_COPY_AND_ASSIGN(WindowSelector); 109 DISALLOW_COPY_AND_ASSIGN(WindowSelector);
135 }; 110 };
136 111
137 } // namespace ash 112 } // namespace ash
138 113
139 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ 114 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698