| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/wm/workspace/frame_maximize_button.h" | 5 #include "ash/wm/workspace/frame_maximize_button.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/maximize_bubble_controller.h" | 10 #include "ash/wm/maximize_bubble_controller.h" |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 | 382 |
| 383 void FrameMaximizeButton::UpdateSnap(const gfx::Point& location, | 383 void FrameMaximizeButton::UpdateSnap(const gfx::Point& location, |
| 384 bool select_default, | 384 bool select_default, |
| 385 bool is_touch) { | 385 bool is_touch) { |
| 386 SnapType type = SnapTypeForLocation(location); | 386 SnapType type = SnapTypeForLocation(location); |
| 387 if (type == snap_type_) { | 387 if (type == snap_type_) { |
| 388 if (snap_sizer_.get()) { | 388 if (snap_sizer_.get()) { |
| 389 snap_sizer_->Update(LocationForSnapSizer(location)); | 389 snap_sizer_->Update(LocationForSnapSizer(location)); |
| 390 phantom_window_->Show(ScreenAsh::ConvertRectToScreen( | 390 phantom_window_->Show(ScreenAsh::ConvertRectToScreen( |
| 391 frame_->GetWidget()->GetNativeView()->parent(), | 391 frame_->GetWidget()->GetNativeView()->parent(), |
| 392 snap_sizer_->target_bounds()), NULL); | 392 snap_sizer_->target_bounds())); |
| 393 } | 393 } |
| 394 return; | 394 return; |
| 395 } | 395 } |
| 396 | 396 |
| 397 snap_type_ = type; | 397 snap_type_ = type; |
| 398 snap_sizer_.reset(); | 398 snap_sizer_.reset(); |
| 399 SchedulePaint(); | 399 SchedulePaint(); |
| 400 | 400 |
| 401 if (snap_type_ == SNAP_NONE) { | 401 if (snap_type_ == SNAP_NONE) { |
| 402 phantom_window_.reset(); | 402 phantom_window_.reset(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 418 } | 418 } |
| 419 if (!phantom_window_.get()) { | 419 if (!phantom_window_.get()) { |
| 420 phantom_window_.reset(new internal::PhantomWindowController( | 420 phantom_window_.reset(new internal::PhantomWindowController( |
| 421 frame_->GetWidget()->GetNativeWindow())); | 421 frame_->GetWidget()->GetNativeWindow())); |
| 422 } | 422 } |
| 423 if (maximizer_.get()) { | 423 if (maximizer_.get()) { |
| 424 phantom_window_->set_phantom_below_window(maximizer_->GetBubbleWindow()); | 424 phantom_window_->set_phantom_below_window(maximizer_->GetBubbleWindow()); |
| 425 maximizer_->SetSnapType(snap_type_); | 425 maximizer_->SetSnapType(snap_type_); |
| 426 } | 426 } |
| 427 phantom_window_->Show( | 427 phantom_window_->Show( |
| 428 ScreenBoundsForType(snap_type_, *snap_sizer_.get()), NULL); | 428 ScreenBoundsForType(snap_type_, *snap_sizer_.get())); |
| 429 } | 429 } |
| 430 | 430 |
| 431 SnapType FrameMaximizeButton::SnapTypeForLocation( | 431 SnapType FrameMaximizeButton::SnapTypeForLocation( |
| 432 const gfx::Point& location) const { | 432 const gfx::Point& location) const { |
| 433 MaximizeBubbleFrameState maximize_type = GetMaximizeBubbleFrameState(); | 433 MaximizeBubbleFrameState maximize_type = GetMaximizeBubbleFrameState(); |
| 434 gfx::Vector2d delta(location - press_location_); | 434 gfx::Vector2d delta(location - press_location_); |
| 435 if (!views::View::ExceededDragThreshold(delta)) | 435 if (!views::View::ExceededDragThreshold(delta)) |
| 436 return maximize_type != FRAME_STATE_FULL ? SNAP_MAXIMIZE : SNAP_RESTORE; | 436 return maximize_type != FRAME_STATE_FULL ? SNAP_MAXIMIZE : SNAP_RESTORE; |
| 437 if (delta.x() < 0 && delta.y() > delta.x() && delta.y() < -delta.x()) | 437 if (delta.x() < 0 && delta.y() > delta.x() && delta.y() < -delta.x()) |
| 438 return maximize_type == FRAME_STATE_SNAP_LEFT ? SNAP_RESTORE : SNAP_LEFT; | 438 return maximize_type == FRAME_STATE_SNAP_LEFT ? SNAP_RESTORE : SNAP_LEFT; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 return FRAME_STATE_SNAP_LEFT; | 558 return FRAME_STATE_SNAP_LEFT; |
| 559 if (bounds.right() == screen.right()) | 559 if (bounds.right() == screen.right()) |
| 560 return FRAME_STATE_SNAP_RIGHT; | 560 return FRAME_STATE_SNAP_RIGHT; |
| 561 // If we come here, it is likely caused by the fact that the | 561 // If we come here, it is likely caused by the fact that the |
| 562 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case | 562 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case |
| 563 // we allow all maximize operations (and keep the restore rectangle). | 563 // we allow all maximize operations (and keep the restore rectangle). |
| 564 return FRAME_STATE_NONE; | 564 return FRAME_STATE_NONE; |
| 565 } | 565 } |
| 566 | 566 |
| 567 } // namespace ash | 567 } // namespace ash |
| OLD | NEW |