Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/hwcomposer/hwcomposer_backend.cpp
Show First 20 Lines • Show All 500 Lines • ▼ Show 20 Line(s) | 496 | uint32_t attributes[] = { | |||
---|---|---|---|---|---|
501 | HWC_DISPLAY_VSYNC_PERIOD , | 501 | HWC_DISPLAY_VSYNC_PERIOD , | ||
502 | HWC_DISPLAY_NO_ATTRIBUTE | 502 | HWC_DISPLAY_NO_ATTRIBUTE | ||
503 | }; | 503 | }; | ||
504 | device->getDisplayAttributes(device, 0, configs[0], attributes, attr_values); | 504 | device->getDisplayAttributes(device, 0, configs[0], attributes, attr_values); | ||
505 | QSize pixel(attr_values[0], attr_values[1]); | 505 | QSize pixel(attr_values[0], attr_values[1]); | ||
506 | if (pixel.isEmpty()) { | 506 | if (pixel.isEmpty()) { | ||
507 | return; | 507 | return; | ||
508 | } | 508 | } | ||
509 | m_pixelSize = pixel; | | |||
510 | 509 | | |||
511 | if (attr_values[2] != 0 && attr_values[3] != 0) { | 510 | if (attr_values[2] != 0 && attr_values[3] != 0) { | ||
512 | static const qreal factor = 25.4; | 511 | static const qreal factor = 25.4; | ||
513 | auto physicalSize = QSizeF(qreal(pixel.width() * 1000) / qreal(attr_values[2]) * factor, | 512 | auto physicalSize = QSizeF(qreal(pixel.width() * 1000) / qreal(attr_values[2]) * factor, | ||
514 | qreal(pixel.height() * 1000) / qreal(attr_values[3]) * factor); | 513 | qreal(pixel.height() * 1000) / qreal(attr_values[3]) * factor); | ||
515 | setRawPhysicalSize(physicalSize.toSize()); | 514 | setRawPhysicalSize(physicalSize.toSize()); | ||
516 | } else { | 515 | } else { | ||
517 | // couldn't read physical size, assume 96 dpi | 516 | // couldn't read physical size, assume 96 dpi | ||
518 | setRawPhysicalSize(pixel / 3.8); | 517 | setRawPhysicalSize(pixel / 3.8); | ||
519 | } | 518 | } | ||
520 | 519 | | |||
521 | OutputDeviceInterface::Mode mode; | 520 | OutputDeviceInterface::Mode mode; | ||
522 | mode.id = 0; | 521 | mode.id = 0; | ||
523 | mode.size = pixel; | 522 | mode.size = pixel; | ||
524 | mode.flags = OutputDeviceInterface::ModeFlag::Current | OutputDeviceInterface::ModeFlag::Preferred; | 523 | mode.flags = OutputDeviceInterface::ModeFlag::Current | OutputDeviceInterface::ModeFlag::Preferred; | ||
525 | mode.refreshRate = (attr_values[4] == 0) ? 60000 : 10E11/attr_values[4]; | 524 | mode.refreshRate = (attr_values[4] == 0) ? 60000 : 10E11/attr_values[4]; | ||
526 | 525 | | |||
527 | initWaylandOutputDevice(QString(), QString(), QByteArray(), {mode}); | 526 | initWaylandOutputDevice(QString(), QString(), QByteArray(), {mode}); | ||
528 | setInternal(true); | 527 | setInternal(true); | ||
529 | setEnabled(true); | 528 | setEnabled(true); | ||
530 | setDpmsSupported(true); | 529 | setDpmsSupported(true); | ||
531 | 530 | | |||
532 | const auto outputGroup = kwinApp()->config()->group("HWComposerOutputs").group("0"); | 531 | const auto outputGroup = kwinApp()->config()->group("HWComposerOutputs").group("0"); | ||
533 | setScale(outputGroup.readEntry("Scale", 1)); | 532 | setScale(outputGroup.readEntry("Scale", 1)); | ||
534 | setWaylandMode(m_pixelSize, mode.refreshRate); | 533 | setWaylandMode(pixel, mode.refreshRate); | ||
535 | } | 534 | } | ||
536 | 535 | | |||
537 | HwcomposerOutput::~HwcomposerOutput() | 536 | HwcomposerOutput::~HwcomposerOutput() | ||
538 | { | 537 | { | ||
539 | hwc_close_1(m_device); | 538 | hwc_close_1(m_device); | ||
540 | } | 539 | } | ||
541 | 540 | | |||
542 | QSize HwcomposerOutput::pixelSize() const | | |||
543 | { | | |||
544 | return m_pixelSize; | | |||
545 | } | | |||
546 | | ||||
547 | bool HwcomposerOutput::isValid() const | 541 | bool HwcomposerOutput::isValid() const | ||
548 | { | 542 | { | ||
549 | return m_pixelSize.isValid(); | 543 | return isEnabled(); | ||
550 | } | 544 | } | ||
551 | 545 | | |||
552 | void HwcomposerOutput::updateDpms(KWayland::Server::OutputInterface::DpmsMode mode) | 546 | void HwcomposerOutput::updateDpms(KWayland::Server::OutputInterface::DpmsMode mode) | ||
553 | { | 547 | { | ||
554 | emit dpmsModeRequested(mode); | 548 | emit dpmsModeRequested(mode); | ||
555 | } | 549 | } | ||
556 | 550 | | |||
557 | } | 551 | } |