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

Side by Side Diff: ash/wm/always_on_top_controller.cc

Issue 10830365: Initial crack at new workspace behavior. Each workspace now has its (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
« no previous file with comments | « ash/wm/always_on_top_controller.h ('k') | ash/wm/base_layout_manager.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 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 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/always_on_top_controller.h" 5 #include "ash/wm/always_on_top_controller.h"
6 6
7 #include "ash/root_window_controller.h"
8 #include "ash/wm/property_util.h"
9 #include "ash/wm/workspace_controller.h"
7 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
8 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
9 12
10 namespace ash { 13 namespace ash {
11 namespace internal { 14 namespace internal {
12 15
13 AlwaysOnTopController::AlwaysOnTopController() 16 AlwaysOnTopController::AlwaysOnTopController()
14 : default_container_(NULL), 17 : default_container_(NULL),
15 always_on_top_container_(NULL) { 18 always_on_top_container_(NULL) {
16 } 19 }
17 20
18 AlwaysOnTopController::~AlwaysOnTopController() { 21 AlwaysOnTopController::~AlwaysOnTopController() {
19 if (default_container_) 22 if (default_container_)
20 default_container_->RemoveObserver(this); 23 default_container_->RemoveObserver(this);
21 if (always_on_top_container_) 24 if (always_on_top_container_)
22 always_on_top_container_->RemoveObserver(this); 25 always_on_top_container_->RemoveObserver(this);
23 } 26 }
24 27
25 void AlwaysOnTopController::SetContainers(aura::Window* default_container, 28 void AlwaysOnTopController::SetContainers(
29 aura::Window* default_container,
26 aura::Window* always_on_top_container) { 30 aura::Window* always_on_top_container) {
31 if (WorkspaceController::IsWorkspace2Enabled())
32 default_container = NULL;
33
27 // Both containers should have no children. 34 // Both containers should have no children.
28 DCHECK(default_container->children().empty());
29 DCHECK(always_on_top_container->children().empty()); 35 DCHECK(always_on_top_container->children().empty());
30 36
31 // We are not handling any containers yet. 37 // We are not handling any containers yet.
32 DCHECK(default_container_ == NULL && always_on_top_container_ == NULL); 38 DCHECK(default_container_ == NULL && always_on_top_container_ == NULL);
33 39
34 default_container_ = default_container; 40 default_container_ = default_container;
35 default_container_->AddObserver(this); 41 if (default_container_)
42 default_container_->AddObserver(this);
36 43
37 always_on_top_container_ = always_on_top_container; 44 always_on_top_container_ = always_on_top_container;
38 always_on_top_container_->AddObserver(this); 45 always_on_top_container_->AddObserver(this);
39 } 46 }
40 47
41 aura::Window* AlwaysOnTopController::GetContainer(aura::Window* window) const { 48 aura::Window* AlwaysOnTopController::GetContainer(aura::Window* window) const {
42 DCHECK(default_container_ && always_on_top_container_); 49 DCHECK(always_on_top_container_ &&
43 return !window->GetProperty(aura::client::kAlwaysOnTopKey) ? 50 (default_container_ || WorkspaceController::IsWorkspace2Enabled()));
44 default_container_ : always_on_top_container_; 51 if (window->GetProperty(aura::client::kAlwaysOnTopKey))
52 return always_on_top_container_;
53 if (default_container_)
54 return default_container_;
55 return GetRootWindowController(always_on_top_container_->GetRootWindow())->
56 workspace_controller()->GetParentForNewWindow(window);
45 } 57 }
46 58
47 void AlwaysOnTopController::OnWindowAdded(aura::Window* child) { 59 void AlwaysOnTopController::OnWindowAdded(aura::Window* child) {
48 // Observe direct child of the containers. 60 // Observe direct child of the containers.
49 if (child->parent() == default_container_ || 61 if ((default_container_ && child->parent() == default_container_) ||
50 child->parent() == always_on_top_container_) { 62 child->parent() == always_on_top_container_) {
51 child->AddObserver(this); 63 child->AddObserver(this);
52 } 64 }
53 } 65 }
54 66
55 void AlwaysOnTopController::OnWillRemoveWindow(aura::Window* child) { 67 void AlwaysOnTopController::OnWillRemoveWindow(aura::Window* child) {
56 child->RemoveObserver(this); 68 child->RemoveObserver(this);
57 } 69 }
58 70
59 void AlwaysOnTopController::OnWindowPropertyChanged(aura::Window* window, 71 void AlwaysOnTopController::OnWindowPropertyChanged(aura::Window* window,
(...skipping 10 matching lines...) Expand all
70 82
71 void AlwaysOnTopController::OnWindowDestroyed(aura::Window* window) { 83 void AlwaysOnTopController::OnWindowDestroyed(aura::Window* window) {
72 if (window == default_container_) 84 if (window == default_container_)
73 default_container_ = NULL; 85 default_container_ = NULL;
74 if (window == always_on_top_container_) 86 if (window == always_on_top_container_)
75 always_on_top_container_ = NULL; 87 always_on_top_container_ = NULL;
76 } 88 }
77 89
78 } // namespace internal 90 } // namespace internal
79 } // namespace ash 91 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/always_on_top_controller.h ('k') | ash/wm/base_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698