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

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 #include "components/mus/ws/server_window_observer.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,
33 public ServerWindowObserver {
31 public: 34 public:
32 FocusController(FocusControllerDelegate* delegate, ServerWindow* root); 35 FocusController(FocusControllerDelegate* delegate, ServerWindow* root);
33 ~FocusController() override; 36 ~FocusController() override;
34 37
35 // Sets the focused window. Does nothing if |window| is currently focused. 38 // Sets the focused window. Does nothing if |window| is currently focused.
36 // This does not notify the delegate. 39 // This does not notify the delegate.
37 void SetFocusedWindow(ServerWindow* window); 40 void SetFocusedWindow(ServerWindow* window);
38 ServerWindow* GetFocusedWindow(); 41 ServerWindow* GetFocusedWindow();
39 42
40 // Moves activation to the next activatable window. 43 // Moves activation to the next activatable window.
41 void ActivateNextWindow(); 44 void ActivateNextWindow();
42 45
43 void AddObserver(FocusControllerObserver* observer); 46 void AddObserver(FocusControllerObserver* observer);
44 void RemoveObserver(FocusControllerObserver* observer); 47 void RemoveObserver(FocusControllerObserver* observer);
45 48
46 private: 49 private:
47 void SetActiveWindow(ServerWindow* window); 50 enum class ActivationChangeReason {
51 UNKNONW,
52 CYCLE, // Activation changed because of ActivateNextWindow().
53 FOCUS, // Focus change required a different window to be activated.
54 DRAWN_STATE_CHANGED, // Active window was hidden or destroyed.
55 };
56 void SetActiveWindow(ServerWindow* window, ActivationChangeReason reason);
48 57
49 // Returns whether |window| can be focused or activated. 58 // Returns whether |window| can be focused or activated.
50 bool CanBeFocused(ServerWindow* window) const; 59 bool CanBeFocused(ServerWindow* window) const;
51 bool CanBeActivated(ServerWindow* window) const; 60 bool CanBeActivated(ServerWindow* window) const;
52 61
53 // Returns the closest activatable ancestor of |window|. Returns nullptr if 62 // Returns the closest activatable ancestor of |window|. Returns nullptr if
54 // there is no such ancestor. 63 // there is no such ancestor.
55 ServerWindow* GetActivatableAncestorOf(ServerWindow* window) const; 64 ServerWindow* GetActivatableAncestorOf(ServerWindow* window) const;
56 65
57 // Implementation of SetFocusedWindow(). 66 // Implementation of SetFocusedWindow().
58 void SetFocusedWindowImpl(FocusControllerChangeSource change_source, 67 void SetFocusedWindowImpl(FocusControllerChangeSource change_source,
59 ServerWindow* window); 68 ServerWindow* window);
60 69
70 void ClearCycleWindows();
71
61 // ServerWindowDrawnTrackerObserver: 72 // ServerWindowDrawnTrackerObserver:
62 void OnDrawnStateWillChange(ServerWindow* ancestor, 73 void OnDrawnStateWillChange(ServerWindow* ancestor,
63 ServerWindow* window, 74 ServerWindow* window,
64 bool is_drawn) override; 75 bool is_drawn) override;
65 void OnDrawnStateChanged(ServerWindow* ancestor, 76 void OnDrawnStateChanged(ServerWindow* ancestor,
66 ServerWindow* window, 77 ServerWindow* window,
67 bool is_drawn) override; 78 bool is_drawn) override;
68 79
80 // ServerWindowObserver:
81 void OnWillDestroyWindow(ServerWindow* window) override;
82
69 FocusControllerDelegate* delegate_; 83 FocusControllerDelegate* delegate_;
70 84
71 ServerWindow* root_; 85 ServerWindow* root_;
72 ServerWindow* focused_window_; 86 ServerWindow* focused_window_;
73 ServerWindow* active_window_; 87 ServerWindow* active_window_;
88 // Tracks what caused |active_window_| to be activated.
89 ActivationChangeReason activation_reason_;
90
91 std::vector<ServerWindow*> cycle_windows_;
sky 2016/01/06 21:02:39 It's not obvious what this is, or how it changes b
sadrul 2016/01/08 20:40:26 Done.
74 92
75 base::ObserverList<FocusControllerObserver> observers_; 93 base::ObserverList<FocusControllerObserver> observers_;
76 94
77 // Keeps track of the visibility of the focused and active window. 95 // Keeps track of the visibility of the focused and active window.
78 scoped_ptr<ServerWindowDrawnTracker> drawn_tracker_; 96 scoped_ptr<ServerWindowDrawnTracker> drawn_tracker_;
79 97
80 DISALLOW_COPY_AND_ASSIGN(FocusController); 98 DISALLOW_COPY_AND_ASSIGN(FocusController);
81 }; 99 };
82 100
83 } // namespace ws 101 } // namespace ws
84 102
85 } // namespace mus 103 } // namespace mus
86 104
87 #endif // COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_ 105 #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