From 22eb154fa03cb96b56592a07b9aedf0a0251d0d0 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 26 Oct 2021 13:31:36 +0300 Subject: [PATCH] platforms/wayland: Allow resizing outputs --- .../platforms/wayland/wayland_output.cpp | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/plugins/platforms/wayland/wayland_output.cpp b/src/plugins/platforms/wayland/wayland_output.cpp index c2d5384124..7a99f150cf 100644 --- a/src/plugins/platforms/wayland/wayland_output.cpp +++ b/src/plugins/platforms/wayland/wayland_output.cpp @@ -24,6 +24,7 @@ namespace Wayland { using namespace KWayland::Client; +static const int s_refreshRate = 60000; // TODO: can we get refresh rate data from Wayland host? WaylandOutput::WaylandOutput(Surface *surface, WaylandBackend *backend) : AbstractWaylandOutput(backend) @@ -60,26 +61,37 @@ RenderLoop *WaylandOutput::renderLoop() const void WaylandOutput::init(const QPoint &logicalPosition, const QSize &pixelSize) { - const int refreshRate = 60000; // TODO: can we get refresh rate data from Wayland host? - m_renderLoop->setRefreshRate(refreshRate); + m_renderLoop->setRefreshRate(s_refreshRate); + + const Mode mode { + .size = pixelSize, + .refreshRate = s_refreshRate, + .flags = ModeFlag::Current, + .id = 0, + }; - Mode mode; - mode.id = 0; - mode.size = pixelSize; - mode.flags = ModeFlag::Current; - mode.refreshRate = refreshRate; static uint i = 0; initialize(QStringLiteral("model_%1").arg(i++), "manufacturer_TODO", "eisa_TODO", "serial_TODO", pixelSize, { mode }, {}); - setGeometry(logicalPosition, pixelSize); + + moveTo(logicalPosition); + setCurrentModeInternal(mode.size, mode.refreshRate); setScale(backend()->initialOutputScale()); } void WaylandOutput::setGeometry(const QPoint &logicalPosition, const QSize &pixelSize) { - // TODO: set mode to have updated pixelSize - Q_UNUSED(pixelSize) + const Mode mode { + .size = pixelSize, + .refreshRate = s_refreshRate, + .flags = ModeFlag::Current, + .id = 0, + }; + + setModes({mode}); + setCurrentModeInternal(mode.size, mode.refreshRate); moveTo(logicalPosition); + Q_EMIT m_backend->screensQueried(); } void WaylandOutput::updateTransform(Transform transform)