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/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 case WINDOW_SNAP_RIGHT: { | 703 case WINDOW_SNAP_RIGHT: { |
704 aura::Window* window = wm::GetActiveWindow(); | 704 aura::Window* window = wm::GetActiveWindow(); |
705 // Disable window docking shortcut key for full screen window due to | 705 // Disable window docking shortcut key for full screen window due to |
706 // http://crbug.com/135487. | 706 // http://crbug.com/135487. |
707 if (!window || | 707 if (!window || |
708 window->type() != aura::client::WINDOW_TYPE_NORMAL || | 708 window->type() != aura::client::WINDOW_TYPE_NORMAL || |
709 wm::IsWindowFullscreen(window)) { | 709 wm::IsWindowFullscreen(window)) { |
710 break; | 710 break; |
711 } | 711 } |
712 | 712 |
713 internal::SnapSizer sizer(window, | 713 internal::SnapSizer::SnapWindow(window, |
714 gfx::Point(), | |
715 action == WINDOW_SNAP_LEFT ? internal::SnapSizer::LEFT_EDGE : | 714 action == WINDOW_SNAP_LEFT ? internal::SnapSizer::LEFT_EDGE : |
716 internal::SnapSizer::RIGHT_EDGE, | 715 internal::SnapSizer::RIGHT_EDGE); |
717 internal::SnapSizer::OTHER_INPUT); | |
718 if (wm::IsWindowFullscreen(window) || | |
719 wm::IsWindowMaximized(window)) { | |
720 // Before we can set the bounds we need to restore the window. | |
721 // Restoring the window will set the window to its restored bounds. | |
722 // To avoid an unnecessary bounds changes (which may have side effects) | |
723 // we set the restore bounds to the bounds we want, restore the window, | |
724 // then reset the restore bounds. This way no unnecessary bounds | |
725 // changes occurs and the original restore bounds is remembered. | |
726 gfx::Rect restore = *GetRestoreBoundsInScreen(window); | |
727 SetRestoreBoundsInParent(window, sizer.GetSnapBounds(window->bounds())); | |
728 wm::RestoreWindow(window); | |
729 SetRestoreBoundsInScreen(window, restore); | |
730 } else { | |
731 window->SetBounds(sizer.GetSnapBounds(window->bounds())); | |
732 } | |
733 return true; | 716 return true; |
734 } | 717 } |
735 case WINDOW_MINIMIZE: { | 718 case WINDOW_MINIMIZE: { |
736 aura::Window* window = wm::GetActiveWindow(); | 719 aura::Window* window = wm::GetActiveWindow(); |
737 // Attempt to restore the window that would be cycled through next from | 720 // Attempt to restore the window that would be cycled through next from |
738 // the launcher when there is no active window. | 721 // the launcher when there is no active window. |
739 if (!window) | 722 if (!window) |
740 return HandleCycleWindowMRU(WindowCycleController::FORWARD, false); | 723 return HandleCycleWindowMRU(WindowCycleController::FORWARD, false); |
741 // Disable the shortcut for minimizing full screen window due to | 724 // Disable the shortcut for minimizing full screen window due to |
742 // crbug.com/131709, which is a crashing issue related to minimizing | 725 // crbug.com/131709, which is a crashing issue related to minimizing |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 keyboard_brightness_control_delegate) { | 877 keyboard_brightness_control_delegate) { |
895 keyboard_brightness_control_delegate_ = | 878 keyboard_brightness_control_delegate_ = |
896 keyboard_brightness_control_delegate.Pass(); | 879 keyboard_brightness_control_delegate.Pass(); |
897 } | 880 } |
898 | 881 |
899 bool AcceleratorController::CanHandleAccelerators() const { | 882 bool AcceleratorController::CanHandleAccelerators() const { |
900 return true; | 883 return true; |
901 } | 884 } |
902 | 885 |
903 } // namespace ash | 886 } // namespace ash |
OLD | NEW |