| 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/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 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 float scale = | 173 float scale = |
| 174 ash::Shell::GetInstance()->magnification_controller()->GetScale(); | 174 ash::Shell::GetInstance()->magnification_controller()->GetScale(); |
| 175 // Calculate rounded logarithm (base kMagnificationScaleFactor) of scale. | 175 // Calculate rounded logarithm (base kMagnificationScaleFactor) of scale. |
| 176 int scale_index = | 176 int scale_index = |
| 177 std::floor(std::log(scale) / std::log(kMagnificationScaleFactor) + 0.5); | 177 std::floor(std::log(scale) / std::log(kMagnificationScaleFactor) + 0.5); |
| 178 | 178 |
| 179 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); | 179 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); |
| 180 | 180 |
| 181 ash::Shell::GetInstance()->magnification_controller()-> | 181 ash::Shell::GetInstance()->magnification_controller()-> |
| 182 SetScale(std::pow(kMagnificationScaleFactor, new_scale_index), true); | 182 SetScale(std::pow(kMagnificationScaleFactor, new_scale_index), true); |
| 183 return true; |
| 183 } else if (ash::Shell::GetInstance()-> | 184 } else if (ash::Shell::GetInstance()-> |
| 184 partial_magnification_controller()->is_enabled()) { | 185 partial_magnification_controller()->is_enabled()) { |
| 185 float scale = delta_index > 0 ? kDefaultPartialMagnifiedScale : 1; | 186 float scale = delta_index > 0 ? kDefaultPartialMagnifiedScale : 1; |
| 186 ash::Shell::GetInstance()->partial_magnification_controller()-> | 187 ash::Shell::GetInstance()->partial_magnification_controller()-> |
| 187 SetScale(scale); | 188 SetScale(scale); |
| 189 return true; |
| 188 } | 190 } |
| 189 | 191 return false; |
| 190 return true; | |
| 191 } | 192 } |
| 192 | 193 |
| 193 bool HandleMediaNextTrack() { | 194 bool HandleMediaNextTrack() { |
| 194 Shell::GetInstance()->media_delegate()->HandleMediaNextTrack(); | 195 Shell::GetInstance()->media_delegate()->HandleMediaNextTrack(); |
| 195 return true; | 196 return true; |
| 196 } | 197 } |
| 197 | 198 |
| 198 bool HandleMediaPlayPause() { | 199 bool HandleMediaPlayPause() { |
| 199 Shell::GetInstance()->media_delegate()->HandleMediaPlayPause(); | 200 Shell::GetInstance()->media_delegate()->HandleMediaPlayPause(); |
| 200 return true; | 201 return true; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 } | 350 } |
| 350 | 351 |
| 351 bool HandleScaleReset() { | 352 bool HandleScaleReset() { |
| 352 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 353 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 353 int64 display_id = display_manager->GetDisplayIdForUIScaling(); | 354 int64 display_id = display_manager->GetDisplayIdForUIScaling(); |
| 354 if (display_id == gfx::Display::kInvalidDisplayID) | 355 if (display_id == gfx::Display::kInvalidDisplayID) |
| 355 return false; | 356 return false; |
| 356 | 357 |
| 357 base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Reset")); | 358 base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Reset")); |
| 358 | 359 |
| 359 display_manager->SetDisplayUIScale(display_id, 1.0f); | 360 float ui_scale = |
| 360 return true; | 361 display_manager->GetDisplayInfo(display_id).configured_ui_scale(); |
| 362 if (ui_scale != 1.0f) { |
| 363 display_manager->SetDisplayUIScale(display_id, 1.0f); |
| 364 return true; |
| 365 } |
| 366 return false; |
| 361 } | 367 } |
| 362 | 368 |
| 363 bool HandleScaleUI(bool up) { | 369 bool HandleScaleUI(bool up) { |
| 364 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 370 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 365 int64 display_id = display_manager->GetDisplayIdForUIScaling(); | 371 int64 display_id = display_manager->GetDisplayIdForUIScaling(); |
| 366 if (display_id == gfx::Display::kInvalidDisplayID) | 372 if (display_id == gfx::Display::kInvalidDisplayID) |
| 367 return false; | 373 return false; |
| 368 | 374 |
| 369 if (up) { | 375 if (up) { |
| 370 base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Up")); | 376 base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Up")); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 386 } | 392 } |
| 387 #endif | 393 #endif |
| 388 | 394 |
| 389 bool HandleShowKeyboardOverlay() { | 395 bool HandleShowKeyboardOverlay() { |
| 390 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); | 396 base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay")); |
| 391 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); | 397 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay(); |
| 392 | 398 |
| 393 return true; | 399 return true; |
| 394 } | 400 } |
| 395 | 401 |
| 396 void HandleShowMessageCenterBubble() { | 402 bool HandleShowMessageCenterBubble() { |
| 397 base::RecordAction(UserMetricsAction("Accel_Show_Message_Center_Bubble")); | 403 base::RecordAction(UserMetricsAction("Accel_Show_Message_Center_Bubble")); |
| 398 RootWindowController* controller = | 404 RootWindowController* controller = |
| 399 RootWindowController::ForTargetRootWindow(); | 405 RootWindowController::ForTargetRootWindow(); |
| 400 StatusAreaWidget* status_area_widget = | 406 StatusAreaWidget* status_area_widget = |
| 401 controller->shelf()->status_area_widget(); | 407 controller->shelf()->status_area_widget(); |
| 402 if (status_area_widget) { | 408 if (status_area_widget) { |
| 403 WebNotificationTray* notification_tray = | 409 WebNotificationTray* notification_tray = |
| 404 status_area_widget->web_notification_tray(); | 410 status_area_widget->web_notification_tray(); |
| 405 if (notification_tray->visible()) | 411 if (notification_tray->visible()) { |
| 406 notification_tray->ShowMessageCenterBubble(); | 412 notification_tray->ShowMessageCenterBubble(); |
| 413 return true; |
| 414 } |
| 407 } | 415 } |
| 416 return false; |
| 408 } | 417 } |
| 409 | 418 |
| 410 bool HandleShowSystemTrayBubble() { | 419 bool HandleShowSystemTrayBubble() { |
| 411 base::RecordAction(UserMetricsAction("Accel_Show_System_Tray_Bubble")); | 420 base::RecordAction(UserMetricsAction("Accel_Show_System_Tray_Bubble")); |
| 412 RootWindowController* controller = | 421 RootWindowController* controller = |
| 413 RootWindowController::ForTargetRootWindow(); | 422 RootWindowController::ForTargetRootWindow(); |
| 414 if (!controller->GetSystemTray()->HasSystemBubble()) { | 423 if (!controller->GetSystemTray()->HasSystemBubble()) { |
| 415 controller->GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | 424 controller->GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 416 return true; | 425 return true; |
| 417 } | 426 } |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 return HandleFocusShelf(); | 1014 return HandleFocusShelf(); |
| 1006 case FOCUS_NEXT_PANE: | 1015 case FOCUS_NEXT_PANE: |
| 1007 return HandleRotatePaneFocus(Shell::FORWARD); | 1016 return HandleRotatePaneFocus(Shell::FORWARD); |
| 1008 case FOCUS_PREVIOUS_PANE: | 1017 case FOCUS_PREVIOUS_PANE: |
| 1009 return HandleRotatePaneFocus(Shell::BACKWARD); | 1018 return HandleRotatePaneFocus(Shell::BACKWARD); |
| 1010 case SHOW_KEYBOARD_OVERLAY: | 1019 case SHOW_KEYBOARD_OVERLAY: |
| 1011 return HandleShowKeyboardOverlay(); | 1020 return HandleShowKeyboardOverlay(); |
| 1012 case SHOW_SYSTEM_TRAY_BUBBLE: | 1021 case SHOW_SYSTEM_TRAY_BUBBLE: |
| 1013 return HandleShowSystemTrayBubble(); | 1022 return HandleShowSystemTrayBubble(); |
| 1014 case SHOW_MESSAGE_CENTER_BUBBLE: | 1023 case SHOW_MESSAGE_CENTER_BUBBLE: |
| 1015 HandleShowMessageCenterBubble(); | 1024 return HandleShowMessageCenterBubble(); |
| 1016 break; | |
| 1017 case SHOW_TASK_MANAGER: | 1025 case SHOW_TASK_MANAGER: |
| 1018 return HandleShowTaskManager(); | 1026 return HandleShowTaskManager(); |
| 1019 case NEXT_IME: | 1027 case NEXT_IME: |
| 1020 HandleNextIme( | 1028 HandleNextIme( |
| 1021 ime_control_delegate_.get(), previous_event_type, previous_key_code); | 1029 ime_control_delegate_.get(), previous_event_type, previous_key_code); |
| 1022 // NEXT_IME is bound to Alt-Shift key up event. To be consistent with | 1030 // NEXT_IME is bound to Alt-Shift key up event. To be consistent with |
| 1023 // Windows behavior, do not consume the key event here. | 1031 // Windows behavior, do not consume the key event here. |
| 1024 return false; | 1032 return false; |
| 1025 case PREVIOUS_IME: | 1033 case PREVIOUS_IME: |
| 1026 return HandlePreviousIme(ime_control_delegate_.get(), accelerator); | 1034 return HandlePreviousIme(ime_control_delegate_.get(), accelerator); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 keyboard_brightness_control_delegate) { | 1220 keyboard_brightness_control_delegate) { |
| 1213 keyboard_brightness_control_delegate_ = | 1221 keyboard_brightness_control_delegate_ = |
| 1214 keyboard_brightness_control_delegate.Pass(); | 1222 keyboard_brightness_control_delegate.Pass(); |
| 1215 } | 1223 } |
| 1216 | 1224 |
| 1217 bool AcceleratorController::CanHandleAccelerators() const { | 1225 bool AcceleratorController::CanHandleAccelerators() const { |
| 1218 return true; | 1226 return true; |
| 1219 } | 1227 } |
| 1220 | 1228 |
| 1221 } // namespace ash | 1229 } // namespace ash |
| OLD | NEW |