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

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

Issue 23471004: Only support left/right maximizing at 50% width when the --ash-enable-alternate-caption-button (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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/workspace_window_resizer.cc
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index 4b8c0aaf7e9366f91aa1fd1bf6f8d88f9429b0c9..89041c8bb452485dd34311eccf4ba4742f5f4e6a 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -23,7 +23,6 @@
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/phantom_window_controller.h"
-#include "ash/wm/workspace/snap_sizer.h"
#include "base/command_line.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/screen_position_client.h"
@@ -414,7 +413,7 @@ void WorkspaceWindowResizer::CompleteDrag(int event_flags) {
if (wm::IsWindowNormal(window()) &&
(window()->type() != aura::client::WINDOW_TYPE_PANEL ||
!window()->GetProperty(kPanelAttachedKey)) &&
- (snap_type_ == SNAP_LEFT_EDGE || snap_type_ == SNAP_RIGHT_EDGE)) {
+ (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT)) {
if (!GetRestoreBoundsInScreen(window())) {
gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen(
window()->parent(), details_.initial_bounds_in_parent);
@@ -422,8 +421,10 @@ void WorkspaceWindowResizer::CompleteDrag(int event_flags) {
initial_bounds :
details_.restore_bounds);
}
- window()->SetBounds(snap_sizer_->target_bounds());
- return;
+ if (snap_type_ == SNAP_LEFT)
+ wm::SnapWindowToEdge(window(), wm::SNAP_LEFT_EDGE);
+ else if (snap_type_ == SNAP_RIGHT)
+ wm::SnapWindowToEdge(window(), wm::SNAP_RIGHT_EDGE);
}
}
@@ -490,7 +491,6 @@ WorkspaceWindowResizer::WorkspaceWindowResizer(
// TODO: figure out how to deal with window going off the edge.
// Calculate sizes so that we can maintain the ratios if we need to resize.
- int total_available = 0;
for (size_t i = 0; i < attached_windows_.size(); ++i) {
gfx::Size min(attached_windows_[i]->delegate()->GetMinimumSize());
int initial_size = PrimaryAxisSize(attached_windows_[i]->bounds().size());
@@ -501,17 +501,7 @@ WorkspaceWindowResizer::WorkspaceWindowResizer(
std::max(PrimaryAxisSize(min), kMinOnscreenSize));
total_min_ += min_size;
total_initial_size_ += initial_size;
- total_available += std::max(min_size, initial_size) - min_size;
- }
-}
-
-gfx::Rect WorkspaceWindowResizer::GetFinalBounds(
- const gfx::Rect& bounds) const {
- if (snap_phantom_window_controller_.get() &&
- snap_phantom_window_controller_->IsShowing()) {
- return snap_phantom_window_controller_->bounds_in_screen();
}
- return bounds;
}
void WorkspaceWindowResizer::LayoutAttachedWindows(
@@ -867,26 +857,19 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
snap_type_ = GetSnapType(location);
if (snap_type_ == SNAP_NONE || snap_type_ != last_type) {
snap_phantom_window_controller_.reset();
- snap_sizer_.reset();
if (snap_type_ == SNAP_NONE)
return;
}
- if (!snap_sizer_) {
- SnapSizer::Edge edge = (snap_type_ == SNAP_LEFT_EDGE) ?
- SnapSizer::LEFT_EDGE : SnapSizer::RIGHT_EDGE;
- snap_sizer_.reset(new SnapSizer(window(),
- location,
- edge,
- internal::SnapSizer::OTHER_INPUT));
- } else {
- snap_sizer_->Update(location);
- }
if (!snap_phantom_window_controller_) {
snap_phantom_window_controller_.reset(
new PhantomWindowController(window()));
}
+
+ wm::SnapEdge edge = (snap_type_ == SNAP_LEFT) ?
+ wm::SNAP_LEFT_EDGE : wm::SNAP_RIGHT_EDGE;
+ gfx::Rect target_bounds = wm::GetSnappedWindowBoundsInParent(window(), edge);
snap_phantom_window_controller_->Show(ScreenAsh::ConvertRectToScreen(
- window()->parent(), snap_sizer_->target_bounds()));
+ window()->parent(), target_bounds));
}
void WorkspaceWindowResizer::RestackWindows() {
@@ -926,9 +909,9 @@ WorkspaceWindowResizer::SnapType WorkspaceWindowResizer::GetSnapType(
// display.
gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window()));
if (location.x() <= area.x())
- return SNAP_LEFT_EDGE;
+ return SNAP_LEFT;
if (location.x() >= area.right() - 1)
- return SNAP_RIGHT_EDGE;
+ return SNAP_RIGHT;
return SNAP_NONE;
}

Powered by Google App Engine
This is Rietveld 408576698