Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: ash/root_window_controller.cc

Issue 10659006: move windows when disconnecting secondary monitors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | Annotate | Revision Log
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/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_factory.h" 8 #include "ash/shell_factory.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/wm/base_layout_manager.h" 10 #include "ash/wm/base_layout_manager.h"
11 #include "ash/wm/event_client_impl.h" 11 #include "ash/wm/event_client_impl.h"
12 #include "ash/wm/property_util.h" 12 #include "ash/wm/property_util.h"
13 #include "ash/wm/root_window_layout_manager.h" 13 #include "ash/wm/root_window_layout_manager.h"
14 #include "ash/wm/screen_dimmer.h" 14 #include "ash/wm/screen_dimmer.h"
15 #include "ash/wm/system_modal_container_layout_manager.h" 15 #include "ash/wm/system_modal_container_layout_manager.h"
16 #include "ash/wm/toplevel_window_event_filter.h" 16 #include "ash/wm/toplevel_window_event_filter.h"
17 #include "ash/wm/visibility_controller.h" 17 #include "ash/wm/visibility_controller.h"
18 #include "ash/wm/workspace/workspace_manager.h" 18 #include "ash/wm/workspace/workspace_manager.h"
19 #include "ash/wm/workspace_controller.h" 19 #include "ash/wm/workspace_controller.h"
20 #include "ui/aura/client/activation_client.h"
21 #include "ui/aura/client/aura_constants.h"
20 #include "ui/aura/client/tooltip_client.h" 22 #include "ui/aura/client/tooltip_client.h"
23 #include "ui/aura/focus_manager.h"
21 #include "ui/aura/root_window.h" 24 #include "ui/aura/root_window.h"
25 #include "ui/views/controls/menu/menu_controller.h"
22 26
23 namespace ash { 27 namespace ash {
24 namespace { 28 namespace {
25 29
26 // Creates a new window for use as a container. 30 // Creates a new window for use as a container.
27 aura::Window* CreateContainer(int window_id, 31 aura::Window* CreateContainer(int window_id,
28 const char* name, 32 const char* name,
29 aura::Window* parent) { 33 aura::Window* parent) {
30 aura::Window* container = new aura::Window(NULL); 34 aura::Window* container = new aura::Window(NULL);
31 container->set_id(window_id); 35 container->set_id(window_id);
32 container->SetName(name); 36 container->SetName(name);
33 container->Init(ui::LAYER_NOT_DRAWN); 37 container->Init(ui::LAYER_NOT_DRAWN);
34 parent->AddChild(container); 38 parent->AddChild(container);
35 if (window_id != internal::kShellWindowId_UnparentedControlContainer) 39 if (window_id != internal::kShellWindowId_UnparentedControlContainer)
36 container->Show(); 40 container->Show();
37 return container; 41 return container;
38 } 42 }
39 43
44 void MoveAllWindows(aura::RootWindow* src,
45 aura::RootWindow* dst,
46 const int* ids,
Daniel Erat 2012/06/25 22:09:33 nit: mind switching this to be a reference to a ve
oshima 2012/06/25 22:42:28 move container_ids from caller to callee because t
47 size_t size) {
48 for (size_t i = 0; i < size; i++) {
49 int id = ids[i];
50 aura::Window* src_container = Shell::GetContainer(src, id);
51 aura::Window* dst_container = Shell::GetContainer(dst, id);
52 aura::Window::Windows children = src_container->children();
53 for (aura::Window::Windows::iterator iter = children.begin();
54 iter != children.end(); ++iter) {
55 aura::Window* window = *iter;
56 // Don't move modal screen.
57 if ((id == internal::kShellWindowId_SystemModalContainer ||
58 id == internal::kShellWindowId_LockSystemModalContainer) &&
59 window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_NONE) {
60 continue;
61 }
62 dst_container->AddChild(window);
63 }
64 }
65 }
66
40 // Creates each of the special window containers that holds windows of various 67 // Creates each of the special window containers that holds windows of various
41 // types in the shell UI. 68 // types in the shell UI.
42 void CreateContainersInRootWindow(aura::RootWindow* root_window) { 69 void CreateContainersInRootWindow(aura::RootWindow* root_window) {
43 // These containers are just used by PowerButtonController to animate groups 70 // These containers are just used by PowerButtonController to animate groups
44 // of containers simultaneously without messing up the current transformations 71 // of containers simultaneously without messing up the current transformations
45 // on those containers. These are direct children of the root window; all of 72 // on those containers. These are direct children of the root window; all of
46 // the other containers are their children. 73 // the other containers are their children.
47 aura::Window* non_lock_screen_containers = CreateContainer( 74 aura::Window* non_lock_screen_containers = CreateContainer(
48 internal::kShellWindowId_NonLockScreenContainersContainer, 75 internal::kShellWindowId_NonLockScreenContainersContainer,
49 "NonLockScreenContainersContainer", 76 "NonLockScreenContainersContainer",
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 while (!root_window_->children().empty()) { 234 while (!root_window_->children().empty()) {
208 aura::Window* child = root_window_->children()[0]; 235 aura::Window* child = root_window_->children()[0];
209 delete child; 236 delete child;
210 } 237 }
211 } 238 }
212 239
213 bool RootWindowController::IsInMaximizedMode() const { 240 bool RootWindowController::IsInMaximizedMode() const {
214 return workspace_controller_->workspace_manager()->IsInMaximizedMode(); 241 return workspace_controller_->workspace_manager()->IsInMaximizedMode();
215 } 242 }
216 243
244 void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) {
245 aura::Window* focused = dst->GetFocusManager()->GetFocusedWindow();
246 aura::client::ActivationClient* activation_client =
247 aura::client::GetActivationClient(dst);
248 aura::Window* active = activation_client->GetActiveWindow();
249 // Deactivate the window to close menu / bubble windows.
250 if (root_window_->Contains(focused) || root_window_->Contains(active))
oshima 2012/06/25 22:42:28 I removed this and changed to always deactivate be
251 activation_client->DeactivateWindow(active);
252 // Close context menu on desktop.
253 views::MenuController* menu_controller =
254 views::MenuController::GetActiveInstance();
255 if (menu_controller)
256 menu_controller->OnWidgetActivationChanged();
sky 2012/06/25 22:05:14 Why do you have to explicitly do this? Doesn't the
oshima 2012/06/25 22:42:28 A desktop context menu can be opened without activ
sky 2012/06/25 23:58:33 I don't like the direct dependency. Some event sho
257
258 // Windows moves only from secondary displays to the primary
Daniel Erat 2012/06/25 22:09:33 nit: s/moves/move/
oshima 2012/06/25 22:42:28 Done.
259 // display, so no need to move windows in the containers that are
260 // available only in the primary display (launcher, panels etc)
261 int copy_layers[] = {
262 internal::kShellWindowId_DefaultContainer,
263 internal::kShellWindowId_AlwaysOnTopContainer,
264 internal::kShellWindowId_SystemModalContainer,
265 internal::kShellWindowId_LockSystemModalContainer,
266 };
267 MoveAllWindows(root_window_.get(), dst, copy_layers, arraysize(copy_layers));
268 // Restore focused / active window.
269 if (focused) {
270 DCHECK(dst->Contains(focused));
271 dst->GetFocusManager()->SetFocusedWindow(focused, NULL);
272 } else if (active) {
Daniel Erat 2012/06/25 22:09:33 will focusing the window automatically update acti
oshima 2012/06/25 22:42:28 Yes. this is "else if" , in case there is an activ
273 DCHECK(dst->Contains(active));
274 activation_client->ActivateWindow(active);
275 }
276 }
277
217 } // namespace internal 278 } // namespace internal
218 } // namespace ash 279 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698