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

Side by Side Diff: ash/wm/mru_window_tracker.h

Issue 20708005: Refactor most recently used window tracking into a separate class. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 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.
4
5 #ifndef ASH_WM_MRU_WINDOW_TRACKER_H_
6 #define ASH_WM_MRU_WINDOW_TRACKER_H_
7
8 #include <list>
9 #include <vector>
10
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"
16
17 namespace aura {
18 class RootWindow;
19 class Window;
20 namespace client {
21 class ActivationClient;
22 }
23 }
24
25 namespace ash {
26
27 // Maintains a most recently used list of windows. This is used for window
28 // cycling using Alt+Tab and overview mode.
29 class ASH_EXPORT MruWindowTracker
30 : public aura::client::ActivationChangeObserver,
31 public aura::WindowObserver {
32 public:
33 typedef std::vector<aura::Window*> WindowList;
34
35 explicit MruWindowTracker(
36 aura::client::ActivationClient* activation_client);
37 virtual ~MruWindowTracker();
38
39 // Set up the observers to handle window changes for the containers we care
40 // about. Called when a new root window is added.
41 void OnRootWindowAdded(aura::RootWindow* root_window);
42
43 // Returns the set of windows which can be cycled through. This method creates
44 // the vector based on the current set of windows across all valid root
45 // windows. As a result it is not necessarily the same as the set of
46 // windows being iterated over.
47 // If |mru_windows| is not NULL, windows in this list are put at the head of
48 // the window list.
49 // If |top_most_at_end| the window list will return in ascending order instead
50 // 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.
51 static WindowList BuildWindowList(
52 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
53 bool top_most_at_end);
54
55 // Returns the set of windows which can be cycled through using the tracked
56 // 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
57 // is returned in ascending order.
58 WindowList BuildMruWindowList(bool top_most_at_end);
59
60 // Starts or stops ignoring window activations. If no longer ignoring
61 // activations the currently active window is moved to the front of the
62 // MRU window list. Used by WindowCycleList to avoid adding all cycled
63 // windows to the front of the MRU window list.
64 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
65 private:
sky 2013/07/29 15:31:05 nit: newline between 64/65.
flackr 2013/07/29 22:49:11 Done.
66 // Checks if the window represents a container whose children we track.
67 static bool IsTrackedContainer(aura::Window* window);
68
69 // Overridden from aura::client::ActivationChangeObserver:
70 virtual void OnWindowActivated(aura::Window* gained_active,
71 aura::Window* lost_active) OVERRIDE;
72
73 // Overridden from WindowObserver:
74 virtual void OnWindowAdded(aura::Window* window) OVERRIDE;
75 virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE;
76 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
77
78 // List of windows that have been activated in containers that we cycle
79 // through, sorted by most recently used.
80 std::list<aura::Window*> mru_windows_;
81
82 aura::client::ActivationClient* activation_client_;
83
84 bool ignore_window_activations_;
85
86 DISALLOW_COPY_AND_ASSIGN(MruWindowTracker);
87 };
88
89 } // namespace ash
90
91 #endif // ASH_WM_MRU_WINDOW_TRACKER_H_
OLDNEW
« no previous file with comments | « ash/shell.cc ('k') | ash/wm/mru_window_tracker.cc » ('j') | ash/wm/window_cycle_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698