| 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> |
| 11 #include <X11/extensions/XInput2.h> | 11 #include <X11/extensions/XInput2.h> |
| 12 #include <X11/extensions/Xrandr.h> | 12 #include <X11/extensions/Xrandr.h> |
| 13 | 13 |
| 14 #include <cmath> | 14 #include <cmath> |
| 15 | 15 |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/message_pump_aurax11.h" | 17 #include "base/message_pump_aurax11.h" |
| 18 #include "chromeos/dbus/dbus_thread_manager.h" | 18 #include "chromeos/dbus/dbus_thread_manager.h" |
| 19 #include "chromeos/dbus/power_manager_client.h" | 19 #include "chromeos/dbus/power_manager_client.h" |
| 20 #include "chromeos/display/output_util.h" |
| 20 | 21 |
| 21 namespace chromeos { | 22 namespace chromeos { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // DPI measurements. | 26 // DPI measurements. |
| 26 const float kMmInInch = 25.4; | 27 const float kMmInInch = 25.4; |
| 27 const float kDpi96 = 96.0; | 28 const float kDpi96 = 96.0; |
| 28 const float kPixelsToMmScale = kMmInInch / kDpi96; | 29 const float kPixelsToMmScale = kMmInInch / kDpi96; |
| 29 | 30 |
| 30 bool IsInternalOutput(const XRROutputInfo* output_info) { | 31 bool IsInternalOutput(const XRROutputInfo* output_info) { |
| 31 return OutputConfigurator::IsInternalOutputName( | 32 return IsInternalOutputName(std::string(output_info->name)); |
| 32 std::string(output_info->name)); | |
| 33 } | 33 } |
| 34 | 34 |
| 35 RRMode GetOutputNativeMode(const XRROutputInfo* output_info) { | 35 RRMode GetOutputNativeMode(const XRROutputInfo* output_info) { |
| 36 return output_info->nmode > 0 ? output_info->modes[0] : None; | 36 return output_info->nmode > 0 ? output_info->modes[0] : None; |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 RealOutputConfiguratorDelegate::RealOutputConfiguratorDelegate() | 41 RealOutputConfiguratorDelegate::RealOutputConfiguratorDelegate() |
| 42 : display_(base::MessagePumpAuraX11::GetDefaultXDisplay()), | 42 : display_(base::MessagePumpAuraX11::GetDefaultXDisplay()), |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 RRCrtc last_used_crtc = None; | 114 RRCrtc last_used_crtc = None; |
| 115 | 115 |
| 116 for (int i = 0; i < screen_->noutput && outputs.size() < 2; ++i) { | 116 for (int i = 0; i < screen_->noutput && outputs.size() < 2; ++i) { |
| 117 RROutput this_id = screen_->outputs[i]; | 117 RROutput this_id = screen_->outputs[i]; |
| 118 XRROutputInfo* output_info = XRRGetOutputInfo(display_, screen_, this_id); | 118 XRROutputInfo* output_info = XRRGetOutputInfo(display_, screen_, this_id); |
| 119 bool is_connected = (output_info->connection == RR_Connected); | 119 bool is_connected = (output_info->connection == RR_Connected); |
| 120 | 120 |
| 121 if (is_connected) { | 121 if (is_connected) { |
| 122 OutputConfigurator::OutputSnapshot to_populate; | 122 OutputConfigurator::OutputSnapshot to_populate; |
| 123 to_populate.output = this_id; | 123 to_populate.output = this_id; |
| 124 to_populate.has_display_id = |
| 125 GetDisplayId(this_id, i, &to_populate.display_id); |
| 124 (outputs.empty() ? one_info : two_info) = output_info; | 126 (outputs.empty() ? one_info : two_info) = output_info; |
| 125 | 127 |
| 126 // Now, look up the current CRTC and any related info. | 128 // Now, look up the current CRTC and any related info. |
| 127 if (output_info->crtc) { | 129 if (output_info->crtc) { |
| 128 XRRCrtcInfo* crtc_info = XRRGetCrtcInfo( | 130 XRRCrtcInfo* crtc_info = XRRGetCrtcInfo( |
| 129 display_, screen_, output_info->crtc); | 131 display_, screen_, output_info->crtc); |
| 130 to_populate.current_mode = crtc_info->mode; | 132 to_populate.current_mode = crtc_info->mode; |
| 131 to_populate.height = crtc_info->height; | 133 to_populate.height = crtc_info->height; |
| 132 to_populate.y = crtc_info->y; | 134 to_populate.y = crtc_info->y; |
| 133 XRRFreeCrtcInfo(crtc_info); | 135 XRRFreeCrtcInfo(crtc_info); |
| 134 } | 136 } |
| 135 | 137 |
| 136 // Assign a CRTC that isn't already in use. | 138 // Assign a CRTC that isn't already in use. |
| 137 for (int j = 0; j < output_info->ncrtc; ++j) { | 139 for (int j = 0; j < output_info->ncrtc; ++j) { |
| 138 if (output_info->crtcs[j] != last_used_crtc) { | 140 if (output_info->crtcs[j] != last_used_crtc) { |
| 139 to_populate.crtc = output_info->crtcs[j]; | 141 to_populate.crtc = output_info->crtcs[j]; |
| 140 last_used_crtc = to_populate.crtc; | 142 last_used_crtc = to_populate.crtc; |
| 141 break; | 143 break; |
| 142 } | 144 } |
| 143 } | 145 } |
| 144 | 146 |
| 145 to_populate.native_mode = GetOutputNativeMode(output_info); | 147 to_populate.native_mode = GetOutputNativeMode(output_info); |
| 146 to_populate.is_internal = IsInternalOutput(output_info); | 148 to_populate.is_internal = IsInternalOutput(output_info); |
| 147 to_populate.is_aspect_preserving_scaling = | 149 to_populate.is_aspect_preserving_scaling = |
| 148 IsOutputAspectPreservingScaling(this_id); | 150 IsOutputAspectPreservingScaling(this_id); |
| 149 to_populate.touch_device_id = None; | 151 to_populate.touch_device_id = None; |
| 150 to_populate.index = i; | |
| 151 | 152 |
| 152 VLOG(1) << "Found display #" << outputs.size() | 153 VLOG(1) << "Found display #" << outputs.size() |
| 153 << " with output " << to_populate.output | 154 << " with output " << to_populate.output |
| 154 << " crtc " << to_populate.crtc | 155 << " crtc " << to_populate.crtc |
| 155 << " current mode " << to_populate.current_mode; | 156 << " current mode " << to_populate.current_mode; |
| 156 outputs.push_back(to_populate); | 157 outputs.push_back(to_populate); |
| 157 } else { | 158 } else { |
| 158 XRRFreeOutputInfo(output_info); | 159 XRRFreeOutputInfo(output_info); |
| 159 } | 160 } |
| 160 } | 161 } |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 << " id " << info[i].deviceid | 563 << " id " << info[i].deviceid |
| 563 << " width " << width | 564 << " width " << width |
| 564 << " height " << height; | 565 << " height " << height; |
| 565 } | 566 } |
| 566 } | 567 } |
| 567 | 568 |
| 568 XIFreeDeviceInfo(info); | 569 XIFreeDeviceInfo(info); |
| 569 } | 570 } |
| 570 | 571 |
| 571 } // namespace chromeos | 572 } // namespace chromeos |
| OLD | NEW |