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

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

Issue 1459463004: mus: Allow the WM to specify the windows that can have active children. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot-merge Created 5 years 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 | « components/mus/ws/BUILD.gn ('k') | 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/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/observer_list.h" 9 #include "base/observer_list.h"
10 #include "components/mus/ws/server_window_drawn_tracker_observer.h" 10 #include "components/mus/ws/server_window_drawn_tracker_observer.h"
11 11
12 namespace mus { 12 namespace mus {
13 13
14 namespace ws { 14 namespace ws {
15 15
16 class FocusControllerDelegate;
16 class FocusControllerObserver; 17 class FocusControllerObserver;
17 class ServerWindow; 18 class ServerWindow;
18 class ServerWindowDrawnTracker; 19 class ServerWindowDrawnTracker;
19 20
20 // Describes the source of the change. 21 // Describes the source of the change.
21 enum class FocusControllerChangeSource { 22 enum class FocusControllerChangeSource {
22 EXPLICIT, 23 EXPLICIT,
23 DRAWN_STATE_CHANGED, 24 DRAWN_STATE_CHANGED,
24 }; 25 };
25 26
26 // Tracks the focused window. Focus is moved to another window when the drawn 27 // Tracks the focused window. Focus is moved to another window when the drawn
27 // state of the focused window changes. 28 // state of the focused window changes.
28 class FocusController : public ServerWindowDrawnTrackerObserver { 29 class FocusController : public ServerWindowDrawnTrackerObserver {
29 public: 30 public:
30 FocusController(); 31 explicit FocusController(FocusControllerDelegate* delegate);
31 ~FocusController() override; 32 ~FocusController() override;
32 33
33 // Sets the focused window. Does nothing if |window| is currently focused. 34 // Sets the focused window. Does nothing if |window| is currently focused.
34 // This does not notify the delegate. 35 // This does not notify the delegate.
35 void SetFocusedWindow(ServerWindow* window); 36 void SetFocusedWindow(ServerWindow* window);
36 ServerWindow* GetFocusedWindow(); 37 ServerWindow* GetFocusedWindow();
37 38
38 // Moves activation to the next activatable window.
39 void CycleActivationForward();
40
41 void AddObserver(FocusControllerObserver* observer); 39 void AddObserver(FocusControllerObserver* observer);
42 void RemoveObserver(FocusControllerObserver* observer); 40 void RemoveObserver(FocusControllerObserver* observer);
43 41
44 private: 42 private:
45 // Returns whether |window| can be focused or activated. 43 // Returns whether |window| can be focused or activated.
46 bool CanBeFocused(ServerWindow* window) const; 44 bool CanBeFocused(ServerWindow* window) const;
47 bool CanBeActivated(ServerWindow* window) const; 45 bool CanBeActivated(ServerWindow* window) const;
48 46
47 // Returns the closest activatable ancestor of |window|. Returns nullptr if
48 // there is no such ancestor.
49 ServerWindow* GetActivatableAncestorOf(ServerWindow* window) const;
50
49 // Implementation of SetFocusedWindow(). 51 // Implementation of SetFocusedWindow().
50 void SetFocusedWindowImpl(FocusControllerChangeSource change_source, 52 void SetFocusedWindowImpl(FocusControllerChangeSource change_source,
51 ServerWindow* window); 53 ServerWindow* window);
52 54
53 // ServerWindowDrawnTrackerObserver: 55 // ServerWindowDrawnTrackerObserver:
54 void OnDrawnStateChanged(ServerWindow* ancestor, 56 void OnDrawnStateChanged(ServerWindow* ancestor,
55 ServerWindow* window, 57 ServerWindow* window,
56 bool is_drawn) override; 58 bool is_drawn) override;
57 59
60 FocusControllerDelegate* delegate_;
61
62 ServerWindow* focused_window_;
63 ServerWindow* active_window_;
64
58 base::ObserverList<FocusControllerObserver> observers_; 65 base::ObserverList<FocusControllerObserver> observers_;
66
67 // Keeps track of the visibility of the focused and active window.
59 scoped_ptr<ServerWindowDrawnTracker> drawn_tracker_; 68 scoped_ptr<ServerWindowDrawnTracker> drawn_tracker_;
60 69
61 DISALLOW_COPY_AND_ASSIGN(FocusController); 70 DISALLOW_COPY_AND_ASSIGN(FocusController);
62 }; 71 };
63 72
64 } // namespace ws 73 } // namespace ws
65 74
66 } // namespace mus 75 } // namespace mus
67 76
68 #endif // COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_ 77 #endif // COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_
OLDNEW
« no previous file with comments | « components/mus/ws/BUILD.gn ('k') | components/mus/ws/focus_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698