| 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/common/accelerators/accelerator_controller.h" | 5 #include "ash/common/accelerators/accelerator_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/accelerators/accelerator_commands.h" | 9 #include "ash/common/accelerators/accelerator_commands.h" |
| 10 #include "ash/common/accelerators/accelerator_controller_delegate.h" | 10 #include "ash/common/accelerators/accelerator_controller_delegate.h" |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 if (!active_window) | 290 if (!active_window) |
| 291 return false; | 291 return false; |
| 292 wm::WindowState* window_state = active_window->GetWindowState(); | 292 wm::WindowState* window_state = active_window->GetWindowState(); |
| 293 // Disable window snapping shortcut key for full screen window due to | 293 // Disable window snapping shortcut key for full screen window due to |
| 294 // http://crbug.com/135487. | 294 // http://crbug.com/135487. |
| 295 return (window_state && window_state->IsUserPositionable() && | 295 return (window_state && window_state->IsUserPositionable() && |
| 296 !window_state->IsFullscreen()); | 296 !window_state->IsFullscreen()); |
| 297 } | 297 } |
| 298 | 298 |
| 299 void HandleWindowSnapOrDock(AcceleratorAction action) { | 299 void HandleWindowSnapOrDock(AcceleratorAction action) { |
| 300 if (action == WINDOW_CYCLE_SNAP_DOCK_LEFT) | 300 if (action == WINDOW_CYCLE_SNAP_LEFT) |
| 301 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left")); | 301 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left")); |
| 302 else | 302 else |
| 303 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right")); | 303 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right")); |
| 304 | 304 |
| 305 const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_DOCK_LEFT | 305 const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_LEFT |
| 306 ? wm::WM_EVENT_CYCLE_SNAP_DOCK_LEFT | 306 ? wm::WM_EVENT_CYCLE_SNAP_LEFT |
| 307 : wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT); | 307 : wm::WM_EVENT_CYCLE_SNAP_RIGHT); |
| 308 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); | 308 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); |
| 309 DCHECK(active_window); | 309 DCHECK(active_window); |
| 310 active_window->GetWindowState()->OnWMEvent(&event); | 310 active_window->GetWindowState()->OnWMEvent(&event); |
| 311 } | 311 } |
| 312 | 312 |
| 313 void HandleWindowMinimize() { | 313 void HandleWindowMinimize() { |
| 314 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Minimized_Minus")); | 314 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Minimized_Minus")); |
| 315 accelerators::ToggleMinimized(); | 315 accelerators::ToggleMinimized(); |
| 316 } | 316 } |
| 317 | 317 |
| 318 bool CanHandlePositionCenter() { | 318 bool CanHandlePositionCenter() { |
| 319 // Docked windows do not support centering. | 319 return !!WmShell::Get()->GetActiveWindow(); |
| 320 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); | |
| 321 return (active_window && !active_window->GetWindowState()->IsDocked()); | |
| 322 } | 320 } |
| 323 | 321 |
| 324 void HandlePositionCenter() { | 322 void HandlePositionCenter() { |
| 325 base::RecordAction(UserMetricsAction("Accel_Window_Position_Center")); | 323 base::RecordAction(UserMetricsAction("Accel_Window_Position_Center")); |
| 326 wm::CenterWindow(WmShell::Get()->GetActiveWindow()); | 324 wm::CenterWindow(WmShell::Get()->GetActiveWindow()); |
| 327 } | 325 } |
| 328 | 326 |
| 329 void HandleShowImeMenuBubble() { | 327 void HandleShowImeMenuBubble() { |
| 330 base::RecordAction(UserMetricsAction("Accel_Show_Ime_Menu_Bubble")); | 328 base::RecordAction(UserMetricsAction("Accel_Show_Ime_Menu_Bubble")); |
| 331 | 329 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 return CanHandleShowStylusTools(); | 790 return CanHandleShowStylusTools(); |
| 793 case SWITCH_IME: | 791 case SWITCH_IME: |
| 794 return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator); | 792 return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator); |
| 795 case SWITCH_TO_PREVIOUS_USER: | 793 case SWITCH_TO_PREVIOUS_USER: |
| 796 case SWITCH_TO_NEXT_USER: | 794 case SWITCH_TO_NEXT_USER: |
| 797 return CanHandleCycleUser(); | 795 return CanHandleCycleUser(); |
| 798 case TOGGLE_APP_LIST: | 796 case TOGGLE_APP_LIST: |
| 799 return CanHandleToggleAppList(accelerator, previous_accelerator); | 797 return CanHandleToggleAppList(accelerator, previous_accelerator); |
| 800 case TOGGLE_CAPS_LOCK: | 798 case TOGGLE_CAPS_LOCK: |
| 801 return CanHandleToggleCapsLock(accelerator, previous_accelerator); | 799 return CanHandleToggleCapsLock(accelerator, previous_accelerator); |
| 802 case WINDOW_CYCLE_SNAP_DOCK_LEFT: | 800 case WINDOW_CYCLE_SNAP_LEFT: |
| 803 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: | 801 case WINDOW_CYCLE_SNAP_RIGHT: |
| 804 return CanHandleWindowSnapOrDock(); | 802 return CanHandleWindowSnapOrDock(); |
| 805 case WINDOW_POSITION_CENTER: | 803 case WINDOW_POSITION_CENTER: |
| 806 return CanHandlePositionCenter(); | 804 return CanHandlePositionCenter(); |
| 807 | 805 |
| 808 // The following are always enabled. | 806 // The following are always enabled. |
| 809 case BRIGHTNESS_DOWN: | 807 case BRIGHTNESS_DOWN: |
| 810 case BRIGHTNESS_UP: | 808 case BRIGHTNESS_UP: |
| 811 case EXIT: | 809 case EXIT: |
| 812 case FOCUS_NEXT_PANE: | 810 case FOCUS_NEXT_PANE: |
| 813 case FOCUS_PREVIOUS_PANE: | 811 case FOCUS_PREVIOUS_PANE: |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 break; | 1054 break; |
| 1057 case VOLUME_DOWN: | 1055 case VOLUME_DOWN: |
| 1058 HandleVolumeDown(volume_controller_.get(), accelerator); | 1056 HandleVolumeDown(volume_controller_.get(), accelerator); |
| 1059 break; | 1057 break; |
| 1060 case VOLUME_MUTE: | 1058 case VOLUME_MUTE: |
| 1061 HandleVolumeMute(volume_controller_.get(), accelerator); | 1059 HandleVolumeMute(volume_controller_.get(), accelerator); |
| 1062 break; | 1060 break; |
| 1063 case VOLUME_UP: | 1061 case VOLUME_UP: |
| 1064 HandleVolumeUp(volume_controller_.get(), accelerator); | 1062 HandleVolumeUp(volume_controller_.get(), accelerator); |
| 1065 break; | 1063 break; |
| 1066 case WINDOW_CYCLE_SNAP_DOCK_LEFT: | 1064 case WINDOW_CYCLE_SNAP_LEFT: |
| 1067 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: | 1065 case WINDOW_CYCLE_SNAP_RIGHT: |
| 1068 HandleWindowSnapOrDock(action); | 1066 HandleWindowSnapOrDock(action); |
| 1069 break; | 1067 break; |
| 1070 case WINDOW_MINIMIZE: | 1068 case WINDOW_MINIMIZE: |
| 1071 HandleWindowMinimize(); | 1069 HandleWindowMinimize(); |
| 1072 break; | 1070 break; |
| 1073 case WINDOW_POSITION_CENTER: | 1071 case WINDOW_POSITION_CENTER: |
| 1074 HandlePositionCenter(); | 1072 HandlePositionCenter(); |
| 1075 break; | 1073 break; |
| 1076 default: | 1074 default: |
| 1077 // Temporary until mash transition complete. Needed as some actions | 1075 // Temporary until mash transition complete. Needed as some actions |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 data->old_shortcut_id, data->new_shortcut_id); | 1162 data->old_shortcut_id, data->new_shortcut_id); |
| 1165 } | 1163 } |
| 1166 | 1164 |
| 1167 if (!data->deprecated_enabled) | 1165 if (!data->deprecated_enabled) |
| 1168 return AcceleratorProcessingStatus::STOP; | 1166 return AcceleratorProcessingStatus::STOP; |
| 1169 | 1167 |
| 1170 return AcceleratorProcessingStatus::PROCEED; | 1168 return AcceleratorProcessingStatus::PROCEED; |
| 1171 } | 1169 } |
| 1172 | 1170 |
| 1173 } // namespace ash | 1171 } // namespace ash |
| OLD | NEW |