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

Side by Side Diff: ui/wm/core/focus_controller.cc

Issue 1153633006: Added UMA statistics for changing the active window via click or touch events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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 "ui/wm/core/focus_controller.h" 5 #include "ui/wm/core/focus_controller.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "ui/aura/client/aura_constants.h" 8 #include "ui/aura/client/aura_constants.h"
9 #include "ui/aura/client/capture_client.h" 9 #include "ui/aura/client/capture_client.h"
10 #include "ui/aura/client/focus_change_observer.h" 10 #include "ui/aura/client/focus_change_observer.h"
11 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
12 #include "ui/aura/window_tracker.h" 12 #include "ui/aura/window_tracker.h"
13 #include "ui/base/ime/text_input_focus_manager.h" 13 #include "ui/base/ime/text_input_focus_manager.h"
14 #include "ui/events/event.h"
15 #include "ui/wm/core/focus_rules.h" 14 #include "ui/wm/core/focus_rules.h"
16 #include "ui/wm/core/window_util.h" 15 #include "ui/wm/core/window_util.h"
17 #include "ui/wm/public/activation_change_observer.h" 16 #include "ui/wm/public/activation_change_observer.h"
18 17
19 namespace wm { 18 namespace wm {
20 namespace { 19 namespace {
21 20
22 // When a modal window is activated, we bring its entire transient parent chain 21 // When a modal window is activated, we bring its entire transient parent chain
23 // to the front. This function must be called before the modal transient is 22 // to the front. This function must be called before the modal transient is
24 // stacked at the top to ensure correct stacking order. 23 // stacked at the top to ensure correct stacking order.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 if (!active_window_->Contains(window)) 143 if (!active_window_->Contains(window))
145 return; 144 return;
146 SetFocusedWindow(window); 145 SetFocusedWindow(window);
147 } 146 }
148 147
149 aura::Window* FocusController::GetFocusedWindow() { 148 aura::Window* FocusController::GetFocusedWindow() {
150 return focused_window_; 149 return focused_window_;
151 } 150 }
152 151
153 //////////////////////////////////////////////////////////////////////////////// 152 ////////////////////////////////////////////////////////////////////////////////
154 // FocusController, ui::EventHandler implementation:
155 void FocusController::OnKeyEvent(ui::KeyEvent* event) {
156 }
157
158 void FocusController::OnMouseEvent(ui::MouseEvent* event) {
159 if (event->type() == ui::ET_MOUSE_PRESSED && !event->handled())
160 WindowFocusedFromInputEvent(static_cast<aura::Window*>(event->target()));
161 }
162
163 void FocusController::OnScrollEvent(ui::ScrollEvent* event) {
164 }
165
166 void FocusController::OnTouchEvent(ui::TouchEvent* event) {
167 }
168
169 void FocusController::OnGestureEvent(ui::GestureEvent* event) {
170 if (event->type() == ui::ET_GESTURE_BEGIN &&
171 event->details().touch_points() == 1 &&
172 !event->handled()) {
173 WindowFocusedFromInputEvent(static_cast<aura::Window*>(event->target()));
174 }
175 }
176
177 ////////////////////////////////////////////////////////////////////////////////
178 // FocusController, aura::WindowObserver implementation: 153 // FocusController, aura::WindowObserver implementation:
179 154
180 void FocusController::OnWindowVisibilityChanged(aura::Window* window, 155 void FocusController::OnWindowVisibilityChanged(aura::Window* window,
181 bool visible) { 156 bool visible) {
182 if (!visible) 157 if (!visible)
183 WindowLostFocusFromDispositionChange(window, window->parent()); 158 WindowLostFocusFromDispositionChange(window, window->parent());
184 } 159 }
185 160
186 void FocusController::OnWindowDestroying(aura::Window* window) { 161 void FocusController::OnWindowDestroying(aura::Window* window) {
187 // A window's modality state will interfere with focus restoration during its 162 // A window's modality state will interfere with focus restoration during its
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 aura::Window* next_activatable = rules_->GetNextActivatableWindow(window); 312 aura::Window* next_activatable = rules_->GetNextActivatableWindow(window);
338 SetActiveWindow(NULL, next_activatable); 313 SetActiveWindow(NULL, next_activatable);
339 if (!(active_window_ && active_window_->Contains(focused_window_))) 314 if (!(active_window_ && active_window_->Contains(focused_window_)))
340 SetFocusedWindow(next_activatable); 315 SetFocusedWindow(next_activatable);
341 } else if (window->Contains(focused_window_)) { 316 } else if (window->Contains(focused_window_)) {
342 // Active window isn't changing, but focused window might be. 317 // Active window isn't changing, but focused window might be.
343 SetFocusedWindow(rules_->GetFocusableWindow(next)); 318 SetFocusedWindow(rules_->GetFocusableWindow(next));
344 } 319 }
345 } 320 }
346 321
347 void FocusController::WindowFocusedFromInputEvent(aura::Window* window) {
348 // Only focus |window| if it or any of its parents can be focused. Otherwise
349 // FocusWindow() will focus the topmost window, which may not be the
350 // currently focused one.
351 if (rules_->CanFocusWindow(GetToplevelWindow(window)))
352 FocusWindow(window);
353 }
354
355 } // namespace wm 322 } // namespace wm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698