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

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

Issue 1263853002: Unified Desktop: Support 2xDSF display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « ash/accelerators/accelerator_commands.cc ('k') | ash/display/display_manager.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_commands.h" 11 #include "ash/accelerators/accelerator_commands.h"
12 #include "ash/accelerators/debug_commands.h" 12 #include "ash/accelerators/debug_commands.h"
13 #include "ash/ash_switches.h" 13 #include "ash/ash_switches.h"
14 #include "ash/debug.h" 14 #include "ash/debug.h"
15 #include "ash/display/display_manager.h"
16 #include "ash/display/display_util.h"
17 #include "ash/display/window_tree_host_manager.h" 15 #include "ash/display/window_tree_host_manager.h"
18 #include "ash/focus_cycler.h" 16 #include "ash/focus_cycler.h"
19 #include "ash/gpu_support.h" 17 #include "ash/gpu_support.h"
20 #include "ash/ime_control_delegate.h" 18 #include "ash/ime_control_delegate.h"
21 #include "ash/magnifier/magnification_controller.h" 19 #include "ash/magnifier/magnification_controller.h"
22 #include "ash/magnifier/partial_magnification_controller.h" 20 #include "ash/magnifier/partial_magnification_controller.h"
23 #include "ash/media_delegate.h" 21 #include "ash/media_delegate.h"
24 #include "ash/multi_profile_uma.h" 22 #include "ash/multi_profile_uma.h"
25 #include "ash/new_window_delegate.h" 23 #include "ash/new_window_delegate.h"
26 #include "ash/root_window_controller.h" 24 #include "ash/root_window_controller.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // right now, queue this animation so when it starts it picks up a neutral 279 // right now, queue this animation so when it starts it picks up a neutral
282 // rotation and position. Use replace so we only enqueue one at a time. 280 // rotation and position. Use replace so we only enqueue one at a time.
283 active_window->layer()->GetAnimator()-> 281 active_window->layer()->GetAnimator()->
284 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 282 set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
285 active_window->layer()->GetAnimator()->StartAnimation( 283 active_window->layer()->GetAnimator()->StartAnimation(
286 new ui::LayerAnimationSequence( 284 new ui::LayerAnimationSequence(
287 new ash::WindowRotation(360, active_window->layer()))); 285 new ash::WindowRotation(360, active_window->layer())));
288 } 286 }
289 } 287 }
290 288
291 void HandleScaleReset() {
292 base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Reset"));
293 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
294
295 if (display_manager->IsInUnifiedMode()) {
296 const DisplayInfo& display_info =
297 display_manager->GetDisplayInfo(DisplayManager::kUnifiedDisplayId);
298 const std::vector<DisplayMode>& modes = display_info.display_modes();
299 auto iter =
300 std::find_if(modes.begin(), modes.end(),
301 [](const DisplayMode& mode) { return mode.native; });
302 display_manager->SetDisplayMode(DisplayManager::kUnifiedDisplayId, *iter);
303 } else {
304 SetDisplayUIScale(display_manager->GetDisplayIdForUIScaling(), 1.0f);
305 }
306 }
307
308 bool CanHandleScaleUI() {
309 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
310 return display_manager->IsDisplayUIScalingEnabled() ||
311 display_manager->IsInUnifiedMode();
312 }
313
314 void HandleScaleUI(bool up) {
315 if (up)
316 base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Up"));
317 else
318 base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Down"));
319
320 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
321
322 int64 display_id = display_manager->IsInUnifiedMode()
323 ? DisplayManager::kUnifiedDisplayId
324 : display_manager->GetDisplayIdForUIScaling();
325 const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id);
326 DisplayMode mode;
327
328 if (display_manager->IsInUnifiedMode()) {
329 if (!GetDisplayModeForNextResolution(display_info, up, &mode))
330 return;
331 } else {
332 if (!GetDisplayModeForNextUIScale(display_info, up, &mode))
333 return;
334 }
335 display_manager->SetDisplayMode(display_id, mode);
336 }
337
338 void HandleShowKeyboardOverlay() { 289 void HandleShowKeyboardOverlay() {
339 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); 290 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay"));
340 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); 291 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay();
341 } 292 }
342 293
343 bool CanHandleShowMessageCenterBubble() { 294 bool CanHandleShowMessageCenterBubble() {
344 RootWindowController* controller = 295 RootWindowController* controller =
345 RootWindowController::ForTargetRootWindow(); 296 RootWindowController::ForTargetRootWindow();
346 StatusAreaWidget* status_area_widget = 297 StatusAreaWidget* status_area_widget =
347 controller->shelf()->status_area_widget(); 298 controller->shelf()->status_area_widget();
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 case NEW_INCOGNITO_WINDOW: 830 case NEW_INCOGNITO_WINDOW:
880 return CanHandleNewIncognitoWindow(); 831 return CanHandleNewIncognitoWindow();
881 case NEXT_IME: 832 case NEXT_IME:
882 return CanHandleNextIme(ime_control_delegate_.get(), 833 return CanHandleNextIme(ime_control_delegate_.get(),
883 previous_accelerator); 834 previous_accelerator);
884 case PREVIOUS_IME: 835 case PREVIOUS_IME:
885 return CanHandlePreviousIme(ime_control_delegate_.get()); 836 return CanHandlePreviousIme(ime_control_delegate_.get());
886 case SCALE_UI_RESET: 837 case SCALE_UI_RESET:
887 case SCALE_UI_UP: 838 case SCALE_UI_UP:
888 case SCALE_UI_DOWN: 839 case SCALE_UI_DOWN:
889 return CanHandleScaleUI(); 840 return accelerators::IsInternalDisplayZoomEnabled();
890 case SHOW_MESSAGE_CENTER_BUBBLE: 841 case SHOW_MESSAGE_CENTER_BUBBLE:
891 return CanHandleShowMessageCenterBubble(); 842 return CanHandleShowMessageCenterBubble();
892 case SWITCH_IME: 843 case SWITCH_IME:
893 return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator); 844 return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator);
894 case TOGGLE_APP_LIST: 845 case TOGGLE_APP_LIST:
895 return CanHandleToggleAppList(accelerator, previous_accelerator); 846 return CanHandleToggleAppList(accelerator, previous_accelerator);
896 case WINDOW_CYCLE_SNAP_DOCK_LEFT: 847 case WINDOW_CYCLE_SNAP_DOCK_LEFT:
897 case WINDOW_CYCLE_SNAP_DOCK_RIGHT: 848 case WINDOW_CYCLE_SNAP_DOCK_RIGHT:
898 return CanHandleWindowSnapOrDock(); 849 return CanHandleWindowSnapOrDock();
899 case WINDOW_POSITION_CENTER: 850 case WINDOW_POSITION_CENTER:
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 case RESTORE_TAB: 1039 case RESTORE_TAB:
1089 HandleRestoreTab(); 1040 HandleRestoreTab();
1090 break; 1041 break;
1091 case ROTATE_SCREEN: 1042 case ROTATE_SCREEN:
1092 HandleRotateScreen(); 1043 HandleRotateScreen();
1093 break; 1044 break;
1094 case ROTATE_WINDOW: 1045 case ROTATE_WINDOW:
1095 HandleRotateActiveWindow(); 1046 HandleRotateActiveWindow();
1096 break; 1047 break;
1097 case SCALE_UI_DOWN: 1048 case SCALE_UI_DOWN:
1098 HandleScaleUI(false /* down */); 1049 accelerators::ZoomInternalDisplay(false /* down */);
1099 break; 1050 break;
1100 case SCALE_UI_RESET: 1051 case SCALE_UI_RESET:
1101 HandleScaleReset(); 1052 accelerators::ResetInternalDisplayZoom();
1102 break; 1053 break;
1103 case SCALE_UI_UP: 1054 case SCALE_UI_UP:
1104 HandleScaleUI(true /* up */); 1055 accelerators::ZoomInternalDisplay(true /* up */);
1105 break; 1056 break;
1106 case SHOW_KEYBOARD_OVERLAY: 1057 case SHOW_KEYBOARD_OVERLAY:
1107 HandleShowKeyboardOverlay(); 1058 HandleShowKeyboardOverlay();
1108 break; 1059 break;
1109 case SHOW_MESSAGE_CENTER_BUBBLE: 1060 case SHOW_MESSAGE_CENTER_BUBBLE:
1110 HandleShowMessageCenterBubble(); 1061 HandleShowMessageCenterBubble();
1111 break; 1062 break;
1112 case SHOW_SYSTEM_TRAY_BUBBLE: 1063 case SHOW_SYSTEM_TRAY_BUBBLE:
1113 HandleShowSystemTrayBubble(); 1064 HandleShowSystemTrayBubble();
1114 break; 1065 break;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 } 1252 }
1302 1253
1303 void AcceleratorController::SetKeyboardBrightnessControlDelegate( 1254 void AcceleratorController::SetKeyboardBrightnessControlDelegate(
1304 scoped_ptr<KeyboardBrightnessControlDelegate> 1255 scoped_ptr<KeyboardBrightnessControlDelegate>
1305 keyboard_brightness_control_delegate) { 1256 keyboard_brightness_control_delegate) {
1306 keyboard_brightness_control_delegate_ = 1257 keyboard_brightness_control_delegate_ =
1307 keyboard_brightness_control_delegate.Pass(); 1258 keyboard_brightness_control_delegate.Pass();
1308 } 1259 }
1309 1260
1310 } // namespace ash 1261 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_commands.cc ('k') | ash/display/display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698