| Index: ash/wm/window_util.cc
|
| diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
|
| index 906c8859534a6776dfc709dcbbc9630410791371..cd39d9c846664480a4e3cb605f7fb31fc2d51b15 100644
|
| --- a/ash/wm/window_util.cc
|
| +++ b/ash/wm/window_util.cc
|
| @@ -9,6 +9,7 @@
|
| #include "ash/ash_constants.h"
|
| #include "ash/screen_util.h"
|
| #include "ash/shell.h"
|
| +#include "ash/snap_to_pixel_layout_manager.h"
|
| #include "ash/wm/window_properties.h"
|
| #include "ash/wm/window_state.h"
|
| #include "ash/wm/wm_event.h"
|
| @@ -16,6 +17,7 @@
|
| #include "ui/aura/window.h"
|
| #include "ui/aura/window_delegate.h"
|
| #include "ui/aura/window_event_dispatcher.h"
|
| +#include "ui/compositor/dip_util.h"
|
| #include "ui/gfx/display.h"
|
| #include "ui/gfx/rect.h"
|
| #include "ui/gfx/screen.h"
|
| @@ -169,5 +171,40 @@ void ReparentTransientChildrenOfChild(aura::Window* child,
|
| }
|
| }
|
|
|
| +void SnapWindowToPixelBoundary(aura::Window* window) {
|
| + aura::Window* snapped_ancestor = window->parent();
|
| + while (snapped_ancestor) {
|
| + if (snapped_ancestor->GetProperty(kSnapChildrenToPixelBoundary)) {
|
| + ui::SnapLayerToPhysicalPixelBoundary(snapped_ancestor->layer(),
|
| + window->layer());
|
| + return;
|
| + }
|
| + snapped_ancestor = snapped_ancestor->parent();
|
| + }
|
| +}
|
| +
|
| +void SetSnapsChildrenToPhysicalPixelBoundary(aura::Window* container) {
|
| + DCHECK(!container->GetProperty(kSnapChildrenToPixelBoundary))
|
| + << container->name();
|
| + container->SetProperty(kSnapChildrenToPixelBoundary, true);
|
| +}
|
| +
|
| +void InstallSnapLayoutManagerToContainers(aura::Window* parent) {
|
| + aura::Window::Windows children = parent->children();
|
| + for (aura::Window::Windows::iterator iter = children.begin();
|
| + iter != children.end();
|
| + ++iter) {
|
| + aura::Window* container = *iter;
|
| + if (container->id() < 0) // not a container
|
| + continue;
|
| + if (container->GetProperty(kSnapChildrenToPixelBoundary)) {
|
| + if (!container->layout_manager())
|
| + container->SetLayoutManager(new SnapToPixelLayoutManager(container));
|
| + } else {
|
| + InstallSnapLayoutManagerToContainers(container);
|
| + }
|
| + }
|
| +}
|
| +
|
| } // namespace wm
|
| } // namespace ash
|
|
|