| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_delegate_aura.h" | 5 #include "ash/accelerators/accelerator_controller_delegate_aura.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "ash/accelerators/accelerator_commands_aura.h" | 12 #include "ash/accelerators/accelerator_commands_aura.h" |
| 13 #include "ash/common/accelerators/debug_commands.h" | 13 #include "ash/common/accelerators/debug_commands.h" |
| 14 #include "ash/common/accessibility_types.h" | 14 #include "ash/common/accessibility_types.h" |
| 15 #include "ash/common/shelf/wm_shelf.h" | 15 #include "ash/common/shelf/wm_shelf.h" |
| 16 #include "ash/common/system/system_notifier.h" | 16 #include "ash/common/system/system_notifier.h" |
| 17 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 17 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 18 #include "ash/common/wm/window_state.h" | 18 #include "ash/common/wm/window_state.h" |
| 19 #include "ash/common/wm/wm_event.h" | 19 #include "ash/common/wm/wm_event.h" |
| 20 #include "ash/common/wm_shell.h" | 20 #include "ash/common/wm_shell.h" |
| 21 #include "ash/debug.h" | 21 #include "ash/debug.h" |
| 22 #include "ash/display/display_configuration_controller.h" | 22 #include "ash/display/display_configuration_controller.h" |
| 23 #include "ash/display/window_tree_host_manager.h" | 23 #include "ash/display/window_tree_host_manager.h" |
| 24 #include "ash/host/ash_window_tree_host.h" | 24 #include "ash/host/ash_window_tree_host.h" |
| 25 #include "ash/magnifier/magnification_controller.h" | 25 #include "ash/magnifier/magnification_controller.h" |
| 26 #include "ash/public/cpp/shell_window_ids.h" | 26 #include "ash/public/cpp/shell_window_ids.h" |
| 27 #include "ash/root_window_controller.h" | 27 #include "ash/root_window_controller.h" |
| 28 #include "ash/rotator/window_rotation.h" | |
| 29 #include "ash/screenshot_delegate.h" | 28 #include "ash/screenshot_delegate.h" |
| 30 #include "ash/shell.h" | 29 #include "ash/shell.h" |
| 31 #include "ash/touch/touch_hud_debug.h" | 30 #include "ash/touch/touch_hud_debug.h" |
| 32 #include "ash/utility/screenshot_controller.h" | 31 #include "ash/utility/screenshot_controller.h" |
| 33 #include "ash/wm/power_button_controller.h" | 32 #include "ash/wm/power_button_controller.h" |
| 34 #include "ash/wm/window_state_aura.h" | 33 #include "ash/wm/window_state_aura.h" |
| 35 #include "ash/wm/window_util.h" | |
| 36 #include "base/memory/ptr_util.h" | 34 #include "base/memory/ptr_util.h" |
| 37 #include "base/metrics/histogram_macros.h" | 35 #include "base/metrics/histogram_macros.h" |
| 38 #include "base/metrics/user_metrics.h" | 36 #include "base/metrics/user_metrics.h" |
| 39 #include "base/sys_info.h" | 37 #include "base/sys_info.h" |
| 40 #include "third_party/skia/include/core/SkColor.h" | 38 #include "third_party/skia/include/core/SkColor.h" |
| 41 #include "ui/base/accelerators/accelerator.h" | 39 #include "ui/base/accelerators/accelerator.h" |
| 42 #include "ui/compositor/layer.h" | |
| 43 #include "ui/compositor/layer_animation_sequence.h" | |
| 44 #include "ui/compositor/layer_animator.h" | |
| 45 #include "ui/display/manager/display_manager.h" | 40 #include "ui/display/manager/display_manager.h" |
| 46 #include "ui/display/screen.h" | 41 #include "ui/display/screen.h" |
| 47 #include "ui/events/event.h" | 42 #include "ui/events/event.h" |
| 48 #include "ui/events/keycodes/keyboard_codes.h" | 43 #include "ui/events/keycodes/keyboard_codes.h" |
| 49 | 44 |
| 50 namespace ash { | 45 namespace ash { |
| 51 namespace { | 46 namespace { |
| 52 | 47 |
| 53 using base::UserMetricsAction; | 48 using base::UserMetricsAction; |
| 54 | 49 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 gfx::Point point = display::Screen::GetScreen()->GetCursorScreenPoint(); | 91 gfx::Point point = display::Screen::GetScreen()->GetCursorScreenPoint(); |
| 97 display::Display display = | 92 display::Display display = |
| 98 display::Screen::GetScreen()->GetDisplayNearestPoint(point); | 93 display::Screen::GetScreen()->GetDisplayNearestPoint(point); |
| 99 const display::ManagedDisplayInfo& display_info = | 94 const display::ManagedDisplayInfo& display_info = |
| 100 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); | 95 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); |
| 101 Shell::GetInstance()->display_configuration_controller()->SetDisplayRotation( | 96 Shell::GetInstance()->display_configuration_controller()->SetDisplayRotation( |
| 102 display.id(), GetNextRotation(display_info.GetActiveRotation()), | 97 display.id(), GetNextRotation(display_info.GetActiveRotation()), |
| 103 display::Display::ROTATION_SOURCE_USER); | 98 display::Display::ROTATION_SOURCE_USER); |
| 104 } | 99 } |
| 105 | 100 |
| 106 // Rotate the active window. | |
| 107 void HandleRotateActiveWindow() { | |
| 108 base::RecordAction(UserMetricsAction("Accel_Rotate_Active_Window")); | |
| 109 aura::Window* active_window = wm::GetActiveWindow(); | |
| 110 if (active_window) { | |
| 111 // The rotation animation bases its target transform on the current | |
| 112 // rotation and position. Since there could be an animation in progress | |
| 113 // right now, queue this animation so when it starts it picks up a neutral | |
| 114 // rotation and position. Use replace so we only enqueue one at a time. | |
| 115 active_window->layer()->GetAnimator()->set_preemption_strategy( | |
| 116 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | |
| 117 active_window->layer()->GetAnimator()->StartAnimation( | |
| 118 new ui::LayerAnimationSequence( | |
| 119 base::MakeUnique<WindowRotation>(360, active_window->layer()))); | |
| 120 } | |
| 121 } | |
| 122 | |
| 123 void HandleTakeWindowScreenshot(ScreenshotDelegate* screenshot_delegate) { | 101 void HandleTakeWindowScreenshot(ScreenshotDelegate* screenshot_delegate) { |
| 124 base::RecordAction(UserMetricsAction("Accel_Take_Window_Screenshot")); | 102 base::RecordAction(UserMetricsAction("Accel_Take_Window_Screenshot")); |
| 125 DCHECK(screenshot_delegate); | 103 DCHECK(screenshot_delegate); |
| 126 Shell::GetInstance()->screenshot_controller()->StartWindowScreenshotSession( | 104 Shell::GetInstance()->screenshot_controller()->StartWindowScreenshotSession( |
| 127 screenshot_delegate); | 105 screenshot_delegate); |
| 128 } | 106 } |
| 129 | 107 |
| 130 void HandleTakePartialScreenshot(ScreenshotDelegate* screenshot_delegate) { | 108 void HandleTakePartialScreenshot(ScreenshotDelegate* screenshot_delegate) { |
| 131 base::RecordAction(UserMetricsAction("Accel_Take_Partial_Screenshot")); | 109 base::RecordAction(UserMetricsAction("Accel_Take_Partial_Screenshot")); |
| 132 DCHECK(screenshot_delegate); | 110 DCHECK(screenshot_delegate); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 case DEV_ADD_REMOVE_DISPLAY: | 182 case DEV_ADD_REMOVE_DISPLAY: |
| 205 case DEV_TOGGLE_ROOT_WINDOW_FULL_SCREEN: | 183 case DEV_TOGGLE_ROOT_WINDOW_FULL_SCREEN: |
| 206 case DEV_TOGGLE_UNIFIED_DESKTOP: | 184 case DEV_TOGGLE_UNIFIED_DESKTOP: |
| 207 case LOCK_PRESSED: | 185 case LOCK_PRESSED: |
| 208 case LOCK_RELEASED: | 186 case LOCK_RELEASED: |
| 209 case MAGNIFY_SCREEN_ZOOM_IN: | 187 case MAGNIFY_SCREEN_ZOOM_IN: |
| 210 case MAGNIFY_SCREEN_ZOOM_OUT: | 188 case MAGNIFY_SCREEN_ZOOM_OUT: |
| 211 case POWER_PRESSED: | 189 case POWER_PRESSED: |
| 212 case POWER_RELEASED: | 190 case POWER_RELEASED: |
| 213 case ROTATE_SCREEN: | 191 case ROTATE_SCREEN: |
| 214 case ROTATE_WINDOW: | |
| 215 case SCALE_UI_DOWN: | 192 case SCALE_UI_DOWN: |
| 216 case SCALE_UI_RESET: | 193 case SCALE_UI_RESET: |
| 217 case SCALE_UI_UP: | 194 case SCALE_UI_UP: |
| 218 case SHOW_MESSAGE_CENTER_BUBBLE: | 195 case SHOW_MESSAGE_CENTER_BUBBLE: |
| 219 case SWAP_PRIMARY_DISPLAY: | 196 case SWAP_PRIMARY_DISPLAY: |
| 220 case TAKE_PARTIAL_SCREENSHOT: | 197 case TAKE_PARTIAL_SCREENSHOT: |
| 221 case TAKE_SCREENSHOT: | 198 case TAKE_SCREENSHOT: |
| 222 case TAKE_WINDOW_SCREENSHOT: | 199 case TAKE_WINDOW_SCREENSHOT: |
| 223 case TOGGLE_MIRROR_MODE: | 200 case TOGGLE_MIRROR_MODE: |
| 224 case TOUCH_HUD_CLEAR: | 201 case TOUCH_HUD_CLEAR: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 return accelerators::IsInternalDisplayZoomEnabled(); | 233 return accelerators::IsInternalDisplayZoomEnabled(); |
| 257 case UNPIN: | 234 case UNPIN: |
| 258 return CanHandleUnpin(); | 235 return CanHandleUnpin(); |
| 259 | 236 |
| 260 // Following are always enabled: | 237 // Following are always enabled: |
| 261 case LOCK_PRESSED: | 238 case LOCK_PRESSED: |
| 262 case LOCK_RELEASED: | 239 case LOCK_RELEASED: |
| 263 case POWER_PRESSED: | 240 case POWER_PRESSED: |
| 264 case POWER_RELEASED: | 241 case POWER_RELEASED: |
| 265 case ROTATE_SCREEN: | 242 case ROTATE_SCREEN: |
| 266 case ROTATE_WINDOW: | |
| 267 case TAKE_PARTIAL_SCREENSHOT: | 243 case TAKE_PARTIAL_SCREENSHOT: |
| 268 case TAKE_SCREENSHOT: | 244 case TAKE_SCREENSHOT: |
| 269 case TAKE_WINDOW_SCREENSHOT: | 245 case TAKE_WINDOW_SCREENSHOT: |
| 270 case TOGGLE_MIRROR_MODE: | 246 case TOGGLE_MIRROR_MODE: |
| 271 case TOUCH_HUD_PROJECTION_TOGGLE: | 247 case TOUCH_HUD_PROJECTION_TOGGLE: |
| 272 return true; | 248 return true; |
| 273 | 249 |
| 274 case SWAP_PRIMARY_DISPLAY: | 250 case SWAP_PRIMARY_DISPLAY: |
| 275 return display::Screen::GetScreen()->GetNumDisplays() > 1; | 251 return display::Screen::GetScreen()->GetNumDisplays() > 1; |
| 276 case TOUCH_HUD_CLEAR: | 252 case TOUCH_HUD_CLEAR: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 action == POWER_PRESSED, base::TimeTicks()); | 306 action == POWER_PRESSED, base::TimeTicks()); |
| 331 } | 307 } |
| 332 // We don't do anything with these at present on the device, | 308 // We don't do anything with these at present on the device, |
| 333 // (power button events are reported to us from powerm via | 309 // (power button events are reported to us from powerm via |
| 334 // D-BUS), but we consume them to prevent them from getting | 310 // D-BUS), but we consume them to prevent them from getting |
| 335 // passed to apps -- see http://crbug.com/146609. | 311 // passed to apps -- see http://crbug.com/146609. |
| 336 break; | 312 break; |
| 337 case ROTATE_SCREEN: | 313 case ROTATE_SCREEN: |
| 338 HandleRotateScreen(); | 314 HandleRotateScreen(); |
| 339 break; | 315 break; |
| 340 case ROTATE_WINDOW: | |
| 341 HandleRotateActiveWindow(); | |
| 342 break; | |
| 343 case SCALE_UI_DOWN: | 316 case SCALE_UI_DOWN: |
| 344 accelerators::ZoomInternalDisplay(false /* down */); | 317 accelerators::ZoomInternalDisplay(false /* down */); |
| 345 break; | 318 break; |
| 346 case SCALE_UI_RESET: | 319 case SCALE_UI_RESET: |
| 347 accelerators::ResetInternalDisplayZoom(); | 320 accelerators::ResetInternalDisplayZoom(); |
| 348 break; | 321 break; |
| 349 case SCALE_UI_UP: | 322 case SCALE_UI_UP: |
| 350 accelerators::ZoomInternalDisplay(true /* up */); | 323 accelerators::ZoomInternalDisplay(true /* up */); |
| 351 break; | 324 break; |
| 352 case SWAP_PRIMARY_DISPLAY: | 325 case SWAP_PRIMARY_DISPLAY: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 375 break; | 348 break; |
| 376 case UNPIN: | 349 case UNPIN: |
| 377 accelerators::Unpin(); | 350 accelerators::Unpin(); |
| 378 break; | 351 break; |
| 379 default: | 352 default: |
| 380 break; | 353 break; |
| 381 } | 354 } |
| 382 } | 355 } |
| 383 | 356 |
| 384 } // namespace ash | 357 } // namespace ash |
| OLD | NEW |