Chromium Code Reviews| 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 "chromeos/display/output_configurator.h" | 5 #include "chromeos/display/output_configurator.h" |
| 6 | 6 |
| 7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
| 8 #include <X11/extensions/Xrandr.h> | 8 #include <X11/extensions/Xrandr.h> |
| 9 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 10 | 10 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 | 235 |
| 236 VLOG(1) << "SetDisplayPower: power_state=" | 236 VLOG(1) << "SetDisplayPower: power_state=" |
| 237 << DisplayPowerStateToString(power_state) << " flags=" << flags; | 237 << DisplayPowerStateToString(power_state) << " flags=" << flags; |
| 238 if (power_state == power_state_ && !(flags & kSetDisplayPowerForceProbe)) | 238 if (power_state == power_state_ && !(flags & kSetDisplayPowerForceProbe)) |
| 239 return true; | 239 return true; |
| 240 | 240 |
| 241 delegate_->GrabServer(); | 241 delegate_->GrabServer(); |
| 242 std::vector<OutputSnapshot> outputs = | 242 std::vector<OutputSnapshot> outputs = |
| 243 delegate_->GetOutputs(state_controller_); | 243 delegate_->GetOutputs(state_controller_); |
| 244 | 244 |
| 245 bool changed = false; | |
| 245 bool only_if_single_internal_display = | 246 bool only_if_single_internal_display = |
| 246 flags & kSetDisplayPowerOnlyIfSingleInternalDisplay; | 247 flags & kSetDisplayPowerOnlyIfSingleInternalDisplay; |
| 247 bool single_internal_display = outputs.size() == 1 && outputs[0].is_internal; | 248 bool single_internal_display = outputs.size() == 1 && outputs[0].is_internal; |
| 248 if ((single_internal_display || !only_if_single_internal_display) && | 249 if ((single_internal_display || !only_if_single_internal_display) && |
| 249 EnterStateOrFallBackToSoftwareMirroring( | 250 EnterStateOrFallBackToSoftwareMirroring( |
| 250 GetOutputState(outputs, power_state), power_state, outputs)) { | 251 GetOutputState(outputs, power_state), power_state, outputs)) { |
| 251 if (power_state != DISPLAY_POWER_ALL_OFF) { | 252 // Force the DPMS on since the driver doesn't always detect that it |
| 252 // Force the DPMS on since the driver doesn't always detect that it | 253 // should turn on. This is needed when coming back from idle suspend. |
| 253 // should turn on. This is needed when coming back from idle suspend. | 254 if (power_state != DISPLAY_POWER_ALL_OFF) |
| 254 delegate_->ForceDPMSOn(); | 255 delegate_->ForceDPMSOn(); |
| 255 } | 256 |
| 257 changed = true; | |
| 256 } | 258 } |
| 257 | 259 |
| 258 delegate_->UngrabServer(); | 260 delegate_->UngrabServer(); |
| 261 if (changed) | |
| 262 NotifyOnDisplayChanged(); | |
|
Daniel Erat
2013/08/16 00:51:46
I don't think that we need to notify about failure
| |
| 259 return true; | 263 return true; |
| 260 } | 264 } |
| 261 | 265 |
| 262 bool OutputConfigurator::SetDisplayMode(OutputState new_state) { | 266 bool OutputConfigurator::SetDisplayMode(OutputState new_state) { |
| 263 if (!configure_display_) | 267 if (!configure_display_) |
| 264 return false; | 268 return false; |
| 265 | 269 |
| 266 VLOG(1) << "SetDisplayMode: state=" << OutputStateToString(new_state); | 270 VLOG(1) << "SetDisplayMode: state=" << OutputStateToString(new_state); |
| 267 if (output_state_ == new_state) { | 271 if (output_state_ == new_state) { |
| 268 // Cancel software mirroring if the state is moving from | 272 // Cancel software mirroring if the state is moving from |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 float width_ratio = static_cast<float>(mirror_mode_info->width) / | 690 float width_ratio = static_cast<float>(mirror_mode_info->width) / |
| 687 static_cast<float>(native_mode_info->width); | 691 static_cast<float>(native_mode_info->width); |
| 688 float height_ratio = static_cast<float>(mirror_mode_info->height) / | 692 float height_ratio = static_cast<float>(mirror_mode_info->height) / |
| 689 static_cast<float>(native_mode_info->height); | 693 static_cast<float>(native_mode_info->height); |
| 690 | 694 |
| 691 area_ratio = width_ratio * height_ratio; | 695 area_ratio = width_ratio * height_ratio; |
| 692 return area_ratio; | 696 return area_ratio; |
| 693 } | 697 } |
| 694 | 698 |
| 695 } // namespace chromeos | 699 } // namespace chromeos |
| OLD | NEW |