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

Side by Side Diff: athena/screen/screen_manager_impl.cc

Issue 653563004: NULL -> nullptr under athena/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
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/screen_manager_impl.h" 5 #include "athena/screen/screen_manager_impl.h"
6 6
7 #include "athena/input/public/accelerator_manager.h" 7 #include "athena/input/public/accelerator_manager.h"
8 #include "athena/screen/modal_window_controller.h" 8 #include "athena/screen/modal_window_controller.h"
9 #include "athena/screen/screen_accelerator_handler.h" 9 #include "athena/screen/screen_accelerator_handler.h"
10 #include "athena/util/container_priorities.h" 10 #include "athena/util/container_priorities.h"
(...skipping 15 matching lines...) Expand all
26 #include "ui/wm/core/window_util.h" 26 #include "ui/wm/core/window_util.h"
27 27
28 // This is to avoid creating type definitoin for kAlwaysOnTopKey. 28 // This is to avoid creating type definitoin for kAlwaysOnTopKey.
29 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ATHENA_EXPORT, bool); 29 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ATHENA_EXPORT, bool);
30 30
31 namespace athena { 31 namespace athena {
32 namespace { 32 namespace {
33 33
34 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ScreenManager::ContainerParams, 34 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ScreenManager::ContainerParams,
35 kContainerParamsKey, 35 kContainerParamsKey,
36 NULL); 36 nullptr);
37 37
38 ScreenManagerImpl* instance = NULL; 38 ScreenManagerImpl* instance = nullptr;
39 39
40 // A functor to find a container that has the higher priority. 40 // A functor to find a container that has the higher priority.
41 struct HigherPriorityFinder { 41 struct HigherPriorityFinder {
42 HigherPriorityFinder(int p) : priority(p) {} 42 HigherPriorityFinder(int p) : priority(p) {}
43 bool operator()(aura::Window* window) { 43 bool operator()(aura::Window* window) {
44 return window->GetProperty(kContainerParamsKey)->z_order_priority > 44 return window->GetProperty(kContainerParamsKey)->z_order_priority >
45 priority; 45 priority;
46 } 46 }
47 int priority; 47 int priority;
48 }; 48 };
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (BlockEvents(*iter)) 104 if (BlockEvents(*iter))
105 return false; 105 return false;
106 } 106 }
107 } 107 }
108 return BaseFocusRules::CanActivateWindow(window); 108 return BaseFocusRules::CanActivateWindow(window);
109 } 109 }
110 110
111 virtual aura::Window* GetNextActivatableWindow( 111 virtual aura::Window* GetNextActivatableWindow(
112 aura::Window* ignore) const override { 112 aura::Window* ignore) const override {
113 aura::Window* next = wm::BaseFocusRules::GetNextActivatableWindow(ignore); 113 aura::Window* next = wm::BaseFocusRules::GetNextActivatableWindow(ignore);
114 // TODO(oshima): Search from activatable containers if |next| is NULL. 114 // TODO(oshima): Search from activatable containers if |next| is nullptr.
115 // crbug.com/424750. 115 // crbug.com/424750.
116 return next; 116 return next;
117 } 117 }
118 118
119 private: 119 private:
120 DISALLOW_COPY_AND_ASSIGN(AthenaFocusRules); 120 DISALLOW_COPY_AND_ASSIGN(AthenaFocusRules);
121 }; 121 };
122 122
123 class AthenaScreenPositionClient : public aura::client::ScreenPositionClient { 123 class AthenaScreenPositionClient : public aura::client::ScreenPositionClient {
124 public: 124 public:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 ui::EventTarget* root, 188 ui::EventTarget* root,
189 ui::LocatedEvent* event) override { 189 ui::LocatedEvent* event) override {
190 ui::EventTarget* target = 190 ui::EventTarget* target =
191 aura::WindowTargeter::FindTargetForLocatedEvent(root, event); 191 aura::WindowTargeter::FindTargetForLocatedEvent(root, event);
192 if (target) 192 if (target)
193 return target; 193 return target;
194 // If the root target is blocking the event, return the container even if 194 // If the root target is blocking the event, return the container even if
195 // there is no target found so that windows behind it will not be searched. 195 // there is no target found so that windows behind it will not be searched.
196 const ScreenManager::ContainerParams* params = 196 const ScreenManager::ContainerParams* params =
197 static_cast<aura::Window*>(root)->GetProperty(kContainerParamsKey); 197 static_cast<aura::Window*>(root)->GetProperty(kContainerParamsKey);
198 return (params && params->block_events) ? root : NULL; 198 return (params && params->block_events) ? root : nullptr;
199 } 199 }
200 200
201 // Not owned. 201 // Not owned.
202 aura::Window* root_window_; 202 aura::Window* root_window_;
203 203
204 DISALLOW_COPY_AND_ASSIGN(AthenaWindowTargeter); 204 DISALLOW_COPY_AND_ASSIGN(AthenaWindowTargeter);
205 }; 205 };
206 206
207 } // namespace 207 } // namespace
208 208
209 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) 209 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window)
210 : root_window_(root_window), 210 : root_window_(root_window),
211 last_requested_rotation_(gfx::Display::ROTATE_0), 211 last_requested_rotation_(gfx::Display::ROTATE_0),
212 rotation_locked_(false) { 212 rotation_locked_(false) {
213 DCHECK(root_window_); 213 DCHECK(root_window_);
214 DCHECK(!instance); 214 DCHECK(!instance);
215 instance = this; 215 instance = this;
216 } 216 }
217 217
218 ScreenManagerImpl::~ScreenManagerImpl() { 218 ScreenManagerImpl::~ScreenManagerImpl() {
219 aura::client::SetScreenPositionClient(root_window_, NULL); 219 aura::client::SetScreenPositionClient(root_window_, nullptr);
220 aura::client::SetWindowTreeClient(root_window_, NULL); 220 aura::client::SetWindowTreeClient(root_window_, nullptr);
221 wm::FocusController* focus_controller = 221 wm::FocusController* focus_controller =
222 static_cast<wm::FocusController*>(focus_client_.get()); 222 static_cast<wm::FocusController*>(focus_client_.get());
223 root_window_->RemovePreTargetHandler(focus_controller); 223 root_window_->RemovePreTargetHandler(focus_controller);
224 aura::client::SetActivationClient(root_window_, NULL); 224 aura::client::SetActivationClient(root_window_, nullptr);
225 aura::client::SetFocusClient(root_window_, NULL); 225 aura::client::SetFocusClient(root_window_, nullptr);
226 aura::Window::Windows children = root_window_->children(); 226 aura::Window::Windows children = root_window_->children();
227 // Close All children: 227 // Close All children:
228 for (aura::Window::Windows::iterator iter = children.begin(); 228 for (aura::Window::Windows::iterator iter = children.begin();
229 iter != children.end(); 229 iter != children.end();
230 ++iter) { 230 ++iter) {
231 delete *iter; 231 delete *iter;
232 } 232 }
233 instance = NULL; 233 instance = nullptr;
234 } 234 }
235 235
236 void ScreenManagerImpl::Init() { 236 void ScreenManagerImpl::Init() {
237 wm::FocusController* focus_controller = 237 wm::FocusController* focus_controller =
238 new wm::FocusController(new AthenaFocusRules()); 238 new wm::FocusController(new AthenaFocusRules());
239 239
240 aura::client::SetFocusClient(root_window_, focus_controller); 240 aura::client::SetFocusClient(root_window_, focus_controller);
241 root_window_->AddPreTargetHandler(focus_controller); 241 root_window_->AddPreTargetHandler(focus_controller);
242 aura::client::SetActivationClient(root_window_, focus_controller); 242 aura::client::SetActivationClient(root_window_, focus_controller);
243 focus_client_.reset(focus_controller); 243 focus_client_.reset(focus_controller);
244 244
245 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); 245 root_window_->SetLayoutManager(new FillLayoutManager(root_window_));
246 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); 246 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_));
247 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); 247 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_));
248 248
249 aura::client::SetWindowTreeClient(root_window_, this); 249 aura::client::SetWindowTreeClient(root_window_, this);
250 250
251 screen_position_client_.reset(new AthenaScreenPositionClient()); 251 screen_position_client_.reset(new AthenaScreenPositionClient());
252 aura::client::SetScreenPositionClient(root_window_, 252 aura::client::SetScreenPositionClient(root_window_,
253 screen_position_client_.get()); 253 screen_position_client_.get());
254 root_window_->SetEventTargeter( 254 root_window_->SetEventTargeter(
255 make_scoped_ptr(new AthenaWindowTargeter(root_window_))); 255 make_scoped_ptr(new AthenaWindowTargeter(root_window_)));
256 } 256 }
257 257
258 aura::Window* ScreenManagerImpl::FindContainerByPriority(int priority) { 258 aura::Window* ScreenManagerImpl::FindContainerByPriority(int priority) {
259 for (aura::Window* window : root_window_->children()) { 259 for (aura::Window* window : root_window_->children()) {
260 if (window->GetProperty(kContainerParamsKey)->z_order_priority == priority) 260 if (window->GetProperty(kContainerParamsKey)->z_order_priority == priority)
261 return window; 261 return window;
262 } 262 }
263 return NULL; 263 return nullptr;
264 } 264 }
265 265
266 aura::Window* ScreenManagerImpl::CreateContainer( 266 aura::Window* ScreenManagerImpl::CreateContainer(
267 const ContainerParams& params) { 267 const ContainerParams& params) {
268 const aura::Window::Windows& children = root_window_->children(); 268 const aura::Window::Windows& children = root_window_->children();
269 269
270 if (params.default_parent) { 270 if (params.default_parent) {
271 CHECK(std::find_if(children.begin(), children.end(), &DefaultContainer) == 271 CHECK(std::find_if(children.begin(), children.end(), &DefaultContainer) ==
272 children.end()); 272 children.end());
273 } 273 }
274 // mmodal container's priority must be higher than the container's priority. 274 // mmodal container's priority must be higher than the container's priority.
275 DCHECK(params.modal_container_priority == -1 || 275 DCHECK(params.modal_container_priority == -1 ||
276 params.modal_container_priority > params.z_order_priority); 276 params.modal_container_priority > params.z_order_priority);
277 // Default parent must specify modal_container_priority. 277 // Default parent must specify modal_container_priority.
278 DCHECK(!params.default_parent || params.modal_container_priority != -1); 278 DCHECK(!params.default_parent || params.modal_container_priority != -1);
279 279
280 aura::Window* container = new aura::Window(NULL); 280 aura::Window* container = new aura::Window(nullptr);
281 CHECK_GE(params.z_order_priority, 0); 281 CHECK_GE(params.z_order_priority, 0);
282 container->Init(aura::WINDOW_LAYER_NOT_DRAWN); 282 container->Init(aura::WINDOW_LAYER_NOT_DRAWN);
283 container->SetName(params.name); 283 container->SetName(params.name);
284 284
285 DCHECK(!FindContainerByPriority(params.z_order_priority)) 285 DCHECK(!FindContainerByPriority(params.z_order_priority))
286 << "The container with the priority " << params.z_order_priority 286 << "The container with the priority " << params.z_order_priority
287 << " already exists."; 287 << " already exists.";
288 288
289 container->SetProperty(kContainerParamsKey, new ContainerParams(params)); 289 container->SetProperty(kContainerParamsKey, new ContainerParams(params));
290 290
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 396 }
397 397
398 // static 398 // static
399 void ScreenManager::Shutdown() { 399 void ScreenManager::Shutdown() {
400 DCHECK(instance); 400 DCHECK(instance);
401 delete instance; 401 delete instance;
402 DCHECK(!instance); 402 DCHECK(!instance);
403 } 403 }
404 404
405 } // namespace athena 405 } // namespace athena
OLDNEW
« no previous file with comments | « athena/screen/modal_window_controller_unittest.cc ('k') | athena/screen/screen_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698