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

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

Issue 11299219: Rework FocusManager as FocusClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/activation_controller.h ('k') | ash/wm/activation_controller_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/activation_controller.h" 5 #include "ash/wm/activation_controller.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/wm/activation_controller_delegate.h" 10 #include "ash/wm/activation_controller_delegate.h"
11 #include "ash/wm/property_util.h" 11 #include "ash/wm/property_util.h"
12 #include "ash/wm/window_modality_controller.h" 12 #include "ash/wm/window_modality_controller.h"
13 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
14 #include "ash/wm/workspace_controller.h" 14 #include "ash/wm/workspace_controller.h"
15 #include "base/auto_reset.h" 15 #include "base/auto_reset.h"
16 #include "ui/aura/client/activation_change_observer.h" 16 #include "ui/aura/client/activation_change_observer.h"
17 #include "ui/aura/client/activation_delegate.h" 17 #include "ui/aura/client/activation_delegate.h"
18 #include "ui/aura/client/aura_constants.h" 18 #include "ui/aura/client/aura_constants.h"
19 #include "ui/aura/client/focus_client.h"
19 #include "ui/aura/env.h" 20 #include "ui/aura/env.h"
20 #include "ui/aura/focus_manager.h"
21 #include "ui/aura/root_window.h" 21 #include "ui/aura/root_window.h"
22 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
23 #include "ui/aura/window_delegate.h" 23 #include "ui/aura/window_delegate.h"
24 #include "ui/base/ui_base_types.h" 24 #include "ui/base/ui_base_types.h"
25 #include "ui/compositor/layer.h" 25 #include "ui/compositor/layer.h"
26 26
27 namespace ash { 27 namespace ash {
28 namespace internal { 28 namespace internal {
29 namespace { 29 namespace {
30 30
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 window = window->parent(); 137 window = window->parent();
138 return window; 138 return window;
139 } 139 }
140 140
141 } // namespace 141 } // namespace
142 142
143 //////////////////////////////////////////////////////////////////////////////// 143 ////////////////////////////////////////////////////////////////////////////////
144 // ActivationController, public: 144 // ActivationController, public:
145 145
146 ActivationController::ActivationController( 146 ActivationController::ActivationController(
147 aura::FocusManager* focus_manager, 147 aura::client::FocusClient* focus_client,
148 ActivationControllerDelegate* delegate) 148 ActivationControllerDelegate* delegate)
149 : focus_manager_(focus_manager), 149 : focus_client_(focus_client),
150 updating_activation_(false), 150 updating_activation_(false),
151 active_window_(NULL), 151 active_window_(NULL),
152 ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)), 152 ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)),
153 delegate_(delegate) { 153 delegate_(delegate) {
154 aura::Env::GetInstance()->AddObserver(this); 154 aura::Env::GetInstance()->AddObserver(this);
155 focus_manager_->AddObserver(this); 155 focus_client_->AddObserver(this);
156 } 156 }
157 157
158 ActivationController::~ActivationController() { 158 ActivationController::~ActivationController() {
159 aura::Env::GetInstance()->RemoveObserver(this); 159 aura::Env::GetInstance()->RemoveObserver(this);
160 focus_manager_->RemoveObserver(this); 160 focus_client_->RemoveObserver(this);
161 } 161 }
162 162
163 // static 163 // static
164 aura::Window* ActivationController::GetActivatableWindow( 164 aura::Window* ActivationController::GetActivatableWindow(
165 aura::Window* window, 165 aura::Window* window,
166 const ui::Event* event) { 166 const ui::Event* event) {
167 aura::Window* parent = window->parent(); 167 aura::Window* parent = window->parent();
168 aura::Window* child = window; 168 aura::Window* child = window;
169 while (parent) { 169 while (parent) {
170 if (CanActivateWindowWithEvent(child, event, CURRENT_VISIBILITY)) 170 if (CanActivateWindowWithEvent(child, event, CURRENT_VISIBILITY))
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 if (window && !CanActivateWindowWithEvent(window, event, CURRENT_VISIBILITY)) 313 if (window && !CanActivateWindowWithEvent(window, event, CURRENT_VISIBILITY))
314 return; 314 return;
315 315
316 if (active_window_ == window) 316 if (active_window_ == window)
317 return; 317 return;
318 318
319 aura::Window* old_active = active_window_; 319 aura::Window* old_active = active_window_;
320 active_window_ = window; 320 active_window_ = window;
321 321
322 if (window && 322 if (window &&
323 !window->Contains(window->GetFocusManager()->GetFocusedWindow())) { 323 !window->Contains(aura::client::GetFocusClient(window)->
324 window->GetFocusManager()->SetFocusedWindow(window, event); 324 GetFocusedWindow())) {
325 aura::client::GetFocusClient(window)->FocusWindow(window, event);
325 } 326 }
326 327
327 FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver, 328 FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver,
328 observers_, 329 observers_,
329 OnWindowActivated(window, old_active)); 330 OnWindowActivated(window, old_active));
330 331
331 // Invoke OnLostActive after we've changed the active window. That way if 332 // Invoke OnLostActive after we've changed the active window. That way if
332 // the delegate queries for active state it doesn't think the window is 333 // the delegate queries for active state it doesn't think the window is
333 // still active. 334 // still active.
334 if (old_active && aura::client::GetActivationDelegate(old_active)) 335 if (old_active && aura::client::GetActivationDelegate(old_active))
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 CanActivateWindowWithEvent(*i, NULL, CURRENT_VISIBILITY) && 407 CanActivateWindowWithEvent(*i, NULL, CURRENT_VISIBILITY) &&
407 !wm::IsWindowMinimized(*i)) 408 !wm::IsWindowMinimized(*i))
408 return *i; 409 return *i;
409 } 410 }
410 return NULL; 411 return NULL;
411 } 412 }
412 413
413 void ActivationController::FocusWindowWithEvent(const ui::Event* event) { 414 void ActivationController::FocusWindowWithEvent(const ui::Event* event) {
414 aura::Window* window = static_cast<aura::Window*>(event->target()); 415 aura::Window* window = static_cast<aura::Window*>(event->target());
415 if (GetActiveWindow() != window) { 416 if (GetActiveWindow() != window) {
416 window->GetFocusManager()->SetFocusedWindow( 417 aura::client::GetFocusClient(window)->FocusWindow(
417 FindFocusableWindowFor(window), event); 418 FindFocusableWindowFor(window), event);
418 } 419 }
419 } 420 }
420 421
421 } // namespace internal 422 } // namespace internal
422 } // namespace ash 423 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/activation_controller.h ('k') | ash/wm/activation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698