| 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 <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "ash/wm/toplevel_window_event_handler.h" | 44 #include "ash/wm/toplevel_window_event_handler.h" |
| 45 #include "ash/wm/window_properties.h" | 45 #include "ash/wm/window_properties.h" |
| 46 #include "ash/wm/window_state.h" | 46 #include "ash/wm/window_state.h" |
| 47 #include "ash/wm/window_util.h" | 47 #include "ash/wm/window_util.h" |
| 48 #include "ash/wm/workspace_controller.h" | 48 #include "ash/wm/workspace_controller.h" |
| 49 #include "base/command_line.h" | 49 #include "base/command_line.h" |
| 50 #include "base/time/time.h" | 50 #include "base/time/time.h" |
| 51 #include "ui/aura/client/aura_constants.h" | 51 #include "ui/aura/client/aura_constants.h" |
| 52 #include "ui/aura/client/drag_drop_client.h" | 52 #include "ui/aura/client/drag_drop_client.h" |
| 53 #include "ui/aura/client/tooltip_client.h" | 53 #include "ui/aura/client/tooltip_client.h" |
| 54 #include "ui/aura/client/window_types.h" | |
| 55 #include "ui/aura/root_window.h" | 54 #include "ui/aura/root_window.h" |
| 56 #include "ui/aura/window.h" | 55 #include "ui/aura/window.h" |
| 57 #include "ui/aura/window_delegate.h" | 56 #include "ui/aura/window_delegate.h" |
| 58 #include "ui/aura/window_observer.h" | 57 #include "ui/aura/window_observer.h" |
| 59 #include "ui/aura/window_tracker.h" | 58 #include "ui/aura/window_tracker.h" |
| 60 #include "ui/base/hit_test.h" | 59 #include "ui/base/hit_test.h" |
| 61 #include "ui/base/models/menu_model.h" | 60 #include "ui/base/models/menu_model.h" |
| 62 #include "ui/gfx/display.h" | 61 #include "ui/gfx/display.h" |
| 63 #include "ui/gfx/screen.h" | 62 #include "ui/gfx/screen.h" |
| 64 #include "ui/keyboard/keyboard_controller.h" | 63 #include "ui/keyboard/keyboard_controller.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 91 aura::Window* container = new aura::Window(NULL); | 90 aura::Window* container = new aura::Window(NULL); |
| 92 container->set_id(window_id); | 91 container->set_id(window_id); |
| 93 container->SetName(name); | 92 container->SetName(name); |
| 94 container->Init(ui::LAYER_NOT_DRAWN); | 93 container->Init(ui::LAYER_NOT_DRAWN); |
| 95 parent->AddChild(container); | 94 parent->AddChild(container); |
| 96 if (window_id != internal::kShellWindowId_UnparentedControlContainer) | 95 if (window_id != internal::kShellWindowId_UnparentedControlContainer) |
| 97 container->Show(); | 96 container->Show(); |
| 98 return container; | 97 return container; |
| 99 } | 98 } |
| 100 | 99 |
| 101 float ToRelativeValue(int value, int src, int dst) { | |
| 102 return static_cast<float>(value) / static_cast<float>(src) * dst; | |
| 103 } | |
| 104 | |
| 105 void MoveOriginRelativeToSize(const gfx::Size& src_size, | |
| 106 const gfx::Size& dst_size, | |
| 107 gfx::Rect* bounds_in_out) { | |
| 108 gfx::Point origin = bounds_in_out->origin(); | |
| 109 bounds_in_out->set_origin(gfx::Point( | |
| 110 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()), | |
| 111 ToRelativeValue(origin.y(), src_size.height(), dst_size.height()))); | |
| 112 } | |
| 113 | |
| 114 // Reparents |window| to |new_parent|. | 100 // Reparents |window| to |new_parent|. |
| 115 void ReparentWindow(aura::Window* window, aura::Window* new_parent) { | 101 void ReparentWindow(aura::Window* window, aura::Window* new_parent) { |
| 116 const gfx::Size src_size = window->parent()->bounds().size(); | |
| 117 const gfx::Size dst_size = new_parent->bounds().size(); | |
| 118 // Update the restore bounds to make it relative to the display. | 102 // Update the restore bounds to make it relative to the display. |
| 119 wm::WindowState* state = wm::GetWindowState(window); | 103 wm::WindowState* state = wm::GetWindowState(window); |
| 120 gfx::Rect restore_bounds; | 104 gfx::Rect restore_bounds; |
| 121 bool has_restore_bounds = state->HasRestoreBounds(); | 105 bool has_restore_bounds = state->HasRestoreBounds(); |
| 122 | 106 if (has_restore_bounds) |
| 123 // TODO(oshima): snapped state should be handled by the layout manager. | |
| 124 bool update_bounds = state->IsNormalShowState() || state->IsMinimized(); | |
| 125 gfx::Rect local_bounds; | |
| 126 if (update_bounds) { | |
| 127 local_bounds = state->window()->bounds(); | |
| 128 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds); | |
| 129 } | |
| 130 | |
| 131 if (has_restore_bounds) { | |
| 132 restore_bounds = state->GetRestoreBoundsInParent(); | 107 restore_bounds = state->GetRestoreBoundsInParent(); |
| 133 MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds); | |
| 134 } | |
| 135 | |
| 136 new_parent->AddChild(window); | 108 new_parent->AddChild(window); |
| 137 | |
| 138 if (update_bounds) | |
| 139 window->SetBounds(local_bounds); | |
| 140 | |
| 141 if (has_restore_bounds) | 109 if (has_restore_bounds) |
| 142 state->SetRestoreBoundsInParent(restore_bounds); | 110 state->SetRestoreBoundsInParent(restore_bounds); |
| 143 } | 111 } |
| 144 | 112 |
| 145 // Reparents the appropriate set of windows from |src| to |dst|. | 113 // Reparents the appropriate set of windows from |src| to |dst|. |
| 146 void ReparentAllWindows(aura::Window* src, aura::Window* dst) { | 114 void ReparentAllWindows(aura::Window* src, aura::Window* dst) { |
| 147 // Set of windows to move. | 115 // Set of windows to move. |
| 148 const int kContainerIdsToMove[] = { | 116 const int kContainerIdsToMove[] = { |
| 149 internal::kShellWindowId_DefaultContainer, | 117 internal::kShellWindowId_DefaultContainer, |
| 150 internal::kShellWindowId_DockedContainer, | 118 internal::kShellWindowId_DockedContainer, |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 DisableTouchHudProjection(); | 943 DisableTouchHudProjection(); |
| 976 } | 944 } |
| 977 | 945 |
| 978 RootWindowController* GetRootWindowController( | 946 RootWindowController* GetRootWindowController( |
| 979 const aura::Window* root_window) { | 947 const aura::Window* root_window) { |
| 980 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; | 948 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; |
| 981 } | 949 } |
| 982 | 950 |
| 983 } // namespace internal | 951 } // namespace internal |
| 984 } // namespace ash | 952 } // namespace ash |
| OLD | NEW |