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 <iostream> | 9 #include <iostream> |
10 #include <string> | 10 #include <string> |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return gfx::Display::ROTATE_180; | 163 return gfx::Display::ROTATE_180; |
164 case gfx::Display::ROTATE_180: | 164 case gfx::Display::ROTATE_180: |
165 return gfx::Display::ROTATE_270; | 165 return gfx::Display::ROTATE_270; |
166 case gfx::Display::ROTATE_270: | 166 case gfx::Display::ROTATE_270: |
167 return gfx::Display::ROTATE_0; | 167 return gfx::Display::ROTATE_0; |
168 } | 168 } |
169 NOTREACHED() << "Unknown rotation:" << current; | 169 NOTREACHED() << "Unknown rotation:" << current; |
170 return gfx::Display::ROTATE_0; | 170 return gfx::Display::ROTATE_0; |
171 } | 171 } |
172 | 172 |
173 float GetNextScale(float scale, bool up) { | |
174 // These scales are equivalent to 1024, 1280, 1600 and 1920 pixel width | |
175 // respectively on 2560 pixel width 2x density display. | |
176 static const float kScales[] = {0.8f, 1.0f, 1.25f, 1.5f}; | |
177 static const size_t kScaleTableSize = arraysize(kScales); | |
178 for (size_t i = 0; i < kScaleTableSize; ++i) { | |
179 if (kScales[i] == scale) { | |
180 if (up && i != kScaleTableSize -1) | |
181 return kScales[i + 1]; | |
182 if (!up && i != 0) | |
183 return kScales[i - 1]; | |
184 return kScales[i]; | |
185 } | |
186 } | |
187 // Fallback to 1.0f if the |scale| wasn't in the list. | |
188 return 1.0f; | |
189 } | |
190 | |
191 bool HandleScaleUI(bool up) { | 173 bool HandleScaleUI(bool up) { |
192 // UI Scaling is effective only on internal display. | 174 // UI Scaling is effective only on internal display. |
193 int64 display_id = gfx::Display::InternalDisplayId(); | 175 int64 display_id = gfx::Display::InternalDisplayId(); |
194 #if defined(OS_CHROMEOS) | 176 #if defined(OS_CHROMEOS) |
195 // On linux desktop, allow ui scalacing on the first dislpay. | 177 // On linux desktop, allow ui scalacing on the first dislpay. |
196 if (!base::chromeos::IsRunningOnChromeOS()) | 178 if (!base::chromeos::IsRunningOnChromeOS()) |
197 display_id = Shell::GetInstance()->display_manager()->first_display_id(); | 179 display_id = Shell::GetInstance()->display_manager()->first_display_id(); |
198 #endif | 180 #endif |
199 const gfx::Display& display = Shell::GetInstance()->display_manager()-> | |
200 GetDisplayForId(display_id); | |
201 const DisplayInfo& display_info = Shell::GetInstance()->display_manager()-> | 181 const DisplayInfo& display_info = Shell::GetInstance()->display_manager()-> |
202 GetDisplayInfo(display); | 182 GetDisplayInfo(display_id); |
203 Shell::GetInstance()->display_manager()->SetDisplayUIScale( | 183 Shell::GetInstance()->display_manager()->SetDisplayUIScale( |
204 display.id(), GetNextScale(display_info.ui_scale(), up)); | 184 display_id, |
| 185 internal::DisplayManager::GetNextUIScale(display_info.ui_scale(), up)); |
205 return true; | 186 return true; |
206 } | 187 } |
207 | 188 |
208 // Rotates the screen. | 189 // Rotates the screen. |
209 bool HandleRotateScreen() { | 190 bool HandleRotateScreen() { |
210 gfx::Point point = Shell::GetScreen()->GetCursorScreenPoint(); | 191 gfx::Point point = Shell::GetScreen()->GetCursorScreenPoint(); |
211 gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(point); | 192 gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(point); |
212 const DisplayInfo& display_info = | 193 const DisplayInfo& display_info = |
213 Shell::GetInstance()->display_manager()->GetDisplayInfo(display); | 194 Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); |
214 Shell::GetInstance()->display_manager()->SetDisplayRotation( | 195 Shell::GetInstance()->display_manager()->SetDisplayRotation( |
215 display.id(), GetNextRotation(display_info.rotation())); | 196 display.id(), GetNextRotation(display_info.rotation())); |
216 return true; | 197 return true; |
217 } | 198 } |
218 | 199 |
219 bool HandleToggleDesktopBackgroundMode() { | 200 bool HandleToggleDesktopBackgroundMode() { |
220 DesktopBackgroundController* desktop_background_controller = | 201 DesktopBackgroundController* desktop_background_controller = |
221 Shell::GetInstance()->desktop_background_controller(); | 202 Shell::GetInstance()->desktop_background_controller(); |
222 if (desktop_background_controller->desktop_background_mode() == | 203 if (desktop_background_controller->desktop_background_mode() == |
223 DesktopBackgroundController::BACKGROUND_IMAGE) { | 204 DesktopBackgroundController::BACKGROUND_IMAGE) { |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 keyboard_brightness_control_delegate) { | 897 keyboard_brightness_control_delegate) { |
917 keyboard_brightness_control_delegate_ = | 898 keyboard_brightness_control_delegate_ = |
918 keyboard_brightness_control_delegate.Pass(); | 899 keyboard_brightness_control_delegate.Pass(); |
919 } | 900 } |
920 | 901 |
921 bool AcceleratorController::CanHandleAccelerators() const { | 902 bool AcceleratorController::CanHandleAccelerators() const { |
922 return true; | 903 return true; |
923 } | 904 } |
924 | 905 |
925 } // namespace ash | 906 } // namespace ash |
OLD | NEW |