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

Unified Diff: ash/wm/workspace/snap_sizer.cc

Issue 11434004: ash: Refactor some code that snaps windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month 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/workspace/snap_sizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/snap_sizer.cc
diff --git a/ash/wm/workspace/snap_sizer.cc b/ash/wm/workspace/snap_sizer.cc
index 2a536aa5208070e249fbfa9a8812616a863f784d..5788481d8d4dd6a98721fa61c0545180e4a76563 100644
--- a/ash/wm/workspace/snap_sizer.cc
+++ b/ash/wm/workspace/snap_sizer.cc
@@ -7,7 +7,9 @@
#include <cmath>
#include "ash/screen_ash.h"
+#include "ash/wm/property_util.h"
#include "ash/wm/window_resizer.h"
+#include "ash/wm/window_util.h"
#include "ui/aura/window.h"
#include "ui/gfx/screen.h"
@@ -86,6 +88,27 @@ SnapSizer::SnapSizer(aura::Window* window,
SnapSizer::~SnapSizer() {
}
+void SnapSizer::SnapWindow(aura::Window* window, SnapSizer::Edge edge) {
+ if (!wm::CanSnapWindow(window))
+ return;
+ internal::SnapSizer sizer(window, gfx::Point(), edge,
+ internal::SnapSizer::OTHER_INPUT);
+ if (wm::IsWindowFullscreen(window) || wm::IsWindowMaximized(window)) {
+ // Before we can set the bounds we need to restore the window.
+ // Restoring the window will set the window to its restored bounds.
+ // To avoid an unnecessary bounds changes (which may have side effects)
+ // we set the restore bounds to the bounds we want, restore the window,
+ // then reset the restore bounds. This way no unnecessary bounds
+ // changes occurs and the original restore bounds is remembered.
+ gfx::Rect restore = *GetRestoreBoundsInScreen(window);
+ SetRestoreBoundsInParent(window, sizer.GetSnapBounds(window->bounds()));
+ wm::RestoreWindow(window);
+ SetRestoreBoundsInScreen(window, restore);
+ } else {
+ window->SetBounds(sizer.GetSnapBounds(window->bounds()));
+ }
+}
+
void SnapSizer::Update(const gfx::Point& location) {
// See description above for details on this behavior.
num_moves_since_adjust_++;
« no previous file with comments | « ash/wm/workspace/snap_sizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698