| 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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 case TOGGLE_MAXIMIZED_PRESSED: { | 706 case TOGGLE_MAXIMIZED_PRESSED: { |
| 707 // We do not want to toggle maximization on the acceleration key | 707 // We do not want to toggle maximization on the acceleration key |
| 708 // repeating. | 708 // repeating. |
| 709 if (toggle_maximized_suppressed_) | 709 if (toggle_maximized_suppressed_) |
| 710 return true; | 710 return true; |
| 711 toggle_maximized_suppressed_ = true; | 711 toggle_maximized_suppressed_ = true; |
| 712 if (key_code == ui::VKEY_F4 && shell->delegate()) { | 712 if (key_code == ui::VKEY_F4 && shell->delegate()) { |
| 713 shell->delegate()->RecordUserMetricsAction( | 713 shell->delegate()->RecordUserMetricsAction( |
| 714 UMA_ACCEL_MAXIMIZE_RESTORE_F4); | 714 UMA_ACCEL_MAXIMIZE_RESTORE_F4); |
| 715 } | 715 } |
| 716 aura::Window* window = wm::GetActiveWindow(); | 716 shell->delegate()->ToggleMaximized(); |
| 717 if (!window) | |
| 718 return true; | |
| 719 if (wm::IsWindowFullscreen(window)) { | |
| 720 // Chrome also uses VKEY_F4 as a shortcut. Its action is to toggle | |
| 721 // fullscreen. We return false below so Chrome will process the | |
| 722 // shortcut again and, in case of VKEY_F4, exit fullscreen. | |
| 723 return false; | |
| 724 } | |
| 725 if (wm::IsWindowMaximized(window)) | |
| 726 wm::RestoreWindow(window); | |
| 727 else if (wm::CanMaximizeWindow(window)) | |
| 728 wm::MaximizeWindow(window); | |
| 729 return true; | 717 return true; |
| 730 } | 718 } |
| 731 case TOGGLE_MAXIMIZED_RELEASED: { | 719 case TOGGLE_MAXIMIZED_RELEASED: { |
| 732 toggle_maximized_suppressed_ = false; | 720 toggle_maximized_suppressed_ = false; |
| 733 return true; | 721 return true; |
| 734 } | 722 } |
| 735 case WINDOW_POSITION_CENTER: { | 723 case WINDOW_POSITION_CENTER: { |
| 736 aura::Window* window = wm::GetActiveWindow(); | 724 aura::Window* window = wm::GetActiveWindow(); |
| 737 if (window) { | 725 if (window) { |
| 738 wm::CenterWindow(window); | 726 wm::CenterWindow(window); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 accelerators_.insert( | 849 accelerators_.insert( |
| 862 std::make_pair(accelerator, accelerators[i].action)); | 850 std::make_pair(accelerator, accelerators[i].action)); |
| 863 } | 851 } |
| 864 } | 852 } |
| 865 | 853 |
| 866 bool AcceleratorController::CanHandleAccelerators() const { | 854 bool AcceleratorController::CanHandleAccelerators() const { |
| 867 return true; | 855 return true; |
| 868 } | 856 } |
| 869 | 857 |
| 870 } // namespace ash | 858 } // namespace ash |
| OLD | NEW |