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

Unified Diff: ash/wm/workspace/frame_maximize_button.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/frame_maximize_button.cc
diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc
index 0329e3f6d4668e5342a2586f4d061dd017991c69..92a74b3100a12d05aeaa3ea253d40155a51e3b68 100644
--- a/ash/wm/workspace/frame_maximize_button.cc
+++ b/ash/wm/workspace/frame_maximize_button.cc
@@ -4,6 +4,7 @@
#include "ash/wm/workspace/frame_maximize_button.h"
+#include "ash/ash_switches.h"
#include "ash/launcher/launcher.h"
#include "ash/screen_ash.h"
#include "ash/shelf/shelf_widget.h"
@@ -15,6 +16,8 @@
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/phantom_window_controller.h"
#include "ash/wm/workspace/snap_sizer.h"
+#include "ash/wm/workspace/workspace_window_resizer.h"
+#include "base/command_line.h"
#include "grit/ash_strings.h"
#include "ui/aura/window.h"
#include "ui/base/events/event.h"
@@ -530,8 +533,10 @@ void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) {
ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT);
// Get the bounds in screen coordinates for restore purposes.
gfx::Rect restore = widget->GetWindowBoundsInScreen();
+ bool restore_set = false;
+ gfx::Rect bounds;
+ aura::Window* window = widget->GetNativeWindow();
if (widget->IsMaximized() || widget->IsFullscreen()) {
- aura::Window* window = widget->GetNativeWindow();
// In case of maximized we have a restore boundary.
DCHECK(ash::GetRestoreBoundsInScreen(window));
// If it was maximized we need to recover the old restore set.
@@ -545,9 +550,8 @@ void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) {
ash::wm::SetWindowPositionManaged(window, false);
// Set the restore size we want to restore to.
- ash::SetRestoreBoundsInScreen(window,
- ScreenBoundsForType(snap_type_,
- snap_sizer));
+ bounds = ScreenBoundsForType(snap_type_, snap_sizer);
+ ash::SetRestoreBoundsInScreen(window, bounds);
widget->Restore();
// After the window is where we want it to be we allow the window to be
@@ -557,12 +561,25 @@ void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) {
} else {
// Others might also have set up a restore rectangle already. If so,
// we should not overwrite the restore rectangle.
- bool restore_set =
+ restore_set =
GetRestoreBoundsInScreen(widget->GetNativeWindow()) != NULL;
- widget->SetBounds(ScreenBoundsForType(snap_type_, snap_sizer));
- if (restore_set)
- break;
+ bounds = ScreenBoundsForType(snap_type_, snap_sizer);
+ widget->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))
flackr 2013/05/22 02:00:56 nit: multiline if condition should use braces.
+ SetStuckToEdge(window, stuck_edges_mask);
flackr 2013/05/22 02:00:56 Why check if the condition is not stuck_edges_mask
+
+ if (restore_set)
+ break;
+
// Remember the widow's bounds for restoration.
flackr 2013/05/22 02:00:56 s/widow/window
ash::SetRestoreBoundsInScreen(widget->GetNativeWindow(), restore);
break;

Powered by Google App Engine
This is Rietveld 408576698