OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_WM_MRU_WINDOW_TRACKER_H_ | 5 #ifndef ASH_WM_MRU_WINDOW_TRACKER_H_ |
6 #define ASH_WM_MRU_WINDOW_TRACKER_H_ | 6 #define ASH_WM_MRU_WINDOW_TRACKER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "ui/aura/window_observer.h" | 13 #include "ui/aura/window_observer.h" |
14 #include "ui/wm/public/activation_change_observer.h" | 14 #include "ui/wm/public/activation_change_observer.h" |
15 | 15 |
16 namespace ash { | 16 namespace ash { |
17 | 17 |
18 class WmWindow; | |
19 | |
20 // Maintains a most recently used list of windows. This is used for window | 18 // Maintains a most recently used list of windows. This is used for window |
21 // cycling using Alt+Tab and overview mode. | 19 // cycling using Alt+Tab and overview mode. |
22 class ASH_EXPORT MruWindowTracker | 20 class ASH_EXPORT MruWindowTracker |
23 : public aura::client::ActivationChangeObserver, | 21 : public aura::client::ActivationChangeObserver, |
24 public aura::WindowObserver { | 22 public aura::WindowObserver { |
25 public: | 23 public: |
26 using WindowList = std::vector<WmWindow*>; | 24 using WindowList = std::vector<aura::Window*>; |
27 | 25 |
28 MruWindowTracker(); | 26 MruWindowTracker(); |
29 ~MruWindowTracker() override; | 27 ~MruWindowTracker() override; |
30 | 28 |
31 // Returns the set of windows which can be cycled through using the tracked | 29 // Returns the set of windows which can be cycled through using the tracked |
32 // list of most recently used windows. | 30 // list of most recently used windows. |
33 WindowList BuildMruWindowList() const; | 31 WindowList BuildMruWindowList() const; |
34 | 32 |
35 // This does the same thing as the above, but ignores the system modal dialog | 33 // This does the same thing as the above, but ignores the system modal dialog |
36 // state and hence the returned list could contain more windows if a system | 34 // state and hence the returned list could contain more windows if a system |
37 // modal dialog window is present. | 35 // modal dialog window is present. |
38 WindowList BuildWindowListIgnoreModal() const; | 36 WindowList BuildWindowListIgnoreModal() const; |
39 | 37 |
40 // Starts or stops ignoring window activations. If no longer ignoring | 38 // Starts or stops ignoring window activations. If no longer ignoring |
41 // activations the currently active window is moved to the front of the | 39 // activations the currently active window is moved to the front of the |
42 // MRU window list. Used by WindowCycleList to avoid adding all cycled | 40 // MRU window list. Used by WindowCycleList to avoid adding all cycled |
43 // windows to the front of the MRU window list. | 41 // windows to the front of the MRU window list. |
44 void SetIgnoreActivations(bool ignore); | 42 void SetIgnoreActivations(bool ignore); |
45 | 43 |
46 private: | 44 private: |
47 // Updates the mru_windows_ list to insert/move |active_window| at/to the | 45 // Updates the mru_windows_ list to insert/move |active_window| at/to the |
48 // front. | 46 // front. |
49 void SetActiveWindow(WmWindow* active_window); | 47 void SetActiveWindow(aura::Window* active_window); |
50 | 48 |
51 // Overridden from aura::client::ActivationChangeObserver: | 49 // Overridden from aura::client::ActivationChangeObserver: |
52 void OnWindowActivated(ActivationReason reason, | 50 void OnWindowActivated(ActivationReason reason, |
53 aura::Window* gained_active, | 51 aura::Window* gained_active, |
54 aura::Window* lost_active) override; | 52 aura::Window* lost_active) override; |
55 | 53 |
56 // Overridden from aura::WindowObserver: | 54 // Overridden from aura::WindowObserver: |
57 void OnWindowDestroyed(aura::Window* window) override; | 55 void OnWindowDestroyed(aura::Window* window) override; |
58 | 56 |
59 // List of windows that have been activated in containers that we cycle | 57 // List of windows that have been activated in containers that we cycle |
60 // through, sorted by most recently used. | 58 // through, sorted by most recently used. |
61 std::list<WmWindow*> mru_windows_; | 59 std::list<aura::Window*> mru_windows_; |
62 | 60 |
63 bool ignore_window_activations_; | 61 bool ignore_window_activations_; |
64 | 62 |
65 DISALLOW_COPY_AND_ASSIGN(MruWindowTracker); | 63 DISALLOW_COPY_AND_ASSIGN(MruWindowTracker); |
66 }; | 64 }; |
67 | 65 |
68 } // namespace ash | 66 } // namespace ash |
69 | 67 |
70 #endif // ASH_WM_MRU_WINDOW_TRACKER_H_ | 68 #endif // ASH_WM_MRU_WINDOW_TRACKER_H_ |
OLD | NEW |