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

Side by Side Diff: components/mus/ws/focus_controller.h

Issue 1560063003: mus: Fix activation cycle direction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot.merge Created 4 years, 11 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
« no previous file with comments | « no previous file | components/mus/ws/focus_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_ 5 #ifndef COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_
6 #define COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_ 6 #define COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "components/mus/ws/server_window_drawn_tracker_observer.h" 11 #include "components/mus/ws/server_window_drawn_tracker_observer.h"
12 #include "components/mus/ws/server_window_tracker.h"
12 13
13 namespace mus { 14 namespace mus {
14 15
15 namespace ws { 16 namespace ws {
16 17
17 class FocusControllerDelegate; 18 class FocusControllerDelegate;
18 class FocusControllerObserver; 19 class FocusControllerObserver;
19 class ServerWindow; 20 class ServerWindow;
20 class ServerWindowDrawnTracker; 21 class ServerWindowDrawnTracker;
22 struct WindowId;
21 23
22 // Describes the source of the change. 24 // Describes the source of the change.
23 enum class FocusControllerChangeSource { 25 enum class FocusControllerChangeSource {
24 EXPLICIT, 26 EXPLICIT,
25 DRAWN_STATE_CHANGED, 27 DRAWN_STATE_CHANGED,
26 }; 28 };
27 29
28 // Tracks the focused window. Focus is moved to another window when the drawn 30 // Tracks the focused window. Focus is moved to another window when the drawn
29 // state of the focused window changes. 31 // state of the focused window changes.
30 class FocusController : public ServerWindowDrawnTrackerObserver { 32 class FocusController : public ServerWindowDrawnTrackerObserver {
31 public: 33 public:
32 FocusController(FocusControllerDelegate* delegate, ServerWindow* root); 34 FocusController(FocusControllerDelegate* delegate, ServerWindow* root);
33 ~FocusController() override; 35 ~FocusController() override;
34 36
35 // Sets the focused window. Does nothing if |window| is currently focused. 37 // Sets the focused window. Does nothing if |window| is currently focused.
36 // This does not notify the delegate. 38 // This does not notify the delegate.
37 void SetFocusedWindow(ServerWindow* window); 39 void SetFocusedWindow(ServerWindow* window);
38 ServerWindow* GetFocusedWindow(); 40 ServerWindow* GetFocusedWindow();
39 41
40 // Moves activation to the next activatable window. 42 // Moves activation to the next activatable window.
41 void ActivateNextWindow(); 43 void ActivateNextWindow();
42 44
43 void AddObserver(FocusControllerObserver* observer); 45 void AddObserver(FocusControllerObserver* observer);
44 void RemoveObserver(FocusControllerObserver* observer); 46 void RemoveObserver(FocusControllerObserver* observer);
45 47
46 private: 48 private:
47 void SetActiveWindow(ServerWindow* window); 49 enum class ActivationChangeReason {
50 UNKNONW,
51 CYCLE, // Activation changed because of ActivateNextWindow().
52 FOCUS, // Focus change required a different window to be activated.
53 DRAWN_STATE_CHANGED, // Active window was hidden or destroyed.
54 };
55 void SetActiveWindow(ServerWindow* window, ActivationChangeReason reason);
48 56
49 // Returns whether |window| can be focused or activated. 57 // Returns whether |window| can be focused or activated.
50 bool CanBeFocused(ServerWindow* window) const; 58 bool CanBeFocused(ServerWindow* window) const;
51 bool CanBeActivated(ServerWindow* window) const; 59 bool CanBeActivated(ServerWindow* window) const;
52 60
53 // Returns the closest activatable ancestor of |window|. Returns nullptr if 61 // Returns the closest activatable ancestor of |window|. Returns nullptr if
54 // there is no such ancestor. 62 // there is no such ancestor.
55 ServerWindow* GetActivatableAncestorOf(ServerWindow* window) const; 63 ServerWindow* GetActivatableAncestorOf(ServerWindow* window) const;
56 64
57 // Implementation of SetFocusedWindow(). 65 // Implementation of SetFocusedWindow().
58 void SetFocusedWindowImpl(FocusControllerChangeSource change_source, 66 void SetFocusedWindowImpl(FocusControllerChangeSource change_source,
59 ServerWindow* window); 67 ServerWindow* window);
60 68
61 // ServerWindowDrawnTrackerObserver: 69 // ServerWindowDrawnTrackerObserver:
62 void OnDrawnStateWillChange(ServerWindow* ancestor, 70 void OnDrawnStateWillChange(ServerWindow* ancestor,
63 ServerWindow* window, 71 ServerWindow* window,
64 bool is_drawn) override; 72 bool is_drawn) override;
65 void OnDrawnStateChanged(ServerWindow* ancestor, 73 void OnDrawnStateChanged(ServerWindow* ancestor,
66 ServerWindow* window, 74 ServerWindow* window,
67 bool is_drawn) override; 75 bool is_drawn) override;
68 76
69 FocusControllerDelegate* delegate_; 77 FocusControllerDelegate* delegate_;
70 78
71 ServerWindow* root_; 79 ServerWindow* root_;
72 ServerWindow* focused_window_; 80 ServerWindow* focused_window_;
73 ServerWindow* active_window_; 81 ServerWindow* active_window_;
82 // Tracks what caused |active_window_| to be activated.
83 ActivationChangeReason activation_reason_;
84
85 // Keeps track of the list of windows that have already been visited during a
86 // window cycle. This is only active when |activation_reason_| is set to
87 // CYCLE.
88 scoped_ptr<ServerWindowTracker> cycle_windows_;
74 89
75 base::ObserverList<FocusControllerObserver> observers_; 90 base::ObserverList<FocusControllerObserver> observers_;
76 91
77 // Keeps track of the visibility of the focused and active window. 92 // Keeps track of the visibility of the focused and active window.
78 scoped_ptr<ServerWindowDrawnTracker> drawn_tracker_; 93 scoped_ptr<ServerWindowDrawnTracker> drawn_tracker_;
79 94
80 DISALLOW_COPY_AND_ASSIGN(FocusController); 95 DISALLOW_COPY_AND_ASSIGN(FocusController);
81 }; 96 };
82 97
83 } // namespace ws 98 } // namespace ws
84 99
85 } // namespace mus 100 } // namespace mus
86 101
87 #endif // COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_ 102 #endif // COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | components/mus/ws/focus_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698