cursor: make position, hotspot and size floating point
This allows all pixel positions to be used on high dpi screens, and corrects damage tracking with Xwayland cursors CCBUG: 466094
This commit is contained in:
parent
7366545d0f
commit
4cd25cf571
75 changed files with 293 additions and 281 deletions
|
@ -144,7 +144,7 @@ void MoveResizeWindowTest::testMove()
|
|||
QCOMPARE(window->geometryRestore(), QRect());
|
||||
|
||||
// send some key events, not going through input redirection
|
||||
const QPoint cursorPos = Cursors::self()->mouse()->pos();
|
||||
const QPointF cursorPos = Cursors::self()->mouse()->pos();
|
||||
window->keyPressEvent(Qt::Key_Right);
|
||||
window->updateInteractiveMoveResize(Cursors::self()->mouse()->pos());
|
||||
QCOMPARE(Cursors::self()->mouse()->pos(), cursorPos + QPoint(8, 0));
|
||||
|
@ -240,7 +240,7 @@ void MoveResizeWindowTest::testResize()
|
|||
QVERIFY(states.testFlag(Test::XdgToplevel::State::Resizing));
|
||||
|
||||
// Trigger a change.
|
||||
const QPoint cursorPos = Cursors::self()->mouse()->pos();
|
||||
const QPointF cursorPos = Cursors::self()->mouse()->pos();
|
||||
window->keyPressEvent(Qt::Key_Right);
|
||||
window->updateInteractiveMoveResize(Cursors::self()->mouse()->pos());
|
||||
QCOMPARE(Cursors::self()->mouse()->pos(), cursorPos + QPoint(8, 0));
|
||||
|
|
|
@ -1659,7 +1659,7 @@ void PointerInputTest::testResizeCursor()
|
|||
cursorSurface->attachBuffer(Test::waylandShmPool()->createBuffer(arrowCursor.image()));
|
||||
cursorSurface->damage(arrowCursor.image().rect());
|
||||
cursorSurface->commit();
|
||||
pointer->setCursor(cursorSurface.get(), arrowCursor.hotSpot());
|
||||
pointer->setCursor(cursorSurface.get(), arrowCursor.hotSpot().toPoint());
|
||||
QVERIFY(cursorRenderedSpy.wait());
|
||||
|
||||
// start resizing the window
|
||||
|
@ -1727,7 +1727,7 @@ void PointerInputTest::testMoveCursor()
|
|||
cursorSurface->attachBuffer(Test::waylandShmPool()->createBuffer(arrowCursor.image()));
|
||||
cursorSurface->damage(arrowCursor.image().rect());
|
||||
cursorSurface->commit();
|
||||
pointer->setCursor(cursorSurface.get(), arrowCursor.hotSpot());
|
||||
pointer->setCursor(cursorSurface.get(), arrowCursor.hotSpot().toPoint());
|
||||
QVERIFY(cursorRenderedSpy.wait());
|
||||
|
||||
// start moving the window
|
||||
|
|
|
@ -200,18 +200,18 @@ void ScreenEdgesTest::testPushBack_data()
|
|||
{
|
||||
QTest::addColumn<KWin::ElectricBorder>("border");
|
||||
QTest::addColumn<int>("pushback");
|
||||
QTest::addColumn<QPoint>("trigger");
|
||||
QTest::addColumn<QPoint>("expected");
|
||||
QTest::addColumn<QPointF>("trigger");
|
||||
QTest::addColumn<QPointF>("expected");
|
||||
|
||||
QTest::newRow("top-left-3") << ElectricTopLeft << 3 << QPoint(0, 0) << QPoint(3, 3);
|
||||
QTest::newRow("top-5") << ElectricTop << 5 << QPoint(50, 0) << QPoint(50, 5);
|
||||
QTest::newRow("top-right-2") << ElectricTopRight << 2 << QPoint(1279, 0) << QPoint(1277, 2);
|
||||
QTest::newRow("right-10") << ElectricRight << 10 << QPoint(1279, 50) << QPoint(1269, 50);
|
||||
QTest::newRow("bottom-right-5") << ElectricBottomRight << 5 << QPoint(1279, 1023) << QPoint(1274, 1018);
|
||||
QTest::newRow("bottom-10") << ElectricBottom << 10 << QPoint(50, 1023) << QPoint(50, 1013);
|
||||
QTest::newRow("bottom-left-3") << ElectricBottomLeft << 3 << QPoint(0, 1023) << QPoint(3, 1020);
|
||||
QTest::newRow("left-10") << ElectricLeft << 10 << QPoint(0, 50) << QPoint(10, 50);
|
||||
QTest::newRow("invalid") << ElectricLeft << 10 << QPoint(50, 0) << QPoint(50, 0);
|
||||
QTest::newRow("top-left-3") << ElectricTopLeft << 3 << QPointF(0, 0) << QPointF(3, 3);
|
||||
QTest::newRow("top-5") << ElectricTop << 5 << QPointF(50, 0) << QPointF(50, 5);
|
||||
QTest::newRow("top-right-2") << ElectricTopRight << 2 << QPointF(1279, 0) << QPointF(1277, 2);
|
||||
QTest::newRow("right-10") << ElectricRight << 10 << QPointF(1279, 50) << QPointF(1269, 50);
|
||||
QTest::newRow("bottom-right-5") << ElectricBottomRight << 5 << QPointF(1279, 1023) << QPointF(1274, 1018);
|
||||
QTest::newRow("bottom-10") << ElectricBottom << 10 << QPointF(50, 1023) << QPointF(50, 1013);
|
||||
QTest::newRow("bottom-left-3") << ElectricBottomLeft << 3 << QPointF(0, 1023) << QPointF(3, 1020);
|
||||
QTest::newRow("left-10") << ElectricLeft << 10 << QPointF(0, 50) << QPointF(10, 50);
|
||||
QTest::newRow("invalid") << ElectricLeft << 10 << QPointF(50, 0) << QPointF(50, 0);
|
||||
}
|
||||
|
||||
void ScreenEdgesTest::testPushBack()
|
||||
|
@ -233,7 +233,7 @@ void ScreenEdgesTest::testPushBack()
|
|||
QFETCH(ElectricBorder, border);
|
||||
s->reserve(border, &callback, "callback");
|
||||
|
||||
QFETCH(QPoint, trigger);
|
||||
QFETCH(QPointF, trigger);
|
||||
Test::pointerMotion(trigger, 0);
|
||||
QVERIFY(spy.isEmpty());
|
||||
QTEST(Cursors::self()->mouse()->pos(), "expected");
|
||||
|
|
|
@ -419,14 +419,12 @@ void TestWindowSelection::testSelectPointPointer()
|
|||
QCOMPARE(input()->pointer()->focus(), window);
|
||||
QVERIFY(pointerEnteredSpy.wait());
|
||||
|
||||
QPoint point;
|
||||
auto callback = [&point](const QPoint &p) {
|
||||
point = p;
|
||||
};
|
||||
|
||||
// start the interaction
|
||||
QCOMPARE(input()->isSelectingWindow(), false);
|
||||
kwinApp()->startInteractivePositionSelection(callback);
|
||||
QPointF point;
|
||||
kwinApp()->startInteractivePositionSelection([&point](const QPointF &p) {
|
||||
point = p;
|
||||
});
|
||||
QCOMPARE(input()->isSelectingWindow(), true);
|
||||
QCOMPARE(point, QPoint());
|
||||
QCOMPARE(keyboardLeftSpy.count(), 0);
|
||||
|
@ -438,8 +436,8 @@ void TestWindowSelection::testSelectPointPointer()
|
|||
QCOMPARE(keyboardLeftSpy.count(), 1);
|
||||
|
||||
// trying again should not be allowed
|
||||
QPoint point2;
|
||||
kwinApp()->startInteractivePositionSelection([&point2](const QPoint &p) {
|
||||
QPointF point2;
|
||||
kwinApp()->startInteractivePositionSelection([&point2](const QPointF &p) {
|
||||
point2 = p;
|
||||
});
|
||||
QCOMPARE(point2, QPoint(-1, -1));
|
||||
|
@ -483,14 +481,12 @@ void TestWindowSelection::testSelectPointPointer()
|
|||
void TestWindowSelection::testSelectPointTouch()
|
||||
{
|
||||
// this test verifies point selection through touch works
|
||||
QPoint point;
|
||||
auto callback = [&point](const QPoint &p) {
|
||||
point = p;
|
||||
};
|
||||
|
||||
// start the interaction
|
||||
QCOMPARE(input()->isSelectingWindow(), false);
|
||||
kwinApp()->startInteractivePositionSelection(callback);
|
||||
QPointF point;
|
||||
kwinApp()->startInteractivePositionSelection([&point](const QPointF &p) {
|
||||
point = p;
|
||||
});
|
||||
QCOMPARE(input()->isSelectingWindow(), true);
|
||||
QCOMPARE(point, QPoint());
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ void X11WindowTest::testMinimumSize()
|
|||
QCOMPARE(clientStartMoveResizedSpy.count(), 1);
|
||||
QVERIFY(window->isInteractiveResize());
|
||||
|
||||
const QPoint cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
const QPointF cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
|
||||
window->keyPressEvent(Qt::Key_Left);
|
||||
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
||||
|
@ -236,7 +236,7 @@ void X11WindowTest::testMaximumSize()
|
|||
QCOMPARE(clientStartMoveResizedSpy.count(), 1);
|
||||
QVERIFY(window->isInteractiveResize());
|
||||
|
||||
const QPoint cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
const QPointF cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
|
||||
window->keyPressEvent(Qt::Key_Right);
|
||||
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
||||
|
@ -342,7 +342,7 @@ void X11WindowTest::testResizeIncrements()
|
|||
QCOMPARE(clientStartMoveResizedSpy.count(), 1);
|
||||
QVERIFY(window->isInteractiveResize());
|
||||
|
||||
const QPoint cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
const QPointF cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
|
||||
window->keyPressEvent(Qt::Key_Right);
|
||||
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
||||
|
@ -426,7 +426,7 @@ void X11WindowTest::testResizeIncrementsNoBaseSize()
|
|||
QCOMPARE(clientStartMoveResizedSpy.count(), 1);
|
||||
QVERIFY(window->isInteractiveResize());
|
||||
|
||||
const QPoint cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
const QPointF cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
|
||||
window->keyPressEvent(Qt::Key_Right);
|
||||
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
||||
|
|
|
@ -330,7 +330,7 @@ void TestXdgShellWindowRules::testPositionApply()
|
|||
QVERIFY(m_window->isInteractiveMove());
|
||||
QVERIFY(!m_window->isInteractiveResize());
|
||||
|
||||
const QPoint cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
const QPointF cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
m_window->keyPressEvent(Qt::Key_Right);
|
||||
m_window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
||||
QCOMPARE(KWin::Cursors::self()->mouse()->pos(), cursorPos + QPoint(8, 0));
|
||||
|
@ -379,7 +379,7 @@ void TestXdgShellWindowRules::testPositionRemember()
|
|||
QVERIFY(m_window->isInteractiveMove());
|
||||
QVERIFY(!m_window->isInteractiveResize());
|
||||
|
||||
const QPoint cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
const QPointF cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
m_window->keyPressEvent(Qt::Key_Right);
|
||||
m_window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
||||
QCOMPARE(KWin::Cursors::self()->mouse()->pos(), cursorPos + QPoint(8, 0));
|
||||
|
@ -471,7 +471,7 @@ void TestXdgShellWindowRules::testPositionApplyNow()
|
|||
QVERIFY(m_window->isInteractiveMove());
|
||||
QVERIFY(!m_window->isInteractiveResize());
|
||||
|
||||
const QPoint cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
const QPointF cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
m_window->keyPressEvent(Qt::Key_Right);
|
||||
m_window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
||||
QCOMPARE(KWin::Cursors::self()->mouse()->pos(), cursorPos + QPoint(8, 0));
|
||||
|
@ -599,7 +599,7 @@ void TestXdgShellWindowRules::testSizeApply()
|
|||
QVERIFY(states.testFlag(Test::XdgToplevel::State::Resizing));
|
||||
m_shellSurface->xdgSurface()->ack_configure(m_surfaceConfigureRequestedSpy->last().at(0).value<quint32>());
|
||||
|
||||
const QPoint cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
const QPointF cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
m_window->keyPressEvent(Qt::Key_Right);
|
||||
m_window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
||||
QCOMPARE(KWin::Cursors::self()->mouse()->pos(), cursorPos + QPoint(8, 0));
|
||||
|
@ -696,7 +696,7 @@ void TestXdgShellWindowRules::testSizeRemember()
|
|||
QVERIFY(states.testFlag(Test::XdgToplevel::State::Resizing));
|
||||
m_shellSurface->xdgSurface()->ack_configure(m_surfaceConfigureRequestedSpy->last().at(0).value<quint32>());
|
||||
|
||||
const QPoint cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
const QPointF cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
m_window->keyPressEvent(Qt::Key_Right);
|
||||
m_window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
||||
QCOMPARE(KWin::Cursors::self()->mouse()->pos(), cursorPos + QPoint(8, 0));
|
||||
|
|
|
@ -1257,7 +1257,7 @@ void TestXdgShellWindow::testXdgWindowGeometryInteractiveResize()
|
|||
QVERIFY(states.testFlag(Test::XdgToplevel::State::Resizing));
|
||||
|
||||
// Go right.
|
||||
QPoint cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
QPointF cursorPos = KWin::Cursors::self()->mouse()->pos();
|
||||
window->keyPressEvent(Qt::Key_Right);
|
||||
window->updateInteractiveMoveResize(KWin::Cursors::self()->mouse()->pos());
|
||||
QCOMPARE(KWin::Cursors::self()->mouse()->pos(), cursorPos + QPoint(8, 0));
|
||||
|
|
|
@ -158,9 +158,9 @@ bool DrmOutput::setCursor(CursorSource *source)
|
|||
}
|
||||
bool rendered = false;
|
||||
const QMatrix4x4 monitorMatrix = logicalToNativeMatrix(rect(), scale(), transform());
|
||||
const QSize cursorSize = m_cursor.source->size();
|
||||
const QRect cursorRect = QRect(m_cursor.position, cursorSize);
|
||||
const QRect nativeCursorRect = monitorMatrix.mapRect(cursorRect);
|
||||
const QSizeF cursorSize = m_cursor.source->size();
|
||||
const QRectF cursorRect = QRectF(m_cursor.position, cursorSize);
|
||||
const QRectF nativeCursorRect = monitorMatrix.mapRect(cursorRect);
|
||||
if (nativeCursorRect.width() <= m_gpu->cursorSize().width() && nativeCursorRect.height() <= m_gpu->cursorSize().height()) {
|
||||
if (auto beginInfo = layer->beginFrame()) {
|
||||
RenderTarget *renderTarget = &beginInfo->renderTarget;
|
||||
|
@ -186,24 +186,24 @@ bool DrmOutput::setCursor(CursorSource *source)
|
|||
}
|
||||
|
||||
const QSize layerSize = m_gpu->cursorSize() / scale();
|
||||
const QRect layerRect = monitorMatrix.mapRect(QRect(m_cursor.position, layerSize));
|
||||
const QRectF layerRect = monitorMatrix.mapRect(QRectF(m_cursor.position, layerSize));
|
||||
layer->setVisible(cursorRect.intersects(rect()));
|
||||
if (layer->isVisible()) {
|
||||
m_setCursorSuccessful = m_pipeline->setCursor(logicalToNativeMatrix(QRect(QPoint(), layerRect.size()), scale(), transform()).map(m_cursor.source->hotspot()));
|
||||
m_setCursorSuccessful = m_pipeline->setCursor(logicalToNativeMatrix(QRectF(QPoint(), layerRect.size()), scale(), transform()).map(m_cursor.source->hotspot()).toPoint());
|
||||
layer->setVisible(m_setCursorSuccessful);
|
||||
}
|
||||
return m_setCursorSuccessful;
|
||||
}
|
||||
|
||||
bool DrmOutput::moveCursor(const QPoint &position)
|
||||
bool DrmOutput::moveCursor(const QPointF &position)
|
||||
{
|
||||
if (!m_setCursorSuccessful || !m_pipeline->crtc()) {
|
||||
return false;
|
||||
}
|
||||
m_cursor.position = position;
|
||||
|
||||
const QSize cursorSize = m_cursor.source ? m_cursor.source->size() : QSize(0, 0);
|
||||
const QRect cursorRect = QRect(m_cursor.position, cursorSize);
|
||||
const QSizeF cursorSize = m_cursor.source ? m_cursor.source->size() : QSize(0, 0);
|
||||
const QRectF cursorRect = QRectF(m_cursor.position, cursorSize);
|
||||
|
||||
if (!cursorRect.intersects(rect())) {
|
||||
const auto layer = m_pipeline->cursorLayer();
|
||||
|
@ -214,12 +214,12 @@ bool DrmOutput::moveCursor(const QPoint &position)
|
|||
return true;
|
||||
}
|
||||
const QMatrix4x4 monitorMatrix = logicalToNativeMatrix(rect(), scale(), transform());
|
||||
const QSize layerSize = m_gpu->cursorSize() / scale();
|
||||
const QRect layerRect = monitorMatrix.mapRect(QRect(m_cursor.position, layerSize));
|
||||
const QSizeF layerSize = m_gpu->cursorSize() / scale();
|
||||
const QRectF layerRect = monitorMatrix.mapRect(QRectF(m_cursor.position, layerSize));
|
||||
const auto layer = m_pipeline->cursorLayer();
|
||||
const bool wasVisible = layer->isVisible();
|
||||
layer->setVisible(true);
|
||||
layer->setPosition(layerRect.topLeft());
|
||||
layer->setPosition(layerRect.topLeft().toPoint());
|
||||
m_moveCursorSuccessful = m_pipeline->moveCursor();
|
||||
layer->setVisible(m_moveCursorSuccessful);
|
||||
if (!m_moveCursorSuccessful || !wasVisible) {
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
void updateDpmsMode(DpmsMode dpmsMode);
|
||||
|
||||
bool setCursor(CursorSource *source) override;
|
||||
bool moveCursor(const QPoint &position) override;
|
||||
bool moveCursor(const QPointF &position) override;
|
||||
|
||||
DrmLease *lease() const;
|
||||
bool addLeaseObjects(QVector<uint32_t> &objectList);
|
||||
|
@ -76,7 +76,7 @@ private:
|
|||
|
||||
struct {
|
||||
QPointer<CursorSource> source;
|
||||
QPoint position;
|
||||
QPointF position;
|
||||
} m_cursor;
|
||||
};
|
||||
|
||||
|
|
|
@ -242,7 +242,8 @@ std::optional<OutputLayerBeginFrameInfo> WaylandEglCursorLayer::beginFrame()
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
const QSize bufferSize = size().expandedTo(QSize(64, 64));
|
||||
const auto tmp = size().expandedTo(QSize(64, 64));
|
||||
const QSize bufferSize(std::ceil(tmp.width()), std::ceil(tmp.height()));
|
||||
if (!m_swapchain || m_swapchain->size() != bufferSize) {
|
||||
const WaylandLinuxDmabufV1 *dmabuf = m_backend->backend()->display()->linuxDmabuf();
|
||||
const uint32_t format = DRM_FORMAT_ARGB8888;
|
||||
|
@ -266,7 +267,7 @@ bool WaylandEglCursorLayer::endFrame(const QRegion &renderedRegion, const QRegio
|
|||
// Flush rendering commands to the dmabuf.
|
||||
glFlush();
|
||||
|
||||
m_output->cursor()->update(m_buffer->buffer(), scale(), hotspot());
|
||||
m_output->cursor()->update(m_buffer->buffer(), scale(), hotspot().toPoint());
|
||||
|
||||
m_swapchain->release(m_buffer);
|
||||
return true;
|
||||
|
|
|
@ -214,7 +214,7 @@ bool WaylandOutput::setCursor(CursorSource *source)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool WaylandOutput::moveCursor(const QPoint &position)
|
||||
bool WaylandOutput::moveCursor(const QPointF &position)
|
||||
{
|
||||
// The cursor position is controlled by the host compositor.
|
||||
return !m_hasPointerLock;
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
|
||||
RenderLoop *renderLoop() const override;
|
||||
bool setCursor(CursorSource *source) override;
|
||||
bool moveCursor(const QPoint &position) override;
|
||||
bool moveCursor(const QPointF &position) override;
|
||||
|
||||
void init(const QSize &pixelSize, qreal scale);
|
||||
|
||||
|
|
|
@ -140,7 +140,8 @@ WaylandQPainterCursorLayer::~WaylandQPainterCursorLayer()
|
|||
|
||||
std::optional<OutputLayerBeginFrameInfo> WaylandQPainterCursorLayer::beginFrame()
|
||||
{
|
||||
const QSize bufferSize = size().expandedTo(QSize(64, 64));
|
||||
const auto tmp = size().expandedTo(QSize(64, 64));
|
||||
const QSize bufferSize(std::ceil(tmp.width()), std::ceil(tmp.height()));
|
||||
if (m_backingStore.size() != bufferSize) {
|
||||
m_backingStore = QImage(bufferSize, QImage::Format_ARGB32_Premultiplied);
|
||||
}
|
||||
|
@ -154,7 +155,7 @@ std::optional<OutputLayerBeginFrameInfo> WaylandQPainterCursorLayer::beginFrame(
|
|||
bool WaylandQPainterCursorLayer::endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion)
|
||||
{
|
||||
KWayland::Client::Buffer::Ptr buffer = m_output->backend()->display()->shmPool()->createBuffer(m_backingStore);
|
||||
m_output->cursor()->update(*buffer.lock(), scale(), hotspot());
|
||||
m_output->cursor()->update(*buffer.lock(), scale(), hotspot().toPoint());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ void X11StandaloneBackend::startInteractiveWindowSelection(std::function<void(KW
|
|||
m_windowSelector->start(callback, cursorName);
|
||||
}
|
||||
|
||||
void X11StandaloneBackend::startInteractivePositionSelection(std::function<void(const QPoint &)> callback)
|
||||
void X11StandaloneBackend::startInteractivePositionSelection(std::function<void(const QPointF &)> callback)
|
||||
{
|
||||
if (!m_windowSelector) {
|
||||
m_windowSelector = std::make_unique<WindowSelector>();
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
std::unique_ptr<Edge> createScreenEdge(ScreenEdges *parent);
|
||||
void createPlatformCursor(QObject *parent = nullptr);
|
||||
void startInteractiveWindowSelection(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName = QByteArray());
|
||||
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback);
|
||||
void startInteractivePositionSelection(std::function<void(const QPointF &)> callback);
|
||||
PlatformCursorImage cursorImage() const;
|
||||
std::unique_ptr<OutlineVisual> createOutline(Outline *outline);
|
||||
void createEffectsHandler(Compositor *compositor, WorkspaceScene *scene);
|
||||
|
|
|
@ -52,7 +52,7 @@ X11Cursor::~X11Cursor()
|
|||
|
||||
void X11Cursor::doSetPos()
|
||||
{
|
||||
const QPoint &pos = currentPos();
|
||||
const QPointF &pos = currentPos();
|
||||
xcb_warp_pointer(connection(), XCB_WINDOW_NONE, rootWindow(), 0, 0, 0, 0, pos.x(), pos.y());
|
||||
// call default implementation to emit signal
|
||||
Cursor::doSetPos();
|
||||
|
@ -70,7 +70,7 @@ void X11Cursor::doGetPos()
|
|||
return;
|
||||
}
|
||||
m_buttonMask = pointer->mask;
|
||||
updatePos(pointer->root_x, pointer->root_y);
|
||||
updatePos(QPointF(pointer->root_x, pointer->root_y));
|
||||
m_resetTimeStampTimer.start(0);
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ void X11Cursor::doStopCursorTracking()
|
|||
|
||||
void X11Cursor::mousePolled()
|
||||
{
|
||||
static QPoint lastPos = currentPos();
|
||||
static QPointF lastPos = currentPos();
|
||||
static uint16_t lastMask = m_buttonMask;
|
||||
doGetPos(); // Update if needed
|
||||
if (lastPos != currentPos() || lastMask != m_buttonMask) {
|
||||
|
|
|
@ -59,7 +59,7 @@ void WindowSelector::start(std::function<void(KWin::Window *)> callback, const Q
|
|||
m_callback = callback;
|
||||
}
|
||||
|
||||
void WindowSelector::start(std::function<void(const QPoint &)> callback)
|
||||
void WindowSelector::start(std::function<void(const QPointF &)> callback)
|
||||
{
|
||||
if (m_active) {
|
||||
callback(QPoint(-1, -1));
|
||||
|
@ -216,7 +216,7 @@ void WindowSelector::release()
|
|||
ungrabXServer();
|
||||
m_active = false;
|
||||
m_callback = std::function<void(KWin::Window *)>();
|
||||
m_pointSelectionFallback = std::function<void(const QPoint &)>();
|
||||
m_pointSelectionFallback = std::function<void(const QPointF &)>();
|
||||
}
|
||||
|
||||
void WindowSelector::selectWindowId(xcb_window_t window_to_select)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include <functional>
|
||||
|
||||
class QPoint;
|
||||
class QPointF;
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ public:
|
|||
~WindowSelector() override;
|
||||
|
||||
void start(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName);
|
||||
void start(std::function<void(const QPoint &)> callback);
|
||||
void start(std::function<void(const QPointF &)> callback);
|
||||
bool isActive() const
|
||||
{
|
||||
return m_active;
|
||||
|
@ -50,7 +50,7 @@ private:
|
|||
void cancelCallback();
|
||||
bool m_active;
|
||||
std::function<void(KWin::Window *)> m_callback;
|
||||
std::function<void(const QPoint &)> m_pointSelectionFallback;
|
||||
std::function<void(const QPointF &)> m_pointSelectionFallback;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -89,7 +89,8 @@ std::optional<OutputLayerBeginFrameInfo> X11WindowedEglCursorLayer::beginFrame()
|
|||
{
|
||||
eglMakeCurrent(m_backend->eglDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, m_backend->context());
|
||||
|
||||
const QSize bufferSize = size().expandedTo(QSize(64, 64));
|
||||
const auto tmp = size().expandedTo(QSize(64, 64));
|
||||
const QSize bufferSize(std::ceil(tmp.width()), std::ceil(tmp.height()));
|
||||
if (!m_texture || m_texture->size() != bufferSize) {
|
||||
m_texture = std::make_unique<GLTexture>(GL_RGBA8, bufferSize);
|
||||
m_framebuffer = std::make_unique<GLFramebuffer>(m_texture.get());
|
||||
|
|
|
@ -44,7 +44,7 @@ X11WindowedCursor::~X11WindowedCursor()
|
|||
}
|
||||
}
|
||||
|
||||
void X11WindowedCursor::update(const QImage &image, const QPoint &hotspot)
|
||||
void X11WindowedCursor::update(const QImage &image, const QPointF &hotspot)
|
||||
{
|
||||
X11WindowedBackend *backend = m_output->backend();
|
||||
|
||||
|
@ -314,7 +314,7 @@ bool X11WindowedOutput::setCursor(CursorSource *source)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool X11WindowedOutput::moveCursor(const QPoint &position)
|
||||
bool X11WindowedOutput::moveCursor(const QPointF &position)
|
||||
{
|
||||
// The cursor position is controlled by the host compositor.
|
||||
return true;
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
explicit X11WindowedCursor(X11WindowedOutput *output);
|
||||
~X11WindowedCursor();
|
||||
|
||||
void update(const QImage &image, const QPoint &hotspot);
|
||||
void update(const QImage &image, const QPointF &hotspot);
|
||||
|
||||
private:
|
||||
X11WindowedOutput *m_output;
|
||||
|
@ -71,7 +71,7 @@ public:
|
|||
QPointF mapFromGlobal(const QPointF &pos) const;
|
||||
|
||||
bool setCursor(CursorSource *source) override;
|
||||
bool moveCursor(const QPoint &position) override;
|
||||
bool moveCursor(const QPointF &position) override;
|
||||
|
||||
QRegion exposedArea() const;
|
||||
void addExposedArea(const QRect &rect);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "x11_windowed_output.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <cmath>
|
||||
#include <string.h>
|
||||
#include <sys/shm.h>
|
||||
#include <xcb/present.h>
|
||||
|
@ -179,7 +180,8 @@ X11WindowedQPainterCursorLayer::X11WindowedQPainterCursorLayer(X11WindowedOutput
|
|||
|
||||
std::optional<OutputLayerBeginFrameInfo> X11WindowedQPainterCursorLayer::beginFrame()
|
||||
{
|
||||
const QSize bufferSize = size().expandedTo(QSize(64, 64));
|
||||
const auto tmp = size().expandedTo(QSize(64, 64));
|
||||
const QSize bufferSize(std::ceil(tmp.width()), std::ceil(tmp.height()));
|
||||
if (m_buffer.size() != bufferSize) {
|
||||
m_buffer = QImage(bufferSize, QImage::Format_ARGB32_Premultiplied);
|
||||
}
|
||||
|
|
|
@ -449,7 +449,7 @@ void Compositor::addOutput(Output *output)
|
|||
|
||||
auto updateCursorLayer = [output, cursorLayer]() {
|
||||
const Cursor *cursor = Cursors::self()->currentCursor();
|
||||
const QRect layerRect = output->mapFromGlobal(cursor->geometry());
|
||||
const QRectF layerRect = output->mapFromGlobal(cursor->geometry());
|
||||
bool usesHardwareCursor = false;
|
||||
if (!Cursors::self()->isCursorHidden()) {
|
||||
usesHardwareCursor = output->setCursor(cursor->source()) && output->moveCursor(layerRect.topLeft());
|
||||
|
@ -462,7 +462,7 @@ void Compositor::addOutput(Output *output)
|
|||
};
|
||||
auto moveCursorLayer = [output, cursorLayer]() {
|
||||
const Cursor *cursor = Cursors::self()->currentCursor();
|
||||
const QRect layerRect = output->mapFromGlobal(cursor->geometry());
|
||||
const QRectF layerRect = output->mapFromGlobal(cursor->geometry());
|
||||
const bool usesHardwareCursor = output->moveCursor(layerRect.topLeft());
|
||||
cursorLayer->setVisible(cursor->isOnOutput(output) && !usesHardwareCursor);
|
||||
cursorLayer->setGeometry(layerRect);
|
||||
|
@ -682,7 +682,7 @@ void Compositor::composite(RenderLoop *renderLoop)
|
|||
auto &[renderTarget, repaint] = beginInfo.value();
|
||||
renderTarget.setDevicePixelRatio(output->scale());
|
||||
|
||||
const QRegion bufferDamage = surfaceDamage.united(repaint).intersected(superLayer->rect());
|
||||
const QRegion bufferDamage = surfaceDamage.united(repaint).intersected(superLayer->rect().toAlignedRect());
|
||||
primaryLayer->aboutToStartPainting(bufferDamage);
|
||||
|
||||
paintPass(superLayer, &renderTarget, bufferDamage);
|
||||
|
|
|
@ -321,7 +321,7 @@ Output::DpmsMode Output::dpmsMode() const
|
|||
return m_state.dpmsMode;
|
||||
}
|
||||
|
||||
QMatrix4x4 Output::logicalToNativeMatrix(const QRect &rect, qreal scale, Transform transform)
|
||||
QMatrix4x4 Output::logicalToNativeMatrix(const QRectF &rect, qreal scale, Transform transform)
|
||||
{
|
||||
QMatrix4x4 matrix;
|
||||
matrix.scale(scale);
|
||||
|
@ -421,7 +421,7 @@ bool Output::setCursor(CursorSource *source)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Output::moveCursor(const QPoint &position)
|
||||
bool Output::moveCursor(const QPointF &position)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ public:
|
|||
/**
|
||||
* Returns a matrix that can translate into the display's coordinates system
|
||||
*/
|
||||
static QMatrix4x4 logicalToNativeMatrix(const QRect &rect, qreal scale, Transform transform);
|
||||
static QMatrix4x4 logicalToNativeMatrix(const QRectF &rect, qreal scale, Transform transform);
|
||||
|
||||
void setVrrPolicy(RenderLoop::VrrPolicy policy);
|
||||
RenderLoop::VrrPolicy vrrPolicy() const;
|
||||
|
@ -261,7 +261,7 @@ public:
|
|||
virtual void setColorTransformation(const std::shared_ptr<ColorTransformation> &transformation);
|
||||
|
||||
virtual bool setCursor(CursorSource *source);
|
||||
virtual bool moveCursor(const QPoint &position);
|
||||
virtual bool moveCursor(const QPointF &position);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
|
|
|
@ -24,22 +24,22 @@ void OutputLayer::setScale(qreal scale)
|
|||
m_scale = scale;
|
||||
}
|
||||
|
||||
QPoint OutputLayer::hotspot() const
|
||||
QPointF OutputLayer::hotspot() const
|
||||
{
|
||||
return m_hotspot;
|
||||
}
|
||||
|
||||
void OutputLayer::setHotspot(const QPoint &hotspot)
|
||||
void OutputLayer::setHotspot(const QPointF &hotspot)
|
||||
{
|
||||
m_hotspot = hotspot;
|
||||
}
|
||||
|
||||
QSize OutputLayer::size() const
|
||||
QSizeF OutputLayer::size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
void OutputLayer::setSize(const QSize &size)
|
||||
void OutputLayer::setSize(const QSizeF &size)
|
||||
{
|
||||
m_size = size;
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@ public:
|
|||
qreal scale() const;
|
||||
void setScale(qreal scale);
|
||||
|
||||
QPoint hotspot() const;
|
||||
void setHotspot(const QPoint &hotspot);
|
||||
QPointF hotspot() const;
|
||||
void setHotspot(const QPointF &hotspot);
|
||||
|
||||
QSize size() const;
|
||||
void setSize(const QSize &size);
|
||||
QSizeF size() const;
|
||||
void setSize(const QSizeF &size);
|
||||
|
||||
QRegion repaints() const;
|
||||
void resetRepaints();
|
||||
|
@ -61,8 +61,8 @@ public:
|
|||
|
||||
private:
|
||||
QRegion m_repaints;
|
||||
QPoint m_hotspot;
|
||||
QSize m_size;
|
||||
QPointF m_hotspot;
|
||||
QSizeF m_size;
|
||||
qreal m_scale = 1.0;
|
||||
};
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ void RenderLayer::setOutputLayer(OutputLayer *layer)
|
|||
return;
|
||||
}
|
||||
if (m_outputLayer) {
|
||||
m_outputLayer->addRepaint(mapToGlobal(boundingRect()));
|
||||
m_outputLayer->addRepaint(mapToGlobal(boundingRect()).toAlignedRect());
|
||||
}
|
||||
m_outputLayer = layer;
|
||||
for (RenderLayer *sublayer : std::as_const(m_sublayers)) {
|
||||
|
@ -101,28 +101,28 @@ void RenderLayer::setDelegate(std::unique_ptr<RenderLayerDelegate> delegate)
|
|||
m_delegate->setLayer(this);
|
||||
}
|
||||
|
||||
QRect RenderLayer::rect() const
|
||||
QRectF RenderLayer::rect() const
|
||||
{
|
||||
return QRect(0, 0, m_geometry.width(), m_geometry.height());
|
||||
}
|
||||
|
||||
QRect RenderLayer::boundingRect() const
|
||||
QRectF RenderLayer::boundingRect() const
|
||||
{
|
||||
return m_boundingRect;
|
||||
}
|
||||
|
||||
QRect RenderLayer::geometry() const
|
||||
QRectF RenderLayer::geometry() const
|
||||
{
|
||||
return m_geometry;
|
||||
}
|
||||
|
||||
void RenderLayer::setGeometry(const QRect &geometry)
|
||||
void RenderLayer::setGeometry(const QRectF &geometry)
|
||||
{
|
||||
if (m_geometry == geometry) {
|
||||
return;
|
||||
}
|
||||
if (m_effectiveVisible && m_outputLayer) {
|
||||
m_outputLayer->addRepaint(mapToGlobal(boundingRect()));
|
||||
m_outputLayer->addRepaint(mapToGlobal(boundingRect()).toAlignedRect());
|
||||
}
|
||||
|
||||
m_geometry = geometry;
|
||||
|
@ -136,7 +136,7 @@ void RenderLayer::setGeometry(const QRect &geometry)
|
|||
|
||||
void RenderLayer::updateBoundingRect()
|
||||
{
|
||||
QRect boundingRect = rect();
|
||||
QRectF boundingRect = rect();
|
||||
for (const RenderLayer *sublayer : std::as_const(m_sublayers)) {
|
||||
boundingRect |= sublayer->boundingRect().translated(sublayer->geometry().topLeft());
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ void RenderLayer::updateBoundingRect()
|
|||
|
||||
void RenderLayer::addRepaintFull()
|
||||
{
|
||||
addRepaint(rect());
|
||||
addRepaint(rect().toAlignedRect());
|
||||
}
|
||||
|
||||
void RenderLayer::addRepaint(int x, int y, int width, int height)
|
||||
|
@ -216,7 +216,7 @@ void RenderLayer::updateEffectiveVisibility()
|
|||
addRepaintFull();
|
||||
} else {
|
||||
if (m_outputLayer) {
|
||||
m_outputLayer->addRepaint(mapToGlobal(boundingRect()));
|
||||
m_outputLayer->addRepaint(mapToGlobal(boundingRect()).toAlignedRect());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,12 @@ void RenderLayer::updateEffectiveVisibility()
|
|||
|
||||
QPoint RenderLayer::mapToGlobal(const QPoint &point) const
|
||||
{
|
||||
QPoint result = point;
|
||||
return mapToGlobal(QPointF(point)).toPoint();
|
||||
}
|
||||
|
||||
QPointF RenderLayer::mapToGlobal(const QPointF &point) const
|
||||
{
|
||||
QPointF result = point;
|
||||
const RenderLayer *layer = this;
|
||||
while (layer) {
|
||||
result += layer->geometry().topLeft();
|
||||
|
@ -241,6 +246,11 @@ QRect RenderLayer::mapToGlobal(const QRect &rect) const
|
|||
return rect.translated(mapToGlobal(QPoint(0, 0)));
|
||||
}
|
||||
|
||||
QRectF RenderLayer::mapToGlobal(const QRectF &rect) const
|
||||
{
|
||||
return rect.translated(mapToGlobal(QPointF(0, 0)));
|
||||
}
|
||||
|
||||
QRegion RenderLayer::mapToGlobal(const QRegion ®ion) const
|
||||
{
|
||||
if (region.isEmpty()) {
|
||||
|
@ -251,7 +261,12 @@ QRegion RenderLayer::mapToGlobal(const QRegion ®ion) const
|
|||
|
||||
QPoint RenderLayer::mapFromGlobal(const QPoint &point) const
|
||||
{
|
||||
QPoint result = point;
|
||||
return mapFromGlobal(QPointF(point)).toPoint();
|
||||
}
|
||||
|
||||
QPointF RenderLayer::mapFromGlobal(const QPointF &point) const
|
||||
{
|
||||
QPointF result = point;
|
||||
const RenderLayer *layer = this;
|
||||
while (layer) {
|
||||
result -= layer->geometry().topLeft();
|
||||
|
@ -265,6 +280,11 @@ QRect RenderLayer::mapFromGlobal(const QRect &rect) const
|
|||
return rect.translated(mapFromGlobal(QPoint(0, 0)));
|
||||
}
|
||||
|
||||
QRectF RenderLayer::mapFromGlobal(const QRectF &rect) const
|
||||
{
|
||||
return rect.translated(mapFromGlobal(QPointF(0, 0)));
|
||||
}
|
||||
|
||||
QRegion RenderLayer::mapFromGlobal(const QRegion ®ion) const
|
||||
{
|
||||
if (region.isEmpty()) {
|
||||
|
|
|
@ -55,18 +55,22 @@ public:
|
|||
void setVisible(bool visible);
|
||||
|
||||
QPoint mapToGlobal(const QPoint &point) const;
|
||||
QPointF mapToGlobal(const QPointF &point) const;
|
||||
QRegion mapToGlobal(const QRegion ®ion) const;
|
||||
QRect mapToGlobal(const QRect &rect) const;
|
||||
QRectF mapToGlobal(const QRectF &rect) const;
|
||||
|
||||
QPoint mapFromGlobal(const QPoint &point) const;
|
||||
QPointF mapFromGlobal(const QPointF &point) const;
|
||||
QRegion mapFromGlobal(const QRegion ®ion) const;
|
||||
QRect mapFromGlobal(const QRect &rect) const;
|
||||
QRectF mapFromGlobal(const QRectF &rect) const;
|
||||
|
||||
QRect rect() const;
|
||||
QRect boundingRect() const;
|
||||
QRectF rect() const;
|
||||
QRectF boundingRect() const;
|
||||
|
||||
QRect geometry() const;
|
||||
void setGeometry(const QRect &rect);
|
||||
QRectF geometry() const;
|
||||
void setGeometry(const QRectF &rect);
|
||||
|
||||
void addRepaint(const QRegion ®ion);
|
||||
void addRepaint(const QRect &rect);
|
||||
|
@ -85,8 +89,8 @@ private:
|
|||
RenderLoop *m_loop;
|
||||
std::unique_ptr<RenderLayerDelegate> m_delegate;
|
||||
QRegion m_repaints;
|
||||
QRect m_boundingRect;
|
||||
QRect m_geometry;
|
||||
QRectF m_boundingRect;
|
||||
QRectF m_geometry;
|
||||
QPointer<OutputLayer> m_outputLayer;
|
||||
RenderLayer *m_superlayer = nullptr;
|
||||
QList<RenderLayer *> m_sublayers;
|
||||
|
|
|
@ -45,7 +45,7 @@ void Cursors::addCursor(Cursor *cursor)
|
|||
Q_ASSERT(!m_cursors.contains(cursor));
|
||||
m_cursors += cursor;
|
||||
|
||||
connect(cursor, &Cursor::posChanged, this, [this, cursor](const QPoint &pos) {
|
||||
connect(cursor, &Cursor::posChanged, this, [this, cursor](const QPointF &pos) {
|
||||
setCurrentCursor(cursor);
|
||||
Q_EMIT positionChanged(cursor, pos);
|
||||
});
|
||||
|
@ -186,40 +186,35 @@ QImage Cursor::image() const
|
|||
return m_source->image();
|
||||
}
|
||||
|
||||
QPoint Cursor::hotspot() const
|
||||
QPointF Cursor::hotspot() const
|
||||
{
|
||||
if (Q_UNLIKELY(!m_source)) {
|
||||
return QPoint();
|
||||
return QPointF();
|
||||
}
|
||||
return m_source->hotspot();
|
||||
}
|
||||
|
||||
QRect Cursor::geometry() const
|
||||
QRectF Cursor::geometry() const
|
||||
{
|
||||
return rect().translated(m_pos - hotspot());
|
||||
}
|
||||
|
||||
QRect Cursor::rect() const
|
||||
QRectF Cursor::rect() const
|
||||
{
|
||||
if (Q_UNLIKELY(!m_source)) {
|
||||
return QRect();
|
||||
return QRectF();
|
||||
} else {
|
||||
return QRect(QPoint(0, 0), m_source->size());
|
||||
return QRectF(QPointF(0, 0), m_source->size());
|
||||
}
|
||||
}
|
||||
|
||||
QPoint Cursor::pos()
|
||||
QPointF Cursor::pos()
|
||||
{
|
||||
doGetPos();
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
void Cursor::setPos(const QPointF &pos)
|
||||
{
|
||||
setPos(pos.toPoint());
|
||||
}
|
||||
|
||||
void Cursor::setPos(const QPoint &pos)
|
||||
{
|
||||
// first query the current pos to not warp to the already existing pos
|
||||
if (pos == m_pos) {
|
||||
|
@ -229,11 +224,6 @@ void Cursor::setPos(const QPoint &pos)
|
|||
doSetPos();
|
||||
}
|
||||
|
||||
void Cursor::setPos(int x, int y)
|
||||
{
|
||||
setPos(QPoint(x, y));
|
||||
}
|
||||
|
||||
void Cursor::markAsRendered(std::chrono::milliseconds timestamp)
|
||||
{
|
||||
Q_EMIT rendered(timestamp);
|
||||
|
@ -288,7 +278,7 @@ void Cursor::doGetPos()
|
|||
{
|
||||
}
|
||||
|
||||
void Cursor::updatePos(const QPoint &pos)
|
||||
void Cursor::updatePos(const QPointF &pos)
|
||||
{
|
||||
if (m_pos == pos) {
|
||||
return;
|
||||
|
|
34
src/cursor.h
34
src/cursor.h
|
@ -156,17 +156,11 @@ public:
|
|||
* Implementing subclasses should prefer to use currentPos which is not performing a check
|
||||
* for update.
|
||||
*/
|
||||
QPoint pos();
|
||||
QPointF pos();
|
||||
/**
|
||||
* Warps the mouse cursor to new @p pos.
|
||||
* Values will be rounded to an integer
|
||||
*/
|
||||
void setPos(const QPointF &pos);
|
||||
/**
|
||||
* Warps the mouse cursor to new @p pos.
|
||||
*/
|
||||
void setPos(const QPoint &pos);
|
||||
void setPos(int x, int y);
|
||||
xcb_cursor_t x11Cursor(CursorShape shape);
|
||||
/**
|
||||
* Notice: if available always use the CursorShape variant to avoid cache duplicates for
|
||||
|
@ -175,9 +169,9 @@ public:
|
|||
xcb_cursor_t x11Cursor(const QByteArray &name);
|
||||
|
||||
QImage image() const;
|
||||
QPoint hotspot() const;
|
||||
QRect geometry() const;
|
||||
QRect rect() const;
|
||||
QPointF hotspot() const;
|
||||
QRectF geometry() const;
|
||||
QRectF rect() const;
|
||||
|
||||
CursorSource *source() const;
|
||||
void setSource(CursorSource *source);
|
||||
|
@ -190,8 +184,8 @@ public:
|
|||
void markAsRendered(std::chrono::milliseconds timestamp);
|
||||
|
||||
Q_SIGNALS:
|
||||
void posChanged(const QPoint &pos);
|
||||
void mouseChanged(const QPoint &pos, const QPoint &oldpos,
|
||||
void posChanged(const QPointF &pos);
|
||||
void mouseChanged(const QPointF &pos, const QPointF &oldpos,
|
||||
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
/**
|
||||
|
@ -242,13 +236,12 @@ protected:
|
|||
* access to the cursor position this method should be used instead of the static @ref pos, as
|
||||
* the static method syncs with the underlying system's cursor.
|
||||
*/
|
||||
const QPoint ¤tPos() const;
|
||||
const QPointF ¤tPos() const;
|
||||
/**
|
||||
* Updates the internal position to @p pos without warping the pointer as
|
||||
* setPos does.
|
||||
*/
|
||||
void updatePos(const QPoint &pos);
|
||||
void updatePos(int x, int y);
|
||||
void updatePos(const QPointF &pos);
|
||||
|
||||
private Q_SLOTS:
|
||||
void loadThemeSettings();
|
||||
|
@ -259,7 +252,7 @@ private:
|
|||
void loadThemeFromKConfig();
|
||||
CursorSource *m_source = nullptr;
|
||||
QHash<QByteArray, xcb_cursor_t> m_cursors;
|
||||
QPoint m_pos;
|
||||
QPointF m_pos;
|
||||
int m_mousePollingCounter;
|
||||
int m_cursorTrackingCounter;
|
||||
QString m_themeName;
|
||||
|
@ -303,7 +296,7 @@ public:
|
|||
Q_SIGNALS:
|
||||
void currentCursorChanged(Cursor *cursor);
|
||||
void hiddenChanged();
|
||||
void positionChanged(Cursor *cursor, const QPoint &position);
|
||||
void positionChanged(Cursor *cursor, const QPointF &position);
|
||||
|
||||
private:
|
||||
void emitCurrentCursorChanged();
|
||||
|
@ -337,16 +330,11 @@ private:
|
|||
static InputConfig *s_self;
|
||||
};
|
||||
|
||||
inline const QPoint &Cursor::currentPos() const
|
||||
inline const QPointF &Cursor::currentPos() const
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
inline void Cursor::updatePos(int x, int y)
|
||||
{
|
||||
updatePos(QPoint(x, y));
|
||||
}
|
||||
|
||||
inline const QString &Cursor::themeName() const
|
||||
{
|
||||
return m_themeName;
|
||||
|
|
|
@ -24,12 +24,12 @@ CursorDelegateOpenGL::~CursorDelegateOpenGL()
|
|||
|
||||
void CursorDelegateOpenGL::paint(RenderTarget *renderTarget, const QRegion ®ion)
|
||||
{
|
||||
if (!region.intersects(layer()->mapToGlobal(layer()->rect()))) {
|
||||
if (!region.intersects(layer()->mapToGlobal(layer()->rect()).toAlignedRect())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Render the cursor scene in an offscreen render target.
|
||||
const QSize bufferSize = Cursors::self()->currentCursor()->rect().size() * renderTarget->devicePixelRatio();
|
||||
const QSize bufferSize = (Cursors::self()->currentCursor()->rect().size() * renderTarget->devicePixelRatio()).toSize();
|
||||
if (!m_texture || m_texture->size() != bufferSize) {
|
||||
m_texture = std::make_unique<GLTexture>(GL_RGBA8, bufferSize);
|
||||
m_framebuffer = std::make_unique<GLFramebuffer>(m_texture.get());
|
||||
|
@ -45,7 +45,7 @@ void CursorDelegateOpenGL::paint(RenderTarget *renderTarget, const QRegion ®i
|
|||
renderLayer.delegate()->postPaint();
|
||||
|
||||
// Show the rendered cursor scene on the screen.
|
||||
const QRect cursorRect = layer()->mapToGlobal(layer()->rect());
|
||||
const QRectF cursorRect = layer()->mapToGlobal(layer()->rect());
|
||||
const qreal scale = renderTarget->devicePixelRatio();
|
||||
|
||||
QMatrix4x4 mvp;
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace KWin
|
|||
|
||||
void CursorDelegateQPainter::paint(RenderTarget *renderTarget, const QRegion ®ion)
|
||||
{
|
||||
if (!region.intersects(layer()->mapToGlobal(layer()->rect()))) {
|
||||
if (!region.intersects(layer()->mapToGlobal(layer()->rect()).toAlignedRect())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ void CursorDelegateQPainter::paint(RenderTarget *renderTarget, const QRegion &re
|
|||
return;
|
||||
}
|
||||
|
||||
const QSize bufferSize = Cursors::self()->currentCursor()->rect().size() * renderTarget->devicePixelRatio();
|
||||
const QSize bufferSize = (Cursors::self()->currentCursor()->rect().size() * renderTarget->devicePixelRatio()).toSize();
|
||||
if (m_buffer.size() != bufferSize) {
|
||||
m_buffer = QImage(bufferSize, QImage::Format_ARGB32_Premultiplied);
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ QImage CursorSource::image() const
|
|||
return m_image;
|
||||
}
|
||||
|
||||
QSize CursorSource::size() const
|
||||
QSizeF CursorSource::size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
QPoint CursorSource::hotspot() const
|
||||
QPointF CursorSource::hotspot() const
|
||||
{
|
||||
return m_hotspot;
|
||||
}
|
||||
|
@ -38,10 +38,10 @@ ImageCursorSource::ImageCursorSource(QObject *parent)
|
|||
{
|
||||
}
|
||||
|
||||
void ImageCursorSource::update(const QImage &image, const QPoint &hotspot)
|
||||
void ImageCursorSource::update(const QImage &image, const QPointF &hotspot)
|
||||
{
|
||||
m_image = image;
|
||||
m_size = image.size() / image.devicePixelRatio();
|
||||
m_size = QSizeF(image.size()) / image.devicePixelRatio();
|
||||
m_hotspot = hotspot;
|
||||
Q_EMIT changed();
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ void ShapeCursorSource::selectSprite(int index)
|
|||
const KXcursorSprite &sprite = m_sprites[index];
|
||||
m_currentSprite = index;
|
||||
m_image = sprite.data();
|
||||
m_size = m_image.size() / m_image.devicePixelRatio();
|
||||
m_size = QSizeF(m_image.size()) / m_image.devicePixelRatio();
|
||||
m_hotspot = sprite.hotspot();
|
||||
if (sprite.delay().count() && m_sprites.size() > 1) {
|
||||
m_delayTimer.start(sprite.delay());
|
||||
|
@ -136,12 +136,12 @@ KWaylandServer::SurfaceInterface *SurfaceCursorSource::surface() const
|
|||
return m_surface;
|
||||
}
|
||||
|
||||
void SurfaceCursorSource::update(KWaylandServer::SurfaceInterface *surface, const QPoint &hotspot)
|
||||
void SurfaceCursorSource::update(KWaylandServer::SurfaceInterface *surface, const QPointF &hotspot)
|
||||
{
|
||||
if (!surface) {
|
||||
m_image = QImage();
|
||||
m_size = QSize(0, 0);
|
||||
m_hotspot = QPoint();
|
||||
m_size = QSizeF(0, 0);
|
||||
m_hotspot = QPointF();
|
||||
m_surface = nullptr;
|
||||
} else {
|
||||
// TODO Plasma 6: once Xwayland cursor scaling can be done correctly, remove this
|
||||
|
@ -155,7 +155,7 @@ void SurfaceCursorSource::update(KWaylandServer::SurfaceInterface *surface, cons
|
|||
} else {
|
||||
m_image = QImage();
|
||||
}
|
||||
m_size = (surface->size() * surface->client()->scaleOverride()).toSize();
|
||||
m_size = surface->size() * surface->client()->scaleOverride();
|
||||
m_hotspot = hotspot;
|
||||
m_surface = surface;
|
||||
}
|
||||
|
|
|
@ -33,16 +33,16 @@ public:
|
|||
explicit CursorSource(QObject *parent = nullptr);
|
||||
|
||||
QImage image() const;
|
||||
QSize size() const;
|
||||
QPoint hotspot() const;
|
||||
QSizeF size() const;
|
||||
QPointF hotspot() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void changed();
|
||||
|
||||
protected:
|
||||
QImage m_image;
|
||||
QSize m_size = QSize(0, 0);
|
||||
QPoint m_hotspot;
|
||||
QSizeF m_size = QSizeF(0, 0);
|
||||
QPointF m_hotspot;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
explicit ImageCursorSource(QObject *parent = nullptr);
|
||||
|
||||
public Q_SLOTS:
|
||||
void update(const QImage &image, const QPoint &hotspot);
|
||||
void update(const QImage &image, const QPointF &hotspot);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -101,7 +101,7 @@ public:
|
|||
KWaylandServer::SurfaceInterface *surface() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void update(KWaylandServer::SurfaceInterface *surface, const QPoint &hotspot);
|
||||
void update(KWaylandServer::SurfaceInterface *surface, const QPointF &hotspot);
|
||||
|
||||
private:
|
||||
QPointer<KWaylandServer::SurfaceInterface> m_surface;
|
||||
|
|
|
@ -79,7 +79,7 @@ DecoratedClientImpl::DecoratedClientImpl(Window *window, KDecoration2::Decorated
|
|||
int fallAsleepDelay = QApplication::style()->styleHint(QStyle::SH_ToolTip_FallAsleepDelay);
|
||||
this->m_toolTipFallAsleep.setRemainingTime(fallAsleepDelay);
|
||||
|
||||
QToolTip::showText(Cursors::self()->mouse()->pos(), this->m_toolTipText);
|
||||
QToolTip::showText(Cursors::self()->mouse()->pos().toPoint(), this->m_toolTipText);
|
||||
m_toolTipShowing = true;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1359,7 +1359,7 @@ void EffectsHandlerImpl::doCheckInputWindowStacking()
|
|||
{
|
||||
}
|
||||
|
||||
QPoint EffectsHandlerImpl::cursorPos() const
|
||||
QPointF EffectsHandlerImpl::cursorPos() const
|
||||
{
|
||||
return Cursors::self()->mouse()->pos();
|
||||
}
|
||||
|
@ -1696,7 +1696,7 @@ void EffectsHandlerImpl::startInteractiveWindowSelection(std::function<void(KWin
|
|||
});
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::startInteractivePositionSelection(std::function<void(const QPoint &)> callback)
|
||||
void EffectsHandlerImpl::startInteractivePositionSelection(std::function<void(const QPointF &)> callback)
|
||||
{
|
||||
kwinApp()->startInteractivePositionSelection(callback);
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
QString desktopName(int desktop) const override;
|
||||
bool optionRollOverDesktops() const override;
|
||||
|
||||
QPoint cursorPos() const override;
|
||||
QPointF cursorPos() const override;
|
||||
bool grabKeyboard(Effect *effect) override;
|
||||
void ungrabKeyboard() override;
|
||||
// not performing XGrabPointer
|
||||
|
@ -203,7 +203,7 @@ public:
|
|||
void showCursor() override;
|
||||
|
||||
void startInteractiveWindowSelection(std::function<void(KWin::EffectWindow *)> callback) override;
|
||||
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback) override;
|
||||
void startInteractivePositionSelection(std::function<void(const QPointF &)> callback) override;
|
||||
|
||||
void showOnScreenMessage(const QString &message, const QString &iconName = QString()) override;
|
||||
void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) override;
|
||||
|
|
|
@ -54,8 +54,8 @@ void ColorPickerEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaint
|
|||
{
|
||||
effects->paintScreen(mask, region, data);
|
||||
|
||||
const QRect geo = effects->renderTargetRect();
|
||||
if (m_scheduledPosition != QPoint(-1, -1) && geo.contains(m_scheduledPosition)) {
|
||||
const QRectF geo = effects->renderTargetRect();
|
||||
if (m_scheduledPosition != QPoint(-1, -1) && exclusiveContains(geo, m_scheduledPosition)) {
|
||||
uint8_t data[4];
|
||||
constexpr GLsizei PIXEL_SIZE = 1;
|
||||
const QPoint screenPosition(m_scheduledPosition.x() - geo.x(), m_scheduledPosition.y() - geo.y());
|
||||
|
@ -82,9 +82,9 @@ QColor ColorPickerEffect::pick()
|
|||
setDelayedReply(true);
|
||||
showInfoMessage();
|
||||
effects->startInteractivePositionSelection(
|
||||
[this](const QPoint &p) {
|
||||
[this](const QPointF &p) {
|
||||
hideInfoMessage();
|
||||
if (p == QPoint(-1, -1)) {
|
||||
if (p == QPointF(-1, -1)) {
|
||||
// error condition
|
||||
QDBusConnection::sessionBus().send(m_replyMessage.createErrorReply(QStringLiteral("org.kde.kwin.ColorPicker.Error.Cancelled"), "Color picking got cancelled"));
|
||||
m_picking = false;
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
void hideInfoMessage();
|
||||
|
||||
QDBusMessage m_replyMessage;
|
||||
QPoint m_scheduledPosition;
|
||||
QPointF m_scheduledPosition;
|
||||
bool m_picking = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ void MagicLampEffect::apply(EffectWindow *w, int mask, WindowPaintData &data, Wi
|
|||
// If there's no icon geometry, minimize to the center of the screen
|
||||
if (!icon.isValid()) {
|
||||
QRect extG = geo;
|
||||
QPoint pt = cursorPos();
|
||||
QPoint pt = cursorPos().toPoint();
|
||||
// focussing inside the window is no good, leads to ugly artefacts, find nearest border
|
||||
if (extG.contains(pt)) {
|
||||
const int d[2][2] = {{pt.x() - extG.x(), extG.right() - pt.x()},
|
||||
|
|
|
@ -115,7 +115,7 @@ void MagnifierEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintDa
|
|||
if (m_zoom != 1.0) {
|
||||
// get the right area from the current rendered screen
|
||||
const QRect area = magnifierArea();
|
||||
const QPoint cursor = cursorPos();
|
||||
const QPointF cursor = cursorPos();
|
||||
const auto scale = effects->renderTargetScale();
|
||||
|
||||
QRectF srcArea(cursor.x() - (double)area.width() / (m_zoom * 2),
|
||||
|
@ -187,7 +187,7 @@ void MagnifierEffect::postPaintScreen()
|
|||
effects->postPaintScreen();
|
||||
}
|
||||
|
||||
QRect MagnifierEffect::magnifierArea(QPoint pos) const
|
||||
QRect MagnifierEffect::magnifierArea(QPointF pos) const
|
||||
{
|
||||
return QRect(pos.x() - m_magnifierSize.width() / 2, pos.y() - m_magnifierSize.height() / 2,
|
||||
m_magnifierSize.width(), m_magnifierSize.height());
|
||||
|
@ -253,7 +253,7 @@ void MagnifierEffect::toggle()
|
|||
effects->addRepaint(magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH));
|
||||
}
|
||||
|
||||
void MagnifierEffect::slotMouseChanged(const QPoint &pos, const QPoint &old,
|
||||
void MagnifierEffect::slotMouseChanged(const QPointF &pos, const QPointF &old,
|
||||
Qt::MouseButtons, Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers)
|
||||
{
|
||||
if (pos != old && m_zoom != 1) {
|
||||
|
|
|
@ -40,13 +40,13 @@ private Q_SLOTS:
|
|||
void zoomIn();
|
||||
void zoomOut();
|
||||
void toggle();
|
||||
void slotMouseChanged(const QPoint &pos, const QPoint &old,
|
||||
void slotMouseChanged(const QPointF &pos, const QPointF &old,
|
||||
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
void slotWindowDamaged();
|
||||
|
||||
private:
|
||||
QRect magnifierArea(QPoint pos = cursorPos()) const;
|
||||
QRect magnifierArea(QPointF pos = cursorPos()) const;
|
||||
double m_zoom;
|
||||
double m_targetZoom;
|
||||
bool m_polling; // Mouse polling
|
||||
|
|
|
@ -146,7 +146,7 @@ float MouseClickEffect::computeAlpha(const MouseEvent *click, int ring)
|
|||
return (m_ringLife - (float)click->m_time - ringDistance * (ring)) / m_ringLife;
|
||||
}
|
||||
|
||||
void MouseClickEffect::slotMouseChanged(const QPoint &pos, const QPoint &,
|
||||
void MouseClickEffect::slotMouseChanged(const QPointF &pos, const QPointF &,
|
||||
Qt::MouseButtons buttons, Qt::MouseButtons oldButtons,
|
||||
Qt::KeyboardModifiers, Qt::KeyboardModifiers)
|
||||
{
|
||||
|
@ -159,11 +159,11 @@ void MouseClickEffect::slotMouseChanged(const QPoint &pos, const QPoint &,
|
|||
while (--i >= 0) {
|
||||
MouseButton *b = m_buttons[i].get();
|
||||
if (isPressed(b->m_button, buttons, oldButtons)) {
|
||||
m = std::make_unique<MouseEvent>(i, pos, 0, createEffectFrame(pos, b->m_labelDown), true);
|
||||
m = std::make_unique<MouseEvent>(i, pos.toPoint(), 0, createEffectFrame(pos.toPoint(), b->m_labelDown), true);
|
||||
break;
|
||||
} else if (isReleased(b->m_button, buttons, oldButtons) && (!b->m_isPressed || b->m_time > m_ringLife)) {
|
||||
// we might miss a press, thus also check !b->m_isPressed, bug #314762
|
||||
m = std::make_unique<MouseEvent>(i, pos, 0, createEffectFrame(pos, b->m_labelUp), false);
|
||||
m = std::make_unique<MouseEvent>(i, pos.toPoint(), 0, createEffectFrame(pos.toPoint(), b->m_labelUp), false);
|
||||
break;
|
||||
}
|
||||
b->setPressed(b->m_button & buttons);
|
||||
|
|
|
@ -117,7 +117,7 @@ public:
|
|||
|
||||
private Q_SLOTS:
|
||||
void toggleEnabled();
|
||||
void slotMouseChanged(const QPoint &pos, const QPoint &old,
|
||||
void slotMouseChanged(const QPointF &pos, const QPointF &old,
|
||||
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ void MouseMarkEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintDa
|
|||
for (const Mark &mark : std::as_const(marks)) {
|
||||
verts.clear();
|
||||
verts.reserve(mark.size() * 2);
|
||||
for (const QPoint &p : std::as_const(mark)) {
|
||||
for (const QPointF &p : std::as_const(mark)) {
|
||||
verts << p.x() * scale << p.y() * scale;
|
||||
}
|
||||
vbo->setData(verts.size() / 2, 2, verts.data(), nullptr);
|
||||
|
@ -104,7 +104,7 @@ void MouseMarkEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintDa
|
|||
if (!drawing.isEmpty()) {
|
||||
verts.clear();
|
||||
verts.reserve(drawing.size() * 2);
|
||||
for (const QPoint &p : std::as_const(drawing)) {
|
||||
for (const QPointF &p : std::as_const(drawing)) {
|
||||
verts << p.x() * scale << p.y() * scale;
|
||||
}
|
||||
vbo->setData(verts.size() / 2, 2, verts.data(), nullptr);
|
||||
|
@ -139,7 +139,7 @@ void MouseMarkEffect::drawMark(QPainter *painter, const Mark &mark)
|
|||
}
|
||||
}
|
||||
|
||||
void MouseMarkEffect::slotMouseChanged(const QPoint &pos, const QPoint &,
|
||||
void MouseMarkEffect::slotMouseChanged(const QPointF &pos, const QPointF &,
|
||||
Qt::MouseButtons, Qt::MouseButtons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers)
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ void MouseMarkEffect::slotMouseChanged(const QPoint &pos, const QPoint &,
|
|||
if (drawing.last() == pos) {
|
||||
return;
|
||||
}
|
||||
QPoint pos2 = drawing.last();
|
||||
QPointF pos2 = drawing.last();
|
||||
drawing.append(pos);
|
||||
QRect repaint = QRect(std::min(pos.x(), pos2.x()), std::min(pos.y(), pos2.y()),
|
||||
std::max(pos.x(), pos2.x()), std::max(pos.y(), pos2.y()));
|
||||
|
@ -196,7 +196,7 @@ void MouseMarkEffect::clearLast()
|
|||
}
|
||||
}
|
||||
|
||||
MouseMarkEffect::Mark MouseMarkEffect::createArrow(QPoint arrow_start, QPoint arrow_end)
|
||||
MouseMarkEffect::Mark MouseMarkEffect::createArrow(QPointF arrow_start, QPointF arrow_end)
|
||||
{
|
||||
Mark ret;
|
||||
double angle = atan2((double)(arrow_end.y() - arrow_start.y()), (double)(arrow_end.x() - arrow_start.x()));
|
||||
|
|
|
@ -41,18 +41,18 @@ public:
|
|||
private Q_SLOTS:
|
||||
void clear();
|
||||
void clearLast();
|
||||
void slotMouseChanged(const QPoint &pos, const QPoint &old,
|
||||
void slotMouseChanged(const QPointF &pos, const QPointF &old,
|
||||
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
void screenLockingChanged(bool locked);
|
||||
|
||||
private:
|
||||
typedef QVector<QPoint> Mark;
|
||||
typedef QVector<QPointF> Mark;
|
||||
void drawMark(QPainter *painter, const Mark &mark);
|
||||
static Mark createArrow(QPoint arrow_start, QPoint arrow_end);
|
||||
static Mark createArrow(QPointF arrow_start, QPointF arrow_end);
|
||||
QVector<Mark> marks;
|
||||
Mark drawing;
|
||||
QPoint arrow_start;
|
||||
QPointF arrow_start;
|
||||
int width;
|
||||
QColor color;
|
||||
};
|
||||
|
|
|
@ -541,7 +541,7 @@ void ScreenShotDBusInterface1::screenshotWindowUnderCursor(int mask)
|
|||
|
||||
EffectWindow *hoveredWindow = nullptr;
|
||||
|
||||
const QPoint cursor = effects->cursorPos();
|
||||
const QPointF cursor = effects->cursorPos();
|
||||
EffectWindowList order = effects->stackingOrder();
|
||||
EffectWindowList::const_iterator it = order.constEnd(), first = order.constBegin();
|
||||
while (it != first) {
|
||||
|
@ -709,12 +709,12 @@ void ScreenShotDBusInterface1::screenshotScreen(QDBusUnixFileDescriptor fd, bool
|
|||
flags |= ScreenShotIncludeCursor;
|
||||
}
|
||||
|
||||
effects->startInteractivePositionSelection([this, fileDescriptor, flags](const QPoint &p) {
|
||||
effects->startInteractivePositionSelection([this, fileDescriptor, flags](const QPointF &p) {
|
||||
hideInfoMessage();
|
||||
if (p == QPoint(-1, -1)) {
|
||||
close(fileDescriptor);
|
||||
} else {
|
||||
EffectScreen *screen = effects->screenAt(p);
|
||||
EffectScreen *screen = effects->screenAt(p.toPoint());
|
||||
if (!screen) {
|
||||
close(fileDescriptor);
|
||||
return;
|
||||
|
|
|
@ -478,7 +478,7 @@ QVariantMap ScreenShotDBusInterface2::CaptureInteractive(uint kind,
|
|||
"Escape or right click to cancel."),
|
||||
QStringLiteral("spectacle"));
|
||||
} else {
|
||||
effects->startInteractivePositionSelection([=, this](const QPoint &point) {
|
||||
effects->startInteractivePositionSelection([=, this](const QPointF &point) {
|
||||
effects->hideOnScreenMessage(EffectsHandler::OnScreenMessageHideFlag::SkipsCloseAnimation);
|
||||
|
||||
if (point == QPoint(-1, -1)) {
|
||||
|
@ -487,7 +487,7 @@ QVariantMap ScreenShotDBusInterface2::CaptureInteractive(uint kind,
|
|||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
bus.send(replyMessage.createErrorReply(s_errorCancelled, s_errorCancelledMessage));
|
||||
} else {
|
||||
EffectScreen *screen = effects->screenAt(point);
|
||||
EffectScreen *screen = effects->screenAt(point.toPoint());
|
||||
takeScreenShot(screen, screenShotFlagsFromOptions(options),
|
||||
new ScreenShotSinkPipe2(fileDescriptor, replyMessage));
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ void StartupFeedbackEffect::postPaintScreen()
|
|||
effects->postPaintScreen();
|
||||
}
|
||||
|
||||
void StartupFeedbackEffect::slotMouseChanged(const QPoint &pos, const QPoint &oldpos, Qt::MouseButtons buttons,
|
||||
void StartupFeedbackEffect::slotMouseChanged(const QPointF &pos, const QPointF &oldpos, Qt::MouseButtons buttons,
|
||||
Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers)
|
||||
{
|
||||
if (m_active) {
|
||||
|
@ -416,7 +416,7 @@ QRect StartupFeedbackEffect::feedbackRect() const
|
|||
// nothing
|
||||
break;
|
||||
}
|
||||
const QPoint cursorPos = effects->cursorPos() + QPoint(xDiff, yDiff + yOffset);
|
||||
const QPoint cursorPos = effects->cursorPos().toPoint() + QPoint(xDiff, yDiff + yOffset);
|
||||
QRect rect;
|
||||
if (texture) {
|
||||
rect = QRect(cursorPos, texture->size());
|
||||
|
|
|
@ -53,7 +53,7 @@ private Q_SLOTS:
|
|||
void gotNewStartup(const QString &id, const QIcon &icon);
|
||||
void gotRemoveStartup(const QString &id);
|
||||
void gotStartupChange(const QString &id, const QIcon &icon);
|
||||
void slotMouseChanged(const QPoint &pos, const QPoint &oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
void slotMouseChanged(const QPointF &pos, const QPointF &oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
|
||||
private:
|
||||
enum FeedbackType {
|
||||
|
|
|
@ -90,8 +90,8 @@ void TrackMouseEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mil
|
|||
{
|
||||
QTime t = QTime::currentTime();
|
||||
m_angle = ((t.second() % 4) * m_angleBase) + (t.msec() / 1000.0 * m_angleBase);
|
||||
m_lastRect[0].moveCenter(cursorPos());
|
||||
m_lastRect[1].moveCenter(cursorPos());
|
||||
m_lastRect[0].moveCenter(cursorPos().toPoint());
|
||||
m_lastRect[1].moveCenter(cursorPos().toPoint());
|
||||
data.paint |= m_lastRect[0].adjusted(-1, -1, 1, 1);
|
||||
|
||||
effects->prePaintScreen(data, presentTime);
|
||||
|
@ -155,8 +155,8 @@ bool TrackMouseEffect::init()
|
|||
return false;
|
||||
}
|
||||
}
|
||||
m_lastRect[0].moveCenter(cursorPos());
|
||||
m_lastRect[1].moveCenter(cursorPos());
|
||||
m_lastRect[0].moveCenter(cursorPos().toPoint());
|
||||
m_lastRect[1].moveCenter(cursorPos().toPoint());
|
||||
m_angle = 0;
|
||||
return true;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ void TrackMouseEffect::toggle()
|
|||
effects->addRepaint(m_lastRect[0].adjusted(-1, -1, 1, 1));
|
||||
}
|
||||
|
||||
void TrackMouseEffect::slotMouseChanged(const QPoint &, const QPoint &,
|
||||
void TrackMouseEffect::slotMouseChanged(const QPointF &, const QPointF &,
|
||||
Qt::MouseButtons, Qt::MouseButtons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers)
|
||||
{
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
}
|
||||
private Q_SLOTS:
|
||||
void toggle();
|
||||
void slotMouseChanged(const QPoint &pos, const QPoint &old,
|
||||
void slotMouseChanged(const QPointF &pos, const QPointF &old,
|
||||
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ void ZoomEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &d
|
|||
cursorSize *= zoom;
|
||||
}
|
||||
|
||||
const QPoint p = (effects->cursorPos() - cursor.hotSpot()) * zoom + QPoint(xTranslation, yTranslation);
|
||||
const QPointF p = (effects->cursorPos() - cursor.hotSpot()) * zoom + QPoint(xTranslation, yTranslation);
|
||||
|
||||
cursorTexture->bind();
|
||||
glEnable(GL_BLEND);
|
||||
|
@ -439,7 +439,7 @@ void ZoomEffect::zoomIn(double to)
|
|||
polling = true;
|
||||
effects->startMousePolling();
|
||||
}
|
||||
cursorPoint = effects->cursorPos();
|
||||
cursorPoint = effects->cursorPos().toPoint();
|
||||
if (mouseTracking == MouseTrackingDisabled) {
|
||||
prevPoint = cursorPoint;
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ void ZoomEffect::zoomOut()
|
|||
}
|
||||
}
|
||||
if (mouseTracking == MouseTrackingDisabled) {
|
||||
prevPoint = effects->cursorPos();
|
||||
prevPoint = effects->cursorPos().toPoint();
|
||||
}
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
|
@ -540,13 +540,13 @@ void ZoomEffect::moveMouseToCenter()
|
|||
QCursor::setPos(r.x() + r.width() / 2, r.y() + r.height() / 2);
|
||||
}
|
||||
|
||||
void ZoomEffect::slotMouseChanged(const QPoint &pos, const QPoint &old, Qt::MouseButtons,
|
||||
void ZoomEffect::slotMouseChanged(const QPointF &pos, const QPointF &old, Qt::MouseButtons,
|
||||
Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers)
|
||||
{
|
||||
if (zoom == 1.0) {
|
||||
return;
|
||||
}
|
||||
cursorPoint = pos;
|
||||
cursorPoint = pos.toPoint();
|
||||
if (pos != old) {
|
||||
lastMouseEvent = QTime::currentTime();
|
||||
effects->addRepaintFull();
|
||||
|
|
|
@ -73,7 +73,7 @@ private Q_SLOTS:
|
|||
void moveMouseToCenter();
|
||||
void timelineFrameChanged(int frame);
|
||||
void moveFocus(const QPoint &point);
|
||||
void slotMouseChanged(const QPoint &pos, const QPoint &old,
|
||||
void slotMouseChanged(const QPointF &pos, const QPointF &old,
|
||||
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
void slotWindowDamaged();
|
||||
|
|
|
@ -548,7 +548,7 @@ void Effect::setPositionTransformations(WindowPaintData &data, QRect ®ion, Ef
|
|||
data.setYTranslation(y - w->y());
|
||||
}
|
||||
|
||||
QPoint Effect::cursorPos()
|
||||
QPointF Effect::cursorPos()
|
||||
{
|
||||
return effects->cursorPos();
|
||||
}
|
||||
|
|
|
@ -627,7 +627,7 @@ public:
|
|||
*/
|
||||
virtual bool tabletPadRingEvent(int number, int position, bool isFinger, void *tabletPadId);
|
||||
|
||||
static QPoint cursorPos();
|
||||
static QPointF cursorPos();
|
||||
|
||||
/**
|
||||
* Read animation time from the configuration and possibly adjust using animationTimeFactor().
|
||||
|
@ -819,7 +819,7 @@ class KWINEFFECTS_EXPORT EffectsHandler : public QObject
|
|||
*/
|
||||
Q_PROPERTY(bool decorationsHaveAlpha READ decorationsHaveAlpha)
|
||||
Q_PROPERTY(CompositingType compositingType READ compositingType CONSTANT)
|
||||
Q_PROPERTY(QPoint cursorPos READ cursorPos)
|
||||
Q_PROPERTY(QPointF cursorPos READ cursorPos)
|
||||
Q_PROPERTY(QSize virtualScreenSize READ virtualScreenSize NOTIFY virtualScreenSizeChanged)
|
||||
Q_PROPERTY(QRect virtualScreenGeometry READ virtualScreenGeometry NOTIFY virtualScreenGeometryChanged)
|
||||
Q_PROPERTY(bool hasActiveFullScreenEffect READ hasActiveFullScreenEffect NOTIFY hasActiveFullScreenEffectChanged)
|
||||
|
@ -855,7 +855,7 @@ public:
|
|||
* @since 4.11
|
||||
*/
|
||||
virtual void defineCursor(Qt::CursorShape shape) = 0;
|
||||
virtual QPoint cursorPos() const = 0;
|
||||
virtual QPointF cursorPos() const = 0;
|
||||
virtual bool grabKeyboard(Effect *effect) = 0;
|
||||
virtual void ungrabKeyboard() = 0;
|
||||
/**
|
||||
|
@ -1332,7 +1332,7 @@ public:
|
|||
* @param callback The function to invoke once the interactive position selection ends
|
||||
* @since 5.9
|
||||
*/
|
||||
virtual void startInteractivePositionSelection(std::function<void(const QPoint &)> callback) = 0;
|
||||
virtual void startInteractivePositionSelection(std::function<void(const QPointF &)> callback) = 0;
|
||||
|
||||
/**
|
||||
* Shows an on-screen-message. To hide it again use hideOnScreenMessage.
|
||||
|
@ -1730,7 +1730,7 @@ Q_SIGNALS:
|
|||
* @see startMousePolling
|
||||
* @since 4.7
|
||||
*/
|
||||
void mouseChanged(const QPoint &pos, const QPoint &oldpos,
|
||||
void mouseChanged(const QPointF &pos, const QPointF &oldpos,
|
||||
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
||||
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||
/**
|
||||
|
|
|
@ -225,7 +225,7 @@ public:
|
|||
, m_hotSpot()
|
||||
{
|
||||
}
|
||||
explicit PlatformCursorImage(const QImage &image, const QPoint &hotSpot)
|
||||
explicit PlatformCursorImage(const QImage &image, const QPointF &hotSpot)
|
||||
: m_image(image)
|
||||
, m_hotSpot(hotSpot)
|
||||
{
|
||||
|
@ -240,14 +240,14 @@ public:
|
|||
{
|
||||
return m_image;
|
||||
}
|
||||
QPoint hotSpot() const
|
||||
QPointF hotSpot() const
|
||||
{
|
||||
return m_hotSpot;
|
||||
}
|
||||
|
||||
private:
|
||||
QImage m_image;
|
||||
QPoint m_hotSpot;
|
||||
QPointF m_hotSpot;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -259,6 +259,15 @@ inline KWIN_EXPORT QRect infiniteRegion()
|
|||
return QRect(INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns if @a point is contained in @a rect, including the left and top borders
|
||||
* but excluding the right and bottom borders
|
||||
*/
|
||||
static inline bool exclusiveContains(const QRectF &rect, const QPointF &point)
|
||||
{
|
||||
return point.x() >= rect.x() && point.y() >= rect.y() && point.x() < (rect.x() + rect.width()) && point.y() < (rect.y() + rect.height());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(std::chrono::nanoseconds)
|
||||
|
|
|
@ -672,10 +672,10 @@ void Application::startInteractiveWindowSelection(std::function<void(KWin::Windo
|
|||
input()->startInteractiveWindowSelection(callback, cursorName);
|
||||
}
|
||||
|
||||
void Application::startInteractivePositionSelection(std::function<void(const QPoint &)> callback)
|
||||
void Application::startInteractivePositionSelection(std::function<void(const QPointF &)> callback)
|
||||
{
|
||||
if (!input()) {
|
||||
callback(QPoint(-1, -1));
|
||||
callback(QPointF(-1, -1));
|
||||
return;
|
||||
}
|
||||
input()->startInteractivePositionSelection(callback);
|
||||
|
|
|
@ -299,7 +299,7 @@ public:
|
|||
*
|
||||
* @param callback The function to invoke once the interactive position selection ends
|
||||
*/
|
||||
virtual void startInteractivePositionSelection(std::function<void(const QPoint &)> callback);
|
||||
virtual void startInteractivePositionSelection(std::function<void(const QPointF &)> callback);
|
||||
|
||||
/**
|
||||
* Returns a PlatformCursorImage. By default this is created by softwareCursor and
|
||||
|
|
|
@ -227,7 +227,7 @@ void ApplicationX11::startInteractiveWindowSelection(std::function<void(KWin::Wi
|
|||
static_cast<X11StandaloneBackend *>(outputBackend())->startInteractiveWindowSelection(callback, cursorName);
|
||||
}
|
||||
|
||||
void ApplicationX11::startInteractivePositionSelection(std::function<void(const QPoint &)> callback)
|
||||
void ApplicationX11::startInteractivePositionSelection(std::function<void(const QPointF &)> callback)
|
||||
{
|
||||
static_cast<X11StandaloneBackend *>(outputBackend())->startInteractivePositionSelection(callback);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
std::unique_ptr<OutlineVisual> createOutline(Outline *outline) override;
|
||||
void createEffectsHandler(Compositor *compositor, WorkspaceScene *scene) override;
|
||||
void startInteractiveWindowSelection(std::function<void(KWin::Window *)> callback, const QByteArray &cursorName = QByteArray()) override;
|
||||
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback) override;
|
||||
void startInteractivePositionSelection(std::function<void(const QPointF &)> callback) override;
|
||||
PlatformCursorImage cursorImage() const override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -23,7 +23,7 @@ PlatformCursor::~PlatformCursor() = default;
|
|||
|
||||
QPoint PlatformCursor::pos() const
|
||||
{
|
||||
return Cursors::self()->mouse()->pos();
|
||||
return Cursors::self()->mouse()->pos().toPoint();
|
||||
}
|
||||
|
||||
void PlatformCursor::setPos(const QPoint &pos)
|
||||
|
|
|
@ -108,7 +108,7 @@ void ScreencastManager::streamWindow(KWaylandServer::ScreencastStreamV1Interface
|
|||
}
|
||||
|
||||
auto stream = new WindowStream(window, this);
|
||||
stream->setCursorMode(mode, 1, window->clientGeometry().toRect());
|
||||
stream->setCursorMode(mode, 1, window->clientGeometry());
|
||||
if (mode != KWaylandServer::ScreencastV1Interface::CursorMode::Hidden) {
|
||||
connect(window, &Window::clientGeometryChanged, stream, [window, stream, mode]() {
|
||||
stream->setCursorMode(mode, 1, window->clientGeometry().toRect());
|
||||
|
|
|
@ -446,7 +446,7 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion)
|
|||
if (m_cursor.mode == KWaylandServer::ScreencastV1Interface::Embedded && m_cursor.viewport.contains(cursor->pos())) {
|
||||
QPainter painter(&dest);
|
||||
const auto position = (cursor->pos() - m_cursor.viewport.topLeft() - cursor->hotspot()) * m_cursor.scale;
|
||||
painter.drawImage(QRect{position, cursor->image().size()}, cursor->image());
|
||||
painter.drawImage(QRect{position.toPoint(), cursor->image().size()}, cursor->image());
|
||||
}
|
||||
} else {
|
||||
auto &buf = m_dmabufDataForPwBuffer[buffer];
|
||||
|
@ -493,10 +493,10 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion)
|
|||
ShaderManager::instance()->popShader();
|
||||
GLFramebuffer::popFramebuffer();
|
||||
|
||||
damagedRegion += QRegion{m_cursor.lastRect} | cursorRect;
|
||||
damagedRegion += QRegion{m_cursor.lastRect.toAlignedRect()} | cursorRect.toAlignedRect();
|
||||
m_cursor.lastRect = cursorRect;
|
||||
} else {
|
||||
damagedRegion |= m_cursor.lastRect;
|
||||
damagedRegion |= m_cursor.lastRect.toAlignedRect();
|
||||
m_cursor.lastRect = {};
|
||||
}
|
||||
}
|
||||
|
@ -692,14 +692,14 @@ spa_pod *ScreenCastStream::buildFormat(struct spa_pod_builder *b, enum spa_video
|
|||
return (spa_pod *)spa_pod_builder_pop(b, &f[0]);
|
||||
}
|
||||
|
||||
QRect ScreenCastStream::cursorGeometry(Cursor *cursor) const
|
||||
QRectF ScreenCastStream::cursorGeometry(Cursor *cursor) const
|
||||
{
|
||||
if (!m_cursor.texture) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto position = (cursor->pos() - m_cursor.viewport.topLeft() - cursor->hotspot()) * m_cursor.scale;
|
||||
return QRect{position, m_cursor.texture->size()};
|
||||
return QRectF{position, m_cursor.texture->size()};
|
||||
}
|
||||
|
||||
void ScreenCastStream::sendCursorData(Cursor *cursor, spa_meta_cursor *spa_meta_cursor)
|
||||
|
@ -736,7 +736,7 @@ void ScreenCastStream::sendCursorData(Cursor *cursor, spa_meta_cursor *spa_meta_
|
|||
m_cursor.lastKey = image.cacheKey();
|
||||
spa_meta_cursor->bitmap_offset = sizeof(struct spa_meta_cursor);
|
||||
|
||||
const QSize targetSize = cursor->rect().size() * m_cursor.scale;
|
||||
const QSize targetSize = (cursor->rect().size() * m_cursor.scale).toSize();
|
||||
|
||||
struct spa_meta_bitmap *spa_meta_bitmap = SPA_MEMBER(spa_meta_cursor,
|
||||
spa_meta_cursor->bitmap_offset,
|
||||
|
@ -761,7 +761,7 @@ void ScreenCastStream::sendCursorData(Cursor *cursor, spa_meta_cursor *spa_meta_
|
|||
}
|
||||
}
|
||||
|
||||
void ScreenCastStream::setCursorMode(KWaylandServer::ScreencastV1Interface::CursorMode mode, qreal scale, const QRect &viewport)
|
||||
void ScreenCastStream::setCursorMode(KWaylandServer::ScreencastV1Interface::CursorMode mode, qreal scale, const QRectF &viewport)
|
||||
{
|
||||
m_cursor.mode = mode;
|
||||
m_cursor.scale = scale;
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
*/
|
||||
void recordFrame(const QRegion &damagedRegion);
|
||||
|
||||
void setCursorMode(KWaylandServer::ScreencastV1Interface::CursorMode mode, qreal scale, const QRect &viewport);
|
||||
void setCursorMode(KWaylandServer::ScreencastV1Interface::CursorMode mode, qreal scale, const QRectF &viewport);
|
||||
|
||||
public Q_SLOTS:
|
||||
void recordCursor();
|
||||
|
@ -112,13 +112,13 @@ private:
|
|||
KWaylandServer::ScreencastV1Interface::CursorMode mode = KWaylandServer::ScreencastV1Interface::Hidden;
|
||||
const QSize bitmapSize = QSize(256, 256);
|
||||
qreal scale = 1;
|
||||
QRect viewport;
|
||||
QRectF viewport;
|
||||
qint64 lastKey = 0;
|
||||
QRect lastRect;
|
||||
QRectF lastRect;
|
||||
std::unique_ptr<GLTexture> texture;
|
||||
bool visible = false;
|
||||
} m_cursor;
|
||||
QRect cursorGeometry(Cursor *cursor) const;
|
||||
QRectF cursorGeometry(Cursor *cursor) const;
|
||||
|
||||
QHash<struct pw_buffer *, std::shared_ptr<DmaBufTexture>> m_dmabufDataForPwBuffer;
|
||||
|
||||
|
|
|
@ -1180,9 +1180,9 @@ void InputRedirectionCursor::doSetPos()
|
|||
|
||||
void InputRedirectionCursor::slotPosChanged(const QPointF &pos)
|
||||
{
|
||||
const QPoint oldPos = currentPos();
|
||||
updatePos(pos.toPoint());
|
||||
Q_EMIT mouseChanged(pos.toPoint(), oldPos, m_currentButtons, m_currentButtons,
|
||||
const QPointF oldPos = currentPos();
|
||||
updatePos(pos);
|
||||
Q_EMIT mouseChanged(pos, oldPos, m_currentButtons, m_currentButtons,
|
||||
input()->keyboardModifiers(), input()->keyboardModifiers());
|
||||
}
|
||||
|
||||
|
@ -1195,7 +1195,7 @@ void InputRedirectionCursor::slotPointerButtonChanged()
|
|||
{
|
||||
const Qt::MouseButtons oldButtons = m_currentButtons;
|
||||
m_currentButtons = input()->qtButtonStates();
|
||||
const QPoint pos = currentPos();
|
||||
const QPointF pos = currentPos();
|
||||
Q_EMIT mouseChanged(pos, pos, m_currentButtons, oldButtons, input()->keyboardModifiers(), input()->keyboardModifiers());
|
||||
}
|
||||
|
||||
|
|
|
@ -516,7 +516,7 @@ void Edge::pushCursorBack(const QPoint &cursorPos)
|
|||
if (isBottom()) {
|
||||
y -= distance.height();
|
||||
}
|
||||
Cursors::self()->mouse()->setPos(x, y);
|
||||
Cursors::self()->mouse()->setPos(QPoint(x, y));
|
||||
}
|
||||
|
||||
void Edge::setGeometry(const QRect &geometry)
|
||||
|
@ -648,46 +648,47 @@ void Edge::doStopApproaching()
|
|||
{
|
||||
}
|
||||
|
||||
void Edge::updateApproaching(const QPoint &point)
|
||||
void Edge::updateApproaching(const QPointF &point)
|
||||
{
|
||||
if (approachGeometry().contains(point)) {
|
||||
if (exclusiveContains(approachGeometry(), point)) {
|
||||
int factor = 0;
|
||||
const int edgeDistance = m_edges->cornerOffset();
|
||||
auto cornerDistance = [=](const QPoint &corner) {
|
||||
auto cornerDistance = [=](const QPointF &corner) {
|
||||
return std::max(std::abs(corner.x() - point.x()), std::abs(corner.y() - point.y()));
|
||||
};
|
||||
constexpr double factorScale = 256;
|
||||
switch (border()) {
|
||||
case ElectricTopLeft:
|
||||
factor = (cornerDistance(approachGeometry().topLeft()) << 8) / edgeDistance;
|
||||
factor = (cornerDistance(approachGeometry().topLeft()) * factorScale) / edgeDistance;
|
||||
break;
|
||||
case ElectricTopRight:
|
||||
factor = (cornerDistance(approachGeometry().topRight()) << 8) / edgeDistance;
|
||||
factor = (cornerDistance(approachGeometry().topRight()) * factorScale) / edgeDistance;
|
||||
break;
|
||||
case ElectricBottomRight:
|
||||
factor = (cornerDistance(approachGeometry().bottomRight()) << 8) / edgeDistance;
|
||||
factor = (cornerDistance(approachGeometry().bottomRight()) * factorScale) / edgeDistance;
|
||||
break;
|
||||
case ElectricBottomLeft:
|
||||
factor = (cornerDistance(approachGeometry().bottomLeft()) << 8) / edgeDistance;
|
||||
factor = (cornerDistance(approachGeometry().bottomLeft()) * factorScale) / edgeDistance;
|
||||
break;
|
||||
case ElectricTop:
|
||||
factor = (std::abs(point.y() - approachGeometry().y()) << 8) / edgeDistance;
|
||||
factor = (std::abs(point.y() - approachGeometry().y()) * factorScale) / edgeDistance;
|
||||
break;
|
||||
case ElectricRight:
|
||||
factor = (std::abs(point.x() - approachGeometry().right()) << 8) / edgeDistance;
|
||||
factor = (std::abs(point.x() - approachGeometry().right()) * factorScale) / edgeDistance;
|
||||
break;
|
||||
case ElectricBottom:
|
||||
factor = (std::abs(point.y() - approachGeometry().bottom()) << 8) / edgeDistance;
|
||||
factor = (std::abs(point.y() - approachGeometry().bottom()) * factorScale) / edgeDistance;
|
||||
break;
|
||||
case ElectricLeft:
|
||||
factor = (std::abs(point.x() - approachGeometry().x()) << 8) / edgeDistance;
|
||||
factor = (std::abs(point.x() - approachGeometry().x()) * factorScale) / edgeDistance;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
factor = 256 - factor;
|
||||
factor = factorScale - factor;
|
||||
if (m_lastApproachingFactor != factor) {
|
||||
m_lastApproachingFactor = factor;
|
||||
Q_EMIT approaching(border(), m_lastApproachingFactor / 256.0f, m_approachGeometry);
|
||||
Q_EMIT approaching(border(), m_lastApproachingFactor / factorScale, m_approachGeometry);
|
||||
}
|
||||
} else {
|
||||
stopApproaching();
|
||||
|
|
|
@ -112,7 +112,7 @@ public Q_SLOTS:
|
|||
void setBorder(ElectricBorder border);
|
||||
void setAction(ElectricBorderAction action);
|
||||
void setGeometry(const QRect &geometry);
|
||||
void updateApproaching(const QPoint &point);
|
||||
void updateApproaching(const QPointF &point);
|
||||
void checkBlocking();
|
||||
Q_SIGNALS:
|
||||
void approaching(ElectricBorder border, qreal factor, const QRect &geometry);
|
||||
|
|
|
@ -108,7 +108,7 @@ QStringList WorkspaceWrapper::activityList() const
|
|||
|
||||
QPoint WorkspaceWrapper::cursorPos() const
|
||||
{
|
||||
return Cursors::self()->mouse()->pos();
|
||||
return Cursors::self()->mouse()->pos().toPoint();
|
||||
}
|
||||
|
||||
#define SLOTWRAPPER(name) \
|
||||
|
|
|
@ -28,10 +28,10 @@ public:
|
|||
Cursor *q;
|
||||
PointerInterface *pointer;
|
||||
quint32 enteredSerial = 0;
|
||||
QPoint hotspot;
|
||||
QPointF hotspot;
|
||||
QPointer<SurfaceInterface> surface;
|
||||
|
||||
void update(SurfaceInterface *surface, quint32 serial, const QPoint &hotspot);
|
||||
void update(SurfaceInterface *surface, quint32 serial, const QPointF &hotspot);
|
||||
};
|
||||
|
||||
PointerInterfacePrivate *PointerInterfacePrivate::get(PointerInterface *pointer)
|
||||
|
@ -86,11 +86,11 @@ void PointerInterfacePrivate::pointer_set_cursor(Resource *resource, uint32_t se
|
|||
|
||||
if (!cursor) { // TODO: Assign the cursor surface role.
|
||||
cursor = new Cursor(q);
|
||||
cursor->d->update(surface, serial, QPoint(hotspot_x, hotspot_y));
|
||||
cursor->d->update(surface, serial, QPointF(hotspot_x, hotspot_y) / focusedSurface->client()->scaleOverride());
|
||||
QObject::connect(cursor, &Cursor::changed, q, &PointerInterface::cursorChanged);
|
||||
Q_EMIT q->cursorChanged();
|
||||
} else {
|
||||
cursor->d->update(surface, serial, QPoint(hotspot_x, hotspot_y));
|
||||
cursor->d->update(surface, serial, QPointF(hotspot_x, hotspot_y) / focusedSurface->client()->scaleOverride());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ CursorPrivate::CursorPrivate(Cursor *q, PointerInterface *pointer)
|
|||
{
|
||||
}
|
||||
|
||||
void CursorPrivate::update(SurfaceInterface *s, quint32 serial, const QPoint &p)
|
||||
void CursorPrivate::update(SurfaceInterface *s, quint32 serial, const QPointF &p)
|
||||
{
|
||||
bool emitChanged = false;
|
||||
if (enteredSerial != serial) {
|
||||
|
@ -416,7 +416,7 @@ quint32 Cursor::enteredSerial() const
|
|||
return d->enteredSerial;
|
||||
}
|
||||
|
||||
QPoint Cursor::hotspot() const
|
||||
QPointF Cursor::hotspot() const
|
||||
{
|
||||
return d->hotspot;
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
/**
|
||||
* The hotspot of the cursor image in surface-relative coordinates.
|
||||
*/
|
||||
QPoint hotspot() const;
|
||||
QPointF hotspot() const;
|
||||
/**
|
||||
* The entered serial when the Cursor got set.
|
||||
*/
|
||||
|
|
|
@ -1817,7 +1817,7 @@ void Window::handleInteractiveMoveResize(const QPointF &local, const QPointF &gl
|
|||
}
|
||||
}
|
||||
|
||||
void Window::handleInteractiveMoveResize(int x, int y, int x_root, int y_root)
|
||||
void Window::handleInteractiveMoveResize(qreal x, qreal y, qreal x_root, qreal y_root)
|
||||
{
|
||||
if (isWaitingForInteractiveMoveResizeSync()) {
|
||||
return; // we're still waiting for the client or the timeout
|
||||
|
|
|
@ -1835,7 +1835,7 @@ protected:
|
|||
* Default implementation does nothing.
|
||||
*/
|
||||
virtual void doInteractiveResizeSync(const QRectF &rect);
|
||||
void handleInteractiveMoveResize(int x, int y, int x_root, int y_root);
|
||||
void handleInteractiveMoveResize(qreal x, qreal y, qreal x_root, qreal y_root);
|
||||
void handleInteractiveMoveResize(const QPointF &local, const QPointF &global);
|
||||
void dontInteractiveMoveResize();
|
||||
|
||||
|
|
|
@ -1353,8 +1353,7 @@ Window *Workspace::findWindowToActivateOnDesktop(VirtualDesktop *desktop)
|
|||
continue;
|
||||
}
|
||||
|
||||
// port to hit test
|
||||
if (window->frameGeometry().toRect().contains(Cursors::self()->mouse()->pos())) {
|
||||
if (window->hitTest(Cursors::self()->mouse()->pos())) {
|
||||
if (!window->isDesktop()) {
|
||||
return window;
|
||||
}
|
||||
|
@ -2439,15 +2438,15 @@ void Workspace::desktopResized()
|
|||
|
||||
// restore cursor position
|
||||
const auto oldCursorOutput = std::find_if(m_oldScreenGeometries.cbegin(), m_oldScreenGeometries.cend(), [](const auto &geometry) {
|
||||
return geometry.contains(Cursors::self()->mouse()->pos());
|
||||
return exclusiveContains(geometry, Cursors::self()->mouse()->pos());
|
||||
});
|
||||
if (oldCursorOutput != m_oldScreenGeometries.cend()) {
|
||||
const Output *cursorOutput = oldCursorOutput.key();
|
||||
if (std::find(m_outputs.cbegin(), m_outputs.cend(), cursorOutput) != m_outputs.cend()) {
|
||||
const QRect oldGeometry = oldCursorOutput.value();
|
||||
const QRect newGeometry = cursorOutput->geometry();
|
||||
const QPoint relativePosition = Cursors::self()->mouse()->pos() - oldGeometry.topLeft();
|
||||
const QPoint newRelativePosition(newGeometry.width() * relativePosition.x() / float(oldGeometry.width()), newGeometry.height() * relativePosition.y() / float(oldGeometry.height()));
|
||||
const QPointF relativePosition = Cursors::self()->mouse()->pos() - oldGeometry.topLeft();
|
||||
const QPointF newRelativePosition(newGeometry.width() * relativePosition.x() / float(oldGeometry.width()), newGeometry.height() * relativePosition.y() / float(oldGeometry.height()));
|
||||
Cursors::self()->mouse()->setPos(newGeometry.topLeft() + newRelativePosition);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue