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

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: 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
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 12
13 namespace mus { 13 namespace mus {
14 14
15 namespace ws { 15 namespace ws {
16 16
17 class FocusControllerDelegate; 17 class FocusControllerDelegate;
18 class FocusControllerObserver; 18 class FocusControllerObserver;
19 class ServerWindow; 19 class ServerWindow;
20 class ServerWindowDrawnTracker; 20 class ServerWindowDrawnTracker;
21 struct WindowId;
21 22
22 // Describes the source of the change. 23 // Describes the source of the change.
23 enum class FocusControllerChangeSource { 24 enum class FocusControllerChangeSource {
24 EXPLICIT, 25 EXPLICIT,
25 DRAWN_STATE_CHANGED, 26 DRAWN_STATE_CHANGED,
26 }; 27 };
27 28
28 // Tracks the focused window. Focus is moved to another window when the drawn 29 // Tracks the focused window. Focus is moved to another window when the drawn
29 // state of the focused window changes. 30 // state of the focused window changes.
30 class FocusController : public ServerWindowDrawnTrackerObserver { 31 class FocusController : public ServerWindowDrawnTrackerObserver {
31 public: 32 public:
32 FocusController(FocusControllerDelegate* delegate, ServerWindow* root); 33 FocusController(FocusControllerDelegate* delegate, ServerWindow* root);
33 ~FocusController() override; 34 ~FocusController() override;
34 35
35 // Sets the focused window. Does nothing if |window| is currently focused. 36 // Sets the focused window. Does nothing if |window| is currently focused.
36 // This does not notify the delegate. 37 // This does not notify the delegate.
37 void SetFocusedWindow(ServerWindow* window); 38 void SetFocusedWindow(ServerWindow* window);
38 ServerWindow* GetFocusedWindow(); 39 ServerWindow* GetFocusedWindow();
39 40
40 // Moves activation to the next activatable window. 41 // Moves activation to the next activatable window.
41 void ActivateNextWindow(); 42 void ActivateNextWindow();
42 43
43 void AddObserver(FocusControllerObserver* observer); 44 void AddObserver(FocusControllerObserver* observer);
44 void RemoveObserver(FocusControllerObserver* observer); 45 void RemoveObserver(FocusControllerObserver* observer);
45 46
46 private: 47 private:
47 void SetActiveWindow(ServerWindow* window); 48 enum class ActivationChangeReason {
49 UNKNONW,
50 CYCLE, // Activation changed because of ActivateNextWindow().
51 FOCUS, // Focus change required a different window to be activated.
52 DRAWN_STATE_CHANGED, // Active window was hidden or destroyed.
53 };
54 void SetActiveWindow(ServerWindow* window, ActivationChangeReason reason);
48 55
49 // Returns whether |window| can be focused or activated. 56 // Returns whether |window| can be focused or activated.
50 bool CanBeFocused(ServerWindow* window) const; 57 bool CanBeFocused(ServerWindow* window) const;
51 bool CanBeActivated(ServerWindow* window) const; 58 bool CanBeActivated(ServerWindow* window) const;
52 59
53 // Returns the closest activatable ancestor of |window|. Returns nullptr if 60 // Returns the closest activatable ancestor of |window|. Returns nullptr if
54 // there is no such ancestor. 61 // there is no such ancestor.
55 ServerWindow* GetActivatableAncestorOf(ServerWindow* window) const; 62 ServerWindow* GetActivatableAncestorOf(ServerWindow* window) const;
56 63
57 // Implementation of SetFocusedWindow(). 64 // Implementation of SetFocusedWindow().
58 void SetFocusedWindowImpl(FocusControllerChangeSource change_source, 65 void SetFocusedWindowImpl(FocusControllerChangeSource change_source,
59 ServerWindow* window); 66 ServerWindow* window);
60 67
61 // ServerWindowDrawnTrackerObserver: 68 // ServerWindowDrawnTrackerObserver:
62 void OnDrawnStateWillChange(ServerWindow* ancestor, 69 void OnDrawnStateWillChange(ServerWindow* ancestor,
63 ServerWindow* window, 70 ServerWindow* window,
64 bool is_drawn) override; 71 bool is_drawn) override;
65 void OnDrawnStateChanged(ServerWindow* ancestor, 72 void OnDrawnStateChanged(ServerWindow* ancestor,
66 ServerWindow* window, 73 ServerWindow* window,
67 bool is_drawn) override; 74 bool is_drawn) override;
68 75
69 FocusControllerDelegate* delegate_; 76 FocusControllerDelegate* delegate_;
70 77
71 ServerWindow* root_; 78 ServerWindow* root_;
72 ServerWindow* focused_window_; 79 ServerWindow* focused_window_;
73 ServerWindow* active_window_; 80 ServerWindow* active_window_;
81 // Tracks what caused |active_window_| to be activated.
82 ActivationChangeReason activation_reason_;
83
84 std::vector<WindowId> cycle_windows_;
sky 2016/01/05 16:42:38 As far as I can tell you don't update this as wind
sadrul 2016/01/05 17:14:53 We don't need to handle new windows, since those w
74 85
75 base::ObserverList<FocusControllerObserver> observers_; 86 base::ObserverList<FocusControllerObserver> observers_;
76 87
77 // Keeps track of the visibility of the focused and active window. 88 // Keeps track of the visibility of the focused and active window.
78 scoped_ptr<ServerWindowDrawnTracker> drawn_tracker_; 89 scoped_ptr<ServerWindowDrawnTracker> drawn_tracker_;
79 90
80 DISALLOW_COPY_AND_ASSIGN(FocusController); 91 DISALLOW_COPY_AND_ASSIGN(FocusController);
81 }; 92 };
82 93
83 } // namespace ws 94 } // namespace ws
84 95
85 } // namespace mus 96 } // namespace mus
86 97
87 #endif // COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_ 98 #endif // COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | components/mus/ws/focus_controller.cc » ('j') | components/mus/ws/focus_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698