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

Side by Side Diff: ash/wm/workspace/workspace_layout_manager.cc

Issue 13896026: Stick windows to sides of workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dock with zero width (no logs) Created 7 years, 6 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
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/workspace/workspace_layout_manager.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/session_state_delegate.h" 9 #include "ash/session_state_delegate.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/shell_window_ids.h"
11 #include "ash/wm/always_on_top_controller.h" 12 #include "ash/wm/always_on_top_controller.h"
12 #include "ash/wm/base_layout_manager.h" 13 #include "ash/wm/base_layout_manager.h"
13 #include "ash/wm/window_animations.h" 14 #include "ash/wm/window_animations.h"
14 #include "ash/wm/window_properties.h" 15 #include "ash/wm/window_properties.h"
15 #include "ash/wm/window_util.h" 16 #include "ash/wm/window_util.h"
16 #include "ash/wm/workspace/workspace.h" 17 #include "ash/wm/workspace/workspace.h"
17 #include "ash/wm/workspace/workspace_manager.h" 18 #include "ash/wm/workspace/workspace_manager.h"
18 #include "ash/wm/workspace/workspace_window_resizer.h" 19 #include "ash/wm/workspace/workspace_window_resizer.h"
19 #include "base/auto_reset.h" 20 #include "base/auto_reset.h"
20 #include "base/command_line.h" 21 #include "base/command_line.h"
(...skipping 20 matching lines...) Expand all
41 typedef std::map<const aura::Window*, gfx::Rect> BoundsMap; 42 typedef std::map<const aura::Window*, gfx::Rect> BoundsMap;
42 43
43 // Adds an entry from |window| to its bounds and recursively invokes this for 44 // Adds an entry from |window| to its bounds and recursively invokes this for
44 // all children. 45 // all children.
45 void BuildWindowBoundsMap(const aura::Window* window, BoundsMap* bounds_map) { 46 void BuildWindowBoundsMap(const aura::Window* window, BoundsMap* bounds_map) {
46 (*bounds_map)[window] = window->bounds(); 47 (*bounds_map)[window] = window->bounds();
47 for (size_t i = 0; i < window->children().size(); ++i) 48 for (size_t i = 0; i < window->children().size(); ++i)
48 BuildWindowBoundsMap(window->children()[i], bounds_map); 49 BuildWindowBoundsMap(window->children()[i], bounds_map);
49 } 50 }
50 51
51 // Resets |window|s bounds from |bounds_map| if currently empty. Recusively 52 // Resets |window|s bounds from |bounds_map| if currently empty. Recursively
52 // invokes this for all children. 53 // invokes this for all children.
53 void ResetBoundsIfNecessary(const BoundsMap& bounds_map, aura::Window* window) { 54 void ResetBoundsIfNecessary(const BoundsMap& bounds_map, aura::Window* window) {
54 if (window->bounds().IsEmpty() && window->GetTargetBounds().IsEmpty()) { 55 if (window->bounds().IsEmpty() && window->GetTargetBounds().IsEmpty()) {
55 BoundsMap::const_iterator i = bounds_map.find(window); 56 BoundsMap::const_iterator i = bounds_map.find(window);
56 if (i != bounds_map.end()) 57 if (i != bounds_map.end())
57 window->SetBounds(i->second); 58 window->SetBounds(i->second);
58 } 59 }
59 for (size_t i = 0; i < window->children().size(); ++i) 60 for (size_t i = 0; i < window->children().size(); ++i)
60 ResetBoundsIfNecessary(bounds_map, window->children()[i]); 61 ResetBoundsIfNecessary(bounds_map, window->children()[i]);
61 } 62 }
62 63
63 // Resets |window|s bounds from |bounds_map| if |window| is marked as a 64 // Resets |window|s bounds from |bounds_map| if |window| is marked as a
64 // constrained window. Recusively invokes this for all children. 65 // constrained window. Recursively invokes this for all children.
65 // TODO(sky): this should key off window type. 66 // TODO(sky): this should key off window type.
66 void ResetConstrainedWindowBoundsIfNecessary(const BoundsMap& bounds_map, 67 void ResetConstrainedWindowBoundsIfNecessary(const BoundsMap& bounds_map,
67 aura::Window* window) { 68 aura::Window* window) {
68 if (window->GetProperty(aura::client::kConstrainedWindowKey)) { 69 if (window->GetProperty(aura::client::kConstrainedWindowKey)) {
69 BoundsMap::const_iterator i = bounds_map.find(window); 70 BoundsMap::const_iterator i = bounds_map.find(window);
70 if (i != bounds_map.end()) 71 if (i != bounds_map.end())
71 window->SetBounds(i->second); 72 window->SetBounds(i->second);
72 } 73 }
73 for (size_t i = 0; i < window->children().size(); ++i) 74 for (size_t i = 0; i < window->children().size(); ++i)
74 ResetConstrainedWindowBoundsIfNecessary(bounds_map, window->children()[i]); 75 ResetConstrainedWindowBoundsIfNecessary(bounds_map, window->children()[i]);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 workspace_manager()->OnTrackedByWorkspaceChanged(workspace_, window); 235 workspace_manager()->OnTrackedByWorkspaceChanged(workspace_, window);
235 } 236 }
236 237
237 if (key == aura::client::kAlwaysOnTopKey && 238 if (key == aura::client::kAlwaysOnTopKey &&
238 window->GetProperty(aura::client::kAlwaysOnTopKey)) { 239 window->GetProperty(aura::client::kAlwaysOnTopKey)) {
239 internal::AlwaysOnTopController* controller = 240 internal::AlwaysOnTopController* controller =
240 window->GetRootWindow()->GetProperty( 241 window->GetRootWindow()->GetProperty(
241 internal::kAlwaysOnTopControllerKey); 242 internal::kAlwaysOnTopControllerKey);
242 controller->GetContainer(window)->AddChild(window); 243 controller->GetContainer(window)->AddChild(window);
243 } 244 }
245
246 if (key == ash::internal::kDockEdge &&
247 IsWindowDocked(window) &&
248 static_cast<DockEdge>(old) == DOCK_EDGE_NONE) {
249 // possibly reparent to dock container
250 window->SetDefaultParentByRootWindow(root_window_,
251 window->GetBoundsInScreen());
252 }
244 } 253 }
245 254
246 void WorkspaceLayoutManager::OnWindowDestroying(aura::Window* window) { 255 void WorkspaceLayoutManager::OnWindowDestroying(aura::Window* window) {
247 if (root_window_ == window) { 256 if (root_window_ == window) {
248 root_window_->RemoveObserver(this); 257 root_window_->RemoveObserver(this);
249 root_window_ = NULL; 258 root_window_ = NULL;
250 } 259 }
251 } 260 }
252 261
253 void WorkspaceLayoutManager::ShowStateChanged( 262 void WorkspaceLayoutManager::ShowStateChanged(
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } 395 }
387 return false; 396 return false;
388 } 397 }
389 398
390 WorkspaceManager* WorkspaceLayoutManager::workspace_manager() { 399 WorkspaceManager* WorkspaceLayoutManager::workspace_manager() {
391 return workspace_->workspace_manager(); 400 return workspace_->workspace_manager();
392 } 401 }
393 402
394 } // namespace internal 403 } // namespace internal
395 } // namespace ash 404 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698