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

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

Issue 10795027: Move a window if the sceren bounds being set is in other display. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adjust for win_aura Created 8 years, 5 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/stacking_controller.h ('k') | ash/wm/system_modal_container_layout_manager.h » ('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/stacking_controller.h" 5 #include "ash/wm/stacking_controller.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/wm/always_on_top_controller.h" 10 #include "ash/wm/always_on_top_controller.h"
(...skipping 13 matching lines...) Expand all
24 // return the active root window. 24 // return the active root window.
25 aura::RootWindow* FindContainerRoot(const gfx::Rect& bounds) { 25 aura::RootWindow* FindContainerRoot(const gfx::Rect& bounds) {
26 if (!DisplayController::IsVirtualScreenCoordinatesEnabled() || 26 if (!DisplayController::IsVirtualScreenCoordinatesEnabled() ||
27 (bounds.origin().x() == 0 && bounds.origin().y() == 0 27 (bounds.origin().x() == 0 && bounds.origin().y() == 0
28 && bounds.IsEmpty())) { 28 && bounds.IsEmpty())) {
29 return Shell::GetActiveRootWindow(); 29 return Shell::GetActiveRootWindow();
30 } 30 }
31 return Shell::GetRootWindowMatching(bounds); 31 return Shell::GetRootWindowMatching(bounds);
32 } 32 }
33 33
34 aura::Window* GetContainerById(const gfx::Rect& bounds, int id) { 34 aura::Window* GetContainerById(aura::RootWindow* root, int id) {
35 return Shell::GetContainer(FindContainerRoot(bounds), id); 35 return Shell::GetContainer(root, id);
36 } 36 }
37 37
38 aura::Window* GetContainerForWindow(aura::Window* window) { 38 aura::Window* GetContainerForWindow(aura::Window* window) {
39 aura::Window* container = window->parent(); 39 aura::Window* container = window->parent();
40 while (container && container->type() != aura::client::WINDOW_TYPE_UNKNOWN) 40 while (container && container->type() != aura::client::WINDOW_TYPE_UNKNOWN)
41 container = container->parent(); 41 container = container->parent();
42 return container; 42 return container;
43 } 43 }
44 44
45 bool IsSystemModal(aura::Window* window) { 45 bool IsSystemModal(aura::Window* window) {
(...skipping 15 matching lines...) Expand all
61 } 61 }
62 62
63 StackingController::~StackingController() { 63 StackingController::~StackingController() {
64 } 64 }
65 65
66 //////////////////////////////////////////////////////////////////////////////// 66 ////////////////////////////////////////////////////////////////////////////////
67 // StackingController, aura::StackingClient implementation: 67 // StackingController, aura::StackingClient implementation:
68 68
69 aura::Window* StackingController::GetDefaultParent(aura::Window* window, 69 aura::Window* StackingController::GetDefaultParent(aura::Window* window,
70 const gfx::Rect& bounds) { 70 const gfx::Rect& bounds) {
71 aura::RootWindow* target_root = NULL;
72 if (window->transient_parent()) {
73 // Transient window should use the same root as its transient parent.
74 target_root = window->transient_parent()->GetRootWindow();
75 } else {
76 target_root = FindContainerRoot(bounds);
77 }
78
71 switch (window->type()) { 79 switch (window->type()) {
72 case aura::client::WINDOW_TYPE_NORMAL: 80 case aura::client::WINDOW_TYPE_NORMAL:
73 case aura::client::WINDOW_TYPE_POPUP: 81 case aura::client::WINDOW_TYPE_POPUP:
74 if (IsSystemModal(window)) 82 if (IsSystemModal(window))
75 return GetSystemModalContainer(window, bounds); 83 return GetSystemModalContainer(target_root, window);
76 else if (IsWindowModal(window)) 84 else if (IsWindowModal(window))
77 return GetContainerForWindow(window->transient_parent()); 85 return GetContainerForWindow(window->transient_parent());
78 return GetAlwaysOnTopController(bounds)->GetContainer(window); 86 return GetAlwaysOnTopController(target_root)->GetContainer(window);
79 case aura::client::WINDOW_TYPE_PANEL: 87 case aura::client::WINDOW_TYPE_PANEL:
80 return GetContainerById(bounds, internal::kShellWindowId_PanelContainer); 88 return GetContainerById(target_root,
89 internal::kShellWindowId_PanelContainer);
81 case aura::client::WINDOW_TYPE_MENU: 90 case aura::client::WINDOW_TYPE_MENU:
82 return GetContainerById(bounds, internal::kShellWindowId_MenuContainer); 91 return GetContainerById(
92 target_root, internal::kShellWindowId_MenuContainer);
83 case aura::client::WINDOW_TYPE_TOOLTIP: 93 case aura::client::WINDOW_TYPE_TOOLTIP:
84 return GetContainerById( 94 return GetContainerById(
85 bounds, internal::kShellWindowId_DragImageAndTooltipContainer); 95 target_root, internal::kShellWindowId_DragImageAndTooltipContainer);
86 case aura::client::WINDOW_TYPE_CONTROL: 96 case aura::client::WINDOW_TYPE_CONTROL:
87 return GetContainerById( 97 return GetContainerById(
88 bounds, internal::kShellWindowId_UnparentedControlContainer); 98 target_root, internal::kShellWindowId_UnparentedControlContainer);
89 default: 99 default:
90 NOTREACHED() << "Window " << window->id() 100 NOTREACHED() << "Window " << window->id()
91 << " has unhandled type " << window->type(); 101 << " has unhandled type " << window->type();
92 break; 102 break;
93 } 103 }
94 return NULL; 104 return NULL;
95 } 105 }
96 106
97 //////////////////////////////////////////////////////////////////////////////// 107 ////////////////////////////////////////////////////////////////////////////////
98 // StackingController, private: 108 // StackingController, private:
99 109
100 aura::Window* StackingController::GetSystemModalContainer( 110 aura::Window* StackingController::GetSystemModalContainer(
101 aura::Window* window, 111 aura::RootWindow* root,
102 const gfx::Rect& bounds) const { 112 aura::Window* window) const {
103 DCHECK(IsSystemModal(window)); 113 DCHECK(IsSystemModal(window));
104 114
105 // If screen lock is not active, all modal windows are placed into the 115 // If screen lock is not active, all modal windows are placed into the
106 // normal modal container. 116 // normal modal container.
107 // TODO(oshima): support multiple root windows.
108 aura::Window* lock_container = 117 aura::Window* lock_container =
109 GetContainerById(bounds, internal::kShellWindowId_LockScreenContainer); 118 GetContainerById(root, internal::kShellWindowId_LockScreenContainer);
110 if (!lock_container->children().size()) { 119 if (!lock_container->children().size()) {
111 return GetContainerById(bounds, 120 return GetContainerById(root,
112 internal::kShellWindowId_SystemModalContainer); 121 internal::kShellWindowId_SystemModalContainer);
113 } 122 }
114 123
115 // Otherwise those that originate from LockScreen container and above are 124 // Otherwise those that originate from LockScreen container and above are
116 // placed in the screen lock modal container. 125 // placed in the screen lock modal container.
117 int lock_container_id = lock_container->id(); 126 int lock_container_id = lock_container->id();
118 int window_container_id = window->transient_parent()->parent()->id(); 127 int window_container_id = window->transient_parent()->parent()->id();
119 128
120 aura::Window* container = NULL; 129 aura::Window* container = NULL;
121 if (window_container_id < lock_container_id) { 130 if (window_container_id < lock_container_id) {
122 container = GetContainerById( 131 container = GetContainerById(
123 bounds, internal::kShellWindowId_SystemModalContainer); 132 root, internal::kShellWindowId_SystemModalContainer);
124 } else { 133 } else {
125 container = GetContainerById( 134 container = GetContainerById(
126 bounds, internal::kShellWindowId_LockSystemModalContainer); 135 root, internal::kShellWindowId_LockSystemModalContainer);
127 } 136 }
128 137
129 return container; 138 return container;
130 } 139 }
131 140
141 // TODO(oshima): Remove this once extended desktop is on by default.
132 internal::AlwaysOnTopController* 142 internal::AlwaysOnTopController*
133 StackingController::GetAlwaysOnTopController(const gfx::Rect& bounds) { 143 StackingController::GetAlwaysOnTopController(
134 aura::RootWindow* root_window = FindContainerRoot(bounds); 144 aura::RootWindow* root_window) {
135 internal::AlwaysOnTopController* controller = 145 internal::AlwaysOnTopController* controller =
136 root_window->GetProperty(internal::kAlwaysOnTopControllerKey); 146 root_window->GetProperty(internal::kAlwaysOnTopControllerKey);
137 if (!controller) { 147 if (!controller) {
138 controller = new internal::AlwaysOnTopController; 148 controller = new internal::AlwaysOnTopController;
139 controller->SetContainers( 149 controller->SetContainers(
140 root_window->GetChildById(internal::kShellWindowId_DefaultContainer), 150 root_window->GetChildById(internal::kShellWindowId_DefaultContainer),
141 root_window->GetChildById( 151 root_window->GetChildById(
142 internal::kShellWindowId_AlwaysOnTopContainer)); 152 internal::kShellWindowId_AlwaysOnTopContainer));
143 // RootWindow owns the AlwaysOnTopController object. 153 // RootWindow owns the AlwaysOnTopController object.
144 root_window->SetProperty(kAlwaysOnTopControllerKey, controller); 154 root_window->SetProperty(kAlwaysOnTopControllerKey, controller);
145 } 155 }
146 return controller; 156 return controller;
147 } 157 }
148 158
149 } // namespace internal 159 } // namespace internal
150 } // namespace ash 160 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/stacking_controller.h ('k') | ash/wm/system_modal_container_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698