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

Side by Side Diff: ash/wm/ash_focus_rules.cc

Issue 2809073002: cros: allow aura window not considered activatable for pointer event (Closed)
Patch Set: const ui::Event* Created 3 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 | « ash/wm/ash_focus_rules.h ('k') | ash/wm/window_manager_unittest.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ash/wm/ash_focus_rules.h" 5 #include "ash/wm/ash_focus_rules.h"
6 6
7 #include "ash/public/cpp/shell_window_ids.h" 7 #include "ash/public/cpp/shell_window_ids.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_port.h" 9 #include "ash/shell_port.h"
10 #include "ash/wm/container_finder.h" 10 #include "ash/wm/container_finder.h"
11 #include "ash/wm/focus_rules.h" 11 #include "ash/wm/focus_rules.h"
12 #include "ash/wm/mru_window_tracker.h" 12 #include "ash/wm/mru_window_tracker.h"
13 #include "ash/wm/window_state.h" 13 #include "ash/wm/window_state.h"
14 #include "ash/wm/window_state_aura.h" 14 #include "ash/wm/window_state_aura.h"
15 #include "ash/wm_window.h" 15 #include "ash/wm_window.h"
16 #include "ui/aura/client/aura_constants.h"
16 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
18 #include "ui/events/event.h"
17 19
18 namespace ash { 20 namespace ash {
19 namespace wm { 21 namespace wm {
20 namespace { 22 namespace {
21 23
22 bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window, 24 bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window,
23 int container_id) { 25 int container_id) {
24 for (; window; window = window->parent()) { 26 for (; window; window = window->parent()) {
25 if (window->id() >= container_id) 27 if (window->id() >= container_id)
26 return true; 28 return true;
27 } 29 }
28 return false; 30 return false;
29 } 31 }
30 32
31 } // namespace 33 } // namespace
32 34
33 //////////////////////////////////////////////////////////////////////////////// 35 ////////////////////////////////////////////////////////////////////////////////
34 // AshFocusRules, public: 36 // AshFocusRules, public:
35 37
36 AshFocusRules::AshFocusRules() {} 38 AshFocusRules::AshFocusRules() = default;
37 39
38 AshFocusRules::~AshFocusRules() {} 40 AshFocusRules::~AshFocusRules() = default;
39
40 bool AshFocusRules::IsWindowConsideredActivatable(aura::Window* window) const {
41 return ash::IsWindowConsideredActivatable(WmWindow::Get(window));
42 }
43 41
44 //////////////////////////////////////////////////////////////////////////////// 42 ////////////////////////////////////////////////////////////////////////////////
45 // AshFocusRules, ::wm::FocusRules: 43 // AshFocusRules, ::wm::FocusRules:
46 44
47 bool AshFocusRules::IsToplevelWindow(aura::Window* window) const { 45 bool AshFocusRules::IsToplevelWindow(aura::Window* window) const {
48 return ash::IsToplevelWindow(WmWindow::Get(window)); 46 return ash::IsToplevelWindow(WmWindow::Get(window));
49 } 47 }
50 48
51 bool AshFocusRules::SupportsChildActivation(aura::Window* window) const { 49 bool AshFocusRules::SupportsChildActivation(aura::Window* window) const {
52 return ash::IsActivatableShellWindowId(window->id()); 50 return ash::IsActivatableShellWindowId(window->id());
(...skipping 13 matching lines...) Expand all
66 return false; 64 return false;
67 65
68 if (ShellPort::Get()->IsSystemModalWindowOpen()) { 66 if (ShellPort::Get()->IsSystemModalWindowOpen()) {
69 return BelongsToContainerWithEqualOrGreaterId( 67 return BelongsToContainerWithEqualOrGreaterId(
70 window, kShellWindowId_SystemModalContainer); 68 window, kShellWindowId_SystemModalContainer);
71 } 69 }
72 70
73 return true; 71 return true;
74 } 72 }
75 73
74 bool AshFocusRules::CanFocusWindow(aura::Window* window,
75 const ui::Event* event) const {
76 if (!window)
77 return true;
78
79 if (event && (event->IsMouseEvent() || event->IsGestureEvent()) &&
oshima 2017/04/27 20:50:17 We don't need to check touch event?
Qiang(Joe) Xu 2017/04/27 21:32:24 yes, touch event is actually handled in https://cs
80 !window->GetProperty(aura::client::kActivateOnPointerKey)) {
81 return false;
82 }
83
84 return BaseFocusRules::CanFocusWindow(window, event);
85 }
86
76 aura::Window* AshFocusRules::GetNextActivatableWindow( 87 aura::Window* AshFocusRules::GetNextActivatableWindow(
77 aura::Window* ignore) const { 88 aura::Window* ignore) const {
78 DCHECK(ignore); 89 DCHECK(ignore);
79 90
80 // Start from the container of the most-recently-used window. If the list of 91 // Start from the container of the most-recently-used window. If the list of
81 // MRU windows is empty, then start from the container of the window that just 92 // MRU windows is empty, then start from the container of the window that just
82 // lost focus |ignore|. 93 // lost focus |ignore|.
83 MruWindowTracker* mru = Shell::Get()->mru_window_tracker(); 94 MruWindowTracker* mru = Shell::Get()->mru_window_tracker();
84 std::vector<WmWindow*> windows = mru->BuildMruWindowList(); 95 std::vector<WmWindow*> windows = mru->BuildMruWindowList();
85 aura::Window* starting_window = 96 aura::Window* starting_window =
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 aura::Window* container, 145 aura::Window* container,
135 aura::Window* ignore) const { 146 aura::Window* ignore) const {
136 for (aura::Window::Windows::const_reverse_iterator i = 147 for (aura::Window::Windows::const_reverse_iterator i =
137 container->children().rbegin(); 148 container->children().rbegin();
138 i != container->children().rend(); ++i) { 149 i != container->children().rend(); ++i) {
139 WindowState* window_state = GetWindowState(*i); 150 WindowState* window_state = GetWindowState(*i);
140 if (*i != ignore && window_state->CanActivate() && 151 if (*i != ignore && window_state->CanActivate() &&
141 !window_state->IsMinimized()) 152 !window_state->IsMinimized())
142 return *i; 153 return *i;
143 } 154 }
144 return NULL; 155 return nullptr;
145 } 156 }
146 157
147 } // namespace wm 158 } // namespace wm
148 } // namespace ash 159 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/ash_focus_rules.h ('k') | ash/wm/window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698