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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP2) | 397 if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP2) |
398 base::RecordAction(UserMetricsAction("Accel_Fullscreen_F4")); | 398 base::RecordAction(UserMetricsAction("Accel_Fullscreen_F4")); |
399 accelerators::ToggleFullscreen(); | 399 accelerators::ToggleFullscreen(); |
400 } | 400 } |
401 | 401 |
402 void HandleToggleOverview() { | 402 void HandleToggleOverview() { |
403 base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); | 403 base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); |
404 WmShell::Get()->window_selector_controller()->ToggleOverview(); | 404 WmShell::Get()->window_selector_controller()->ToggleOverview(); |
405 } | 405 } |
406 | 406 |
407 bool CanHandleWindowSnapOrDock() { | 407 bool CanHandleWindowSnap() { |
408 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); | 408 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); |
409 if (!active_window) | 409 if (!active_window) |
410 return false; | 410 return false; |
411 wm::WindowState* window_state = active_window->GetWindowState(); | 411 wm::WindowState* window_state = active_window->GetWindowState(); |
412 // Disable window snapping shortcut key for full screen window due to | 412 // Disable window snapping shortcut key for full screen window due to |
413 // http://crbug.com/135487. | 413 // http://crbug.com/135487. |
414 return (window_state && window_state->IsUserPositionable() && | 414 return (window_state && window_state->IsUserPositionable() && |
415 !window_state->IsFullscreen()); | 415 !window_state->IsFullscreen()); |
416 } | 416 } |
417 | 417 |
418 void HandleWindowSnapOrDock(AcceleratorAction action) { | 418 void HandleWindowSnap(AcceleratorAction action) { |
419 if (action == WINDOW_CYCLE_SNAP_DOCK_LEFT) | 419 if (action == WINDOW_CYCLE_SNAP_LEFT) |
420 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left")); | 420 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left")); |
421 else | 421 else |
422 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right")); | 422 base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right")); |
423 | 423 |
424 const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_DOCK_LEFT | 424 const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_LEFT |
425 ? wm::WM_EVENT_CYCLE_SNAP_DOCK_LEFT | 425 ? wm::WM_EVENT_CYCLE_SNAP_LEFT |
426 : wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT); | 426 : wm::WM_EVENT_CYCLE_SNAP_RIGHT); |
427 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); | 427 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); |
428 DCHECK(active_window); | 428 DCHECK(active_window); |
429 active_window->GetWindowState()->OnWMEvent(&event); | 429 active_window->GetWindowState()->OnWMEvent(&event); |
430 } | 430 } |
431 | 431 |
432 void HandleWindowMinimize() { | 432 void HandleWindowMinimize() { |
433 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Minimized_Minus")); | 433 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Minimized_Minus")); |
434 accelerators::ToggleMinimized(); | 434 accelerators::ToggleMinimized(); |
435 } | 435 } |
436 | 436 |
437 bool CanHandlePositionCenter() { | 437 bool CanHandlePositionCenter() { |
438 // Docked windows do not support centering. | 438 return WmShell::Get()->GetActiveWindow() != nullptr; |
439 WmWindow* active_window = WmShell::Get()->GetActiveWindow(); | |
440 return (active_window && !active_window->GetWindowState()->IsDocked()); | |
441 } | 439 } |
442 | 440 |
443 void HandlePositionCenter() { | 441 void HandlePositionCenter() { |
444 base::RecordAction(UserMetricsAction("Accel_Window_Position_Center")); | 442 base::RecordAction(UserMetricsAction("Accel_Window_Position_Center")); |
445 wm::CenterWindow(WmShell::Get()->GetActiveWindow()); | 443 wm::CenterWindow(WmShell::Get()->GetActiveWindow()); |
446 } | 444 } |
447 | 445 |
448 void HandleShowImeMenuBubble() { | 446 void HandleShowImeMenuBubble() { |
449 base::RecordAction(UserMetricsAction("Accel_Show_Ime_Menu_Bubble")); | 447 base::RecordAction(UserMetricsAction("Accel_Show_Ime_Menu_Bubble")); |
450 | 448 |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 return CanHandleShowStylusTools(); | 913 return CanHandleShowStylusTools(); |
916 case SWITCH_IME: | 914 case SWITCH_IME: |
917 return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator); | 915 return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator); |
918 case SWITCH_TO_PREVIOUS_USER: | 916 case SWITCH_TO_PREVIOUS_USER: |
919 case SWITCH_TO_NEXT_USER: | 917 case SWITCH_TO_NEXT_USER: |
920 return CanHandleCycleUser(); | 918 return CanHandleCycleUser(); |
921 case TOGGLE_APP_LIST: | 919 case TOGGLE_APP_LIST: |
922 return CanHandleToggleAppList(accelerator, previous_accelerator); | 920 return CanHandleToggleAppList(accelerator, previous_accelerator); |
923 case TOGGLE_CAPS_LOCK: | 921 case TOGGLE_CAPS_LOCK: |
924 return CanHandleToggleCapsLock(accelerator, previous_accelerator); | 922 return CanHandleToggleCapsLock(accelerator, previous_accelerator); |
925 case WINDOW_CYCLE_SNAP_DOCK_LEFT: | 923 case WINDOW_CYCLE_SNAP_LEFT: |
926 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: | 924 case WINDOW_CYCLE_SNAP_RIGHT: |
927 return CanHandleWindowSnapOrDock(); | 925 return CanHandleWindowSnap(); |
928 case WINDOW_POSITION_CENTER: | 926 case WINDOW_POSITION_CENTER: |
929 return CanHandlePositionCenter(); | 927 return CanHandlePositionCenter(); |
930 | 928 |
931 // The following are always enabled. | 929 // The following are always enabled. |
932 case BRIGHTNESS_DOWN: | 930 case BRIGHTNESS_DOWN: |
933 case BRIGHTNESS_UP: | 931 case BRIGHTNESS_UP: |
934 case EXIT: | 932 case EXIT: |
935 case FOCUS_NEXT_PANE: | 933 case FOCUS_NEXT_PANE: |
936 case FOCUS_PREVIOUS_PANE: | 934 case FOCUS_PREVIOUS_PANE: |
937 case FOCUS_SHELF: | 935 case FOCUS_SHELF: |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 break; | 1185 break; |
1188 case VOLUME_DOWN: | 1186 case VOLUME_DOWN: |
1189 HandleVolumeDown(volume_controller_.get(), accelerator); | 1187 HandleVolumeDown(volume_controller_.get(), accelerator); |
1190 break; | 1188 break; |
1191 case VOLUME_MUTE: | 1189 case VOLUME_MUTE: |
1192 HandleVolumeMute(volume_controller_.get(), accelerator); | 1190 HandleVolumeMute(volume_controller_.get(), accelerator); |
1193 break; | 1191 break; |
1194 case VOLUME_UP: | 1192 case VOLUME_UP: |
1195 HandleVolumeUp(volume_controller_.get(), accelerator); | 1193 HandleVolumeUp(volume_controller_.get(), accelerator); |
1196 break; | 1194 break; |
1197 case WINDOW_CYCLE_SNAP_DOCK_LEFT: | 1195 case WINDOW_CYCLE_SNAP_LEFT: |
1198 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: | 1196 case WINDOW_CYCLE_SNAP_RIGHT: |
1199 HandleWindowSnapOrDock(action); | 1197 HandleWindowSnap(action); |
1200 break; | 1198 break; |
1201 case WINDOW_MINIMIZE: | 1199 case WINDOW_MINIMIZE: |
1202 HandleWindowMinimize(); | 1200 HandleWindowMinimize(); |
1203 break; | 1201 break; |
1204 case WINDOW_POSITION_CENTER: | 1202 case WINDOW_POSITION_CENTER: |
1205 HandlePositionCenter(); | 1203 HandlePositionCenter(); |
1206 break; | 1204 break; |
1207 default: | 1205 default: |
1208 // Temporary until mash transition complete. Needed as some actions | 1206 // Temporary until mash transition complete. Needed as some actions |
1209 // don't yet work with mash. | 1207 // don't yet work with mash. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 data->uma_histogram_name, data->notification_message_id, | 1290 data->uma_histogram_name, data->notification_message_id, |
1293 data->old_shortcut_id, data->new_shortcut_id); | 1291 data->old_shortcut_id, data->new_shortcut_id); |
1294 | 1292 |
1295 if (!data->deprecated_enabled) | 1293 if (!data->deprecated_enabled) |
1296 return AcceleratorProcessingStatus::STOP; | 1294 return AcceleratorProcessingStatus::STOP; |
1297 | 1295 |
1298 return AcceleratorProcessingStatus::PROCEED; | 1296 return AcceleratorProcessingStatus::PROCEED; |
1299 } | 1297 } |
1300 | 1298 |
1301 } // namespace ash | 1299 } // namespace ash |
OLD | NEW |