1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ASH_WM_MRU_WINDOW_TRACKER_H_
6 #define ASH_WM_MRU_WINDOW_TRACKER_H_
11 #include "ash/ash_export.h"
12 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "ui/aura/client/activation_change_observer.h"
15 #include "ui/aura/window_observer.h"
21 class ActivationClient
;
27 // List of containers which contain windows that can be switched to.
28 ASH_EXPORT
extern const int kSwitchableWindowContainerIds
[];
30 // The number of elements in kSwitchableWindowContainerIds.
31 ASH_EXPORT
extern const size_t kSwitchableWindowContainerIdsLength
;
33 // Maintains a most recently used list of windows. This is used for window
34 // cycling using Alt+Tab and overview mode.
35 class ASH_EXPORT MruWindowTracker
36 : public aura::client::ActivationChangeObserver
,
37 public aura::WindowObserver
{
39 typedef std::vector
<aura::Window
*> WindowList
;
41 explicit MruWindowTracker(
42 aura::client::ActivationClient
* activation_client
);
43 virtual ~MruWindowTracker();
45 // Returns the set of windows which can be cycled through. This method creates
46 // the vector based on the current set of windows across all valid root
47 // windows. As a result it is not necessarily the same as the set of
48 // windows being iterated over.
49 // If |top_most_at_end| the window list will return in ascending (lowest
50 // window in stacking order first) order instead of the default descending
51 // (top most window first) order.
52 static WindowList
BuildWindowList(bool top_most_at_end
);
54 // Returns the set of windows which can be cycled through using the tracked
55 // list of most recently used windows.
56 WindowList
BuildMruWindowList();
58 // Starts or stops ignoring window activations. If no longer ignoring
59 // activations the currently active window is moved to the front of the
60 // MRU window list. Used by WindowCycleList to avoid adding all cycled
61 // windows to the front of the MRU window list.
62 void SetIgnoreActivations(bool ignore
);
65 // Updates the mru_windows_ list to insert/move |active_window| at/to the
67 void SetActiveWindow(aura::Window
* active_window
);
69 // Overridden from aura::client::ActivationChangeObserver:
70 virtual void OnWindowActivated(aura::Window
* gained_active
,
71 aura::Window
* lost_active
) OVERRIDE
;
73 // Overridden from WindowObserver:
74 virtual void OnWindowDestroying(aura::Window
* window
) OVERRIDE
;
76 // List of windows that have been activated in containers that we cycle
77 // through, sorted by most recently used.
78 std::list
<aura::Window
*> mru_windows_
;
80 aura::client::ActivationClient
* activation_client_
;
82 bool ignore_window_activations_
;
84 DISALLOW_COPY_AND_ASSIGN(MruWindowTracker
);
89 #endif // ASH_WM_MRU_WINDOW_TRACKER_H_