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

Side by Side Diff: services/window_manager/focus_controller.h

Issue 788453002: Put code in //services/window_manager in namespace window_manager (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 SERVICES_WINDOW_MANAGER_FOCUS_CONTROLLER_H_ 5 #ifndef SERVICES_WINDOW_MANAGER_FOCUS_CONTROLLER_H_
6 #define SERVICES_WINDOW_MANAGER_FOCUS_CONTROLLER_H_ 6 #define SERVICES_WINDOW_MANAGER_FOCUS_CONTROLLER_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.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 "base/scoped_observer.h" 11 #include "base/scoped_observer.h"
12 #include "mojo/services/public/cpp/view_manager/view_observer.h" 12 #include "mojo/services/public/cpp/view_manager/view_observer.h"
13 #include "ui/events/event_handler.h" 13 #include "ui/events/event_handler.h"
14 14
15 namespace mojo { 15 namespace window_manager {
16 16
17 class FocusControllerObserver; 17 class FocusControllerObserver;
18 class FocusRules; 18 class FocusRules;
19 19
20 // FocusController handles focus and activation changes in a mojo window 20 // FocusController handles focus and activation changes in a mojo window
21 // manager. Within the window manager, there can only be one focused and one 21 // manager. Within the window manager, there can only be one focused and one
22 // active window at a time. When focus or activation changes, notifications are 22 // active window at a time. When focus or activation changes, notifications are
23 // sent using the FocusControllerObserver interface. 23 // sent using the FocusControllerObserver interface.
24 class FocusController : public ui::EventHandler, 24 class FocusController : public ui::EventHandler, public mojo::ViewObserver {
25 public ViewObserver {
26 public: 25 public:
27 // |rules| cannot be null. 26 // |rules| cannot be null.
28 explicit FocusController(scoped_ptr<FocusRules> rules); 27 explicit FocusController(scoped_ptr<FocusRules> rules);
29 virtual ~FocusController(); 28 virtual ~FocusController();
30 29
31 void AddObserver(FocusControllerObserver* observer); 30 void AddObserver(FocusControllerObserver* observer);
32 void RemoveObserver(FocusControllerObserver* observer); 31 void RemoveObserver(FocusControllerObserver* observer);
33 32
34 void ActivateView(View* view); 33 void ActivateView(mojo::View* view);
35 void DeactivateView(View* view); 34 void DeactivateView(mojo::View* view);
36 View* GetActiveView(); 35 mojo::View* GetActiveView();
37 View* GetActivatableView(View* view); 36 mojo::View* GetActivatableView(mojo::View* view);
38 View* GetToplevelView(View* view); 37 mojo::View* GetToplevelView(mojo::View* view);
39 bool CanActivateView(View* view) const; 38 bool CanActivateView(mojo::View* view) const;
40 39
41 void FocusView(View* view); 40 void FocusView(mojo::View* view);
42 41
43 void ResetFocusWithinActiveView(View* view); 42 void ResetFocusWithinActiveView(mojo::View* view);
44 View* GetFocusedView(); 43 mojo::View* GetFocusedView();
45 44
46 // Overridden from ui::EventHandler: 45 // Overridden from ui::EventHandler:
47 void OnKeyEvent(ui::KeyEvent* event) override; 46 void OnKeyEvent(ui::KeyEvent* event) override;
48 void OnMouseEvent(ui::MouseEvent* event) override; 47 void OnMouseEvent(ui::MouseEvent* event) override;
49 void OnScrollEvent(ui::ScrollEvent* event) override; 48 void OnScrollEvent(ui::ScrollEvent* event) override;
50 void OnTouchEvent(ui::TouchEvent* event) override; 49 void OnTouchEvent(ui::TouchEvent* event) override;
51 void OnGestureEvent(ui::GestureEvent* event) override; 50 void OnGestureEvent(ui::GestureEvent* event) override;
52 51
53 // Overridden from ViewObserver: 52 // Overridden from ViewObserver:
54 void OnTreeChanging(const TreeChangeParams& params) override; 53 void OnTreeChanging(const TreeChangeParams& params) override;
55 void OnTreeChanged(const TreeChangeParams& params) override; 54 void OnTreeChanged(const TreeChangeParams& params) override;
56 void OnViewVisibilityChanged(View* view) override; 55 void OnViewVisibilityChanged(mojo::View* view) override;
57 void OnViewDestroying(View* view) override; 56 void OnViewDestroying(mojo::View* view) override;
58 57
59 private: 58 private:
60 // Internal implementation that sets the focused view, fires events etc. 59 // Internal implementation that sets the focused view, fires events etc.
61 // This function must be called with a valid focusable view. 60 // This function must be called with a valid focusable view.
62 void SetFocusedView(View* view); 61 void SetFocusedView(mojo::View* view);
63 62
64 // Internal implementation that sets the active window, fires events etc. 63 // Internal implementation that sets the active window, fires events etc.
65 // This function must be called with a valid |activatable_window|. 64 // This function must be called with a valid |activatable_window|.
66 // |requested window| refers to the window that was passed in to an external 65 // |requested window| refers to the window that was passed in to an external
67 // request (e.g. FocusWindow or ActivateWindow). It may be null, e.g. if 66 // request (e.g. FocusWindow or ActivateWindow). It may be null, e.g. if
68 // SetActiveWindow was not called by an external request. |activatable_window| 67 // SetActiveWindow was not called by an external request. |activatable_window|
69 // refers to the actual window to be activated, which may be different. 68 // refers to the actual window to be activated, which may be different.
70 void SetActiveView(View* requested_view, 69 void SetActiveView(mojo::View* requested_view, mojo::View* activatable_view);
71 View* activatable_view);
72 70
73 // Called when a window's disposition changed such that it and its hierarchy 71 // Called when a window's disposition changed such that it and its hierarchy
74 // are no longer focusable/activatable. |next| is a valid window that is used 72 // are no longer focusable/activatable. |next| is a valid window that is used
75 // as a starting point for finding a window to focus next based on rules. 73 // as a starting point for finding a window to focus next based on rules.
76 void ViewLostFocusFromDispositionChange(View* view, View* next); 74 void ViewLostFocusFromDispositionChange(mojo::View* view, mojo::View* next);
77 75
78 // Called when an attempt is made to focus or activate a window via an input 76 // Called when an attempt is made to focus or activate a window via an input
79 // event targeted at that window. Rules determine the best focusable window 77 // event targeted at that window. Rules determine the best focusable window
80 // for the input window. 78 // for the input window.
81 void ViewFocusedFromInputEvent(View* view); 79 void ViewFocusedFromInputEvent(mojo::View* view);
82 80
83 View* active_view_; 81 mojo::View* active_view_;
84 View* focused_view_; 82 mojo::View* focused_view_;
85 83
86 bool updating_focus_; 84 bool updating_focus_;
87 bool updating_activation_; 85 bool updating_activation_;
88 86
89 scoped_ptr<FocusRules> rules_; 87 scoped_ptr<FocusRules> rules_;
90 88
91 ObserverList<FocusControllerObserver> focus_controller_observers_; 89 ObserverList<FocusControllerObserver> focus_controller_observers_;
92 90
93 ScopedObserver<View, ViewObserver> observer_manager_; 91 ScopedObserver<mojo::View, ViewObserver> observer_manager_;
94 92
95 DISALLOW_COPY_AND_ASSIGN(FocusController); 93 DISALLOW_COPY_AND_ASSIGN(FocusController);
96 }; 94 };
97 95
98 // Sets/Gets the focus controller for a root view. 96 // Sets/Gets the focus controller for a root view.
99 void SetFocusController(View* view, FocusController* focus_controller); 97 void SetFocusController(mojo::View* view, FocusController* focus_controller);
100 FocusController* GetFocusController(View* view); 98 FocusController* GetFocusController(mojo::View* view);
101 99
102 } // namespace mojo 100 } // namespace window_manager
103 101
104 #endif // SERVICES_WINDOW_MANAGER_FOCUS_CONTROLLER_H_ 102 #endif // SERVICES_WINDOW_MANAGER_FOCUS_CONTROLLER_H_
OLDNEW
« no previous file with comments | « services/window_manager/basic_focus_rules.cc ('k') | services/window_manager/focus_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698