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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
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..1741c40a7d612838029f21548f2effd2169ddf12 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,18 +25,22 @@ 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,
BACKWARD
};
WindowCycleController();
- ~WindowCycleController();
+ virtual ~WindowCycleController();
// Returns true if cycling through windows is enabled. This is false at
// certain times, such as when the lock screen is visible.
@@ -53,11 +61,18 @@ class ASH_EXPORT WindowCycleController {
// Returns the WindowCycleList. Really only useful for testing.
const WindowCycleList* windows() const { return windows_.get(); }
+ // Set up 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(
+ 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();
+ // Checks if the window represents a container whose children we track.
+ static bool IsTrackedContainer(aura::Window* window);
+
+ // 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);
};

Powered by Google App Engine
This is Rietveld 408576698