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

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

Issue 13896026: Stick windows to sides of workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Correcting logic to avoid getting stuck on resize Created 7 years, 7 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
Index: ash/wm/workspace/snap_sizer.cc
diff --git a/ash/wm/workspace/snap_sizer.cc b/ash/wm/workspace/snap_sizer.cc
index 11b59470fcd87d5be27e934cc992feac57b7c90a..93eb912d88a2b5571e52e13fec7bba8a80f23742 100644
--- a/ash/wm/workspace/snap_sizer.cc
+++ b/ash/wm/workspace/snap_sizer.cc
@@ -6,10 +6,13 @@
#include <cmath>
+#include "ash/ash_switches.h"
#include "ash/screen_ash.h"
#include "ash/wm/property_util.h"
#include "ash/wm/window_resizer.h"
#include "ash/wm/window_util.h"
+#include "ash/wm/workspace/workspace_window_resizer.h"
+#include "base/command_line.h"
#include "ui/aura/window.h"
#include "ui/gfx/screen.h"
@@ -93,6 +96,7 @@ void SnapSizer::SnapWindow(aura::Window* window, SnapSizer::Edge edge) {
return;
internal::SnapSizer sizer(window, gfx::Point(), edge,
internal::SnapSizer::OTHER_INPUT);
+ gfx::Rect bounds = sizer.GetSnapBounds(window->bounds());
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.
@@ -101,12 +105,22 @@ void SnapSizer::SnapWindow(aura::Window* window, SnapSizer::Edge edge) {
// 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()));
+ SetRestoreBoundsInParent(window, bounds);
wm::RestoreWindow(window);
SetRestoreBoundsInScreen(window, restore);
} else {
- window->SetBounds(sizer.GetSnapBounds(window->bounds()));
+ window->SetBounds(bounds);
}
+ gfx::Rect bounds_in_parent = ScreenAsh::ConvertRectToScreen(
+ window->parent(),
+ ScreenAsh::GetMaximizedWindowBoundsInParent(window));
+ int stuck_edges_mask =
+ internal::WorkspaceWindowResizer::CalculateStuckEdges(
+ bounds, bounds_in_parent);
+ if (GetStuckToEdge(window) != stuck_edges_mask &&
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAshEnableDockedWindows))
+ SetStuckToEdge(window, stuck_edges_mask);
}
void SnapSizer::Update(const gfx::Point& location) {

Powered by Google App Engine
This is Rietveld 408576698