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

Side by Side Diff: ui/aura/focus_manager.cc

Issue 26116008: Remove old FocusManager code from Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/focus_manager.h ('k') | ui/aura/remote_root_window_host_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/aura/focus_manager.h"
6
7 #include "ui/aura/client/activation_client.h"
8 #include "ui/aura/client/focus_change_observer.h"
9 #include "ui/aura/root_window.h"
10 #include "ui/aura/window_delegate.h"
11
12 namespace aura {
13
14 ////////////////////////////////////////////////////////////////////////////////
15 // FocusManager, public:
16
17 FocusManager::FocusManager() : focused_window_(NULL) {
18 }
19
20 FocusManager::~FocusManager() {
21 }
22
23 ////////////////////////////////////////////////////////////////////////////////
24 // FocusManager, client::FocusClient implementation:
25
26 void FocusManager::AddObserver(client::FocusChangeObserver* observer) {
27 observers_.AddObserver(observer);
28 }
29
30 void FocusManager::RemoveObserver(client::FocusChangeObserver* observer) {
31 observers_.RemoveObserver(observer);
32 }
33
34 void FocusManager::FocusWindow(Window* focused_window) {
35 if (focused_window == focused_window_)
36 return;
37 if (focused_window && !focused_window->CanFocus())
38 return;
39 // The NULL-check of |focused_window| is essential here before asking the
40 // activation client, since it is valid to clear the focus by calling
41 // SetFocusedWindow() to NULL.
42
43 if (focused_window) {
44 RootWindow* root = focused_window->GetRootWindow();
45 DCHECK(root);
46 if (client::GetActivationClient(root) &&
47 !client::GetActivationClient(root)->OnWillFocusWindow(
48 focused_window, NULL)) {
49 return;
50 }
51 }
52
53 Window* old_focused_window = focused_window_;
54 focused_window_ = focused_window;
55
56 FOR_EACH_OBSERVER(client::FocusChangeObserver, observers_,
57 OnWindowFocused(focused_window, old_focused_window));
58 client::FocusChangeObserver* observer =
59 client::GetFocusChangeObserver(old_focused_window);
60 if (observer)
61 observer->OnWindowFocused(focused_window_, old_focused_window);
62 observer = client::GetFocusChangeObserver(focused_window_);
63 if (observer)
64 observer->OnWindowFocused(focused_window_, old_focused_window);
65 }
66
67 void FocusManager::ResetFocusWithinActiveWindow(Window* window) {
68 FocusWindow(window);
69 }
70
71 Window* FocusManager::GetFocusedWindow() {
72 return focused_window_;
73 }
74
75 void FocusManager::OnWindowHiddenInRootWindow(
76 aura::Window* window,
77 aura::RootWindow* root_window,
78 bool destroyed) {
79 Window* focused_window =
80 client::GetFocusClient(root_window)->GetFocusedWindow();
81 if (window->Contains(focused_window)) {
82 Window* focus_to = window->transient_parent();
83 if (focus_to) {
84 // Has to be removed from the transient parent before focusing,
85 // otherwise |window| will be focused again.
86 if (destroyed)
87 focus_to->RemoveTransientChild(window);
88 } else {
89 // If the invisible view has no visible transient window, focus to the
90 // topmost visible parent window.
91 focus_to = window->parent();
92 }
93 if (focus_to &&
94 (!focus_to->IsVisible() ||
95 !focus_to->CanFocus() ||
96 (client::GetActivationClient(root_window) &&
97 !client::GetActivationClient(root_window)->OnWillFocusWindow(
98 focus_to, NULL)))) {
99 focus_to = NULL;
100 }
101 client::GetFocusClient(root_window)->FocusWindow(focus_to);
102 }
103 }
104
105 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/focus_manager.h ('k') | ui/aura/remote_root_window_host_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698