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/wm/window_util.h" | 5 #include "ash/wm/window_util.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/snap_to_pixel_layout_manager.h" |
12 #include "ash/wm/window_properties.h" | 13 #include "ash/wm/window_properties.h" |
13 #include "ash/wm/window_state.h" | 14 #include "ash/wm/window_state.h" |
14 #include "ash/wm/wm_event.h" | 15 #include "ash/wm/wm_event.h" |
15 #include "ui/aura/client/aura_constants.h" | 16 #include "ui/aura/client/aura_constants.h" |
16 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
17 #include "ui/aura/window_delegate.h" | 18 #include "ui/aura/window_delegate.h" |
18 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
| 20 #include "ui/compositor/dip_util.h" |
19 #include "ui/gfx/display.h" | 21 #include "ui/gfx/display.h" |
20 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
21 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
22 #include "ui/gfx/size.h" | 24 #include "ui/gfx/size.h" |
23 #include "ui/views/view.h" | 25 #include "ui/views/view.h" |
24 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
25 #include "ui/wm/core/window_util.h" | 27 #include "ui/wm/core/window_util.h" |
26 #include "ui/wm/public/activation_client.h" | 28 #include "ui/wm/public/activation_client.h" |
27 | 29 |
28 namespace ash { | 30 namespace ash { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 for (size_t i = 0; | 164 for (size_t i = 0; |
163 i < ::wm::GetTransientChildren(child).size(); | 165 i < ::wm::GetTransientChildren(child).size(); |
164 ++i) { | 166 ++i) { |
165 ReparentChildWithTransientChildren( | 167 ReparentChildWithTransientChildren( |
166 ::wm::GetTransientChildren(child)[i], | 168 ::wm::GetTransientChildren(child)[i], |
167 old_parent, | 169 old_parent, |
168 new_parent); | 170 new_parent); |
169 } | 171 } |
170 } | 172 } |
171 | 173 |
| 174 void SnapWindowToPixelBoundary(aura::Window* window) { |
| 175 aura::Window* snapped_ancestor = window->parent(); |
| 176 while (snapped_ancestor) { |
| 177 if (snapped_ancestor->GetProperty(kSnapChildrenToPixelBoundary)) { |
| 178 ui::SnapLayerToPhysicalPixelBoundary(snapped_ancestor->layer(), |
| 179 window->layer()); |
| 180 return; |
| 181 } |
| 182 snapped_ancestor = snapped_ancestor->parent(); |
| 183 } |
| 184 } |
| 185 |
| 186 void SetSnapsChildrenToPhysicalPixelBoundary(aura::Window* container) { |
| 187 DCHECK(!container->GetProperty(kSnapChildrenToPixelBoundary)) |
| 188 << container->name(); |
| 189 container->SetProperty(kSnapChildrenToPixelBoundary, true); |
| 190 } |
| 191 |
| 192 void InstallSnapLayoutManagerToContainers(aura::Window* parent) { |
| 193 aura::Window::Windows children = parent->children(); |
| 194 for (aura::Window::Windows::iterator iter = children.begin(); |
| 195 iter != children.end(); |
| 196 ++iter) { |
| 197 aura::Window* container = *iter; |
| 198 if (container->id() < 0) // not a container |
| 199 continue; |
| 200 if (container->GetProperty(kSnapChildrenToPixelBoundary)) { |
| 201 if (!container->layout_manager()) |
| 202 container->SetLayoutManager(new SnapToPixelLayoutManager(container)); |
| 203 } else { |
| 204 InstallSnapLayoutManagerToContainers(container); |
| 205 } |
| 206 } |
| 207 } |
| 208 |
172 } // namespace wm | 209 } // namespace wm |
173 } // namespace ash | 210 } // namespace ash |
OLD | NEW |