| 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 78438f02f158f04c256ad55403adfd20f7ed26fc..d504c967e7937364333ace22499966550dcc201a 100644
|
| --- a/ash/wm/workspace/frame_maximize_button.cc
|
| +++ b/ash/wm/workspace/frame_maximize_button.cc
|
| @@ -16,7 +16,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 "grit/ash_strings.h"
|
| #include "ui/aura/window.h"
|
| #include "ui/base/events/event.h"
|
| @@ -28,8 +27,6 @@
|
| #include "ui/views/widget/widget.h"
|
| #include "ui/views/window/non_client_view.h"
|
|
|
| -using ash::internal::SnapSizer;
|
| -
|
| namespace ash {
|
|
|
| namespace {
|
| @@ -109,7 +106,7 @@ FrameMaximizeButton::~FrameMaximizeButton() {
|
| void FrameMaximizeButton::SnapButtonHovered(SnapType type) {
|
| // Make sure to only show hover operations when no button is pressed and
|
| // a similar snap operation in progress does not get re-applied.
|
| - if (is_snap_enabled_ || (type == snap_type_ && snap_sizer_))
|
| + if (is_snap_enabled_)
|
| return;
|
| // Prime the mouse location with the center of the (local) button.
|
| press_location_ = gfx::Point(width() / 2, height() / 2);
|
| @@ -156,10 +153,7 @@ void FrameMaximizeButton::ExecuteSnapAndCloseMenu(SnapType snap_type) {
|
| // Tell our menu to close.
|
| maximizer_.reset();
|
| snap_type_ = snap_type;
|
| - // Since Snap might destroy |this|, but the snap_sizer needs to be destroyed,
|
| - // The ownership of the snap_sizer is taken now.
|
| - scoped_ptr<SnapSizer> snap_sizer(snap_sizer_.release());
|
| - Snap(*snap_sizer.get());
|
| + Snap();
|
| }
|
|
|
| void FrameMaximizeButton::DestroyMaximizeMenu() {
|
| @@ -338,7 +332,6 @@ void FrameMaximizeButton::ProcessStartEvent(const ui::LocatedEvent& event) {
|
| // If the menu did not show up yet, we delay it even a bit more.
|
| maximizer_->DelayCreation();
|
| }
|
| - snap_sizer_.reset(NULL);
|
| InstallEventFilter();
|
| snap_type_ = SNAP_NONE;
|
| press_location_ = event.location();
|
| @@ -378,10 +371,7 @@ bool FrameMaximizeButton::ProcessEndEvent(const ui::LocatedEvent& event) {
|
| // STATE_NORMAL during a drag.
|
| SchedulePaint();
|
| phantom_window_.reset();
|
| - // Since Snap might destroy |this|, but the snap_sizer needs to be destroyed,
|
| - // The ownership of the snap_sizer is taken now.
|
| - scoped_ptr<SnapSizer> snap_sizer(snap_sizer_.release());
|
| - Snap(*snap_sizer.get());
|
| + Snap();
|
| return true;
|
| }
|
|
|
| @@ -390,7 +380,6 @@ void FrameMaximizeButton::Cancel(bool keep_menu_open) {
|
| maximizer_.reset();
|
| UninstallEventFilter();
|
| is_snap_enabled_ = false;
|
| - snap_sizer_.reset();
|
| }
|
| phantom_window_.reset();
|
| snap_type_ = SNAP_NONE;
|
| @@ -421,18 +410,10 @@ void FrameMaximizeButton::UpdateSnap(const gfx::Point& location,
|
| bool select_default,
|
| bool is_touch) {
|
| SnapType type = SnapTypeForLocation(location);
|
| - if (type == snap_type_) {
|
| - if (snap_sizer_) {
|
| - snap_sizer_->Update(LocationForSnapSizer(location));
|
| - phantom_window_->Show(ScreenAsh::ConvertRectToScreen(
|
| - frame_->GetWidget()->GetNativeView()->parent(),
|
| - snap_sizer_->target_bounds()));
|
| - }
|
| + if (type == snap_type_)
|
| return;
|
| - }
|
|
|
| snap_type_ = type;
|
| - snap_sizer_.reset();
|
| SchedulePaint();
|
|
|
| if (snap_type_ == SNAP_NONE) {
|
| @@ -440,19 +421,6 @@ void FrameMaximizeButton::UpdateSnap(const gfx::Point& location,
|
| return;
|
| }
|
|
|
| - if (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT) {
|
| - SnapSizer::Edge snap_edge = snap_type_ == SNAP_LEFT ?
|
| - SnapSizer::LEFT_EDGE : SnapSizer::RIGHT_EDGE;
|
| - SnapSizer::InputType input_type =
|
| - is_touch ? SnapSizer::TOUCH_MAXIMIZE_BUTTON_INPUT :
|
| - SnapSizer::OTHER_INPUT;
|
| - snap_sizer_.reset(new SnapSizer(frame_->GetWidget()->GetNativeWindow(),
|
| - LocationForSnapSizer(location),
|
| - snap_edge,
|
| - input_type));
|
| - if (select_default)
|
| - snap_sizer_->SelectDefaultSizeAndDisableResize();
|
| - }
|
| if (!phantom_window_) {
|
| phantom_window_.reset(new internal::PhantomWindowController(
|
| frame_->GetWidget()->GetNativeWindow()));
|
| @@ -461,8 +429,7 @@ void FrameMaximizeButton::UpdateSnap(const gfx::Point& location,
|
| phantom_window_->set_phantom_below_window(maximizer_->GetBubbleWindow());
|
| maximizer_->SetSnapType(snap_type_);
|
| }
|
| - phantom_window_->Show(
|
| - ScreenBoundsForType(snap_type_, *snap_sizer_.get()));
|
| + phantom_window_->Show(ScreenBoundsForType(snap_type_));
|
| }
|
|
|
| SnapType FrameMaximizeButton::SnapTypeForLocation(
|
| @@ -480,16 +447,17 @@ SnapType FrameMaximizeButton::SnapTypeForLocation(
|
| return maximize_type != FRAME_STATE_FULL ? SNAP_MAXIMIZE : SNAP_RESTORE;
|
| }
|
|
|
| -gfx::Rect FrameMaximizeButton::ScreenBoundsForType(
|
| - SnapType type,
|
| - const SnapSizer& snap_sizer) const {
|
| +gfx::Rect FrameMaximizeButton::ScreenBoundsForType(SnapType type) const {
|
| aura::Window* window = frame_->GetWidget()->GetNativeWindow();
|
| switch (type) {
|
| case SNAP_LEFT:
|
| + return ScreenAsh::ConvertRectToScreen(
|
| + window->parent(),
|
| + wm::GetSnappedWindowBoundsInParent(window, wm::SNAP_LEFT_EDGE));
|
| case SNAP_RIGHT:
|
| return ScreenAsh::ConvertRectToScreen(
|
| - frame_->GetWidget()->GetNativeView()->parent(),
|
| - snap_sizer.target_bounds());
|
| + window->parent(),
|
| + wm::GetSnappedWindowBoundsInParent(window, wm::SNAP_RIGHT_EDGE));
|
| case SNAP_MAXIMIZE:
|
| return ScreenAsh::ConvertRectToScreen(
|
| window->parent(),
|
| @@ -514,14 +482,7 @@ gfx::Rect FrameMaximizeButton::ScreenBoundsForType(
|
| return gfx::Rect();
|
| }
|
|
|
| -gfx::Point FrameMaximizeButton::LocationForSnapSizer(
|
| - const gfx::Point& location) const {
|
| - gfx::Point result(location);
|
| - views::View::ConvertPointToScreen(this, &result);
|
| - return result;
|
| -}
|
| -
|
| -void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) {
|
| +void FrameMaximizeButton::Snap() {
|
| ash::Shell* shell = ash::Shell::GetInstance();
|
| views::Widget* widget = frame_->GetWidget();
|
| switch (snap_type_) {
|
| @@ -548,9 +509,7 @@ 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));
|
| + ash::SetRestoreBoundsInScreen(window, ScreenBoundsForType(snap_type_));
|
| widget->Restore();
|
|
|
| // After the window is where we want it to be we allow the window to be
|
| @@ -562,7 +521,7 @@ void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) {
|
| // we should not overwrite the restore rectangle.
|
| bool restore_set =
|
| GetRestoreBoundsInScreen(widget->GetNativeWindow()) != NULL;
|
| - widget->SetBounds(ScreenBoundsForType(snap_type_, snap_sizer));
|
| + widget->SetBounds(ScreenBoundsForType(snap_type_));
|
| if (restore_set)
|
| break;
|
| }
|
|
|