OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/screen/public/screen_manager.h" | 5 #include "athena/screen/public/screen_manager.h" |
6 | 6 |
7 #include "athena/input/public/accelerator_manager.h" | 7 #include "athena/input/public/accelerator_manager.h" |
8 #include "athena/screen/screen_accelerator_handler.h" | 8 #include "athena/screen/screen_accelerator_handler.h" |
9 #include "athena/util/container_priorities.h" | 9 #include "athena/util/container_priorities.h" |
10 #include "athena/util/fill_layout_manager.h" | 10 #include "athena/util/fill_layout_manager.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 container = container->parent(); | 48 container = container->parent(); |
49 return container; | 49 return container; |
50 } | 50 } |
51 | 51 |
52 class AthenaFocusRules : public wm::BaseFocusRules { | 52 class AthenaFocusRules : public wm::BaseFocusRules { |
53 public: | 53 public: |
54 AthenaFocusRules() {} | 54 AthenaFocusRules() {} |
55 virtual ~AthenaFocusRules() {} | 55 virtual ~AthenaFocusRules() {} |
56 | 56 |
57 // wm::BaseFocusRules: | 57 // wm::BaseFocusRules: |
58 virtual bool SupportsChildActivation(aura::Window* window) const OVERRIDE { | 58 virtual bool SupportsChildActivation(aura::Window* window) const override { |
59 ScreenManager::ContainerParams* params = | 59 ScreenManager::ContainerParams* params = |
60 window->GetProperty(kContainerParamsKey); | 60 window->GetProperty(kContainerParamsKey); |
61 return params && params->can_activate_children; | 61 return params && params->can_activate_children; |
62 } | 62 } |
63 virtual bool CanActivateWindow(aura::Window* window) const OVERRIDE { | 63 virtual bool CanActivateWindow(aura::Window* window) const override { |
64 // Check if containers of higher z-order than |window| have 'grab_inputs' | 64 // Check if containers of higher z-order than |window| have 'grab_inputs' |
65 // fields. | 65 // fields. |
66 if (window) { | 66 if (window) { |
67 const aura::Window::Windows& containers = | 67 const aura::Window::Windows& containers = |
68 window->GetRootWindow()->children(); | 68 window->GetRootWindow()->children(); |
69 aura::Window::Windows::const_iterator iter = | 69 aura::Window::Windows::const_iterator iter = |
70 std::find(containers.begin(), containers.end(), GetContainer(window)); | 70 std::find(containers.begin(), containers.end(), GetContainer(window)); |
71 DCHECK(iter != containers.end()); | 71 DCHECK(iter != containers.end()); |
72 for (++iter; iter != containers.end(); ++iter) { | 72 for (++iter; iter != containers.end(); ++iter) { |
73 if (GrabsInput(*iter)) | 73 if (GrabsInput(*iter)) |
(...skipping 11 matching lines...) Expand all Loading... |
85 public: | 85 public: |
86 explicit AthenaWindowTreeClient(aura::Window* container) | 86 explicit AthenaWindowTreeClient(aura::Window* container) |
87 : container_(container) {} | 87 : container_(container) {} |
88 | 88 |
89 private: | 89 private: |
90 virtual ~AthenaWindowTreeClient() {} | 90 virtual ~AthenaWindowTreeClient() {} |
91 | 91 |
92 // aura::client::WindowTreeClient: | 92 // aura::client::WindowTreeClient: |
93 virtual aura::Window* GetDefaultParent(aura::Window* context, | 93 virtual aura::Window* GetDefaultParent(aura::Window* context, |
94 aura::Window* window, | 94 aura::Window* window, |
95 const gfx::Rect& bounds) OVERRIDE { | 95 const gfx::Rect& bounds) override { |
96 aura::Window* transient_parent = wm::GetTransientParent(window); | 96 aura::Window* transient_parent = wm::GetTransientParent(window); |
97 if (transient_parent) | 97 if (transient_parent) |
98 return GetContainer(transient_parent); | 98 return GetContainer(transient_parent); |
99 return container_; | 99 return container_; |
100 } | 100 } |
101 | 101 |
102 aura::Window* container_; | 102 aura::Window* container_; |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(AthenaWindowTreeClient); | 104 DISALLOW_COPY_AND_ASSIGN(AthenaWindowTreeClient); |
105 }; | 105 }; |
106 | 106 |
107 class AthenaScreenPositionClient : public aura::client::ScreenPositionClient { | 107 class AthenaScreenPositionClient : public aura::client::ScreenPositionClient { |
108 public: | 108 public: |
109 AthenaScreenPositionClient() { | 109 AthenaScreenPositionClient() { |
110 } | 110 } |
111 virtual ~AthenaScreenPositionClient() { | 111 virtual ~AthenaScreenPositionClient() { |
112 } | 112 } |
113 | 113 |
114 private: | 114 private: |
115 // aura::client::ScreenPositionClient: | 115 // aura::client::ScreenPositionClient: |
116 virtual void ConvertPointToScreen(const aura::Window* window, | 116 virtual void ConvertPointToScreen(const aura::Window* window, |
117 gfx::Point* point) OVERRIDE { | 117 gfx::Point* point) override { |
118 const aura::Window* root = window->GetRootWindow(); | 118 const aura::Window* root = window->GetRootWindow(); |
119 aura::Window::ConvertPointToTarget(window, root, point); | 119 aura::Window::ConvertPointToTarget(window, root, point); |
120 } | 120 } |
121 | 121 |
122 virtual void ConvertPointFromScreen(const aura::Window* window, | 122 virtual void ConvertPointFromScreen(const aura::Window* window, |
123 gfx::Point* point) OVERRIDE { | 123 gfx::Point* point) override { |
124 const aura::Window* root = window->GetRootWindow(); | 124 const aura::Window* root = window->GetRootWindow(); |
125 aura::Window::ConvertPointToTarget(root, window, point); | 125 aura::Window::ConvertPointToTarget(root, window, point); |
126 } | 126 } |
127 | 127 |
128 virtual void ConvertHostPointToScreen(aura::Window* window, | 128 virtual void ConvertHostPointToScreen(aura::Window* window, |
129 gfx::Point* point) OVERRIDE { | 129 gfx::Point* point) override { |
130 // TODO(oshima): Implement this when adding multiple display support. | 130 // TODO(oshima): Implement this when adding multiple display support. |
131 NOTREACHED(); | 131 NOTREACHED(); |
132 } | 132 } |
133 | 133 |
134 virtual void SetBounds(aura::Window* window, | 134 virtual void SetBounds(aura::Window* window, |
135 const gfx::Rect& bounds, | 135 const gfx::Rect& bounds, |
136 const gfx::Display& display) OVERRIDE { | 136 const gfx::Display& display) override { |
137 window->SetBounds(bounds); | 137 window->SetBounds(bounds); |
138 } | 138 } |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(AthenaScreenPositionClient); | 140 DISALLOW_COPY_AND_ASSIGN(AthenaScreenPositionClient); |
141 }; | 141 }; |
142 | 142 |
143 class AthenaEventTargeter : public aura::WindowTargeter, | 143 class AthenaEventTargeter : public aura::WindowTargeter, |
144 public aura::WindowObserver { | 144 public aura::WindowObserver { |
145 public: | 145 public: |
146 explicit AthenaEventTargeter(aura::Window* container) | 146 explicit AthenaEventTargeter(aura::Window* container) |
147 : container_(container) { | 147 : container_(container) { |
148 container_->AddObserver(this); | 148 container_->AddObserver(this); |
149 } | 149 } |
150 | 150 |
151 virtual ~AthenaEventTargeter() { | 151 virtual ~AthenaEventTargeter() { |
152 // Removed before the container is removed. | 152 // Removed before the container is removed. |
153 if (container_) | 153 if (container_) |
154 container_->RemoveObserver(this); | 154 container_->RemoveObserver(this); |
155 } | 155 } |
156 | 156 |
157 private: | 157 private: |
158 // aura::WindowTargeter: | 158 // aura::WindowTargeter: |
159 virtual bool SubtreeCanAcceptEvent( | 159 virtual bool SubtreeCanAcceptEvent( |
160 ui::EventTarget* target, | 160 ui::EventTarget* target, |
161 const ui::LocatedEvent& event) const OVERRIDE { | 161 const ui::LocatedEvent& event) const override { |
162 aura::Window* window = static_cast<aura::Window*>(target); | 162 aura::Window* window = static_cast<aura::Window*>(target); |
163 const aura::Window::Windows& containers = | 163 const aura::Window::Windows& containers = |
164 container_->GetRootWindow()->children(); | 164 container_->GetRootWindow()->children(); |
165 aura::Window::Windows::const_iterator iter = | 165 aura::Window::Windows::const_iterator iter = |
166 std::find(containers.begin(), containers.end(), container_); | 166 std::find(containers.begin(), containers.end(), container_); |
167 DCHECK(iter != containers.end()); | 167 DCHECK(iter != containers.end()); |
168 for (; iter != containers.end(); ++iter) { | 168 for (; iter != containers.end(); ++iter) { |
169 if ((*iter)->Contains(window)) | 169 if ((*iter)->Contains(window)) |
170 return true; | 170 return true; |
171 } | 171 } |
172 return false; | 172 return false; |
173 } | 173 } |
174 | 174 |
175 // aura::WindowObserver: | 175 // aura::WindowObserver: |
176 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { | 176 virtual void OnWindowDestroying(aura::Window* window) override { |
177 aura::Window* root_window = container_->GetRootWindow(); | 177 aura::Window* root_window = container_->GetRootWindow(); |
178 DCHECK_EQ(window, container_); | 178 DCHECK_EQ(window, container_); |
179 DCHECK_EQ( | 179 DCHECK_EQ( |
180 this, static_cast<ui::EventTarget*>(root_window)->GetEventTargeter()); | 180 this, static_cast<ui::EventTarget*>(root_window)->GetEventTargeter()); |
181 | 181 |
182 container_->RemoveObserver(this); | 182 container_->RemoveObserver(this); |
183 container_ = NULL; | 183 container_ = NULL; |
184 | 184 |
185 // This will remove myself. | 185 // This will remove myself. |
186 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); | 186 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); |
187 } | 187 } |
188 | 188 |
189 aura::Window* container_; | 189 aura::Window* container_; |
190 | 190 |
191 DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter); | 191 DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter); |
192 }; | 192 }; |
193 | 193 |
194 class ScreenManagerImpl : public ScreenManager { | 194 class ScreenManagerImpl : public ScreenManager { |
195 public: | 195 public: |
196 explicit ScreenManagerImpl(aura::Window* root_window); | 196 explicit ScreenManagerImpl(aura::Window* root_window); |
197 virtual ~ScreenManagerImpl(); | 197 virtual ~ScreenManagerImpl(); |
198 | 198 |
199 void Init(); | 199 void Init(); |
200 | 200 |
201 private: | 201 private: |
202 // ScreenManager: | 202 // ScreenManager: |
203 virtual aura::Window* CreateDefaultContainer( | 203 virtual aura::Window* CreateDefaultContainer( |
204 const ContainerParams& params) OVERRIDE; | 204 const ContainerParams& params) override; |
205 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; | 205 virtual aura::Window* CreateContainer(const ContainerParams& params) override; |
206 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } | 206 virtual aura::Window* GetContext() override { return root_window_; } |
207 virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE; | 207 virtual void SetRotation(gfx::Display::Rotation rotation) override; |
208 virtual void SetRotationLocked(bool rotation_locked) OVERRIDE; | 208 virtual void SetRotationLocked(bool rotation_locked) override; |
209 | 209 |
210 // Not owned. | 210 // Not owned. |
211 aura::Window* root_window_; | 211 aura::Window* root_window_; |
212 | 212 |
213 scoped_ptr<aura::client::FocusClient> focus_client_; | 213 scoped_ptr<aura::client::FocusClient> focus_client_; |
214 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; | 214 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; |
215 scoped_ptr<AcceleratorHandler> accelerator_handler_; | 215 scoped_ptr<AcceleratorHandler> accelerator_handler_; |
216 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; | 216 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; |
217 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; | 217 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; |
218 | 218 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } | 385 } |
386 | 386 |
387 // static | 387 // static |
388 void ScreenManager::Shutdown() { | 388 void ScreenManager::Shutdown() { |
389 DCHECK(instance); | 389 DCHECK(instance); |
390 delete instance; | 390 delete instance; |
391 DCHECK(!instance); | 391 DCHECK(!instance); |
392 } | 392 } |
393 | 393 |
394 } // namespace athena | 394 } // namespace athena |
OLD | NEW |