diff --git a/plugins/platforms/wayland/wayland_backend.cpp b/plugins/platforms/wayland/wayland_backend.cpp --- a/plugins/platforms/wayland/wayland_backend.cpp +++ b/plugins/platforms/wayland/wayland_backend.cpp @@ -454,6 +454,7 @@ , m_connectionThread(nullptr) { connect(this, &WaylandBackend::connectionFailed, this, &WaylandBackend::initFailed); + handleOutputs(); } WaylandBackend::~WaylandBackend() @@ -707,8 +708,7 @@ return; } - waylandOutput->setScale(initialOutputScale()); - waylandOutput->setGeometry(QPoint(logicalWidthSum, 0), QSize(pixelWidth, pixelHeight)); + waylandOutput->init(QPoint(logicalWidthSum, 0), QSize(pixelWidth, pixelHeight)); connect(waylandOutput, &WaylandOutput::sizeChanged, this, [this, waylandOutput](const QSize &size) { Q_UNUSED(size) diff --git a/plugins/platforms/wayland/wayland_output.h b/plugins/platforms/wayland/wayland_output.h --- a/plugins/platforms/wayland/wayland_output.h +++ b/plugins/platforms/wayland/wayland_output.h @@ -50,9 +50,11 @@ { Q_OBJECT public: - explicit WaylandOutput(KWayland::Client::Surface *surface, QObject *parent = nullptr); + WaylandOutput(KWayland::Client::Surface *surface, WaylandBackend *backend); ~WaylandOutput() override; + void init(const QPoint &logicalPosition, const QSize &pixelSize); + virtual void lockPointer(KWayland::Client::Pointer *pointer, bool lock) { Q_UNUSED(pointer) Q_UNUSED(lock) @@ -84,8 +86,14 @@ void sizeChanged(const QSize &size); void frameRendered(); +protected: + WaylandBackend *backend() { + return m_backend; + } + private: KWayland::Client::Surface *m_surface; + WaylandBackend *m_backend; QSize m_pixelSize; bool m_rendered = false; @@ -118,7 +126,6 @@ void updateWindowTitle(); KWayland::Client::XdgShellSurface *m_xdgShellSurface = nullptr; - WaylandBackend *m_backend; int m_number; KWayland::Client::LockedPointer *m_pointerLock = nullptr; bool m_hasPointerLock = false; diff --git a/plugins/platforms/wayland/wayland_output.cpp b/plugins/platforms/wayland/wayland_output.cpp --- a/plugins/platforms/wayland/wayland_output.cpp +++ b/plugins/platforms/wayland/wayland_output.cpp @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ - #include "wayland_output.h" #include "wayland_backend.h" @@ -38,9 +37,10 @@ using namespace KWayland::Client; -WaylandOutput::WaylandOutput(Surface *surface, QObject *parent) - : AbstractWaylandOutput(parent), - m_surface(surface) +WaylandOutput::WaylandOutput(Surface *surface, WaylandBackend *backend) + : AbstractWaylandOutput(backend) + , m_surface(surface) + , m_backend(backend) { connect(surface, &Surface::frameRendered, [this] { m_rendered = true; @@ -54,6 +54,21 @@ delete m_surface; } +void WaylandOutput::init(const QPoint &logicalPosition, const QSize &pixelSize) +{ + KWayland::Server::OutputDeviceInterface::Mode mode; + mode.id = 0; + mode.size = pixelSize; + mode.flags = KWayland::Server::OutputDeviceInterface::ModeFlag::Current; + mode.refreshRate = 60000; // TODO: can we get refresh rate data from Wayland host? + AbstractWaylandOutput::initWaylandOutputDevice("model_TODO", "manufacturer_TODO", + "UUID_TODO", { mode }); + setRawPhysicalSize(pixelSize); + setEnabled(true); + setGeometry(logicalPosition, pixelSize); + setScale(backend()->initialOutputScale()); +} + QSize WaylandOutput::pixelSize() const { return m_pixelSize; @@ -81,7 +96,6 @@ XdgShellOutput::XdgShellOutput(Surface *surface, XdgShell *xdgShell, WaylandBackend *backend, int number) : WaylandOutput(surface, backend) - , m_backend(backend) , m_number(number) { m_xdgShellSurface = xdgShell->createSurface(surface, this); @@ -130,7 +144,7 @@ QString grab; if (m_hasPointerLock) { grab = i18n("Press right control to ungrab pointer"); - } else if (m_backend->pointerConstraints()) { + } else if (backend()->pointerConstraints()) { grab = i18n("Press right control key to grab pointer"); } const QString title = i18nc("Title of nested KWin Wayland with Wayland socket identifier as argument", @@ -151,13 +165,13 @@ m_pointerLock = nullptr; m_hasPointerLock = false; if (surfaceWasLocked) { - emit m_backend->pointerLockChanged(false); + emit backend()->pointerLockChanged(false); } return; } Q_ASSERT(!m_pointerLock); - m_pointerLock = m_backend->pointerConstraints()->lockPointer(surface(), pointer, nullptr, + m_pointerLock = backend()->pointerConstraints()->lockPointer(surface(), pointer, nullptr, PointerConstraints::LifeTime::OneShot, this); if (!m_pointerLock->isValid()) { @@ -168,15 +182,15 @@ connect(m_pointerLock, &LockedPointer::locked, this, [this] { m_hasPointerLock = true; - emit m_backend->pointerLockChanged(true); + emit backend()->pointerLockChanged(true); } ); connect(m_pointerLock, &LockedPointer::unlocked, this, [this] { delete m_pointerLock; m_pointerLock = nullptr; m_hasPointerLock = false; - emit m_backend->pointerLockChanged(false); + emit backend()->pointerLockChanged(false); } ); }