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

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
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/root_window_controller_unittest.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/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 // Windows move only from secondary displays to the primary
47 // display, so no need to move windows in the containers that are
48 // available only in the primary display (launcher, panels etc)
49 const int container_ids_to_move[] = {
Daniel Erat 2012/06/25 23:13:36 nit: kContainerIdsToMove
50 internal::kShellWindowId_DefaultContainer,
51 internal::kShellWindowId_AlwaysOnTopContainer,
52 internal::kShellWindowId_SystemModalContainer,
53 internal::kShellWindowId_LockSystemModalContainer,
54 };
55
56 for (size_t i = 0; i < arraysize(container_ids_to_move); i++) {
57 int id = container_ids_to_move[i];
58 aura::Window* src_container = Shell::GetContainer(src, id);
59 aura::Window* dst_container = Shell::GetContainer(dst, id);
60 aura::Window::Windows children = src_container->children();
61 for (aura::Window::Windows::iterator iter = children.begin();
62 iter != children.end(); ++iter) {
63 aura::Window* window = *iter;
64 // Don't move modal screen.
65 if ((id == internal::kShellWindowId_SystemModalContainer ||
66 id == internal::kShellWindowId_LockSystemModalContainer) &&
67 window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_NONE) {
68 continue;
69 }
70 dst_container->AddChild(window);
71 }
72 }
73 }
74
40 // Creates each of the special window containers that holds windows of various 75 // Creates each of the special window containers that holds windows of various
41 // types in the shell UI. 76 // types in the shell UI.
42 void CreateContainersInRootWindow(aura::RootWindow* root_window) { 77 void CreateContainersInRootWindow(aura::RootWindow* root_window) {
43 // These containers are just used by PowerButtonController to animate groups 78 // These containers are just used by PowerButtonController to animate groups
44 // of containers simultaneously without messing up the current transformations 79 // of containers simultaneously without messing up the current transformations
45 // on those containers. These are direct children of the root window; all of 80 // on those containers. These are direct children of the root window; all of
46 // the other containers are their children. 81 // the other containers are their children.
47 aura::Window* non_lock_screen_containers = CreateContainer( 82 aura::Window* non_lock_screen_containers = CreateContainer(
48 internal::kShellWindowId_NonLockScreenContainersContainer, 83 internal::kShellWindowId_NonLockScreenContainersContainer,
49 "NonLockScreenContainersContainer", 84 "NonLockScreenContainersContainer",
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 while (!root_window_->children().empty()) { 242 while (!root_window_->children().empty()) {
208 aura::Window* child = root_window_->children()[0]; 243 aura::Window* child = root_window_->children()[0];
209 delete child; 244 delete child;
210 } 245 }
211 } 246 }
212 247
213 bool RootWindowController::IsInMaximizedMode() const { 248 bool RootWindowController::IsInMaximizedMode() const {
214 return workspace_controller_->workspace_manager()->IsInMaximizedMode(); 249 return workspace_controller_->workspace_manager()->IsInMaximizedMode();
215 } 250 }
216 251
252 void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) {
253 aura::Window* focused = dst->GetFocusManager()->GetFocusedWindow();
254 aura::client::ActivationClient* activation_client =
255 aura::client::GetActivationClient(dst);
256 aura::Window* active = activation_client->GetActiveWindow();
257 // Deactivate the window to close menu / bubble windows.
258 activation_client->DeactivateWindow(active);
259 // Close context menu on desktop.
260 views::MenuController* menu_controller =
261 views::MenuController::GetActiveInstance();
262 if (menu_controller)
263 menu_controller->OnWidgetActivationChanged();
264
265 MoveAllWindows(root_window_.get(), dst);
266
267 // Restore focused / active window.
268 if (focused) {
269 DCHECK(dst->Contains(focused));
270 dst->GetFocusManager()->SetFocusedWindow(focused, NULL);
271 } else if (active) {
272 DCHECK(dst->Contains(active));
273 activation_client->ActivateWindow(active);
274 }
275 }
276
217 } // namespace internal 277 } // namespace internal
218 } // namespace ash 278 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/root_window_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698