Chromium Code Reviews| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP2) | 281 if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP2) |
| 282 base::RecordAction(UserMetricsAction("Accel_Fullscreen_F4")); | 282 base::RecordAction(UserMetricsAction("Accel_Fullscreen_F4")); |
| 283 accelerators::ToggleFullscreen(); | 283 accelerators::ToggleFullscreen(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void HandleToggleOverview() { | 286 void HandleToggleOverview() { |
| 287 base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); | 287 base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); |
| 288 WmShell::Get()->window_selector_controller()->ToggleOverview(); | 288 WmShell::Get()->window_selector_controller()->ToggleOverview(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 bool CanHandleWindowSnapOrDock() { | 291 bool CanHandleWindowSnap() { |
| 292 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); | 292 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); |
| 293 if (!active_window) | 293 if (!active_window) |
| 294 return false; | 294 return false; |
| 295 wm::WindowState* window_state = active_window->GetWindowState(); | 295 wm::WindowState* window_state = active_window->GetWindowState(); |
| 296 // Disable window snapping shortcut key for full screen window due to | 296 // Disable window snapping shortcut key for full screen window due to |
| 297 // http://crbug.com/135487. | 297 // http://crbug.com/135487. |
| 298 return (window_state && window_state->IsUserPositionable() && | 298 return (window_state && window_state->IsUserPositionable() && |
| 299 !window_state->IsFullscreen()); | 299 !window_state->IsFullscreen()); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void HandleWindowSnapOrDock(AcceleratorAction action) { | 302 void HandleWindowSnap(AcceleratorAction action) { |
| 303 if (action == WINDOW_CYCLE_SNAP_DOCK_LEFT) | 303 if (action == WINDOW_CYCLE_SNAP_LEFT) |
| 304 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left")); | 304 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left")); |
| 305 else | 305 else |
| 306 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right")); | 306 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right")); |
| 307 | 307 |
| 308 const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_DOCK_LEFT | 308 const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_LEFT |
| 309 ? wm::WM_EVENT_CYCLE_SNAP_DOCK_LEFT | 309 ? wm::WM_EVENT_CYCLE_SNAP_LEFT |
| 310 : wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT); | 310 : wm::WM_EVENT_CYCLE_SNAP_RIGHT); |
| 311 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); | 311 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); |
| 312 DCHECK(active_window); | 312 DCHECK(active_window); |
| 313 active_window->GetWindowState()->OnWMEvent(&event); | 313 active_window->GetWindowState()->OnWMEvent(&event); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void HandleWindowMinimize() { | 316 void HandleWindowMinimize() { |
| 317 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Minimized_Minus")); | 317 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Minimized_Minus")); |
| 318 accelerators::ToggleMinimized(); | 318 accelerators::ToggleMinimized(); |
| 319 } | 319 } |
| 320 | 320 |
| 321 bool CanHandlePositionCenter() { | 321 bool CanHandlePositionCenter() { |
| 322 // Docked windows do not support centering. | 322 return !!WmShell::Get()->GetActiveWindow(); |
|
varkha
2017/03/15 19:51:16
nit: I don't remember when but I had a comment onc
afakhry
2017/03/15 20:27:26
Done.
| |
| 323 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); | |
| 324 return (active_window && !active_window->GetWindowState()->IsDocked()); | |
| 325 } | 323 } |
| 326 | 324 |
| 327 void HandlePositionCenter() { | 325 void HandlePositionCenter() { |
| 328 base::RecordAction(UserMetricsAction("Accel_Window_Position_Center")); | 326 base::RecordAction(UserMetricsAction("Accel_Window_Position_Center")); |
| 329 wm::CenterWindow(WmShell::Get()->GetActiveWindow()); | 327 wm::CenterWindow(WmShell::Get()->GetActiveWindow()); |
| 330 } | 328 } |
| 331 | 329 |
| 332 void HandleShowImeMenuBubble() { | 330 void HandleShowImeMenuBubble() { |
| 333 base::RecordAction(UserMetricsAction("Accel_Show_Ime_Menu_Bubble")); | 331 base::RecordAction(UserMetricsAction("Accel_Show_Ime_Menu_Bubble")); |
| 334 | 332 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 795 return CanHandleShowStylusTools(); | 793 return CanHandleShowStylusTools(); |
| 796 case SWITCH_IME: | 794 case SWITCH_IME: |
| 797 return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator); | 795 return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator); |
| 798 case SWITCH_TO_PREVIOUS_USER: | 796 case SWITCH_TO_PREVIOUS_USER: |
| 799 case SWITCH_TO_NEXT_USER: | 797 case SWITCH_TO_NEXT_USER: |
| 800 return CanHandleCycleUser(); | 798 return CanHandleCycleUser(); |
| 801 case TOGGLE_APP_LIST: | 799 case TOGGLE_APP_LIST: |
| 802 return CanHandleToggleAppList(accelerator, previous_accelerator); | 800 return CanHandleToggleAppList(accelerator, previous_accelerator); |
| 803 case TOGGLE_CAPS_LOCK: | 801 case TOGGLE_CAPS_LOCK: |
| 804 return CanHandleToggleCapsLock(accelerator, previous_accelerator); | 802 return CanHandleToggleCapsLock(accelerator, previous_accelerator); |
| 805 case WINDOW_CYCLE_SNAP_DOCK_LEFT: | 803 case WINDOW_CYCLE_SNAP_LEFT: |
| 806 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: | 804 case WINDOW_CYCLE_SNAP_RIGHT: |
| 807 return CanHandleWindowSnapOrDock(); | 805 return CanHandleWindowSnap(); |
| 808 case WINDOW_POSITION_CENTER: | 806 case WINDOW_POSITION_CENTER: |
| 809 return CanHandlePositionCenter(); | 807 return CanHandlePositionCenter(); |
| 810 | 808 |
| 811 // The following are always enabled. | 809 // The following are always enabled. |
| 812 case BRIGHTNESS_DOWN: | 810 case BRIGHTNESS_DOWN: |
| 813 case BRIGHTNESS_UP: | 811 case BRIGHTNESS_UP: |
| 814 case EXIT: | 812 case EXIT: |
| 815 case FOCUS_NEXT_PANE: | 813 case FOCUS_NEXT_PANE: |
| 816 case FOCUS_PREVIOUS_PANE: | 814 case FOCUS_PREVIOUS_PANE: |
| 817 case FOCUS_SHELF: | 815 case FOCUS_SHELF: |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1059 break; | 1057 break; |
| 1060 case VOLUME_DOWN: | 1058 case VOLUME_DOWN: |
| 1061 HandleVolumeDown(volume_controller_.get(), accelerator); | 1059 HandleVolumeDown(volume_controller_.get(), accelerator); |
| 1062 break; | 1060 break; |
| 1063 case VOLUME_MUTE: | 1061 case VOLUME_MUTE: |
| 1064 HandleVolumeMute(volume_controller_.get(), accelerator); | 1062 HandleVolumeMute(volume_controller_.get(), accelerator); |
| 1065 break; | 1063 break; |
| 1066 case VOLUME_UP: | 1064 case VOLUME_UP: |
| 1067 HandleVolumeUp(volume_controller_.get(), accelerator); | 1065 HandleVolumeUp(volume_controller_.get(), accelerator); |
| 1068 break; | 1066 break; |
| 1069 case WINDOW_CYCLE_SNAP_DOCK_LEFT: | 1067 case WINDOW_CYCLE_SNAP_LEFT: |
| 1070 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: | 1068 case WINDOW_CYCLE_SNAP_RIGHT: |
| 1071 HandleWindowSnapOrDock(action); | 1069 HandleWindowSnap(action); |
| 1072 break; | 1070 break; |
| 1073 case WINDOW_MINIMIZE: | 1071 case WINDOW_MINIMIZE: |
| 1074 HandleWindowMinimize(); | 1072 HandleWindowMinimize(); |
| 1075 break; | 1073 break; |
| 1076 case WINDOW_POSITION_CENTER: | 1074 case WINDOW_POSITION_CENTER: |
| 1077 HandlePositionCenter(); | 1075 HandlePositionCenter(); |
| 1078 break; | 1076 break; |
| 1079 default: | 1077 default: |
| 1080 // Temporary until mash transition complete. Needed as some actions | 1078 // Temporary until mash transition complete. Needed as some actions |
| 1081 // don't yet work with mash. | 1079 // don't yet work with mash. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1167 data->old_shortcut_id, data->new_shortcut_id); | 1165 data->old_shortcut_id, data->new_shortcut_id); |
| 1168 } | 1166 } |
| 1169 | 1167 |
| 1170 if (!data->deprecated_enabled) | 1168 if (!data->deprecated_enabled) |
| 1171 return AcceleratorProcessingStatus::STOP; | 1169 return AcceleratorProcessingStatus::STOP; |
| 1172 | 1170 |
| 1173 return AcceleratorProcessingStatus::PROCEED; | 1171 return AcceleratorProcessingStatus::PROCEED; |
| 1174 } | 1172 } |
| 1175 | 1173 |
| 1176 } // namespace ash | 1174 } // namespace ash |
| OLD | NEW |