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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 gfx::Point result(location); | 503 gfx::Point result(location); |
504 views::View::ConvertPointToScreen(this, &result); | 504 views::View::ConvertPointToScreen(this, &result); |
505 return result; | 505 return result; |
506 } | 506 } |
507 | 507 |
508 void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) { | 508 void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) { |
509 views::Widget* widget = frame_->GetWidget(); | 509 views::Widget* widget = frame_->GetWidget(); |
510 switch (snap_type_) { | 510 switch (snap_type_) { |
511 case SNAP_LEFT: | 511 case SNAP_LEFT: |
512 case SNAP_RIGHT: { | 512 case SNAP_RIGHT: { |
513 // Get the bounds in screen coordinates for restore purposes. | 513 // Get the window coordinates on the screen for restore purposes. |
514 gfx::Rect restore = widget->GetWindowBoundsInScreen(); | 514 gfx::Rect restore = widget->GetNativeWindow()->bounds(); |
515 if (widget->IsMaximized()) { | 515 if (widget->IsMaximized()) { |
516 // In case of maximized we have a restore boundary. | 516 // In case of maximized we have a restore boundary. |
517 DCHECK(ash::GetRestoreBoundsInScreen(widget->GetNativeWindow())); | 517 DCHECK(ash::GetRestoreBoundsInScreen(widget->GetNativeWindow())); |
518 // If it was maximized we need to recover the old restore set. | 518 // If it was maximized we need to recover the old restore set. |
519 restore = *ash::GetRestoreBoundsInScreen(widget->GetNativeWindow()); | 519 restore = *ash::GetRestoreBoundsInScreen(widget->GetNativeWindow()); |
520 // Set the restore size we want to restore to. | 520 // Set the restore size we want to restore to. |
521 ash::SetRestoreBoundsInScreen(widget->GetNativeWindow(), | 521 ash::SetRestoreBoundsInScreen(widget->GetNativeWindow(), |
522 ScreenBoundsForType(snap_type_, | 522 ScreenBoundsForType(snap_type_, |
523 snap_sizer)); | 523 snap_sizer)); |
524 widget->Restore(); | 524 widget->Restore(); |
525 } else { | 525 } else { |
526 // Others might also have set up a restore rectangle already. If so, | 526 // Others might also have set up a restore rectangle already. If so, |
527 // we should not overwrite the restore rectangle. | 527 // we should not overwrite the restore rectangle. |
528 bool restore_set = | 528 bool restore_set = |
529 GetRestoreBoundsInScreen(widget->GetNativeWindow()) != NULL; | 529 GetRestoreBoundsInScreen(widget->GetNativeWindow()) != NULL; |
530 widget->SetBounds(ScreenBoundsForType(snap_type_, snap_sizer)); | 530 widget->SetBounds(ScreenBoundsForType(snap_type_, snap_sizer)); |
531 if (restore_set) | 531 if (restore_set) |
532 break; | 532 break; |
533 } | 533 } |
534 // Remember the widow's bounds for restoration. | 534 // Remember the widow's bounds for restoration. |
535 ash::SetRestoreBoundsInScreen(widget->GetNativeWindow(), restore); | 535 ash::SetRestoreBoundsInScreen(widget->GetNativeWindow(), restore); |
| 536 } |
536 break; | 537 break; |
537 } | |
538 case SNAP_MAXIMIZE: | 538 case SNAP_MAXIMIZE: |
539 widget->Maximize(); | 539 widget->Maximize(); |
540 break; | 540 break; |
541 case SNAP_MINIMIZE: | 541 case SNAP_MINIMIZE: |
542 widget->Minimize(); | 542 widget->Minimize(); |
543 break; | 543 break; |
544 case SNAP_RESTORE: | 544 case SNAP_RESTORE: |
545 widget->Restore(); | 545 widget->Restore(); |
546 break; | 546 break; |
547 case SNAP_NONE: | 547 case SNAP_NONE: |
(...skipping 25 matching lines...) Expand all Loading... |
573 return FRAME_STATE_SNAP_LEFT; | 573 return FRAME_STATE_SNAP_LEFT; |
574 if (bounds.right() == screen.right()) | 574 if (bounds.right() == screen.right()) |
575 return FRAME_STATE_SNAP_RIGHT; | 575 return FRAME_STATE_SNAP_RIGHT; |
576 // If we come here, it is likely caused by the fact that the | 576 // If we come here, it is likely caused by the fact that the |
577 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case | 577 // "VerticalResizeDoubleClick" stored a restore rectangle. In that case |
578 // we allow all maximize operations (and keep the restore rectangle). | 578 // we allow all maximize operations (and keep the restore rectangle). |
579 return FRAME_STATE_NONE; | 579 return FRAME_STATE_NONE; |
580 } | 580 } |
581 | 581 |
582 } // namespace ash | 582 } // namespace ash |
OLD | NEW |