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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_activation_client.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
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/views/widget/desktop_aura/desktop_activation_client.h" 5 #include "ui/views/widget/desktop_aura/desktop_activation_client.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "ui/aura/client/activation_delegate.h" 9 #include "ui/aura/client/activation_delegate.h"
10 #include "ui/aura/client/activation_change_observer.h" 10 #include "ui/aura/client/activation_change_observer.h"
11 #include "ui/aura/focus_manager.h" 11 #include "ui/aura/client/focus_client.h"
12 #include "ui/aura/root_window.h" 12 #include "ui/aura/root_window.h"
13 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
14 14
15 namespace views { 15 namespace views {
16 16
17 DesktopActivationClient::DesktopActivationClient(aura::RootWindow* root_window) 17 DesktopActivationClient::DesktopActivationClient(aura::RootWindow* root_window)
18 : root_window_(root_window), 18 : root_window_(root_window),
19 current_active_(NULL), 19 current_active_(NULL),
20 updating_activation_(false), 20 updating_activation_(false),
21 ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)) { 21 ALLOW_THIS_IN_INITIALIZER_LIST(observer_manager_(this)) {
22 root_window->GetFocusManager()->AddObserver(this); 22 aura::client::GetFocusClient(root_window_)->AddObserver(this);
23 aura::client::SetActivationClient(root_window_, this); 23 aura::client::SetActivationClient(root_window_, this);
24 } 24 }
25 25
26 DesktopActivationClient::~DesktopActivationClient() { 26 DesktopActivationClient::~DesktopActivationClient() {
27 root_window_->GetFocusManager()->RemoveObserver(this); 27 aura::client::GetFocusClient(root_window_)->RemoveObserver(this);
28 aura::client::SetActivationClient(root_window_, NULL); 28 aura::client::SetActivationClient(root_window_, NULL);
29 } 29 }
30 30
31 void DesktopActivationClient::AddObserver( 31 void DesktopActivationClient::AddObserver(
32 aura::client::ActivationChangeObserver* observer) { 32 aura::client::ActivationChangeObserver* observer) {
33 observers_.AddObserver(observer); 33 observers_.AddObserver(observer);
34 } 34 }
35 35
36 void DesktopActivationClient::RemoveObserver( 36 void DesktopActivationClient::RemoveObserver(
37 aura::client::ActivationChangeObserver* observer) { 37 aura::client::ActivationChangeObserver* observer) {
38 observers_.RemoveObserver(observer); 38 observers_.RemoveObserver(observer);
39 } 39 }
40 40
41 void DesktopActivationClient::ActivateWindow(aura::Window* window) { 41 void DesktopActivationClient::ActivateWindow(aura::Window* window) {
42 // Prevent recursion when called from focus. 42 // Prevent recursion when called from focus.
43 if (updating_activation_) 43 if (updating_activation_)
44 return; 44 return;
45 45
46 base::AutoReset<bool> in_activate_window(&updating_activation_, true); 46 base::AutoReset<bool> in_activate_window(&updating_activation_, true);
47 // Nothing may actually have changed. 47 // Nothing may actually have changed.
48 if (current_active_ == window) 48 if (current_active_ == window)
49 return; 49 return;
50 // The stacking client may impose rules on what window configurations can be 50 // The stacking client may impose rules on what window configurations can be
51 // activated or deactivated. 51 // activated or deactivated.
52 if (window && !CanActivateWindow(window)) 52 if (window && !CanActivateWindow(window))
53 return; 53 return;
54 // Switch internal focus before we change the activation. Will probably cause 54 // Switch internal focus before we change the activation. Will probably cause
55 // recursion. 55 // recursion.
56 if (window && 56 if (window &&
57 !window->Contains(window->GetFocusManager()->GetFocusedWindow())) { 57 !window->Contains(aura::client::GetFocusClient(window)->
58 window->GetFocusManager()->SetFocusedWindow(window, NULL); 58 GetFocusedWindow())) {
59 aura::client::GetFocusClient(window)->FocusWindow(window, NULL);
59 } 60 }
60 61
61 aura::Window* old_active = current_active_; 62 aura::Window* old_active = current_active_;
62 current_active_ = window; 63 current_active_ = window;
63 if (window && !observer_manager_.IsObserving(window)) 64 if (window && !observer_manager_.IsObserving(window))
64 observer_manager_.Add(window); 65 observer_manager_.Add(window);
65 66
66 FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver, 67 FOR_EACH_OBSERVER(aura::client::ActivationChangeObserver,
67 observers_, 68 observers_,
68 OnWindowActivated(window, old_active)); 69 OnWindowActivated(window, old_active));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // that path instead. 128 // that path instead.
128 if (child->transient_parent()) 129 if (child->transient_parent())
129 return GetActivatableWindow(child->transient_parent()); 130 return GetActivatableWindow(child->transient_parent());
130 parent = parent->parent(); 131 parent = parent->parent();
131 child = child->parent(); 132 child = child->parent();
132 } 133 }
133 return NULL; 134 return NULL;
134 } 135 }
135 136
136 } // namespace views 137 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_activation_client.h ('k') | ui/views/widget/desktop_aura/desktop_native_widget_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698