diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.h b/plugins/platforms/x11/windowed/x11windowed_backend.h --- a/plugins/platforms/x11/windowed/x11windowed_backend.h +++ b/plugins/platforms/x11/windowed/x11windowed_backend.h @@ -91,6 +91,7 @@ struct Output { xcb_window_t window = XCB_WINDOW_NONE; QSize size; + qreal scale = 1; QPoint xPosition; QPoint internalPosition; NETWinInfo *winInfo = nullptr; diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.cpp b/plugins/platforms/x11/windowed/x11windowed_backend.cpp --- a/plugins/platforms/x11/windowed/x11windowed_backend.cpp +++ b/plugins/platforms/x11/windowed/x11windowed_backend.cpp @@ -198,9 +198,11 @@ if (it == m_windows.constEnd()) { break; } + //generally we don't need to normalise input to the output scale; however because we're getting input + //from a host window that doesn't understand scaling, we need to apply it ourselves so the cursor matches pointerMotion(QPointF(event->root_x - (*it).xPosition.x() + (*it).internalPosition.x(), - event->root_y - (*it).xPosition.y() + (*it).internalPosition.y()), - event->time); + event->root_y - (*it).xPosition.y() + (*it).internalPosition.y()) / it->scale, + event->time); } break; case XCB_KEY_PRESS: @@ -230,8 +232,8 @@ break; } pointerMotion(QPointF(event->root_x - (*it).xPosition.x() + (*it).internalPosition.x(), - event->root_y - (*it).xPosition.y() + (*it).internalPosition.y()), - event->time); + event->root_y - (*it).xPosition.y() + (*it).internalPosition.y()) / it->scale, + event->time); } break; case XCB_CLIENT_MESSAGE: @@ -364,9 +366,10 @@ button = event->detail + BTN_LEFT - 1; return; } + pointerMotion(QPointF(event->root_x - (*it).xPosition.x() + (*it).internalPosition.x(), - event->root_y - (*it).xPosition.y() + (*it).internalPosition.y()), - event->time); + event->root_y - (*it).xPosition.y() + (*it).internalPosition.y()) / it->scale, + event->time); if (pressed) { pointerButtonPressed(button, event->time); } else { @@ -476,7 +479,9 @@ QVector X11WindowedBackend::screenScales() const { QVector ret; - ret.fill(initialOutputScale(), m_windows.count()); + for (auto it = m_windows.constBegin(); it != m_windows.constEnd(); ++it) { + ret << (*it).scale; + } return ret; }