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

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

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

Powered by Google App Engine
This is Rietveld 408576698