Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_output.cpp
Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Line(s) | 177 | { | |||
---|---|---|---|---|---|
178 | return QRect(m_globalPos, pixelSize() / scale()); | 178 | return QRect(m_globalPos, pixelSize() / scale()); | ||
179 | } | 179 | } | ||
180 | 180 | | |||
181 | qreal DrmOutput::scale() const | 181 | qreal DrmOutput::scale() const | ||
182 | { | 182 | { | ||
183 | return m_scale; | 183 | return m_scale; | ||
184 | } | 184 | } | ||
185 | 185 | | |||
186 | void DrmOutput::setEnabled(bool enabled) | ||||
187 | { | ||||
188 | if (enabled == isEnabled()) { | ||||
189 | return; | ||||
190 | } | ||||
191 | if (enabled) { | ||||
192 | setDpms(DpmsMode::On); | ||||
193 | initOutput(); | ||||
194 | } else { | ||||
195 | setDpms(DpmsMode::Off); | ||||
196 | delete m_waylandOutput.data(); | ||||
197 | } | ||||
198 | m_waylandOutputDevice->setEnabled(enabled ? | ||||
199 | KWayland::Server::OutputDeviceInterface::Enablement::Enabled : KWayland::Server::OutputDeviceInterface::Enablement::Disabled); | ||||
200 | } | ||||
201 | | ||||
202 | bool DrmOutput::isEnabled() const | ||||
203 | { | ||||
204 | return !m_waylandOutput.isNull(); | ||||
205 | } | ||||
186 | 206 | | |||
187 | static KWayland::Server::OutputInterface::DpmsMode toWaylandDpmsMode(DrmOutput::DpmsMode mode) | 207 | static KWayland::Server::OutputInterface::DpmsMode toWaylandDpmsMode(DrmOutput::DpmsMode mode) | ||
188 | { | 208 | { | ||
189 | using namespace KWayland::Server; | 209 | using namespace KWayland::Server; | ||
190 | switch (mode) { | 210 | switch (mode) { | ||
191 | case DrmOutput::DpmsMode::On: | 211 | case DrmOutput::DpmsMode::On: | ||
192 | return OutputInterface::DpmsMode::On; | 212 | return OutputInterface::DpmsMode::On; | ||
193 | case DrmOutput::DpmsMode::Standby: | 213 | case DrmOutput::DpmsMode::Standby: | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 286 | if (!initPrimaryPlane()) { | |||
267 | return false; | 287 | return false; | ||
268 | } | 288 | } | ||
269 | } else if (!m_crtc->blank()) { | 289 | } else if (!m_crtc->blank()) { | ||
270 | return false; | 290 | return false; | ||
271 | } | 291 | } | ||
272 | 292 | | |||
273 | m_internal = connector->connector_type == DRM_MODE_CONNECTOR_LVDS || connector->connector_type == DRM_MODE_CONNECTOR_eDP; | 293 | m_internal = connector->connector_type == DRM_MODE_CONNECTOR_LVDS || connector->connector_type == DRM_MODE_CONNECTOR_eDP; | ||
274 | 294 | | |||
275 | setDpms(DpmsMode::On); | | |||
276 | | ||||
277 | if (m_internal) { | 295 | if (m_internal) { | ||
278 | connect(kwinApp(), &Application::screensCreated, this, | 296 | connect(kwinApp(), &Application::screensCreated, this, | ||
279 | [this] { | 297 | [this] { | ||
280 | connect(screens()->orientationSensor(), &OrientationSensor::orientationChanged, this, &DrmOutput::automaticRotation); | 298 | connect(screens()->orientationSensor(), &OrientationSensor::orientationChanged, this, &DrmOutput::automaticRotation); | ||
281 | } | 299 | } | ||
282 | ); | 300 | ); | ||
283 | } | 301 | } | ||
284 | 302 | | |||
285 | QSize physicalSize = !m_edid.physicalSize.isEmpty() ? m_edid.physicalSize : QSize(connector->mmWidth, connector->mmHeight); | 303 | QSize physicalSize = !m_edid.physicalSize.isEmpty() ? m_edid.physicalSize : QSize(connector->mmWidth, connector->mmHeight); | ||
286 | // the size might be completely borked. E.g. Samsung SyncMaster 2494HS reports 160x90 while in truth it's 520x292 | 304 | // the size might be completely borked. E.g. Samsung SyncMaster 2494HS reports 160x90 while in truth it's 520x292 | ||
287 | // as this information is used to calculate DPI info, it's going to result in everything being huge | 305 | // as this information is used to calculate DPI info, it's going to result in everything being huge | ||
288 | const QByteArray unknown = QByteArrayLiteral("unkown"); | 306 | const QByteArray unknown = QByteArrayLiteral("unkown"); | ||
289 | KConfigGroup group = kwinApp()->config()->group("EdidOverwrite").group(m_edid.eisaId.isEmpty() ? unknown : m_edid.eisaId) | 307 | KConfigGroup group = kwinApp()->config()->group("EdidOverwrite").group(m_edid.eisaId.isEmpty() ? unknown : m_edid.eisaId) | ||
290 | .group(m_edid.monitorName.isEmpty() ? unknown : m_edid.monitorName) | 308 | .group(m_edid.monitorName.isEmpty() ? unknown : m_edid.monitorName) | ||
291 | .group(m_edid.serialNumber.isEmpty() ? unknown : m_edid.serialNumber); | 309 | .group(m_edid.serialNumber.isEmpty() ? unknown : m_edid.serialNumber); | ||
292 | if (group.hasKey("PhysicalSize")) { | 310 | if (group.hasKey("PhysicalSize")) { | ||
293 | const QSize overwriteSize = group.readEntry("PhysicalSize", physicalSize); | 311 | const QSize overwriteSize = group.readEntry("PhysicalSize", physicalSize); | ||
294 | qCWarning(KWIN_DRM) << "Overwriting monitor physical size for" << m_edid.eisaId << "/" << m_edid.monitorName << "/" << m_edid.serialNumber << " from " << physicalSize << "to " << overwriteSize; | 312 | qCWarning(KWIN_DRM) << "Overwriting monitor physical size for" << m_edid.eisaId << "/" << m_edid.monitorName << "/" << m_edid.serialNumber << " from " << physicalSize << "to " << overwriteSize; | ||
295 | physicalSize = overwriteSize; | 313 | physicalSize = overwriteSize; | ||
296 | } | 314 | } | ||
297 | m_physicalSize = physicalSize; | 315 | m_physicalSize = physicalSize; | ||
298 | 316 | | |||
299 | initOutputDevice(connector); | 317 | initOutputDevice(connector); | ||
300 | initOutput(); | | |||
301 | 318 | | |||
319 | setEnabled(true); | ||||
302 | return true; | 320 | return true; | ||
303 | } | 321 | } | ||
304 | 322 | | |||
305 | void DrmOutput::initUuid() | 323 | void DrmOutput::initUuid() | ||
306 | { | 324 | { | ||
307 | QCryptographicHash hash(QCryptographicHash::Md5); | 325 | QCryptographicHash hash(QCryptographicHash::Md5); | ||
308 | hash.addData(QByteArray::number(m_conn->id())); | 326 | hash.addData(QByteArray::number(m_conn->id())); | ||
309 | hash.addData(m_edid.eisaId); | 327 | hash.addData(m_edid.eisaId); | ||
▲ Show 20 Lines • Show All 469 Lines • ▼ Show 20 Line(s) | 796 | { | |||
779 | m_changeset = changes; | 797 | m_changeset = changes; | ||
780 | qCDebug(KWIN_DRM) << "set changes in DrmOutput"; | 798 | qCDebug(KWIN_DRM) << "set changes in DrmOutput"; | ||
781 | commitChanges(); | 799 | commitChanges(); | ||
782 | } | 800 | } | ||
783 | 801 | | |||
784 | bool DrmOutput::commitChanges() | 802 | bool DrmOutput::commitChanges() | ||
785 | { | 803 | { | ||
786 | Q_ASSERT(!m_waylandOutputDevice.isNull()); | 804 | Q_ASSERT(!m_waylandOutputDevice.isNull()); | ||
787 | Q_ASSERT(!m_waylandOutput.isNull()); | | |||
788 | 805 | | |||
789 | if (m_changeset.isNull()) { | 806 | if (m_changeset.isNull()) { | ||
790 | qCDebug(KWIN_DRM) << "no changes"; | 807 | qCDebug(KWIN_DRM) << "no changes"; | ||
791 | // No changes to an output is an entirely valid thing | 808 | // No changes to an output is an entirely valid thing | ||
792 | return true; | 809 | return true; | ||
793 | } | 810 | } | ||
794 | 811 | //enabledChanged is handled by drmbackend | |||
795 | if (m_changeset->enabledChanged()) { | | |||
796 | qCDebug(KWIN_DRM) << "Setting enabled:"; | | |||
797 | m_waylandOutputDevice->setEnabled(m_changeset->enabled()); | | |||
798 | } | | |||
799 | if (m_changeset->modeChanged()) { | 812 | if (m_changeset->modeChanged()) { | ||
800 | qCDebug(KWIN_DRM) << "Setting new mode:" << m_changeset->mode(); | 813 | qCDebug(KWIN_DRM) << "Setting new mode:" << m_changeset->mode(); | ||
801 | m_waylandOutputDevice->setCurrentMode(m_changeset->mode()); | 814 | m_waylandOutputDevice->setCurrentMode(m_changeset->mode()); | ||
802 | updateMode(m_changeset->mode()); | 815 | updateMode(m_changeset->mode()); | ||
803 | } | 816 | } | ||
804 | if (m_changeset->transformChanged()) { | 817 | if (m_changeset->transformChanged()) { | ||
805 | qCDebug(KWIN_DRM) << "Server setting transform: " << (int)(m_changeset->transform()); | 818 | qCDebug(KWIN_DRM) << "Server setting transform: " << (int)(m_changeset->transform()); | ||
806 | transform(m_changeset->transform()); | 819 | transform(m_changeset->transform()); | ||
▲ Show 20 Lines • Show All 479 Lines • Show Last 20 Lines |