--- a/src/backends/wayland/wayland_output.cpp +++ b/src/backends/wayland/wayland_output.cpp @@ -294,6 +294,11 @@ } } +qreal WaylandOutput::presentationScale() const +{ + return qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE") ? m_pendingScale : scale(); +} + bool WaylandOutput::present(const QList &layersToUpdate, const std::shared_ptr &frame) { auto cursorLayers = layersToUpdate | std::views::filter([](OutputLayer *layer) { @@ -312,7 +317,7 @@ m_surface->attachBuffer(buffer); m_mapped = true; } - m_viewport->setDestination(QSize(std::round(modeSize().width() / scale()), std::round(modeSize().height() / scale()))); + m_viewport->setDestination(QSize(std::round(modeSize().width() / presentationScale()), std::round(modeSize().height() / presentationScale()))); m_surface->setScale(1); // commit the subsurfaces before the main surface for (OutputLayer *layer : layersToUpdate) { @@ -375,9 +380,11 @@ next.enabled = props->enabled.value_or(m_state.enabled); next.transform = props->transform.value_or(m_state.transform); next.position = props->pos.value_or(m_state.position); - // intentionally ignored, as it would get overwritten - // with the fractional scale protocol anyways - // next.scale = props->scale.value_or(m_state.scale); + + if (qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")) { + next.scale = props->scale.value_or(m_state.scale); + next.scaleSetting = props->scaleSetting.value_or(m_state.scaleSetting); + } next.desiredMode = props->desiredMode.value_or(m_state.desiredMode); next.uuid = props->uuid.value_or(m_state.uuid); next.replicationSource = props->replicationSource.value_or(m_state.replicationSource); @@ -466,7 +473,9 @@ State next = m_state; next.modes = {mode}; next.currentMode = mode; - next.scale = m_pendingScale; + if (!qEnvironmentVariableIsSet("DROIDDECK_NESTED_SCALE")) { + next.scale = m_pendingScale; + } setState(next); Q_EMIT m_backend->outputsQueried(); --- a/src/backends/wayland/wayland_output.h +++ b/src/backends/wayland/wayland_output.h @@ -93,6 +93,8 @@ void init(const QSize &pixelSize, qreal scale, bool fullscreen); + + qreal presentationScale() const; bool isReady() const; KWayland::Client::Surface *surface() const; WaylandCursor *cursor() const; --- a/src/backends/wayland/wayland_backend.cpp +++ b/src/backends/wayland/wayland_backend.cpp @@ -107,8 +107,9 @@ WaylandOutput *output = m_seat->backend()->findOutput(m_pointer->enteredSurface()); Q_ASSERT(output); const auto subsurface = m_seat->backend()->findSubSurface(m_pointer->enteredSurface()); - const QPointF absolutePos = output->position() + relativeToSurface - + (subsurface ? subsurface->position() : QPoint()); + const QPointF absolutePos = output->position() + + (relativeToSurface + (subsurface ? subsurface->position() : QPoint())) + * output->presentationScale() / output->scale(); Q_EMIT pointerMotionAbsolute(absolutePos, std::chrono::milliseconds(time), this); }); connect(pointer, &Pointer::buttonStateChanged, this, [this](quint32 serial, quint32 time, quint32 button, Pointer::ButtonState nativeState) { @@ -182,7 +183,11 @@ , m_relativePointer(relativePointer) { connect(relativePointer, &RelativePointer::relativeMotion, this, [this](const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 timestamp) { - Q_EMIT pointerMotion(sizeToPoint(delta), sizeToPoint(deltaNonAccelerated), std::chrono::microseconds(timestamp), this); + const auto pointer = m_seat->pointerDevice(); + const auto output = pointer && pointer->m_pointer + ? m_seat->backend()->findOutput(pointer->m_pointer->enteredSurface()) : nullptr; + const qreal factor = output ? output->presentationScale() / output->scale() : 1.0; + Q_EMIT pointerMotion(sizeToPoint(delta) * factor, sizeToPoint(deltaNonAccelerated) * factor, std::chrono::microseconds(timestamp), this); }); } @@ -199,13 +204,19 @@ connect(touch, &Touch::sequenceStarted, this, [this](TouchPoint *tp) { auto o = m_seat->backend()->findOutput(tp->surface()); Q_ASSERT(o); - const QPointF position = o->position() + tp->position(); + const auto subsurface = m_seat->backend()->findSubSurface(tp->surface()); + const QPointF position = o->position() + + (tp->position() + (subsurface ? subsurface->position() : QPoint())) + * o->presentationScale() / o->scale(); Q_EMIT touchDown(tp->id(), position, std::chrono::milliseconds(tp->time()), this); }); connect(touch, &Touch::pointAdded, this, [this](TouchPoint *tp) { auto o = m_seat->backend()->findOutput(tp->surface()); Q_ASSERT(o); - const QPointF position = o->position() + tp->position(); + const auto subsurface = m_seat->backend()->findSubSurface(tp->surface()); + const QPointF position = o->position() + + (tp->position() + (subsurface ? subsurface->position() : QPoint())) + * o->presentationScale() / o->scale(); Q_EMIT touchDown(tp->id(), position, std::chrono::milliseconds(tp->time()), this); }); connect(touch, &Touch::pointRemoved, this, [this](TouchPoint *tp) { @@ -214,7 +225,10 @@ connect(touch, &Touch::pointMoved, this, [this](TouchPoint *tp) { auto o = m_seat->backend()->findOutput(tp->surface()); Q_ASSERT(o); - const QPointF position = o->position() + tp->position(); + const auto subsurface = m_seat->backend()->findSubSurface(tp->surface()); + const QPointF position = o->position() + + (tp->position() + (subsurface ? subsurface->position() : QPoint())) + * o->presentationScale() / o->scale(); Q_EMIT touchMotion(tp->id(), position, std::chrono::milliseconds(tp->time()), this); }); } --- a/src/backends/wayland/wayland_layer.cpp +++ b/src/backends/wayland/wayland_layer.cpp @@ -95,7 +95,7 @@ // this is a bit annoying, we need a new Wayland protocol // to do this properly with fractional scaling. Until we // have that, it may cause blurriness in some cases! - const Rect logicalTarget = targetRect().scaled(1.0 / m_output->scale()).rounded(); + const Rect logicalTarget = targetRect().scaled(1.0 / output->presentationScale()).rounded(); if (m_viewport) { m_viewport->setSource(sourceRect()); m_viewport->setDestination(logicalTarget.size()); --- a/src/backends/wayland/wayland_qpainter_backend.cpp +++ b/src/backends/wayland/wayland_qpainter_backend.cpp @@ -124,7 +124,9 @@ wl_buffer *buffer = static_cast(m_output.get())->backend()->importBuffer(m_back->buffer()); Q_ASSERT(buffer); - static_cast(m_output.get())->cursor()->update(buffer, m_back->buffer()->size() / m_output->scale(), hotspot().toPoint()); + auto output = static_cast(m_output.get()); + output->cursor()->update(buffer, m_back->buffer()->size() / output->presentationScale(), + (hotspot() * output->scale() / output->presentationScale()).toPoint()); m_swapchain->release(m_back); return true; } --- a/src/backends/wayland/wayland_egl_backend.cpp +++ b/src/backends/wayland/wayland_egl_backend.cpp @@ -202,7 +202,9 @@ wl_buffer *buffer = m_backend->backend()->importBuffer(m_buffer->buffer()); Q_ASSERT(buffer); - static_cast(m_output.get())->cursor()->update(buffer, m_buffer->buffer()->size() / m_output->scale(), (hotspot() / m_output->scale()).toPoint()); + auto output = static_cast(m_output.get()); + output->cursor()->update(buffer, m_buffer->buffer()->size() / output->presentationScale(), + (hotspot() / output->presentationScale()).toPoint()); EGLNativeFence releaseFence{m_backend->eglDisplayObject()}; m_swapchain->release(m_buffer, releaseFence.takeFileDescriptor());