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

Side by Side Diff: ash/wm/window_cycle_controller.h

Issue 10700057: Add always on top windows to the alt+tab list (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix clang Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
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_WINDOW_CYCLE_CONTROLLER_H_ 5 #ifndef ASH_WM_WINDOW_CYCLE_CONTROLLER_H_
6 #define ASH_WM_WINDOW_CYCLE_CONTROLLER_H_ 6 #define ASH_WM_WINDOW_CYCLE_CONTROLLER_H_
7 7
8 #include <list>
8 #include <vector> 9 #include <vector>
9 10
10 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "ui/aura/client/activation_change_observer.h"
15 #include "ui/aura/window_observer.h"
13 16
14 namespace aura { 17 namespace aura {
15 class EventFilter; 18 class EventFilter;
19 class RootWindow;
16 class Window; 20 class Window;
17 } 21 }
18 22
19 namespace ash { 23 namespace ash {
20 24
21 class WindowCycleList; 25 class WindowCycleList;
22 26
23 // Controls cycling through windows with the keyboard, for example, via alt-tab. 27 // Controls cycling through windows with the keyboard, for example, via alt-tab.
28 // Windows are sorted primarily by most recently used, and then by screen order.
24 // We activate windows as you cycle through them, so the order on the screen 29 // We activate windows as you cycle through them, so the order on the screen
25 // may change during the gesture. Thus we maintain the state of the windows 30 // may change during the gesture, but the most recently used list isn't updated
31 // until the cycling ends. Thus we maintain the state of the windows
26 // at the beginning of the gesture so you can cycle through in a consistent 32 // at the beginning of the gesture so you can cycle through in a consistent
27 // order. 33 // order.
28 class ASH_EXPORT WindowCycleController { 34 class ASH_EXPORT WindowCycleController
35 : public aura::client::ActivationChangeObserver,
36 public aura::WindowObserver {
29 public: 37 public:
30 enum Direction { 38 enum Direction {
31 FORWARD, 39 FORWARD,
32 BACKWARD 40 BACKWARD
33 }; 41 };
34 WindowCycleController(); 42 WindowCycleController();
35 ~WindowCycleController(); 43 virtual ~WindowCycleController();
36 44
37 // Returns true if cycling through windows is enabled. This is false at 45 // Returns true if cycling through windows is enabled. This is false at
38 // certain times, such as when the lock screen is visible. 46 // certain times, such as when the lock screen is visible.
39 static bool CanCycle(); 47 static bool CanCycle();
40 48
41 // Cycles between windows in the given |direction|. If |is_alt_down| then 49 // Cycles between windows in the given |direction|. If |is_alt_down| then
42 // interprets this call as the start of a multi-step cycle sequence and 50 // interprets this call as the start of a multi-step cycle sequence and
43 // installs a key filter to watch for alt being released. 51 // installs a key filter to watch for alt being released.
44 void HandleCycleWindow(Direction direction, bool is_alt_down); 52 void HandleCycleWindow(Direction direction, bool is_alt_down);
45 53
46 // Informs the controller that the Alt key has been released and it can 54 // Informs the controller that the Alt key has been released and it can
47 // terminate the existing multi-step cycle. 55 // terminate the existing multi-step cycle.
48 void AltKeyReleased(); 56 void AltKeyReleased();
49 57
50 // Returns true if we are in the middle of a window cycling gesture. 58 // Returns true if we are in the middle of a window cycling gesture.
51 bool IsCycling() const { return windows_.get() != NULL; } 59 bool IsCycling() const { return windows_.get() != NULL; }
52 60
53 // Returns the WindowCycleList. Really only useful for testing. 61 // Returns the WindowCycleList. Really only useful for testing.
54 const WindowCycleList* windows() const { return windows_.get(); } 62 const WindowCycleList* windows() const { return windows_.get(); }
55 63
64 // Set up the observers to handle window changes for the containers we care
65 // about. Called when a new root window is added.
66 void OnRootWindowAdded(aura::RootWindow* root_window);
67
56 // Returns the set of windows to cycle through. This method creates 68 // Returns the set of windows to cycle through. This method creates
57 // the vector based on the current set of windows across all valid root 69 // the vector based on the current set of windows across all valid root
58 // windows. As a result it is not necessarily the same as the set of 70 // windows. As a result it is not necessarily the same as the set of
59 // windows being iterated over. 71 // windows being iterated over.
60 static std::vector<aura::Window*> BuildWindowList(); 72 // If |mru_windows| is not NULL, windows in this list are put at the head of
73 // the window list.
74 static std::vector<aura::Window*> BuildWindowList(
75 const std::list<aura::Window*>* mru_windows);
61 76
62 private: 77 private:
63 // Call to start cycling windows. You must call StopCycling() when done. 78 // Call to start cycling windows. You must call StopCycling() when done.
64 void StartCycling(); 79 void StartCycling();
65 80
66 // Cycles to the next or previous window based on |direction|. 81 // Cycles to the next or previous window based on |direction|.
67 void Step(Direction direction); 82 void Step(Direction direction);
68 83
69 // Installs an event filter to watch for release of the alt key. 84 // Installs an event filter to watch for release of the alt key.
70 void InstallEventFilter(); 85 void InstallEventFilter();
71 86
72 // Stops the current window cycle and cleans up the event filter. 87 // Stops the current window cycle and cleans up the event filter.
73 void StopCycling(); 88 void StopCycling();
74 89
90 // Checks if the window represents a container whose children we track.
91 static bool IsTrackedContainer(aura::Window* window);
92
93 // Overridden from ActivationChangeObserver:
94 virtual void OnWindowActivated(aura::Window* active,
95 aura::Window* old_active) OVERRIDE;
96
97 // Overridden from WindowObserver:
98 virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE;
99 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
100
75 scoped_ptr<WindowCycleList> windows_; 101 scoped_ptr<WindowCycleList> windows_;
76 102
77 // Event filter to watch for release of alt key. 103 // Event filter to watch for release of alt key.
78 scoped_ptr<aura::EventFilter> event_filter_; 104 scoped_ptr<aura::EventFilter> event_filter_;
79 105
106 // List of windows that have been activated in containers that we cycle
107 // through, sorted by most recently used.
108 std::list<aura::Window*> mru_windows_;
109
80 DISALLOW_COPY_AND_ASSIGN(WindowCycleController); 110 DISALLOW_COPY_AND_ASSIGN(WindowCycleController);
81 }; 111 };
82 112
83 } // namespace ash 113 } // namespace ash
84 114
85 #endif // ASH_WM_WINDOW_CYCLE_CONTROLLER_H_ 115 #endif // ASH_WM_WINDOW_CYCLE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698