| 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/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/shell_delegate.h" | 11 #include "ash/shell_delegate.h" |
| 12 #include "ash/touch/touch_uma.h" | 12 #include "ash/touch/touch_uma.h" |
| 13 #include "ash/wm/maximize_bubble_controller.h" | 13 #include "ash/wm/maximize_bubble_controller.h" |
| 14 #include "ash/wm/property_util.h" | 14 #include "ash/wm/property_util.h" |
| 15 #include "ash/wm/window_animations.h" | 15 #include "ash/wm/window_animations.h" |
| 16 #include "ash/wm/window_properties.h" | 16 #include "ash/wm/window_properties.h" |
| 17 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
| 18 #include "ash/wm/workspace/phantom_window_controller.h" | 18 #include "ash/wm/workspace/phantom_window_controller.h" |
| 19 #include "ash/wm/workspace/snap_sizer.h" | |
| 20 #include "grit/ash_strings.h" | 19 #include "grit/ash_strings.h" |
| 21 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
| 22 #include "ui/base/events/event.h" | 21 #include "ui/base/events/event.h" |
| 23 #include "ui/base/events/event_handler.h" | 22 #include "ui/base/events/event_handler.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 26 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
| 27 #include "ui/gfx/screen.h" | 26 #include "ui/gfx/screen.h" |
| 28 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
| 29 #include "ui/views/window/non_client_view.h" | 28 #include "ui/views/window/non_client_view.h" |
| 30 | 29 |
| 31 using ash::internal::SnapSizer; | |
| 32 | |
| 33 namespace ash { | 30 namespace ash { |
| 34 | 31 |
| 35 namespace { | 32 namespace { |
| 36 | 33 |
| 37 // Delay before forcing an update of the snap location. | 34 // Delay before forcing an update of the snap location. |
| 38 const int kUpdateDelayMS = 400; | 35 const int kUpdateDelayMS = 400; |
| 39 | 36 |
| 40 // The delay of the bubble appearance. | 37 // The delay of the bubble appearance. |
| 41 const int kBubbleAppearanceDelayMS = 500; | 38 const int kBubbleAppearanceDelayMS = 500; |
| 42 | 39 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // Before the window gets destroyed, the maximizer dialog needs to be shut | 99 // Before the window gets destroyed, the maximizer dialog needs to be shut |
| 103 // down since it would otherwise call into a deleted object. | 100 // down since it would otherwise call into a deleted object. |
| 104 maximizer_.reset(); | 101 maximizer_.reset(); |
| 105 if (widget_) | 102 if (widget_) |
| 106 OnWindowDestroying(widget_->GetNativeWindow()); | 103 OnWindowDestroying(widget_->GetNativeWindow()); |
| 107 } | 104 } |
| 108 | 105 |
| 109 void FrameMaximizeButton::SnapButtonHovered(SnapType type) { | 106 void FrameMaximizeButton::SnapButtonHovered(SnapType type) { |
| 110 // Make sure to only show hover operations when no button is pressed and | 107 // Make sure to only show hover operations when no button is pressed and |
| 111 // a similar snap operation in progress does not get re-applied. | 108 // a similar snap operation in progress does not get re-applied. |
| 112 if (is_snap_enabled_ || (type == snap_type_ && snap_sizer_)) | 109 if (is_snap_enabled_) |
| 113 return; | 110 return; |
| 114 // Prime the mouse location with the center of the (local) button. | 111 // Prime the mouse location with the center of the (local) button. |
| 115 press_location_ = gfx::Point(width() / 2, height() / 2); | 112 press_location_ = gfx::Point(width() / 2, height() / 2); |
| 116 // Then get an adjusted mouse position to initiate the effect. | 113 // Then get an adjusted mouse position to initiate the effect. |
| 117 gfx::Point location = press_location_; | 114 gfx::Point location = press_location_; |
| 118 switch (type) { | 115 switch (type) { |
| 119 case SNAP_LEFT: | 116 case SNAP_LEFT: |
| 120 location.set_x(location.x() - width()); | 117 location.set_x(location.x() - width()); |
| 121 break; | 118 break; |
| 122 case SNAP_RIGHT: | 119 case SNAP_RIGHT: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 149 void FrameMaximizeButton::ExecuteSnapAndCloseMenu(SnapType snap_type) { | 146 void FrameMaximizeButton::ExecuteSnapAndCloseMenu(SnapType snap_type) { |
| 150 // We can come here with no snap type set in case that the mouse opened the | 147 // We can come here with no snap type set in case that the mouse opened the |
| 151 // maximize button and a touch event "touched" a button. | 148 // maximize button and a touch event "touched" a button. |
| 152 if (snap_type_ == SNAP_NONE) | 149 if (snap_type_ == SNAP_NONE) |
| 153 SnapButtonHovered(snap_type); | 150 SnapButtonHovered(snap_type); |
| 154 | 151 |
| 155 Cancel(true); | 152 Cancel(true); |
| 156 // Tell our menu to close. | 153 // Tell our menu to close. |
| 157 maximizer_.reset(); | 154 maximizer_.reset(); |
| 158 snap_type_ = snap_type; | 155 snap_type_ = snap_type; |
| 159 // Since Snap might destroy |this|, but the snap_sizer needs to be destroyed, | 156 Snap(); |
| 160 // The ownership of the snap_sizer is taken now. | |
| 161 scoped_ptr<SnapSizer> snap_sizer(snap_sizer_.release()); | |
| 162 Snap(*snap_sizer.get()); | |
| 163 } | 157 } |
| 164 | 158 |
| 165 void FrameMaximizeButton::DestroyMaximizeMenu() { | 159 void FrameMaximizeButton::DestroyMaximizeMenu() { |
| 166 Cancel(false); | 160 Cancel(false); |
| 167 } | 161 } |
| 168 | 162 |
| 169 void FrameMaximizeButton::OnWindowBoundsChanged( | 163 void FrameMaximizeButton::OnWindowBoundsChanged( |
| 170 aura::Window* window, | 164 aura::Window* window, |
| 171 const gfx::Rect& old_bounds, | 165 const gfx::Rect& old_bounds, |
| 172 const gfx::Rect& new_bounds) { | 166 const gfx::Rect& new_bounds) { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // Prepare the help menu. | 325 // Prepare the help menu. |
| 332 if (!maximizer_) { | 326 if (!maximizer_) { |
| 333 maximizer_.reset(new MaximizeBubbleController( | 327 maximizer_.reset(new MaximizeBubbleController( |
| 334 this, | 328 this, |
| 335 GetMaximizeBubbleFrameState(), | 329 GetMaximizeBubbleFrameState(), |
| 336 bubble_appearance_delay_ms_)); | 330 bubble_appearance_delay_ms_)); |
| 337 } else { | 331 } else { |
| 338 // If the menu did not show up yet, we delay it even a bit more. | 332 // If the menu did not show up yet, we delay it even a bit more. |
| 339 maximizer_->DelayCreation(); | 333 maximizer_->DelayCreation(); |
| 340 } | 334 } |
| 341 snap_sizer_.reset(NULL); | |
| 342 InstallEventFilter(); | 335 InstallEventFilter(); |
| 343 snap_type_ = SNAP_NONE; | 336 snap_type_ = SNAP_NONE; |
| 344 press_location_ = event.location(); | 337 press_location_ = event.location(); |
| 345 press_is_gesture_ = event.IsGestureEvent(); | 338 press_is_gesture_ = event.IsGestureEvent(); |
| 346 exceeded_drag_threshold_ = false; | 339 exceeded_drag_threshold_ = false; |
| 347 update_timer_.Start( | 340 update_timer_.Start( |
| 348 FROM_HERE, | 341 FROM_HERE, |
| 349 base::TimeDelta::FromMilliseconds(kUpdateDelayMS), | 342 base::TimeDelta::FromMilliseconds(kUpdateDelayMS), |
| 350 this, | 343 this, |
| 351 &FrameMaximizeButton::UpdateSnapFromEventLocation); | 344 &FrameMaximizeButton::UpdateSnapFromEventLocation); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 371 maximizer_.reset(); | 364 maximizer_.reset(); |
| 372 | 365 |
| 373 if (!should_snap || snap_type_ == SNAP_NONE) | 366 if (!should_snap || snap_type_ == SNAP_NONE) |
| 374 return false; | 367 return false; |
| 375 | 368 |
| 376 SetState(views::CustomButton::STATE_NORMAL); | 369 SetState(views::CustomButton::STATE_NORMAL); |
| 377 // SetState will not call SchedulePaint() if state was already set to | 370 // SetState will not call SchedulePaint() if state was already set to |
| 378 // STATE_NORMAL during a drag. | 371 // STATE_NORMAL during a drag. |
| 379 SchedulePaint(); | 372 SchedulePaint(); |
| 380 phantom_window_.reset(); | 373 phantom_window_.reset(); |
| 381 // Since Snap might destroy |this|, but the snap_sizer needs to be destroyed, | 374 Snap(); |
| 382 // The ownership of the snap_sizer is taken now. | |
| 383 scoped_ptr<SnapSizer> snap_sizer(snap_sizer_.release()); | |
| 384 Snap(*snap_sizer.get()); | |
| 385 return true; | 375 return true; |
| 386 } | 376 } |
| 387 | 377 |
| 388 void FrameMaximizeButton::Cancel(bool keep_menu_open) { | 378 void FrameMaximizeButton::Cancel(bool keep_menu_open) { |
| 389 if (!keep_menu_open) { | 379 if (!keep_menu_open) { |
| 390 maximizer_.reset(); | 380 maximizer_.reset(); |
| 391 UninstallEventFilter(); | 381 UninstallEventFilter(); |
| 392 is_snap_enabled_ = false; | 382 is_snap_enabled_ = false; |
| 393 snap_sizer_.reset(); | |
| 394 } | 383 } |
| 395 phantom_window_.reset(); | 384 phantom_window_.reset(); |
| 396 snap_type_ = SNAP_NONE; | 385 snap_type_ = SNAP_NONE; |
| 397 update_timer_.Stop(); | 386 update_timer_.Stop(); |
| 398 SchedulePaint(); | 387 SchedulePaint(); |
| 399 } | 388 } |
| 400 | 389 |
| 401 void FrameMaximizeButton::InstallEventFilter() { | 390 void FrameMaximizeButton::InstallEventFilter() { |
| 402 if (escape_event_filter_) | 391 if (escape_event_filter_) |
| 403 return; | 392 return; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 414 if (exceeded_drag_threshold_) | 403 if (exceeded_drag_threshold_) |
| 415 return; | 404 return; |
| 416 exceeded_drag_threshold_ = true; | 405 exceeded_drag_threshold_ = true; |
| 417 UpdateSnap(press_location_, false, press_is_gesture_); | 406 UpdateSnap(press_location_, false, press_is_gesture_); |
| 418 } | 407 } |
| 419 | 408 |
| 420 void FrameMaximizeButton::UpdateSnap(const gfx::Point& location, | 409 void FrameMaximizeButton::UpdateSnap(const gfx::Point& location, |
| 421 bool select_default, | 410 bool select_default, |
| 422 bool is_touch) { | 411 bool is_touch) { |
| 423 SnapType type = SnapTypeForLocation(location); | 412 SnapType type = SnapTypeForLocation(location); |
| 424 if (type == snap_type_) { | 413 if (type == snap_type_) |
| 425 if (snap_sizer_) { | |
| 426 snap_sizer_->Update(LocationForSnapSizer(location)); | |
| 427 phantom_window_->Show(ScreenAsh::ConvertRectToScreen( | |
| 428 frame_->GetWidget()->GetNativeView()->parent(), | |
| 429 snap_sizer_->target_bounds())); | |
| 430 } | |
| 431 return; | 414 return; |
| 432 } | |
| 433 | 415 |
| 434 snap_type_ = type; | 416 snap_type_ = type; |
| 435 snap_sizer_.reset(); | |
| 436 SchedulePaint(); | 417 SchedulePaint(); |
| 437 | 418 |
| 438 if (snap_type_ == SNAP_NONE) { | 419 if (snap_type_ == SNAP_NONE) { |
| 439 phantom_window_.reset(); | 420 phantom_window_.reset(); |
| 440 return; | 421 return; |
| 441 } | 422 } |
| 442 | 423 |
| 443 if (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT) { | |
| 444 SnapSizer::Edge snap_edge = snap_type_ == SNAP_LEFT ? | |
| 445 SnapSizer::LEFT_EDGE : SnapSizer::RIGHT_EDGE; | |
| 446 SnapSizer::InputType input_type = | |
| 447 is_touch ? SnapSizer::TOUCH_MAXIMIZE_BUTTON_INPUT : | |
| 448 SnapSizer::OTHER_INPUT; | |
| 449 snap_sizer_.reset(new SnapSizer(frame_->GetWidget()->GetNativeWindow(), | |
| 450 LocationForSnapSizer(location), | |
| 451 snap_edge, | |
| 452 input_type)); | |
| 453 if (select_default) | |
| 454 snap_sizer_->SelectDefaultSizeAndDisableResize(); | |
| 455 } | |
| 456 if (!phantom_window_) { | 424 if (!phantom_window_) { |
| 457 phantom_window_.reset(new internal::PhantomWindowController( | 425 phantom_window_.reset(new internal::PhantomWindowController( |
| 458 frame_->GetWidget()->GetNativeWindow())); | 426 frame_->GetWidget()->GetNativeWindow())); |
| 459 } | 427 } |
| 460 if (maximizer_) { | 428 if (maximizer_) { |
| 461 phantom_window_->set_phantom_below_window(maximizer_->GetBubbleWindow()); | 429 phantom_window_->set_phantom_below_window(maximizer_->GetBubbleWindow()); |
| 462 maximizer_->SetSnapType(snap_type_); | 430 maximizer_->SetSnapType(snap_type_); |
| 463 } | 431 } |
| 464 phantom_window_->Show( | 432 phantom_window_->Show(ScreenBoundsForType(snap_type_)); |
| 465 ScreenBoundsForType(snap_type_, *snap_sizer_.get())); | |
| 466 } | 433 } |
| 467 | 434 |
| 468 SnapType FrameMaximizeButton::SnapTypeForLocation( | 435 SnapType FrameMaximizeButton::SnapTypeForLocation( |
| 469 const gfx::Point& location) const { | 436 const gfx::Point& location) const { |
| 470 MaximizeBubbleFrameState maximize_type = GetMaximizeBubbleFrameState(); | 437 MaximizeBubbleFrameState maximize_type = GetMaximizeBubbleFrameState(); |
| 471 gfx::Vector2d delta(location - press_location_); | 438 gfx::Vector2d delta(location - press_location_); |
| 472 if (!views::View::ExceededDragThreshold(delta)) | 439 if (!views::View::ExceededDragThreshold(delta)) |
| 473 return maximize_type != FRAME_STATE_FULL ? SNAP_MAXIMIZE : SNAP_RESTORE; | 440 return maximize_type != FRAME_STATE_FULL ? SNAP_MAXIMIZE : SNAP_RESTORE; |
| 474 if (delta.x() < 0 && delta.y() > delta.x() && delta.y() < -delta.x()) | 441 if (delta.x() < 0 && delta.y() > delta.x() && delta.y() < -delta.x()) |
| 475 return maximize_type == FRAME_STATE_SNAP_LEFT ? SNAP_RESTORE : SNAP_LEFT; | 442 return maximize_type == FRAME_STATE_SNAP_LEFT ? SNAP_RESTORE : SNAP_LEFT; |
| 476 if (delta.x() > 0 && delta.y() > -delta.x() && delta.y() < delta.x()) | 443 if (delta.x() > 0 && delta.y() > -delta.x() && delta.y() < delta.x()) |
| 477 return maximize_type == FRAME_STATE_SNAP_RIGHT ? SNAP_RESTORE : SNAP_RIGHT; | 444 return maximize_type == FRAME_STATE_SNAP_RIGHT ? SNAP_RESTORE : SNAP_RIGHT; |
| 478 if (delta.y() > 0) | 445 if (delta.y() > 0) |
| 479 return SNAP_MINIMIZE; | 446 return SNAP_MINIMIZE; |
| 480 return maximize_type != FRAME_STATE_FULL ? SNAP_MAXIMIZE : SNAP_RESTORE; | 447 return maximize_type != FRAME_STATE_FULL ? SNAP_MAXIMIZE : SNAP_RESTORE; |
| 481 } | 448 } |
| 482 | 449 |
| 483 gfx::Rect FrameMaximizeButton::ScreenBoundsForType( | 450 gfx::Rect FrameMaximizeButton::ScreenBoundsForType(SnapType type) const { |
| 484 SnapType type, | |
| 485 const SnapSizer& snap_sizer) const { | |
| 486 aura::Window* window = frame_->GetWidget()->GetNativeWindow(); | 451 aura::Window* window = frame_->GetWidget()->GetNativeWindow(); |
| 487 switch (type) { | 452 switch (type) { |
| 488 case SNAP_LEFT: | 453 case SNAP_LEFT: |
| 454 return ScreenAsh::ConvertRectToScreen( |
| 455 window->parent(), |
| 456 wm::GetSnappedWindowBoundsInParent(window, wm::SNAP_LEFT_EDGE)); |
| 489 case SNAP_RIGHT: | 457 case SNAP_RIGHT: |
| 490 return ScreenAsh::ConvertRectToScreen( | 458 return ScreenAsh::ConvertRectToScreen( |
| 491 frame_->GetWidget()->GetNativeView()->parent(), | 459 window->parent(), |
| 492 snap_sizer.target_bounds()); | 460 wm::GetSnappedWindowBoundsInParent(window, wm::SNAP_RIGHT_EDGE)); |
| 493 case SNAP_MAXIMIZE: | 461 case SNAP_MAXIMIZE: |
| 494 return ScreenAsh::ConvertRectToScreen( | 462 return ScreenAsh::ConvertRectToScreen( |
| 495 window->parent(), | 463 window->parent(), |
| 496 ScreenAsh::GetMaximizedWindowBoundsInParent(window)); | 464 ScreenAsh::GetMaximizedWindowBoundsInParent(window)); |
| 497 case SNAP_MINIMIZE: { | 465 case SNAP_MINIMIZE: { |
| 498 gfx::Rect rect = GetMinimizeAnimationTargetBoundsInScreen(window); | 466 gfx::Rect rect = GetMinimizeAnimationTargetBoundsInScreen(window); |
| 499 if (!rect.IsEmpty()) { | 467 if (!rect.IsEmpty()) { |
| 500 // PhantomWindowController insets slightly, outset it so the phantom | 468 // PhantomWindowController insets slightly, outset it so the phantom |
| 501 // doesn't appear inset. | 469 // doesn't appear inset. |
| 502 rect.Inset(-8, -8); | 470 rect.Inset(-8, -8); |
| 503 } | 471 } |
| 504 return rect; | 472 return rect; |
| 505 } | 473 } |
| 506 case SNAP_RESTORE: { | 474 case SNAP_RESTORE: { |
| 507 const gfx::Rect* restore = GetRestoreBoundsInScreen(window); | 475 const gfx::Rect* restore = GetRestoreBoundsInScreen(window); |
| 508 return restore ? | 476 return restore ? |
| 509 *restore : frame_->GetWidget()->GetWindowBoundsInScreen(); | 477 *restore : frame_->GetWidget()->GetWindowBoundsInScreen(); |
| 510 } | 478 } |
| 511 case SNAP_NONE: | 479 case SNAP_NONE: |
| 512 NOTREACHED(); | 480 NOTREACHED(); |
| 513 } | 481 } |
| 514 return gfx::Rect(); | 482 return gfx::Rect(); |
| 515 } | 483 } |
| 516 | 484 |
| 517 gfx::Point FrameMaximizeButton::LocationForSnapSizer( | 485 void FrameMaximizeButton::Snap() { |
| 518 const gfx::Point& location) const { | |
| 519 gfx::Point result(location); | |
| 520 views::View::ConvertPointToScreen(this, &result); | |
| 521 return result; | |
| 522 } | |
| 523 | |
| 524 void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) { | |
| 525 ash::Shell* shell = ash::Shell::GetInstance(); | 486 ash::Shell* shell = ash::Shell::GetInstance(); |
| 526 views::Widget* widget = frame_->GetWidget(); | 487 views::Widget* widget = frame_->GetWidget(); |
| 527 switch (snap_type_) { | 488 switch (snap_type_) { |
| 528 case SNAP_LEFT: | 489 case SNAP_LEFT: |
| 529 case SNAP_RIGHT: { | 490 case SNAP_RIGHT: { |
| 530 shell->delegate()->RecordUserMetricsAction( | 491 shell->delegate()->RecordUserMetricsAction( |
| 531 snap_type_ == SNAP_LEFT ? | 492 snap_type_ == SNAP_LEFT ? |
| 532 ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT : | 493 ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT : |
| 533 ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT); | 494 ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT); |
| 534 // Get the bounds in screen coordinates for restore purposes. | 495 // Get the bounds in screen coordinates for restore purposes. |
| 535 gfx::Rect restore = widget->GetWindowBoundsInScreen(); | 496 gfx::Rect restore = widget->GetWindowBoundsInScreen(); |
| 536 if (widget->IsMaximized() || widget->IsFullscreen()) { | 497 if (widget->IsMaximized() || widget->IsFullscreen()) { |
| 537 aura::Window* window = widget->GetNativeWindow(); | 498 aura::Window* window = widget->GetNativeWindow(); |
| 538 // In case of maximized we have a restore boundary. | 499 // In case of maximized we have a restore boundary. |
| 539 DCHECK(ash::GetRestoreBoundsInScreen(window)); | 500 DCHECK(ash::GetRestoreBoundsInScreen(window)); |
| 540 // If it was maximized we need to recover the old restore set. | 501 // If it was maximized we need to recover the old restore set. |
| 541 restore = *ash::GetRestoreBoundsInScreen(window); | 502 restore = *ash::GetRestoreBoundsInScreen(window); |
| 542 | 503 |
| 543 // The auto position manager will kick in when this is the only window. | 504 // The auto position manager will kick in when this is the only window. |
| 544 // To avoid interference with it we tell it temporarily to not change | 505 // To avoid interference with it we tell it temporarily to not change |
| 545 // the coordinates of this window. | 506 // the coordinates of this window. |
| 546 bool is_managed = ash::wm::IsWindowPositionManaged(window); | 507 bool is_managed = ash::wm::IsWindowPositionManaged(window); |
| 547 if (is_managed) | 508 if (is_managed) |
| 548 ash::wm::SetWindowPositionManaged(window, false); | 509 ash::wm::SetWindowPositionManaged(window, false); |
| 549 | 510 |
| 550 // Set the restore size we want to restore to. | 511 // Set the restore size we want to restore to. |
| 551 ash::SetRestoreBoundsInScreen(window, | 512 ash::SetRestoreBoundsInScreen(window, ScreenBoundsForType(snap_type_)); |
| 552 ScreenBoundsForType(snap_type_, | |
| 553 snap_sizer)); | |
| 554 widget->Restore(); | 513 widget->Restore(); |
| 555 | 514 |
| 556 // After the window is where we want it to be we allow the window to be | 515 // After the window is where we want it to be we allow the window to be |
| 557 // auto managed again. | 516 // auto managed again. |
| 558 if (is_managed) | 517 if (is_managed) |
| 559 ash::wm::SetWindowPositionManaged(window, true); | 518 ash::wm::SetWindowPositionManaged(window, true); |
| 560 } else { | 519 } else { |
| 561 // Others might also have set up a restore rectangle already. If so, | 520 // Others might also have set up a restore rectangle already. If so, |
| 562 // we should not overwrite the restore rectangle. | 521 // we should not overwrite the restore rectangle. |
| 563 bool restore_set = | 522 bool restore_set = |
| 564 GetRestoreBoundsInScreen(widget->GetNativeWindow()) != NULL; | 523 GetRestoreBoundsInScreen(widget->GetNativeWindow()) != NULL; |
| 565 widget->SetBounds(ScreenBoundsForType(snap_type_, snap_sizer)); | 524 widget->SetBounds(ScreenBoundsForType(snap_type_)); |
| 566 if (restore_set) | 525 if (restore_set) |
| 567 break; | 526 break; |
| 568 } | 527 } |
| 569 // Remember the widow's bounds for restoration. | 528 // Remember the widow's bounds for restoration. |
| 570 ash::SetRestoreBoundsInScreen(widget->GetNativeWindow(), restore); | 529 ash::SetRestoreBoundsInScreen(widget->GetNativeWindow(), restore); |
| 571 break; | 530 break; |
| 572 } | 531 } |
| 573 case SNAP_MAXIMIZE: | 532 case SNAP_MAXIMIZE: |
| 574 widget->Maximize(); | 533 widget->Maximize(); |
| 575 shell->delegate()->RecordUserMetricsAction( | 534 shell->delegate()->RecordUserMetricsAction( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 return FRAME_STATE_SNAP_LEFT; | 574 return FRAME_STATE_SNAP_LEFT; |
| 616 if (bounds.right() == screen.right()) | 575 if (bounds.right() == screen.right()) |
| 617 return FRAME_STATE_SNAP_RIGHT; | 576 return FRAME_STATE_SNAP_RIGHT; |
| 618 // If we come here, it is likely caused by the fact that the | 577 // If we come here, it is likely caused by the fact that the |
| 619 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case | 578 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case |
| 620 // we allow all maximize operations (and keep the restore rectangle). | 579 // we allow all maximize operations (and keep the restore rectangle). |
| 621 return FRAME_STATE_NONE; | 580 return FRAME_STATE_NONE; |
| 622 } | 581 } |
| 623 | 582 |
| 624 } // namespace ash | 583 } // namespace ash |
| OLD | NEW |