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" |
54 #include "ui/aura/root_window.h" | 55 #include "ui/aura/root_window.h" |
55 #include "ui/aura/window.h" | 56 #include "ui/aura/window.h" |
56 #include "ui/aura/window_delegate.h" | 57 #include "ui/aura/window_delegate.h" |
57 #include "ui/aura/window_observer.h" | 58 #include "ui/aura/window_observer.h" |
58 #include "ui/aura/window_tracker.h" | 59 #include "ui/aura/window_tracker.h" |
59 #include "ui/base/hit_test.h" | 60 #include "ui/base/hit_test.h" |
60 #include "ui/base/models/menu_model.h" | 61 #include "ui/base/models/menu_model.h" |
61 #include "ui/gfx/display.h" | 62 #include "ui/gfx/display.h" |
62 #include "ui/gfx/screen.h" | 63 #include "ui/gfx/screen.h" |
63 #include "ui/keyboard/keyboard_controller.h" | 64 #include "ui/keyboard/keyboard_controller.h" |
(...skipping 26 matching lines...) Expand all Loading... |
90 aura::Window* container = new aura::Window(NULL); | 91 aura::Window* container = new aura::Window(NULL); |
91 container->set_id(window_id); | 92 container->set_id(window_id); |
92 container->SetName(name); | 93 container->SetName(name); |
93 container->Init(ui::LAYER_NOT_DRAWN); | 94 container->Init(ui::LAYER_NOT_DRAWN); |
94 parent->AddChild(container); | 95 parent->AddChild(container); |
95 if (window_id != internal::kShellWindowId_UnparentedControlContainer) | 96 if (window_id != internal::kShellWindowId_UnparentedControlContainer) |
96 container->Show(); | 97 container->Show(); |
97 return container; | 98 return container; |
98 } | 99 } |
99 | 100 |
| 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 |
100 // Reparents |window| to |new_parent|. | 114 // Reparents |window| to |new_parent|. |
101 void ReparentWindow(aura::Window* window, aura::Window* new_parent) { | 115 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(); |
102 // Update the restore bounds to make it relative to the display. | 118 // Update the restore bounds to make it relative to the display. |
103 wm::WindowState* state = wm::GetWindowState(window); | 119 wm::WindowState* state = wm::GetWindowState(window); |
104 gfx::Rect restore_bounds; | 120 gfx::Rect restore_bounds; |
105 bool has_restore_bounds = state->HasRestoreBounds(); | 121 bool has_restore_bounds = state->HasRestoreBounds(); |
106 if (has_restore_bounds) | 122 |
| 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) { |
107 restore_bounds = state->GetRestoreBoundsInParent(); | 132 restore_bounds = state->GetRestoreBoundsInParent(); |
| 133 MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds); |
| 134 } |
| 135 |
108 new_parent->AddChild(window); | 136 new_parent->AddChild(window); |
| 137 |
| 138 if (update_bounds) |
| 139 window->SetBounds(local_bounds); |
| 140 |
109 if (has_restore_bounds) | 141 if (has_restore_bounds) |
110 state->SetRestoreBoundsInParent(restore_bounds); | 142 state->SetRestoreBoundsInParent(restore_bounds); |
111 } | 143 } |
112 | 144 |
113 // Reparents the appropriate set of windows from |src| to |dst|. | 145 // Reparents the appropriate set of windows from |src| to |dst|. |
114 void ReparentAllWindows(aura::Window* src, aura::Window* dst) { | 146 void ReparentAllWindows(aura::Window* src, aura::Window* dst) { |
115 // Set of windows to move. | 147 // Set of windows to move. |
116 const int kContainerIdsToMove[] = { | 148 const int kContainerIdsToMove[] = { |
117 internal::kShellWindowId_DefaultContainer, | 149 internal::kShellWindowId_DefaultContainer, |
118 internal::kShellWindowId_DockedContainer, | 150 internal::kShellWindowId_DockedContainer, |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 DisableTouchHudProjection(); | 975 DisableTouchHudProjection(); |
944 } | 976 } |
945 | 977 |
946 RootWindowController* GetRootWindowController( | 978 RootWindowController* GetRootWindowController( |
947 const aura::Window* root_window) { | 979 const aura::Window* root_window) { |
948 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; | 980 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; |
949 } | 981 } |
950 | 982 |
951 } // namespace internal | 983 } // namespace internal |
952 } // namespace ash | 984 } // namespace ash |
OLD | NEW |