Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Unified Diff: ash/wm/window_util.cc

Issue 357063002: Snap widgets to pixel boundary on ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adjust tests Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/window_util.h ('k') | ash/wm/workspace/workspace_layout_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ash/wm/window_util.h ('k') | ash/wm/workspace/workspace_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698