OLD | NEW |
---|---|
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" |
22 | 25 |
23 namespace ash { | 26 namespace ash { |
24 namespace { | 27 namespace { |
25 | 28 |
26 // Creates a new window for use as a container. | 29 // Creates a new window for use as a container. |
27 aura::Window* CreateContainer(int window_id, | 30 aura::Window* CreateContainer(int window_id, |
28 const char* name, | 31 const char* name, |
29 aura::Window* parent) { | 32 aura::Window* parent) { |
30 aura::Window* container = new aura::Window(NULL); | 33 aura::Window* container = new aura::Window(NULL); |
31 container->set_id(window_id); | 34 container->set_id(window_id); |
32 container->SetName(name); | 35 container->SetName(name); |
33 container->Init(ui::LAYER_NOT_DRAWN); | 36 container->Init(ui::LAYER_NOT_DRAWN); |
34 parent->AddChild(container); | 37 parent->AddChild(container); |
35 if (window_id != internal::kShellWindowId_UnparentedControlContainer) | 38 if (window_id != internal::kShellWindowId_UnparentedControlContainer) |
36 container->Show(); | 39 container->Show(); |
37 return container; | 40 return container; |
38 } | 41 } |
39 | 42 |
43 void MoveAllWindows(aura::RootWindow* src, | |
44 aura::RootWindow* dst) { | |
45 // Windows move only from secondary displays to the primary | |
46 // display, so no need to move windows in the containers that are | |
47 // available only in the primary display (launcher, panels etc) | |
48 const int kContainerIdsToMove[] = { | |
49 internal::kShellWindowId_DefaultContainer, | |
50 internal::kShellWindowId_AlwaysOnTopContainer, | |
51 internal::kShellWindowId_SystemModalContainer, | |
52 internal::kShellWindowId_LockSystemModalContainer, | |
53 }; | |
54 | |
55 for (size_t i = 0; i < arraysize(kContainerIdsToMove); i++) { | |
56 int id = kContainerIdsToMove[i]; | |
57 aura::Window* src_container = Shell::GetContainer(src, id); | |
58 aura::Window* dst_container = Shell::GetContainer(dst, id); | |
59 aura::Window::Windows children = src_container->children(); | |
60 for (aura::Window::Windows::iterator iter = children.begin(); | |
61 iter != children.end(); ++iter) { | |
62 aura::Window* window = *iter; | |
63 // Don't move modal screen. | |
64 if ((id == internal::kShellWindowId_SystemModalContainer || | |
65 id == internal::kShellWindowId_LockSystemModalContainer) && | |
66 window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_NONE) { | |
67 continue; | |
68 } | |
69 dst_container->AddChild(window); | |
70 } | |
71 } | |
72 } | |
73 | |
40 // Creates each of the special window containers that holds windows of various | 74 // Creates each of the special window containers that holds windows of various |
41 // types in the shell UI. | 75 // types in the shell UI. |
42 void CreateContainersInRootWindow(aura::RootWindow* root_window) { | 76 void CreateContainersInRootWindow(aura::RootWindow* root_window) { |
43 // These containers are just used by PowerButtonController to animate groups | 77 // These containers are just used by PowerButtonController to animate groups |
44 // of containers simultaneously without messing up the current transformations | 78 // of containers simultaneously without messing up the current transformations |
45 // on those containers. These are direct children of the root window; all of | 79 // on those containers. These are direct children of the root window; all of |
46 // the other containers are their children. | 80 // the other containers are their children. |
47 aura::Window* non_lock_screen_containers = CreateContainer( | 81 aura::Window* non_lock_screen_containers = CreateContainer( |
48 internal::kShellWindowId_NonLockScreenContainersContainer, | 82 internal::kShellWindowId_NonLockScreenContainersContainer, |
49 "NonLockScreenContainersContainer", | 83 "NonLockScreenContainersContainer", |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 while (!root_window_->children().empty()) { | 241 while (!root_window_->children().empty()) { |
208 aura::Window* child = root_window_->children()[0]; | 242 aura::Window* child = root_window_->children()[0]; |
209 delete child; | 243 delete child; |
210 } | 244 } |
211 } | 245 } |
212 | 246 |
213 bool RootWindowController::IsInMaximizedMode() const { | 247 bool RootWindowController::IsInMaximizedMode() const { |
214 return workspace_controller_->workspace_manager()->IsInMaximizedMode(); | 248 return workspace_controller_->workspace_manager()->IsInMaximizedMode(); |
215 } | 249 } |
216 | 250 |
251 void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) { | |
252 aura::Window* focused = dst->GetFocusManager()->GetFocusedWindow(); | |
253 aura::client::ActivationClient* activation_client = | |
254 aura::client::GetActivationClient(dst); | |
255 aura::Window* active = activation_client->GetActiveWindow(); | |
256 // Deactivate the window to close menu / bubble windows. | |
257 activation_client->DeactivateWindow(active); | |
258 // Close the background menu if any. | |
259 Shell::GetInstance()->HideBackgroundMenu(); | |
sky
2012/06/26 04:10:44
I don't want anything special like this. There sho
| |
260 | |
261 MoveAllWindows(root_window_.get(), dst); | |
262 | |
263 // Restore focused / active window. | |
264 if (focused) { | |
265 DCHECK(dst->Contains(focused)); | |
266 dst->GetFocusManager()->SetFocusedWindow(focused, NULL); | |
267 } else if (active) { | |
268 DCHECK(dst->Contains(active)); | |
269 activation_client->ActivateWindow(active); | |
270 } | |
271 } | |
272 | |
217 } // namespace internal | 273 } // namespace internal |
218 } // namespace ash | 274 } // namespace ash |
OLD | NEW |