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

Side by Side Diff: ash/wm/aura/wm_globals_aura.cc

Issue 1907863002: Converts DockedWindowLayoutManager to common ash/wm types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 4 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/aura/wm_globals_aura.h ('k') | ash/wm/aura/wm_root_window_controller_aura.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/aura/wm_globals_aura.h" 5 #include "ash/wm/aura/wm_globals_aura.h"
6 6
7 #include "ash/display/window_tree_host_manager.h" 7 #include "ash/display/window_tree_host_manager.h"
8 #include "ash/session/session_state_delegate.h" 8 #include "ash/session/session_state_delegate.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 10 #include "ash/shell_delegate.h"
11 #include "ash/wm/aura/wm_window_aura.h" 11 #include "ash/wm/aura/wm_window_aura.h"
12 #include "ash/wm/common/wm_activation_observer.h"
12 #include "ash/wm/mru_window_tracker.h" 13 #include "ash/wm/mru_window_tracker.h"
13 #include "ash/wm/window_util.h" 14 #include "ash/wm/window_util.h"
15 #include "ui/aura/client/focus_client.h"
14 #include "ui/wm/public/activation_client.h" 16 #include "ui/wm/public/activation_client.h"
15 17
16 namespace ash { 18 namespace ash {
17 namespace wm { 19 namespace wm {
18 namespace { 20 namespace {
19 21
20 WmGlobalsAura* instance_ = nullptr; 22 WmGlobalsAura* instance_ = nullptr;
21 23
22 } // namespace 24 } // namespace
23 25
24 // static 26 // static
25 WmGlobals* WmGlobals::Get() { 27 WmGlobals* WmGlobals::Get() {
26 return instance_; 28 return instance_;
27 } 29 }
28 30
29 WmGlobalsAura::WmGlobalsAura() { 31 WmGlobalsAura::WmGlobalsAura() {
30 DCHECK(!instance_); 32 DCHECK(!instance_);
31 instance_ = this; 33 instance_ = this;
32 } 34 }
33 35
34 WmGlobalsAura::~WmGlobalsAura() { 36 WmGlobalsAura::~WmGlobalsAura() {
35 instance_ = nullptr; 37 instance_ = nullptr;
38 if (added_activation_observer_) {
39 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())
varkha 2016/04/21 14:56:09 I think this fails in the tests. Is that because S
40 ->RemoveObserver(this);
41 }
36 } 42 }
37 43
38 // static 44 // static
39 WmGlobalsAura* WmGlobalsAura::Get() { 45 WmGlobalsAura* WmGlobalsAura::Get() {
40 if (!instance_) 46 if (!instance_)
41 new WmGlobalsAura; 47 new WmGlobalsAura;
42 return instance_; 48 return instance_;
43 } 49 }
44 50
51 WmWindow* WmGlobalsAura::GetFocusedWindow() {
52 return WmWindowAura::Get(
53 aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())
54 ->GetFocusedWindow());
55 }
56
45 WmWindow* WmGlobalsAura::GetActiveWindow() { 57 WmWindow* WmGlobalsAura::GetActiveWindow() {
46 return WmWindowAura::Get(wm::GetActiveWindow()); 58 return WmWindowAura::Get(wm::GetActiveWindow());
47 } 59 }
48 60
49 WmWindow* WmGlobalsAura::GetRootWindowForDisplayId(int64_t display_id) { 61 WmWindow* WmGlobalsAura::GetRootWindowForDisplayId(int64_t display_id) {
50 return WmWindowAura::Get(Shell::GetInstance() 62 return WmWindowAura::Get(Shell::GetInstance()
51 ->window_tree_host_manager() 63 ->window_tree_host_manager()
52 ->GetRootWindowForDisplayId(display_id)); 64 ->GetRootWindowForDisplayId(display_id));
53 } 65 }
54 66
(...skipping 24 matching lines...) Expand all
79 } 91 }
80 92
81 std::vector<WmWindow*> WmGlobalsAura::GetAllRootWindows() { 93 std::vector<WmWindow*> WmGlobalsAura::GetAllRootWindows() {
82 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 94 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
83 std::vector<WmWindow*> wm_windows(root_windows.size()); 95 std::vector<WmWindow*> wm_windows(root_windows.size());
84 for (size_t i = 0; i < root_windows.size(); ++i) 96 for (size_t i = 0; i < root_windows.size(); ++i)
85 wm_windows[i] = WmWindowAura::Get(root_windows[i]); 97 wm_windows[i] = WmWindowAura::Get(root_windows[i]);
86 return wm_windows; 98 return wm_windows;
87 } 99 }
88 100
101 void WmGlobalsAura::AddActivationObserver(WmActivationObserver* observer) {
102 if (!added_activation_observer_) {
103 added_activation_observer_ = true;
104 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())
105 ->AddObserver(this);
106 }
107 activation_observers_.AddObserver(observer);
108 }
109
110 void WmGlobalsAura::RemoveActivationObserver(WmActivationObserver* observer) {
111 activation_observers_.RemoveObserver(observer);
112 }
113
114 void WmGlobalsAura::OnWindowActivated(
115 aura::client::ActivationChangeObserver::ActivationReason reason,
116 aura::Window* gained_active,
117 aura::Window* lost_active) {
118 FOR_EACH_OBSERVER(WmActivationObserver, activation_observers_,
119 OnWindowActivated(WmWindowAura::Get(gained_active),
120 WmWindowAura::Get(lost_active)));
121 }
122
89 } // namespace wm 123 } // namespace wm
90 } // namespace ash 124 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/aura/wm_globals_aura.h ('k') | ash/wm/aura/wm_root_window_controller_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698