Chromium Code Reviews| Index: ash/wm/mru_window_tracker.h |
| diff --git a/ash/wm/mru_window_tracker.h b/ash/wm/mru_window_tracker.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..278f3154956b12842ff851f5da2dea4d72bc8118 |
| --- /dev/null |
| +++ b/ash/wm/mru_window_tracker.h |
| @@ -0,0 +1,91 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ASH_WM_MRU_WINDOW_TRACKER_H_ |
| +#define ASH_WM_MRU_WINDOW_TRACKER_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 RootWindow; |
| +class Window; |
| +namespace client { |
| +class ActivationClient; |
| +} |
| +} |
| + |
| +namespace ash { |
| + |
| +// Maintains a most recently used list of windows. This is used for window |
| +// cycling using Alt+Tab and overview mode. |
| +class ASH_EXPORT MruWindowTracker |
| + : public aura::client::ActivationChangeObserver, |
| + public aura::WindowObserver { |
| + public: |
| + typedef std::vector<aura::Window*> WindowList; |
| + |
| + explicit MruWindowTracker( |
| + aura::client::ActivationClient* activation_client); |
| + virtual ~MruWindowTracker(); |
| + |
| + // 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 which can be cycled 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. |
| + // If |mru_windows| is not NULL, windows in this list are put at the head of |
| + // the window list. |
| + // If |top_most_at_end| the window list will return in ascending order instead |
| + // of the default descending. |
|
sky
2013/07/29 15:31:05
It isn't clear what descending/ascending means her
flackr
2013/07/29 22:49:11
Done.
|
| + static WindowList BuildWindowList( |
| + const std::list<aura::Window*>* mru_windows, |
|
sky
2013/07/29 15:31:05
Why is mru_windows part of the API? Seems like its
flackr
2013/07/29 22:49:11
From a codesearch, the only callers who actually c
|
| + bool top_most_at_end); |
| + |
| + // Returns the set of windows which can be cycled through using the tracked |
| + // list of most recently used windows. If |top_most_at_end| the window list |
|
sky
2013/07/29 15:31:05
Since you refer the ordering twice (here and Build
|
| + // is returned in ascending order. |
| + WindowList BuildMruWindowList(bool top_most_at_end); |
| + |
| + // Starts or stops ignoring window activations. If no longer ignoring |
| + // activations the currently active window is moved to the front of the |
| + // MRU window list. Used by WindowCycleList to avoid adding all cycled |
| + // windows to the front of the MRU window list. |
| + void IgnoreActivations(bool ignore); |
|
sky
2013/07/29 15:31:05
SetIgnoreActivations. That said, since you're goin
flackr
2013/07/29 22:49:11
Done.
Overview mode won't actually need to ignore
|
| + private: |
|
sky
2013/07/29 15:31:05
nit: newline between 64/65.
flackr
2013/07/29 22:49:11
Done.
|
| + // Checks if the window represents a container whose children we track. |
| + static bool IsTrackedContainer(aura::Window* window); |
| + |
| + // Overridden from aura::client::ActivationChangeObserver: |
| + virtual void OnWindowActivated(aura::Window* gained_active, |
| + aura::Window* lost_active) OVERRIDE; |
| + |
| + // Overridden from WindowObserver: |
| + virtual void OnWindowAdded(aura::Window* window) OVERRIDE; |
| + virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE; |
| + virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
| + |
| + // List of windows that have been activated in containers that we cycle |
| + // through, sorted by most recently used. |
| + std::list<aura::Window*> mru_windows_; |
| + |
| + aura::client::ActivationClient* activation_client_; |
| + |
| + bool ignore_window_activations_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MruWindowTracker); |
| +}; |
| + |
| +} // namespace ash |
| + |
| +#endif // ASH_WM_MRU_WINDOW_TRACKER_H_ |