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/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 172 } |
173 | 173 |
174 void DisplayManager::SetDisplayRotation(int64 display_id, | 174 void DisplayManager::SetDisplayRotation(int64 display_id, |
175 gfx::Display::Rotation rotation) { | 175 gfx::Display::Rotation rotation) { |
176 if (!IsDisplayRotationEnabled()) | 176 if (!IsDisplayRotationEnabled()) |
177 return; | 177 return; |
178 DisplayInfoList display_info_list; | 178 DisplayInfoList display_info_list; |
179 for (DisplayList::const_iterator iter = displays_.begin(); | 179 for (DisplayList::const_iterator iter = displays_.begin(); |
180 iter != displays_.end(); ++iter) { | 180 iter != displays_.end(); ++iter) { |
181 DisplayInfo info = GetDisplayInfo(*iter); | 181 DisplayInfo info = GetDisplayInfo(*iter); |
182 if (info.id() == display_id) | 182 if (info.id() == display_id) { |
| 183 if (info.rotation() == rotation) |
| 184 return; |
183 info.set_rotation(rotation); | 185 info.set_rotation(rotation); |
| 186 } |
184 display_info_list.push_back(info); | 187 display_info_list.push_back(info); |
185 } | 188 } |
186 UpdateDisplays(display_info_list); | 189 UpdateDisplays(display_info_list); |
187 } | 190 } |
188 | 191 |
189 void DisplayManager::SetDisplayUIScale(int64 display_id, | 192 void DisplayManager::SetDisplayUIScale(int64 display_id, |
190 float ui_scale) { | 193 float ui_scale) { |
191 if (!IsDisplayUIScalingEnabled()) | 194 if (!IsDisplayUIScalingEnabled()) |
192 return; | 195 return; |
193 DisplayInfoList display_info_list; | 196 DisplayInfoList display_info_list; |
194 for (DisplayList::const_iterator iter = displays_.begin(); | 197 for (DisplayList::const_iterator iter = displays_.begin(); |
195 iter != displays_.end(); ++iter) { | 198 iter != displays_.end(); ++iter) { |
196 DisplayInfo info = GetDisplayInfo(*iter); | 199 DisplayInfo info = GetDisplayInfo(*iter); |
197 if (info.id() == display_id) | 200 if (info.id() == display_id) { |
| 201 if (info.ui_scale() == ui_scale) |
| 202 return; |
198 info.set_ui_scale(ui_scale); | 203 info.set_ui_scale(ui_scale); |
| 204 } |
199 display_info_list.push_back(info); | 205 display_info_list.push_back(info); |
200 } | 206 } |
201 UpdateDisplays(display_info_list); | 207 UpdateDisplays(display_info_list); |
202 } | 208 } |
203 | 209 |
204 | 210 |
205 bool DisplayManager::IsDisplayRotationEnabled() const { | 211 bool DisplayManager::IsDisplayRotationEnabled() const { |
206 static bool enabled = !CommandLine::ForCurrentProcess()-> | 212 static bool enabled = !CommandLine::ForCurrentProcess()-> |
207 HasSwitch(switches::kAshDisableDisplayRotation); | 213 HasSwitch(switches::kAshDisableDisplayRotation); |
208 return enabled; | 214 return enabled; |
209 } | 215 } |
210 | 216 |
211 bool DisplayManager::IsDisplayUIScalingEnabled() const { | 217 bool DisplayManager::IsDisplayUIScalingEnabled() const { |
212 static bool enabled = !CommandLine::ForCurrentProcess()-> | 218 static bool enabled = !CommandLine::ForCurrentProcess()-> |
213 HasSwitch(switches::kAshDisableUIScaling); | 219 HasSwitch(switches::kAshDisableUIScaling); |
214 if (!enabled) | 220 if (!enabled) |
215 return false; | 221 return false; |
216 // UI Scaling is effective only when the internal display has | 222 // UI Scaling is effective only when the internal display has |
217 // 2x density (currently Pixel). | 223 // 2x density (currently Pixel). |
218 int64 display_id = gfx::Display::InternalDisplayId(); | 224 int64 display_id = gfx::Display::InternalDisplayId(); |
219 #if defined(OS_CHROMEOS) | 225 #if defined(OS_CHROMEOS) |
220 // On linux desktop, allow ui scaling on the first dislpay. | 226 // On linux desktop, allow ui scaling on the first dislpay if an internal |
221 if (!base::chromeos::IsRunningOnChromeOS()) | 227 // display isn't specified. |
| 228 if (display_id == gfx::Display::kInvalidDisplayID && |
| 229 !base::chromeos::IsRunningOnChromeOS()) { |
222 display_id = Shell::GetInstance()->display_manager()->first_display_id(); | 230 display_id = Shell::GetInstance()->display_manager()->first_display_id(); |
| 231 } |
223 #endif | 232 #endif |
224 return GetDisplayForId(display_id).device_scale_factor() == 2.0f; | 233 return GetDisplayForId(display_id).device_scale_factor() == 2.0f; |
225 } | 234 } |
226 | 235 |
227 gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const { | 236 gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const { |
228 std::map<int64, DisplayInfo>::const_iterator it = | 237 std::map<int64, DisplayInfo>::const_iterator it = |
229 display_info_.find(display_id); | 238 display_info_.find(display_id); |
230 return (it != display_info_.end()) ? | 239 return (it != display_info_.end()) ? |
231 it->second.overscan_insets_in_dip() : gfx::Insets(); | 240 it->second.overscan_insets_in_dip() : gfx::Insets(); |
232 } | 241 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 removed_displays.empty()) { | 373 removed_displays.empty()) { |
365 return; | 374 return; |
366 } | 375 } |
367 | 376 |
368 displays_ = new_displays; | 377 displays_ = new_displays; |
369 | 378 |
370 // Temporarily add displays to be removed because display object | 379 // Temporarily add displays to be removed because display object |
371 // being removed are accessed during shutting down the root. | 380 // being removed are accessed during shutting down the root. |
372 displays_.insert(displays_.end(), removed_displays.begin(), | 381 displays_.insert(displays_.end(), removed_displays.begin(), |
373 removed_displays.end()); | 382 removed_displays.end()); |
| 383 DisplayController* display_controller = |
| 384 Shell::GetInstance()->display_controller(); |
| 385 // |display_controller| is NULL during the bootstrap. |
| 386 if (display_controller) |
| 387 display_controller->NotifyDisplayConfigurationChanging(); |
| 388 |
374 for (DisplayList::const_reverse_iterator iter = removed_displays.rbegin(); | 389 for (DisplayList::const_reverse_iterator iter = removed_displays.rbegin(); |
375 iter != removed_displays.rend(); ++iter) { | 390 iter != removed_displays.rend(); ++iter) { |
376 Shell::GetInstance()->screen()->NotifyDisplayRemoved(displays_.back()); | 391 Shell::GetInstance()->screen()->NotifyDisplayRemoved(displays_.back()); |
377 displays_.pop_back(); | 392 displays_.pop_back(); |
378 } | 393 } |
379 for (std::vector<size_t>::iterator iter = added_display_indices.begin(); | 394 for (std::vector<size_t>::iterator iter = added_display_indices.begin(); |
380 iter != added_display_indices.end(); ++iter) { | 395 iter != added_display_indices.end(); ++iter) { |
381 Shell::GetInstance()->screen()->NotifyDisplayAdded(displays_[*iter]); | 396 Shell::GetInstance()->screen()->NotifyDisplayAdded(displays_[*iter]); |
382 } | 397 } |
383 for (std::vector<size_t>::iterator iter = changed_display_indices.begin(); | 398 for (std::vector<size_t>::iterator iter = changed_display_indices.begin(); |
384 iter != changed_display_indices.end(); ++iter) { | 399 iter != changed_display_indices.end(); ++iter) { |
385 Shell::GetInstance()->screen()->NotifyBoundsChanged(displays_[*iter]); | 400 Shell::GetInstance()->screen()->NotifyBoundsChanged(displays_[*iter]); |
386 } | 401 } |
| 402 if (display_controller) |
| 403 display_controller->NotifyDisplayConfigurationChanged(); |
| 404 |
387 EnsurePointerInDisplays(); | 405 EnsurePointerInDisplays(); |
388 | |
389 #if defined(USE_X11) && defined(OS_CHROMEOS) | 406 #if defined(USE_X11) && defined(OS_CHROMEOS) |
390 if (!changed_display_indices.empty() && base::chromeos::IsRunningOnChromeOS()) | 407 if (!changed_display_indices.empty() && base::chromeos::IsRunningOnChromeOS()) |
391 ui::ClearX11DefaultRootWindow(); | 408 ui::ClearX11DefaultRootWindow(); |
392 #endif | 409 #endif |
393 } | 410 } |
394 | 411 |
395 gfx::Display* DisplayManager::GetDisplayAt(size_t index) { | 412 gfx::Display* DisplayManager::GetDisplayAt(size_t index) { |
396 return index < displays_.size() ? &displays_[index] : NULL; | 413 return index < displays_.size() ? &displays_[index] : NULL; |
397 } | 414 } |
398 | 415 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 // always (0,0) and the secondary display's bounds will be updated | 662 // always (0,0) and the secondary display's bounds will be updated |
646 // by |DisplayController::UpdateDisplayBoundsForLayout|. | 663 // by |DisplayController::UpdateDisplayBoundsForLayout|. |
647 new_display.SetScaleAndBounds( | 664 new_display.SetScaleAndBounds( |
648 display_info.device_scale_factor(), gfx::Rect(bounds_in_pixel.size())); | 665 display_info.device_scale_factor(), gfx::Rect(bounds_in_pixel.size())); |
649 new_display.set_rotation(display_info.rotation()); | 666 new_display.set_rotation(display_info.rotation()); |
650 return new_display; | 667 return new_display; |
651 } | 668 } |
652 | 669 |
653 } // namespace internal | 670 } // namespace internal |
654 } // namespace ash | 671 } // namespace ash |
OLD | NEW |