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

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

Issue 1868783003: Makes SetFocus() notify callback correctly on failure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/display_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
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"
(...skipping 17 matching lines...) Expand all
28 }; 28 };
29 29
30 // 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
31 // state of the focused window changes. 31 // state of the focused window changes.
32 class FocusController : public ServerWindowDrawnTrackerObserver { 32 class FocusController : public ServerWindowDrawnTrackerObserver {
33 public: 33 public:
34 FocusController(FocusControllerDelegate* delegate, ServerWindow* root); 34 FocusController(FocusControllerDelegate* delegate, ServerWindow* root);
35 ~FocusController() override; 35 ~FocusController() override;
36 36
37 // Sets the focused window. Does nothing if |window| is currently focused. 37 // Sets the focused window. Does nothing if |window| is currently focused.
38 // This does not notify the delegate. 38 // This does not notify the delegate. See ServerWindow::SetFocusedWindow()
39 void SetFocusedWindow(ServerWindow* window); 39 // for details on return value.
40 bool SetFocusedWindow(ServerWindow* window);
40 ServerWindow* GetFocusedWindow(); 41 ServerWindow* GetFocusedWindow();
41 42
42 // Moves activation to the next activatable window. 43 // Moves activation to the next activatable window.
43 void ActivateNextWindow(); 44 void ActivateNextWindow();
44 45
45 void AddObserver(FocusControllerObserver* observer); 46 void AddObserver(FocusControllerObserver* observer);
46 void RemoveObserver(FocusControllerObserver* observer); 47 void RemoveObserver(FocusControllerObserver* observer);
47 48
48 private: 49 private:
49 enum class ActivationChangeReason { 50 enum class ActivationChangeReason {
50 UNKNONW, 51 UNKNONW,
51 CYCLE, // Activation changed because of ActivateNextWindow(). 52 CYCLE, // Activation changed because of ActivateNextWindow().
52 FOCUS, // Focus change required a different window to be activated. 53 FOCUS, // Focus change required a different window to be activated.
53 DRAWN_STATE_CHANGED, // Active window was hidden or destroyed. 54 DRAWN_STATE_CHANGED, // Active window was hidden or destroyed.
54 }; 55 };
55 void SetActiveWindow(ServerWindow* window, ActivationChangeReason reason); 56 void SetActiveWindow(ServerWindow* window, ActivationChangeReason reason);
56 57
57 // Returns whether |window| can be focused or activated. 58 // Returns whether |window| can be focused or activated.
58 bool CanBeFocused(ServerWindow* window) const; 59 bool CanBeFocused(ServerWindow* window) const;
59 bool CanBeActivated(ServerWindow* window) const; 60 bool CanBeActivated(ServerWindow* window) const;
60 61
61 // Returns the closest activatable ancestor of |window|. Returns nullptr if 62 // Returns the closest activatable ancestor of |window|. Returns nullptr if
62 // there is no such ancestor. 63 // there is no such ancestor.
63 ServerWindow* GetActivatableAncestorOf(ServerWindow* window) const; 64 ServerWindow* GetActivatableAncestorOf(ServerWindow* window) const;
64 65
65 // Implementation of SetFocusedWindow(). 66 // Implementation of SetFocusedWindow().
66 void SetFocusedWindowImpl(FocusControllerChangeSource change_source, 67 bool SetFocusedWindowImpl(FocusControllerChangeSource change_source,
67 ServerWindow* window); 68 ServerWindow* window);
68 69
69 // ServerWindowDrawnTrackerObserver: 70 // ServerWindowDrawnTrackerObserver:
70 void OnDrawnStateWillChange(ServerWindow* ancestor, 71 void OnDrawnStateWillChange(ServerWindow* ancestor,
71 ServerWindow* window, 72 ServerWindow* window,
72 bool is_drawn) override; 73 bool is_drawn) override;
73 void OnDrawnStateChanged(ServerWindow* ancestor, 74 void OnDrawnStateChanged(ServerWindow* ancestor,
74 ServerWindow* window, 75 ServerWindow* window,
75 bool is_drawn) override; 76 bool is_drawn) override;
76 77
(...skipping 16 matching lines...) Expand all
93 scoped_ptr<ServerWindowDrawnTracker> drawn_tracker_; 94 scoped_ptr<ServerWindowDrawnTracker> drawn_tracker_;
94 95
95 DISALLOW_COPY_AND_ASSIGN(FocusController); 96 DISALLOW_COPY_AND_ASSIGN(FocusController);
96 }; 97 };
97 98
98 } // namespace ws 99 } // namespace ws
99 100
100 } // namespace mus 101 } // namespace mus
101 102
102 #endif // COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_ 103 #endif // COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_
OLDNEW
« no previous file with comments | « components/mus/ws/display_unittest.cc ('k') | components/mus/ws/focus_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698