scene: Set preferred output scale for DND icon

Otherwise the icon will have a scale of 1, leading to blurry
drag pixmaps on Wayland.
This commit is contained in:
Kai Uwe Broulik 2023-08-02 14:01:02 +02:00
parent 8727fcb752
commit dc2965efad
3 changed files with 26 additions and 8 deletions

View file

@ -37,6 +37,13 @@ void DragAndDropIconItem::frameRendered(quint32 timestamp)
}
}
void DragAndDropIconItem::setOutput(Output *output)
{
if (m_surfaceItem && output) {
m_surfaceItem->surface()->setPreferredBufferScale(output->scale());
}
}
} // namespace KWin
#include "moc_dndiconitem.cpp"

View file

@ -6,6 +6,7 @@
#pragma once
#include "core/output.h"
#include "scene/item.h"
namespace KWaylandServer
@ -28,6 +29,8 @@ public:
void frameRendered(quint32 timestamp);
void setOutput(Output *output);
private:
std::unique_ptr<SurfaceItemWayland> m_surfaceItem;
};

View file

@ -113,15 +113,23 @@ void WorkspaceScene::createDndIconItem()
}
m_dndIcon = std::make_unique<DragAndDropIconItem>(dragIcon, this);
if (waylandServer()->seat()->isDragPointer()) {
m_dndIcon->setPosition(waylandServer()->seat()->pointerPos());
connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::pointerPosChanged, m_dndIcon.get(), [this]() {
m_dndIcon->setPosition(waylandServer()->seat()->pointerPos());
});
auto updatePosition = [this]() {
const auto pointerPos = waylandServer()->seat()->pointerPos();
m_dndIcon->setPosition(pointerPos);
m_dndIcon->setOutput(workspace()->outputAt(pointerPos));
};
updatePosition();
connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::pointerPosChanged, m_dndIcon.get(), updatePosition);
} else if (waylandServer()->seat()->isDragTouch()) {
m_dndIcon->setPosition(waylandServer()->seat()->firstTouchPointPosition());
connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::touchMoved, m_dndIcon.get(), [this]() {
m_dndIcon->setPosition(waylandServer()->seat()->firstTouchPointPosition());
});
auto updatePosition = [this]() {
const auto touchPos = waylandServer()->seat()->firstTouchPointPosition();
m_dndIcon->setPosition(touchPos);
m_dndIcon->setOutput(workspace()->outputAt(touchPos));
};
updatePosition();
connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::touchMoved, m_dndIcon.get(), updatePosition);
}
}