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

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

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

Powered by Google App Engine
This is Rietveld 408576698