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/display/screen_position_controller.h" | 5 #include "ash/display/screen_position_controller.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
22 #include "ui/wm/core/window_util.h" | 22 #include "ui/wm/core/window_util.h" |
23 #include "ui/wm/public/activation_client.h" | 23 #include "ui/wm/public/activation_client.h" |
24 | 24 |
25 namespace ash { | 25 namespace ash { |
26 namespace { | 26 namespace { |
27 | 27 |
28 // Return true if the window or its ancestor has |kStayInSameRootWindowkey| | 28 // Return true if the window or its ancestor has |kStayInSameRootWindowkey| |
29 // property. | 29 // property. |
30 bool ShouldStayInSameRootWindow(const aura::Window* window) { | 30 bool ShouldStayInSameRootWindow(const aura::Window* window) { |
31 return window && | 31 return window && (window->GetProperty(kStayInSameRootWindowKey) || |
32 (window->GetProperty(internal::kStayInSameRootWindowKey) || | 32 ShouldStayInSameRootWindow(window->parent())); |
33 ShouldStayInSameRootWindow(window->parent())); | |
34 } | 33 } |
35 | 34 |
36 // Move all transient children to |dst_root|, including the ones in | 35 // Move all transient children to |dst_root|, including the ones in |
37 // the child windows and transient children of the transient children. | 36 // the child windows and transient children of the transient children. |
38 void MoveAllTransientChildrenToNewRoot(const gfx::Display& display, | 37 void MoveAllTransientChildrenToNewRoot(const gfx::Display& display, |
39 aura::Window* window) { | 38 aura::Window* window) { |
40 aura::Window* dst_root = Shell::GetInstance()->display_controller()-> | 39 aura::Window* dst_root = Shell::GetInstance()->display_controller()-> |
41 GetRootWindowForDisplayId(display.id()); | 40 GetRootWindowForDisplayId(display.id()); |
42 aura::Window::Windows transient_children = | 41 aura::Window::Windows transient_children = |
43 ::wm::GetTransientChildren(window); | 42 ::wm::GetTransientChildren(window); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 107 } |
109 #else | 108 #else |
110 // TODO(yusukes): Support non-X11 platforms if necessary. | 109 // TODO(yusukes): Support non-X11 platforms if necessary. |
111 #endif | 110 #endif |
112 | 111 |
113 return std::make_pair(root_window, location_in_root); | 112 return std::make_pair(root_window, location_in_root); |
114 } | 113 } |
115 | 114 |
116 } // namespace | 115 } // namespace |
117 | 116 |
118 namespace internal { | |
119 | |
120 void ScreenPositionController::ConvertPointToScreen( | 117 void ScreenPositionController::ConvertPointToScreen( |
121 const aura::Window* window, | 118 const aura::Window* window, |
122 gfx::Point* point) { | 119 gfx::Point* point) { |
123 const aura::Window* root = window->GetRootWindow(); | 120 const aura::Window* root = window->GetRootWindow(); |
124 aura::Window::ConvertPointToTarget(window, root, point); | 121 aura::Window::ConvertPointToTarget(window, root, point); |
125 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( | 122 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( |
126 const_cast<aura::Window*>(root)).bounds().origin(); | 123 const_cast<aura::Window*>(root)).bounds().origin(); |
127 point->Offset(display_origin.x(), display_origin.y()); | 124 point->Offset(display_origin.x(), display_origin.y()); |
128 } | 125 } |
129 | 126 |
(...skipping 15 matching lines...) Expand all Loading... |
145 std::pair<aura::Window*, gfx::Point> pair = | 142 std::pair<aura::Window*, gfx::Point> pair = |
146 GetRootWindowRelativeToWindow(root, *point); | 143 GetRootWindowRelativeToWindow(root, *point); |
147 *point = pair.second; | 144 *point = pair.second; |
148 ConvertPointToScreen(pair.first, point); | 145 ConvertPointToScreen(pair.first, point); |
149 } | 146 } |
150 | 147 |
151 void ScreenPositionController::SetBounds(aura::Window* window, | 148 void ScreenPositionController::SetBounds(aura::Window* window, |
152 const gfx::Rect& bounds, | 149 const gfx::Rect& bounds, |
153 const gfx::Display& display) { | 150 const gfx::Display& display) { |
154 DCHECK_NE(-1, display.id()); | 151 DCHECK_NE(-1, display.id()); |
155 if (!window->parent()->GetProperty(internal::kUsesScreenCoordinatesKey)) { | 152 if (!window->parent()->GetProperty(kUsesScreenCoordinatesKey)) { |
156 window->SetBounds(bounds); | 153 window->SetBounds(bounds); |
157 return; | 154 return; |
158 } | 155 } |
159 | 156 |
160 // Don't move a window to other root window if: | 157 // Don't move a window to other root window if: |
161 // a) the window is a transient window. It moves when its | 158 // a) the window is a transient window. It moves when its |
162 // transient_parent moves. | 159 // transient_parent moves. |
163 // b) if the window or its ancestor has kStayInSameRootWindowkey. It's | 160 // b) if the window or its ancestor has kStayInSameRootWindowkey. It's |
164 // intentionally kept in the same root window even if the bounds is | 161 // intentionally kept in the same root window even if the bounds is |
165 // outside of the display. | 162 // outside of the display. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // constraints are applied by the layout manager. | 218 // constraints are applied by the layout manager. |
222 } | 219 } |
223 } | 220 } |
224 gfx::Point origin(bounds.origin()); | 221 gfx::Point origin(bounds.origin()); |
225 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( | 222 const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( |
226 window).bounds().origin(); | 223 window).bounds().origin(); |
227 origin.Offset(-display_origin.x(), -display_origin.y()); | 224 origin.Offset(-display_origin.x(), -display_origin.y()); |
228 window->SetBounds(gfx::Rect(origin, bounds.size())); | 225 window->SetBounds(gfx::Rect(origin, bounds.size())); |
229 } | 226 } |
230 | 227 |
231 } // internal | 228 } // namespace ash |
232 } // ash | |
OLD | NEW |