| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/real_output_configurator_delegate.h" | 5 #include "chromeos/display/real_output_configurator_delegate.h" |
| 6 | 6 |
| 7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 #include <X11/extensions/dpms.h> | 9 #include <X11/extensions/dpms.h> |
| 10 #include <X11/extensions/XInput.h> | 10 #include <X11/extensions/XInput.h> |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 XChangeWindowAttributes(display_, window_, CWBackPixel, &swa); | 98 XChangeWindowAttributes(display_, window_, CWBackPixel, &swa); |
| 99 XFreeColors(display_, colormap, &color.pixel, 1, 0); | 99 XFreeColors(display_, colormap, &color.pixel, 1, 0); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void RealOutputConfiguratorDelegate::ForceDPMSOn() { | 102 void RealOutputConfiguratorDelegate::ForceDPMSOn() { |
| 103 CHECK(DPMSEnable(display_)); | 103 CHECK(DPMSEnable(display_)); |
| 104 CHECK(DPMSForceLevel(display_, DPMSModeOn)); | 104 CHECK(DPMSForceLevel(display_, DPMSModeOn)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 std::vector<OutputConfigurator::OutputSnapshot> | 107 std::vector<OutputConfigurator::OutputSnapshot> |
| 108 RealOutputConfiguratorDelegate::GetOutputs() { | 108 RealOutputConfiguratorDelegate::GetOutputs( |
| 109 const OutputConfigurator::StateController* state_controller) { |
| 109 CHECK(screen_) << "Server not grabbed"; | 110 CHECK(screen_) << "Server not grabbed"; |
| 110 | 111 |
| 111 std::vector<OutputConfigurator::OutputSnapshot> outputs; | 112 std::vector<OutputConfigurator::OutputSnapshot> outputs; |
| 112 XRROutputInfo* one_info = NULL; | 113 XRROutputInfo* one_info = NULL; |
| 113 XRROutputInfo* two_info = NULL; | 114 XRROutputInfo* two_info = NULL; |
| 114 RRCrtc last_used_crtc = None; | 115 RRCrtc last_used_crtc = None; |
| 115 | 116 |
| 116 for (int i = 0; i < screen_->noutput && outputs.size() < 2; ++i) { | 117 for (int i = 0; i < screen_->noutput && outputs.size() < 2; ++i) { |
| 117 RROutput this_id = screen_->outputs[i]; | 118 RROutput this_id = screen_->outputs[i]; |
| 118 XRROutputInfo* output_info = XRRGetOutputInfo(display_, screen_, this_id); | 119 XRROutputInfo* output_info = XRRGetOutputInfo(display_, screen_, this_id); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 143 } | 144 } |
| 144 | 145 |
| 145 // Assign a CRTC that isn't already in use. | 146 // Assign a CRTC that isn't already in use. |
| 146 for (int j = 0; j < output_info->ncrtc; ++j) { | 147 for (int j = 0; j < output_info->ncrtc; ++j) { |
| 147 if (output_info->crtcs[j] != last_used_crtc) { | 148 if (output_info->crtcs[j] != last_used_crtc) { |
| 148 to_populate.crtc = output_info->crtcs[j]; | 149 to_populate.crtc = output_info->crtcs[j]; |
| 149 last_used_crtc = to_populate.crtc; | 150 last_used_crtc = to_populate.crtc; |
| 150 break; | 151 break; |
| 151 } | 152 } |
| 152 } | 153 } |
| 154 to_populate.native_mode = GetOutputNativeMode(output_info); |
| 155 if (to_populate.has_display_id) { |
| 156 int width = 0, height = 0; |
| 157 if (state_controller && |
| 158 state_controller->GetResolutionForDisplayId( |
| 159 to_populate.display_id, &width, &height)) { |
| 160 to_populate.selected_mode = |
| 161 FindOutputModeMatchingSize(screen_, output_info, width, height); |
| 162 } |
| 163 } |
| 164 // Fallback to native mode. |
| 165 if (to_populate.selected_mode == None) |
| 166 to_populate.selected_mode = to_populate.native_mode; |
| 153 | 167 |
| 154 to_populate.native_mode = GetOutputNativeMode(output_info); | |
| 155 to_populate.is_aspect_preserving_scaling = | 168 to_populate.is_aspect_preserving_scaling = |
| 156 IsOutputAspectPreservingScaling(this_id); | 169 IsOutputAspectPreservingScaling(this_id); |
| 157 to_populate.touch_device_id = None; | 170 to_populate.touch_device_id = None; |
| 158 | 171 |
| 159 VLOG(2) << "Found display " << outputs.size() << ":" | 172 VLOG(2) << "Found display " << outputs.size() << ":" |
| 160 << " output=" << to_populate.output | 173 << " output=" << to_populate.output |
| 161 << " crtc=" << to_populate.crtc | 174 << " crtc=" << to_populate.crtc |
| 162 << " current_mode=" << to_populate.current_mode; | 175 << " current_mode=" << to_populate.current_mode; |
| 163 outputs.push_back(to_populate); | 176 outputs.push_back(to_populate); |
| 164 } else { | 177 } else { |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 << " id " << info[i].deviceid | 584 << " id " << info[i].deviceid |
| 572 << " width " << width | 585 << " width " << width |
| 573 << " height " << height; | 586 << " height " << height; |
| 574 } | 587 } |
| 575 } | 588 } |
| 576 | 589 |
| 577 XIFreeDeviceInfo(info); | 590 XIFreeDeviceInfo(info); |
| 578 } | 591 } |
| 579 | 592 |
| 580 } // namespace chromeos | 593 } // namespace chromeos |
| OLD | NEW |