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

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

Issue 465803002: Make the minimized home card not overlap activities on Athena (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
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/public/screen_manager.h" 5 #include "athena/screen/public/screen_manager.h"
6 6
7 #include "athena/common/container_priorities.h" 7 #include "athena/common/container_priorities.h"
8 #include "athena/common/fill_layout_manager.h" 8 #include "athena/common/fill_layout_manager.h"
9 #include "athena/input/public/accelerator_manager.h" 9 #include "athena/input/public/accelerator_manager.h"
10 #include "athena/screen/background_controller.h" 10 #include "athena/screen/background_controller.h"
11 #include "athena/screen/public/screen_manager_delegate.h"
11 #include "athena/screen/screen_accelerator_handler.h" 12 #include "athena/screen/screen_accelerator_handler.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "ui/aura/client/screen_position_client.h" 15 #include "ui/aura/client/screen_position_client.h"
15 #include "ui/aura/client/window_tree_client.h" 16 #include "ui/aura/client/window_tree_client.h"
16 #include "ui/aura/layout_manager.h" 17 #include "ui/aura/layout_manager.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 #include "ui/aura/window_property.h" 19 #include "ui/aura/window_property.h"
19 #include "ui/aura/window_targeter.h" 20 #include "ui/aura/window_targeter.h"
20 #include "ui/aura/window_tree_host.h" 21 #include "ui/aura/window_tree_host.h"
21 #include "ui/compositor/layer.h" 22 #include "ui/compositor/layer.h"
23 #include "ui/gfx/display.h"
24 #include "ui/gfx/insets.h"
25 #include "ui/gfx/rect.h"
26 #include "ui/gfx/screen.h"
22 #include "ui/wm/core/base_focus_rules.h" 27 #include "ui/wm/core/base_focus_rules.h"
23 #include "ui/wm/core/capture_controller.h" 28 #include "ui/wm/core/capture_controller.h"
24 29
25 namespace athena { 30 namespace athena {
26 namespace { 31 namespace {
27 32
28 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ScreenManager::ContainerParams, 33 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ScreenManager::ContainerParams,
29 kContainerParamsKey, 34 kContainerParamsKey,
30 NULL); 35 NULL);
31 36
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>()); 186 root_window->SetEventTargeter(scoped_ptr<ui::EventTargeter>());
182 } 187 }
183 188
184 aura::Window* container_; 189 aura::Window* container_;
185 190
186 DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter); 191 DISALLOW_COPY_AND_ASSIGN(AthenaEventTargeter);
187 }; 192 };
188 193
189 class ScreenManagerImpl : public ScreenManager { 194 class ScreenManagerImpl : public ScreenManager {
190 public: 195 public:
191 explicit ScreenManagerImpl(aura::Window* root_window); 196 explicit ScreenManagerImpl(ScreenManagerDelegate* delegate,
197 aura::Window* root_window);
192 virtual ~ScreenManagerImpl(); 198 virtual ~ScreenManagerImpl();
193 199
194 void Init(); 200 void Init();
195 201
196 private: 202 private:
197 // ScreenManager: 203 // ScreenManager:
204 virtual gfx::Rect GetWorkArea() OVERRIDE;
205 virtual void SetWorkAreaInsets(const gfx::Insets& insets) OVERRIDE;
198 virtual aura::Window* CreateDefaultContainer( 206 virtual aura::Window* CreateDefaultContainer(
199 const ContainerParams& params) OVERRIDE; 207 const ContainerParams& params) OVERRIDE;
200 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE; 208 virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE;
201 virtual aura::Window* GetContext() OVERRIDE { return root_window_; } 209 virtual aura::Window* GetContext() OVERRIDE { return root_window_; }
202 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE; 210 virtual void SetBackgroundImage(const gfx::ImageSkia& image) OVERRIDE;
203 virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE; 211 virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE;
204 212
213 // Not owned.
214 ScreenManagerDelegate* delegate_;
205 aura::Window* root_window_; 215 aura::Window* root_window_;
206 aura::Window* background_window_; 216 aura::Window* background_window_;
207 217
208 scoped_ptr<BackgroundController> background_controller_; 218 scoped_ptr<BackgroundController> background_controller_;
209 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_; 219 scoped_ptr<aura::client::WindowTreeClient> window_tree_client_;
210 scoped_ptr<AcceleratorHandler> accelerator_handler_; 220 scoped_ptr<AcceleratorHandler> accelerator_handler_;
211 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_; 221 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_;
212 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_; 222 scoped_ptr<aura::client::ScreenPositionClient> screen_position_client_;
213 223
214 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl); 224 DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl);
215 }; 225 };
216 226
217 ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window) 227 ScreenManagerImpl::ScreenManagerImpl(ScreenManagerDelegate* delegate,
218 : root_window_(root_window) { 228 aura::Window* root_window)
229 : delegate_(delegate),
230 root_window_(root_window) {
219 DCHECK(root_window_); 231 DCHECK(root_window_);
220 DCHECK(!instance); 232 DCHECK(!instance);
221 instance = this; 233 instance = this;
222 } 234 }
223 235
224 ScreenManagerImpl::~ScreenManagerImpl() { 236 ScreenManagerImpl::~ScreenManagerImpl() {
225 aura::client::SetScreenPositionClient(root_window_, NULL); 237 aura::client::SetScreenPositionClient(root_window_, NULL);
226 aura::client::SetWindowTreeClient(root_window_, NULL); 238 aura::client::SetWindowTreeClient(root_window_, NULL);
227 instance = NULL; 239 instance = NULL;
228 } 240 }
229 241
230 void ScreenManagerImpl::Init() { 242 void ScreenManagerImpl::Init() {
231 // TODO(oshima): Move the background out from ScreenManager. 243 // TODO(oshima): Move the background out from ScreenManager.
232 root_window_->SetLayoutManager(new FillLayoutManager(root_window_)); 244 root_window_->SetLayoutManager(new FillLayoutManager(root_window_));
233 background_window_ = 245 background_window_ =
234 CreateContainer(ContainerParams("AthenaBackground", CP_BACKGROUND)); 246 CreateContainer(ContainerParams("AthenaBackground", CP_BACKGROUND));
235 247
236 background_window_->SetLayoutManager( 248 background_window_->SetLayoutManager(
237 new FillLayoutManager(background_window_)); 249 new FillLayoutManager(background_window_));
238 background_controller_.reset(new BackgroundController(background_window_)); 250 background_controller_.reset(new BackgroundController(background_window_));
239 251
240 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_)); 252 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_));
241 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_)); 253 accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_));
242 } 254 }
243 255
256 gfx::Rect ScreenManagerImpl::GetWorkArea() {
257 return gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area();
258 }
259
260 void ScreenManagerImpl::SetWorkAreaInsets(const gfx::Insets& insets) {
261 // |delegate_| may be NULL in tests.
262 if (delegate_)
263 delegate_->SetWorkAreaInsets(insets);
264 }
265
244 aura::Window* ScreenManagerImpl::CreateDefaultContainer( 266 aura::Window* ScreenManagerImpl::CreateDefaultContainer(
245 const ContainerParams& params) { 267 const ContainerParams& params) {
246 aura::Window* container = CreateContainer(params); 268 aura::Window* container = CreateContainer(params);
247 window_tree_client_.reset(new AthenaWindowTreeClient(container)); 269 window_tree_client_.reset(new AthenaWindowTreeClient(container));
248 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get()); 270 aura::client::SetWindowTreeClient(root_window_, window_tree_client_.get());
249 271
250 screen_position_client_.reset(new AthenaScreenPositionClient()); 272 screen_position_client_.reset(new AthenaScreenPositionClient());
251 aura::client::SetScreenPositionClient(root_window_, 273 aura::client::SetScreenPositionClient(root_window_,
252 screen_position_client_.get()); 274 screen_position_client_.get());
253 275
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 354
333 ScreenManager::ContainerParams::ContainerParams(const std::string& n, 355 ScreenManager::ContainerParams::ContainerParams(const std::string& n,
334 int priority) 356 int priority)
335 : name(n), 357 : name(n),
336 can_activate_children(false), 358 can_activate_children(false),
337 grab_inputs(false), 359 grab_inputs(false),
338 z_order_priority(priority) { 360 z_order_priority(priority) {
339 } 361 }
340 362
341 // static 363 // static
342 ScreenManager* ScreenManager::Create(aura::Window* root_window) { 364 ScreenManager* ScreenManager::Create(ScreenManagerDelegate* delegate,
343 (new ScreenManagerImpl(root_window))->Init(); 365 aura::Window* root_window) {
366 (new ScreenManagerImpl(delegate, root_window))->Init();
344 DCHECK(instance); 367 DCHECK(instance);
345 return instance; 368 return instance;
346 } 369 }
347 370
348 // static 371 // static
349 ScreenManager* ScreenManager::Get() { 372 ScreenManager* ScreenManager::Get() {
350 DCHECK(instance); 373 DCHECK(instance);
351 return instance; 374 return instance;
352 } 375 }
353 376
354 // static 377 // static
355 void ScreenManager::Shutdown() { 378 void ScreenManager::Shutdown() {
356 DCHECK(instance); 379 DCHECK(instance);
357 delete instance; 380 delete instance;
358 DCHECK(!instance); 381 DCHECK(!instance);
359 } 382 }
360 383
361 // static 384 // static
362 wm::FocusRules* ScreenManager::CreateFocusRules() { 385 wm::FocusRules* ScreenManager::CreateFocusRules() {
363 return new AthenaFocusRules(); 386 return new AthenaFocusRules();
364 } 387 }
365 388
366 } // namespace athena 389 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698