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..fb27ae76e43b8da16d5fa634e3d5db06eb44e4d3 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 |
+ // 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( |
+ std::list<aura::Window*>* mru_windows); |
private: |
// Call to start cycling windows. You must call StopCycling() when done. |
@@ -72,11 +87,27 @@ class ASH_EXPORT WindowCycleController { |
// Stops the current window cycle and cleans up the event filter. |
void StopCycling(); |
+ // 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_; |
+ |
+ // Indicates that we should not update the mru_windows_ list when windows are |
sky
2012/07/24 03:53:31
|mru_windows_|
Zachary Kuznia
2012/07/30 07:49:48
Removed.
On 2012/07/24 03:53:31, sky wrote:
|
+ // activated. This is set while cycles with alt+tab. |
+ bool mru_ignore_; |
sky
2012/07/24 03:53:31
I think this should be is cycling. Do you even nee
Zachary Kuznia
2012/07/30 07:49:48
Done.
|
+ |
DISALLOW_COPY_AND_ASSIGN(WindowCycleController); |
}; |