| 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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 } | 495 } |
| 496 accelerators::ToggleFullscreen(); | 496 accelerators::ToggleFullscreen(); |
| 497 return true; | 497 return true; |
| 498 } | 498 } |
| 499 | 499 |
| 500 bool HandleToggleRootWindowFullScreen() { | 500 bool HandleToggleRootWindowFullScreen() { |
| 501 Shell::GetPrimaryRootWindowController()->ash_host()->ToggleFullScreen(); | 501 Shell::GetPrimaryRootWindowController()->ash_host()->ToggleFullScreen(); |
| 502 return true; | 502 return true; |
| 503 } | 503 } |
| 504 | 504 |
| 505 bool HandleWindowSnap(int action) { | 505 bool HandleWindowSnapOrDock(int action) { |
| 506 wm::WindowState* window_state = wm::GetActiveWindowState(); | 506 wm::WindowState* window_state = wm::GetActiveWindowState(); |
| 507 // Disable window snapping shortcut key for full screen window due to | 507 // Disable window snapping shortcut key for full screen window due to |
| 508 // http://crbug.com/135487. | 508 // http://crbug.com/135487. |
| 509 if (!window_state || | 509 if (!window_state || |
| 510 window_state->window()->type() != ui::wm::WINDOW_TYPE_NORMAL || | 510 (window_state->window()->type() != ui::wm::WINDOW_TYPE_NORMAL && |
| 511 window_state->IsFullscreen() || | 511 window_state->window()->type() != ui::wm::WINDOW_TYPE_PANEL) || |
| 512 !window_state->CanSnap()) { | 512 window_state->IsFullscreen()) { |
| 513 return false; | 513 return false; |
| 514 } | 514 } |
| 515 | 515 |
| 516 if (action == WINDOW_SNAP_LEFT) { | 516 if (action == WINDOW_CYCLE_SNAP_DOCK_LEFT) |
| 517 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left")); | 517 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left")); |
| 518 } else { | 518 else |
| 519 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right")); | 519 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right")); |
| 520 } | 520 |
| 521 const wm::WMEvent event(action == WINDOW_SNAP_LEFT ? | 521 const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_DOCK_LEFT ? |
| 522 wm::WM_EVENT_SNAP_LEFT : wm::WM_EVENT_SNAP_RIGHT); | 522 wm::WM_EVENT_CYCLE_SNAP_DOCK_LEFT : |
| 523 wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT); |
| 523 window_state->OnWMEvent(&event); | 524 window_state->OnWMEvent(&event); |
| 524 return true; | 525 return true; |
| 525 } | 526 } |
| 526 | 527 |
| 527 bool HandleWindowMinimize() { | 528 bool HandleWindowMinimize() { |
| 528 base::RecordAction( | 529 base::RecordAction( |
| 529 base::UserMetricsAction("Accel_Toggle_Minimized_Minus")); | 530 base::UserMetricsAction("Accel_Toggle_Minimized_Minus")); |
| 530 return accelerators::ToggleMinimized(); | 531 return accelerators::ToggleMinimized(); |
| 531 } | 532 } |
| 532 | 533 |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 case LAUNCH_APP_4: | 1045 case LAUNCH_APP_4: |
| 1045 return HandleLaunchAppN(4); | 1046 return HandleLaunchAppN(4); |
| 1046 case LAUNCH_APP_5: | 1047 case LAUNCH_APP_5: |
| 1047 return HandleLaunchAppN(5); | 1048 return HandleLaunchAppN(5); |
| 1048 case LAUNCH_APP_6: | 1049 case LAUNCH_APP_6: |
| 1049 return HandleLaunchAppN(6); | 1050 return HandleLaunchAppN(6); |
| 1050 case LAUNCH_APP_7: | 1051 case LAUNCH_APP_7: |
| 1051 return HandleLaunchAppN(7); | 1052 return HandleLaunchAppN(7); |
| 1052 case LAUNCH_LAST_APP: | 1053 case LAUNCH_LAST_APP: |
| 1053 return HandleLaunchLastApp(); | 1054 return HandleLaunchLastApp(); |
| 1054 case WINDOW_SNAP_LEFT: | 1055 case WINDOW_CYCLE_SNAP_DOCK_LEFT: |
| 1055 case WINDOW_SNAP_RIGHT: | 1056 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: |
| 1056 return HandleWindowSnap(action); | 1057 return HandleWindowSnapOrDock(action); |
| 1057 case WINDOW_MINIMIZE: | 1058 case WINDOW_MINIMIZE: |
| 1058 return HandleWindowMinimize(); | 1059 return HandleWindowMinimize(); |
| 1059 case TOGGLE_FULLSCREEN: | 1060 case TOGGLE_FULLSCREEN: |
| 1060 return HandleToggleFullscreen(key_code); | 1061 return HandleToggleFullscreen(key_code); |
| 1061 case TOGGLE_MAXIMIZED: | 1062 case TOGGLE_MAXIMIZED: |
| 1062 accelerators::ToggleMaximized(); | 1063 accelerators::ToggleMaximized(); |
| 1063 return true; | 1064 return true; |
| 1064 case WINDOW_POSITION_CENTER: | 1065 case WINDOW_POSITION_CENTER: |
| 1065 return HandlePositionCenter(); | 1066 return HandlePositionCenter(); |
| 1066 case SCALE_UI_UP: | 1067 case SCALE_UI_UP: |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 keyboard_brightness_control_delegate) { | 1218 keyboard_brightness_control_delegate) { |
| 1218 keyboard_brightness_control_delegate_ = | 1219 keyboard_brightness_control_delegate_ = |
| 1219 keyboard_brightness_control_delegate.Pass(); | 1220 keyboard_brightness_control_delegate.Pass(); |
| 1220 } | 1221 } |
| 1221 | 1222 |
| 1222 bool AcceleratorController::CanHandleAccelerators() const { | 1223 bool AcceleratorController::CanHandleAccelerators() const { |
| 1223 return true; | 1224 return true; |
| 1224 } | 1225 } |
| 1225 | 1226 |
| 1226 } // namespace ash | 1227 } // namespace ash |
| OLD | NEW |