Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: ash/accelerators/accelerator_controller.cc

Issue 10905288: Switch primary display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/accelerators/accelerator_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "ash/accelerators/accelerator_table.h" 11 #include "ash/accelerators/accelerator_table.h"
12 #include "ash/ash_switches.h" 12 #include "ash/ash_switches.h"
13 #include "ash/caps_lock_delegate.h" 13 #include "ash/caps_lock_delegate.h"
14 #include "ash/desktop_background/desktop_background_controller.h" 14 #include "ash/desktop_background/desktop_background_controller.h"
15 #include "ash/display/display_controller.h" 15 #include "ash/display/display_controller.h"
16 #include "ash/display/multi_display_manager.h" 16 #include "ash/display/multi_display_manager.h"
17 #include "ash/focus_cycler.h" 17 #include "ash/focus_cycler.h"
18 #include "ash/ime_control_delegate.h" 18 #include "ash/ime_control_delegate.h"
19 #include "ash/launcher/launcher.h" 19 #include "ash/launcher/launcher.h"
20 #include "ash/launcher/launcher_delegate.h" 20 #include "ash/launcher/launcher_delegate.h"
21 #include "ash/launcher/launcher_model.h" 21 #include "ash/launcher/launcher_model.h"
22 #include "ash/magnifier/magnification_controller.h" 22 #include "ash/magnifier/magnification_controller.h"
23 #include "ash/root_window_controller.h" 23 #include "ash/root_window_controller.h"
24 #include "ash/rotator/screen_rotation.h" 24 #include "ash/rotator/screen_rotation.h"
25 #include "ash/screen_ash.h"
25 #include "ash/screenshot_delegate.h" 26 #include "ash/screenshot_delegate.h"
26 #include "ash/shell.h" 27 #include "ash/shell.h"
27 #include "ash/shell_delegate.h" 28 #include "ash/shell_delegate.h"
28 #include "ash/shell_window_ids.h" 29 #include "ash/shell_window_ids.h"
29 #include "ash/system/brightness/brightness_control_delegate.h" 30 #include "ash/system/brightness/brightness_control_delegate.h"
30 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h" 31 #include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h"
31 #include "ash/system/tray/system_tray.h" 32 #include "ash/system/tray/system_tray.h"
32 #include "ash/system/tray/system_tray_delegate.h" 33 #include "ash/system/tray/system_tray_delegate.h"
33 #include "ash/volume_control_delegate.h" 34 #include "ash/volume_control_delegate.h"
34 #include "ash/wm/partial_screenshot_view.h" 35 #include "ash/wm/partial_screenshot_view.h"
35 #include "ash/wm/property_util.h" 36 #include "ash/wm/property_util.h"
36 #include "ash/wm/window_cycle_controller.h" 37 #include "ash/wm/window_cycle_controller.h"
37 #include "ash/wm/window_util.h" 38 #include "ash/wm/window_util.h"
38 #include "ash/wm/workspace/snap_sizer.h" 39 #include "ash/wm/workspace/snap_sizer.h"
39 #include "base/bind.h" 40 #include "base/bind.h"
40 #include "base/command_line.h" 41 #include "base/command_line.h"
41 #include "ui/aura/env.h" 42 #include "ui/aura/env.h"
42 #include "ui/aura/root_window.h" 43 #include "ui/aura/root_window.h"
43 #include "ui/base/accelerators/accelerator.h" 44 #include "ui/base/accelerators/accelerator.h"
44 #include "ui/base/accelerators/accelerator_manager.h" 45 #include "ui/base/accelerators/accelerator_manager.h"
45 #include "ui/base/events/event.h" 46 #include "ui/base/events/event.h"
46 #include "ui/base/keycodes/keyboard_codes.h" 47 #include "ui/base/keycodes/keyboard_codes.h"
47 #include "ui/compositor/debug_utils.h" 48 #include "ui/compositor/debug_utils.h"
48 #include "ui/compositor/layer.h" 49 #include "ui/compositor/layer.h"
49 #include "ui/compositor/layer_animation_sequence.h" 50 #include "ui/compositor/layer_animation_sequence.h"
50 #include "ui/compositor/layer_animator.h" 51 #include "ui/compositor/layer_animator.h"
52 #include "ui/gfx/screen.h"
51 #include "ui/oak/oak.h" 53 #include "ui/oak/oak.h"
52 #include "ui/views/debug_utils.h" 54 #include "ui/views/debug_utils.h"
53 #include "ui/views/widget/widget.h" 55 #include "ui/views/widget/widget.h"
54 56
55 #if defined(OS_CHROMEOS) 57 #if defined(OS_CHROMEOS)
56 #include "ash/display/output_configurator_animation.h" 58 #include "ash/display/output_configurator_animation.h"
57 #include "base/chromeos/chromeos_version.h" 59 #include "base/chromeos/chromeos_version.h"
58 #include "chromeos/display/output_configurator.h" 60 #include "chromeos/display/output_configurator.h"
59 #endif // defined(OS_CHROMEOS) 61 #endif // defined(OS_CHROMEOS)
60 62
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 internal::MultiDisplayManager::CycleDisplay(); 115 internal::MultiDisplayManager::CycleDisplay();
114 } else if (shell->output_configurator()->connected_output_count() > 1) { 116 } else if (shell->output_configurator()->connected_output_count() > 1) {
115 internal::OutputConfiguratorAnimation* animation = 117 internal::OutputConfiguratorAnimation* animation =
116 shell->output_configurator_animation(); 118 shell->output_configurator_animation();
117 animation->StartFadeOutAnimation(base::Bind( 119 animation->StartFadeOutAnimation(base::Bind(
118 base::IgnoreResult(&chromeos::OutputConfigurator::CycleDisplayMode), 120 base::IgnoreResult(&chromeos::OutputConfigurator::CycleDisplayMode),
119 base::Unretained(shell->output_configurator()))); 121 base::Unretained(shell->output_configurator())));
120 } 122 }
121 } 123 }
122 124
125 void HandleSwapPrimaryDisplay() {
126 if (gfx::Screen::GetNumDisplays() > 1) {
127 Shell::GetInstance()->display_controller()->SetPrimaryDisplay(
128 ScreenAsh::GetSecondaryDisplay());
129 }
130 }
131
123 #endif // defined(OS_CHROMEOS) 132 #endif // defined(OS_CHROMEOS)
124 133
125 bool HandleExit() { 134 bool HandleExit() {
126 ShellDelegate* delegate = Shell::GetInstance()->delegate(); 135 ShellDelegate* delegate = Shell::GetInstance()->delegate();
127 if (!delegate) 136 if (!delegate)
128 return false; 137 return false;
129 delegate->Exit(); 138 delegate->Exit();
130 return true; 139 return true;
131 } 140 }
132 141
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 if (key_code == ui::VKEY_F5 && shell->delegate()) 443 if (key_code == ui::VKEY_F5 && shell->delegate())
435 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_PREVWINDOW_F5); 444 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_PREVWINDOW_F5);
436 HandleCycleWindowLinear(CYCLE_BACKWARD); 445 HandleCycleWindowLinear(CYCLE_BACKWARD);
437 return true; 446 return true;
438 case CYCLE_FORWARD_LINEAR: 447 case CYCLE_FORWARD_LINEAR:
439 if (key_code == ui::VKEY_F5 && shell->delegate()) 448 if (key_code == ui::VKEY_F5 && shell->delegate())
440 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEXTWINDOW_F5); 449 shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEXTWINDOW_F5);
441 HandleCycleWindowLinear(CYCLE_FORWARD); 450 HandleCycleWindowLinear(CYCLE_FORWARD);
442 return true; 451 return true;
443 #if defined(OS_CHROMEOS) 452 #if defined(OS_CHROMEOS)
453 case CYCLE_DISPLAY_MODE:
454 HandleCycleDisplayMode();
455 return true;
444 case LOCK_SCREEN: 456 case LOCK_SCREEN:
445 return HandleLock(); 457 return HandleLock();
446 case OPEN_FILE_MANAGER_DIALOG: 458 case OPEN_FILE_MANAGER_DIALOG:
447 return HandleFileManager(true /* as_dialog */); 459 return HandleFileManager(true /* as_dialog */);
448 case OPEN_FILE_MANAGER_TAB: 460 case OPEN_FILE_MANAGER_TAB:
449 return HandleFileManager(false /* as_dialog */); 461 return HandleFileManager(false /* as_dialog */);
450 case OPEN_CROSH: 462 case OPEN_CROSH:
451 return HandleCrosh(); 463 return HandleCrosh();
464 case SWAP_PRIMARY_DISPLAY:
465 HandleSwapPrimaryDisplay();
466 return true;
452 case TOGGLE_SPOKEN_FEEDBACK: 467 case TOGGLE_SPOKEN_FEEDBACK:
453 return HandleToggleSpokenFeedback(); 468 return HandleToggleSpokenFeedback();
454 case TOGGLE_WIFI: 469 case TOGGLE_WIFI:
455 if (Shell::GetInstance()->tray_delegate()) 470 if (Shell::GetInstance()->tray_delegate())
456 Shell::GetInstance()->tray_delegate()->ToggleWifi(); 471 Shell::GetInstance()->tray_delegate()->ToggleWifi();
457 return true; 472 return true;
458 case CYCLE_DISPLAY_MODE:
459 HandleCycleDisplayMode();
460 return true;
461 #endif 473 #endif
462 case OPEN_FEEDBACK_PAGE: 474 case OPEN_FEEDBACK_PAGE:
463 ash::Shell::GetInstance()->delegate()->OpenFeedbackPage(); 475 ash::Shell::GetInstance()->delegate()->OpenFeedbackPage();
464 return true; 476 return true;
465 case EXIT: 477 case EXIT:
466 return HandleExit(); 478 return HandleExit();
467 case NEW_INCOGNITO_WINDOW: 479 case NEW_INCOGNITO_WINDOW:
468 return HandleNewWindow(true /* is_incognito */); 480 return HandleNewWindow(true /* is_incognito */);
469 case NEW_TAB: 481 case NEW_TAB:
470 if (key_code == ui::VKEY_T && shell->delegate()) 482 if (key_code == ui::VKEY_T && shell->delegate())
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 accelerators_.insert( 810 accelerators_.insert(
799 std::make_pair(accelerator, accelerators[i].action)); 811 std::make_pair(accelerator, accelerators[i].action));
800 } 812 }
801 } 813 }
802 814
803 bool AcceleratorController::CanHandleAccelerators() const { 815 bool AcceleratorController::CanHandleAccelerators() const {
804 return true; 816 return true;
805 } 817 }
806 818
807 } // namespace ash 819 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/accelerators/accelerator_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698