diff --git a/src/wayland/autotests/client/test_wayland_output.cpp b/src/wayland/autotests/client/test_wayland_output.cpp index 4d09afb5af..cde24d89af 100644 --- a/src/wayland/autotests/client/test_wayland_output.cpp +++ b/src/wayland/autotests/client/test_wayland_output.cpp @@ -75,7 +75,7 @@ void TestWaylandOutput::init() m_serverOutput = new OutputInterface(m_display, this); QCOMPARE(m_serverOutput->pixelSize(), QSize()); QCOMPARE(m_serverOutput->refreshRate(), 60000); - m_serverOutput->setMode(QSize(1024, 768)); + m_serverOutput->setMode(QSharedPointer::create(QSize(1024, 768), 60000)); QCOMPARE(m_serverOutput->pixelSize(), QSize(1024, 768)); QCOMPARE(m_serverOutput->refreshRate(), 60000); QCOMPARE(m_serverOutput->isDpmsSupported(), false); @@ -218,7 +218,7 @@ void TestWaylandOutput::testModeChange() QCOMPARE(output.refreshRate(), 60000); // change once more - m_serverOutput->setMode(QSize(1280, 1024), 90000); + m_serverOutput->setMode(QSharedPointer::create(QSize(1280, 1024), 90000)); QCOMPARE(m_serverOutput->refreshRate(), 90000); m_serverOutput->done(); QVERIFY(outputChanged.wait()); diff --git a/src/wayland/autotests/client/test_xdg_output.cpp b/src/wayland/autotests/client/test_xdg_output.cpp index dfa5e9c40b..9e6989cf68 100644 --- a/src/wayland/autotests/client/test_xdg_output.cpp +++ b/src/wayland/autotests/client/test_xdg_output.cpp @@ -59,7 +59,7 @@ void TestXdgOutput::init() QVERIFY(m_display->isRunning()); m_serverOutput = new OutputInterface(m_display, this); - m_serverOutput->setMode(QSize(1920, 1080)); + m_serverOutput->setMode(QSharedPointer::create(QSize(1920, 1080), 60000)); m_serverXdgOutputManager = new XdgOutputManagerV1Interface(m_display, this); m_serverXdgOutput = m_serverXdgOutputManager->createXdgOutput(m_serverOutput, this); diff --git a/src/wayland/autotests/client/test_xdg_shell.cpp b/src/wayland/autotests/client/test_xdg_shell.cpp index 742703b397..c40db9004e 100644 --- a/src/wayland/autotests/client/test_xdg_shell.cpp +++ b/src/wayland/autotests/client/test_xdg_shell.cpp @@ -94,9 +94,9 @@ void XdgShellTest::init() QVERIFY(m_display->isRunning()); m_display->createShm(); m_o1Interface = new OutputInterface(m_display, m_display); - m_o1Interface->setMode(QSize(1024, 768)); + m_o1Interface->setMode(QSharedPointer::create(QSize(1024, 768), 60000)); m_o2Interface = new OutputInterface(m_display, m_display); - m_o2Interface->setMode(QSize(1024, 768)); + m_o2Interface->setMode(QSharedPointer::create(QSize(1024, 768), 60000)); m_seatInterface = new SeatInterface(m_display, m_display); m_seatInterface->setHasKeyboard(true); m_seatInterface->setHasPointer(true); diff --git a/src/wayland/output_interface.cpp b/src/wayland/output_interface.cpp index 8d47167abd..e94b04d4f6 100644 --- a/src/wayland/output_interface.cpp +++ b/src/wayland/output_interface.cpp @@ -39,7 +39,7 @@ public: int scale = 1; KWin::Output::SubPixel subPixel = KWin::Output::SubPixel::Unknown; KWin::Output::Transform transform = KWin::Output::Transform::Normal; - OutputInterface::Mode mode; + QSharedPointer mode; struct { KWin::Output::DpmsMode mode = KWin::Output::DpmsMode::Off; @@ -61,7 +61,7 @@ OutputInterfacePrivate::OutputInterfacePrivate(Display *display, OutputInterface void OutputInterfacePrivate::sendMode(Resource *resource) { - send_mode(resource->handle, mode_current, mode.size.width(), mode.size.height(), mode.refreshRate); + send_mode(resource->handle, mode_current, mode->size().width(), mode->size().height(), mode->refreshRate()); } void OutputInterfacePrivate::sendScale(Resource *resource) @@ -197,22 +197,22 @@ void OutputInterface::remove() QSize OutputInterface::pixelSize() const { - return d->mode.size; + return d->mode->size(); } int OutputInterface::refreshRate() const { - return d->mode.refreshRate; + return d->mode->refreshRate(); } -OutputInterface::Mode OutputInterface::mode() const +QSharedPointer OutputInterface::mode() const { return d->mode; } -void OutputInterface::setMode(const Mode &mode) +void OutputInterface::setMode(const QSharedPointer &mode) { - if (d->mode.size == mode.size && d->mode.refreshRate == mode.refreshRate) { + if (d->mode->size() == mode->size() && d->mode->refreshRate() == mode->refreshRate()) { return; } @@ -224,13 +224,8 @@ void OutputInterface::setMode(const Mode &mode) } Q_EMIT modeChanged(); - Q_EMIT refreshRateChanged(mode.refreshRate); - Q_EMIT pixelSizeChanged(mode.size); -} - -void OutputInterface::setMode(const QSize &size, int refreshRate) -{ - setMode({size, refreshRate}); + Q_EMIT refreshRateChanged(mode->refreshRate()); + Q_EMIT pixelSizeChanged(mode->size()); } QSize OutputInterface::physicalSize() const diff --git a/src/wayland/output_interface.h b/src/wayland/output_interface.h index 26852e5df8..922ba8df0c 100644 --- a/src/wayland/output_interface.h +++ b/src/wayland/output_interface.h @@ -37,12 +37,6 @@ class KWIN_EXPORT OutputInterface : public QObject Q_PROPERTY(int refreshRate READ refreshRate NOTIFY refreshRateChanged) Q_PROPERTY(int scale READ scale WRITE setScale NOTIFY scaleChanged) public: - struct Mode - { - QSize size = QSize(); - int refreshRate = 60000; - }; - explicit OutputInterface(Display *display, QObject *parent = nullptr); ~OutputInterface() override; @@ -57,7 +51,7 @@ public: int scale() const; KWin::Output::SubPixel subPixel() const; KWin::Output::Transform transform() const; - Mode mode() const; + QSharedPointer mode() const; bool isDpmsSupported() const; KWin::Output::DpmsMode dpmsMode() const; @@ -68,8 +62,7 @@ public: void setScale(int scale); void setSubPixel(KWin::Output::SubPixel subPixel); void setTransform(KWin::Output::Transform transform); - void setMode(const Mode &mode); - void setMode(const QSize &size, int refreshRate = 60000); + void setMode(const QSharedPointer &mode); /** * Sets whether Dpms is supported for this output. diff --git a/src/wayland/tests/renderingservertest.cpp b/src/wayland/tests/renderingservertest.cpp index aa12f7e598..57823fa2ce 100644 --- a/src/wayland/tests/renderingservertest.cpp +++ b/src/wayland/tests/renderingservertest.cpp @@ -245,7 +245,7 @@ int main(int argc, char **argv) OutputInterface *output = new OutputInterface(&display, &display); output->setPhysicalSize(QSize(269, 202)); const QSize windowSize(1024, 768); - output->setMode(windowSize); + output->setMode(QSharedPointer::create(windowSize, 60000)); SeatInterface *seat = new SeatInterface(&display); seat->setHasKeyboard(true); seat->setHasPointer(true); diff --git a/src/wayland/tests/waylandservertest.cpp b/src/wayland/tests/waylandservertest.cpp index 04405dca4c..4d3dfd4628 100644 --- a/src/wayland/tests/waylandservertest.cpp +++ b/src/wayland/tests/waylandservertest.cpp @@ -77,7 +77,7 @@ int main(int argc, char **argv) new XdgShellInterface(&display, &display); OutputInterface *output = new OutputInterface(&display, &display); output->setPhysicalSize(QSize(10, 10)); - output->setMode(QSize(1024, 768)); + output->setMode(QSharedPointer::create(QSize(1024, 768), 60000)); // starts XWayland by forking and opening a pipe const int pipe = startXServer(); diff --git a/src/waylandoutput.cpp b/src/waylandoutput.cpp index 104a5e4030..3ef5418a98 100644 --- a/src/waylandoutput.cpp +++ b/src/waylandoutput.cpp @@ -28,7 +28,7 @@ WaylandOutput::WaylandOutput(Output *output, QObject *parent) m_waylandOutput->setDpmsSupported(output->capabilities() & Output::Capability::Dpms); m_waylandOutput->setGlobalPosition(geometry.topLeft()); m_waylandOutput->setScale(std::ceil(output->scale())); - m_waylandOutput->setMode(output->modeSize(), output->refreshRate()); + m_waylandOutput->setMode(output->currentMode()); m_waylandOutput->setSubPixel(output->subPixel()); m_xdgOutputV1->setName(output->name()); @@ -72,7 +72,7 @@ void WaylandOutput::update() m_waylandOutput->setGlobalPosition(geometry.topLeft()); m_waylandOutput->setScale(std::ceil(m_platformOutput->scale())); m_waylandOutput->setTransform(m_platformOutput->transform()); - m_waylandOutput->setMode(m_platformOutput->modeSize(), m_platformOutput->refreshRate()); + m_waylandOutput->setMode(m_platformOutput->currentMode()); m_xdgOutputV1->setLogicalPosition(geometry.topLeft()); m_xdgOutputV1->setLogicalSize(geometry.size());