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

Side by Side Diff: mojo/services/window_manager/basic_focus_rules.cc

Issue 765753003: Move window_manager service implementation to //services (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
(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 #include "mojo/services/window_manager/basic_focus_rules.h"
6
7 #include "base/macros.h"
8 #include "mojo/services/public/cpp/view_manager/view.h"
9
10 namespace mojo {
11
12 BasicFocusRules::BasicFocusRules(mojo::View* window_container)
13 : window_container_(window_container) {
14 }
15
16 BasicFocusRules::~BasicFocusRules() {}
17
18 bool BasicFocusRules::IsToplevelView(mojo::View* view) const {
19 return view->parent() == window_container_;
20 }
21
22 bool BasicFocusRules::CanActivateView(mojo::View* view) const {
23 // TODO(erg): This needs to check visibility, along with focus, and several
24 // other things (see wm::BaseFocusRules).
25 return view->parent() == window_container_;
26 }
27
28 bool BasicFocusRules::CanFocusView(mojo::View* view) const {
29 return true;
30 }
31
32 mojo::View* BasicFocusRules::GetToplevelView(mojo::View* view) const {
33 while (view->parent() != window_container_) {
34 view = view->parent();
35 // Unparented hierarchy, there is no "top level" window.
36 if (!view)
37 return nullptr;
38 }
39
40 return view;
41 }
42
43 mojo::View* BasicFocusRules::GetActivatableView(mojo::View* view) const {
44 return GetToplevelView(view);
45 }
46
47 mojo::View* BasicFocusRules::GetFocusableView(mojo::View* view) const {
48 return view;
49 }
50
51 mojo::View* BasicFocusRules::GetNextActivatableView(
52 mojo::View* activatable) const {
53 const mojo::View::Children& children = activatable->parent()->children();
54 for (mojo::View::Children::const_reverse_iterator it = children.rbegin();
55 it != children.rend(); ++it) {
56 if (*it != activatable)
57 return *it;
58 }
59 return nullptr;
60 }
61
62 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/window_manager/basic_focus_rules.h ('k') | mojo/services/window_manager/focus_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698