Index: ash/wm/window_cycle_controller.h |
diff --git a/ash/wm/window_cycle_controller.h b/ash/wm/window_cycle_controller.h |
index aa667899d45e6e2cc7e70798b4ea067c9f1af9c9..8f8401a33b0183530ce9d526f78e153ae25dfa31 100644 |
--- a/ash/wm/window_cycle_controller.h |
+++ b/ash/wm/window_cycle_controller.h |
@@ -5,14 +5,18 @@ |
#ifndef ASH_WM_WINDOW_CYCLE_CONTROLLER_H_ |
#define ASH_WM_WINDOW_CYCLE_CONTROLLER_H_ |
+#include <list> |
#include <vector> |
#include "ash/ash_export.h" |
#include "base/basictypes.h" |
#include "base/memory/scoped_ptr.h" |
+#include "ui/aura/client/activation_change_observer.h" |
+#include "ui/aura/window_observer.h" |
namespace aura { |
class EventFilter; |
+class RootWindow; |
class Window; |
} |
@@ -21,11 +25,15 @@ namespace ash { |
class WindowCycleList; |
// Controls cycling through windows with the keyboard, for example, via alt-tab. |
+// Windows are sorted primarily by most recently used, and then by screen order. |
// We activate windows as you cycle through them, so the order on the screen |
-// may change during the gesture. Thus we maintain the state of the windows |
+// may change during the gesture, but the most recently used list isn't updated |
+// until the cycling ends. Thus we maintain the state of the windows |
// at the beginning of the gesture so you can cycle through in a consistent |
// order. |
-class ASH_EXPORT WindowCycleController { |
+class ASH_EXPORT WindowCycleController |
+ : public aura::client::ActivationChangeObserver, |
+ public aura::WindowObserver { |
public: |
enum Direction { |
FORWARD, |
@@ -53,11 +61,18 @@ class ASH_EXPORT WindowCycleController { |
// Returns the WindowCycleList. Really only useful for testing. |
const WindowCycleList* windows() const { return windows_.get(); } |
+ // Setup the observers to handle window changes for the containers we care |
Daniel Erat
2012/07/30 15:32:52
nit: s/Setup/Sets up/
Zachary Kuznia
2012/07/31 03:36:43
Done.
|
+ // about. Called when a new root window is added. |
+ void OnRootWindowAdded(aura::RootWindow* root_window); |
+ |
// Returns the set of windows to cycle through. This method creates |
// the vector based on the current set of windows across all valid root |
// windows. As a result it is not necessarily the same as the set of |
// windows being iterated over. |
- static std::vector<aura::Window*> BuildWindowList(); |
+ // If |mru_windows| is not NULL, windows in this list are put at the head of |
+ // the window list. |
+ static std::vector<aura::Window*> BuildWindowList( |
+ const std::list<aura::Window*>* mru_windows); |
private: |
// Call to start cycling windows. You must call StopCycling() when done. |
@@ -72,11 +87,26 @@ class ASH_EXPORT WindowCycleController { |
// Stops the current window cycle and cleans up the event filter. |
void StopCycling(); |
+ // Check if the window represents a container whose children we track. |
Daniel Erat
2012/07/30 15:32:52
nit:s/Check/Checks/
Zachary Kuznia
2012/07/31 03:36:43
Done.
|
+ static bool IsTrackedWindow(aura::Window* window); |
Daniel Erat
2012/07/30 15:32:52
nit: IsTrackedContainer()?
Zachary Kuznia
2012/07/31 03:36:43
Done.
|
+ |
+ // Overridden from ActivationChangeObserver: |
+ virtual void OnWindowActivated(aura::Window* active, |
+ aura::Window* old_active) OVERRIDE; |
+ |
+ // Overridden from WindowObserver: |
+ virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE; |
+ virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
+ |
scoped_ptr<WindowCycleList> windows_; |
// Event filter to watch for release of alt key. |
scoped_ptr<aura::EventFilter> event_filter_; |
+ // List of windows that have been activated in containers that we cycle |
+ // through, sorted by most recently used. |
+ std::list<aura::Window*> mru_windows_; |
+ |
DISALLOW_COPY_AND_ASSIGN(WindowCycleController); |
}; |