aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <[email protected]>2016-11-04 21:48:29 +0000
committerDavid Edmundson <[email protected]>2017-03-29 20:53:22 +0100
commitdec76a77e2fa34f543da72f3dfd6e4267c47d0a5 (patch)
treede1214eaefbc0f83d060bbf1e7a2eb8e4cdb7da3
parent59515b1681a835e1ad5afe4438ab755021297f65 (diff)
Scale input on windowed backend so input co-ordinate system matches host
Summary: In theory we shouldn't need to scale input, however when in windowed mode we need to convert the host into output normal. Reviewers: #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3496
-rw-r--r--plugins/platforms/x11/windowed/x11windowed_backend.cpp19
-rw-r--r--plugins/platforms/x11/windowed/x11windowed_backend.h1
2 files changed, 13 insertions, 7 deletions
diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.cpp b/plugins/platforms/x11/windowed/x11windowed_backend.cpp
index 81abcae..9256f13 100644
--- a/plugins/platforms/x11/windowed/x11windowed_backend.cpp
+++ b/plugins/platforms/x11/windowed/x11windowed_backend.cpp
@@ -198,9 +198,11 @@ void X11WindowedBackend::handleEvent(xcb_generic_event_t *e)
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 @@ void X11WindowedBackend::handleEvent(xcb_generic_event_t *e)
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 @@ void X11WindowedBackend::handleButtonPress(xcb_button_press_event_t *event)
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<QRect> X11WindowedBackend::screenGeometries() const
QVector<qreal> X11WindowedBackend::screenScales() const
{
QVector<qreal> ret;
- ret.fill(initialOutputScale(), m_windows.count());
+ for (auto it = m_windows.constBegin(); it != m_windows.constEnd(); ++it) {
+ ret << (*it).scale;
+ }
return ret;
}
diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.h b/plugins/platforms/x11/windowed/x11windowed_backend.h
index 17ada57..511cd2a 100644
--- a/plugins/platforms/x11/windowed/x11windowed_backend.h
+++ b/plugins/platforms/x11/windowed/x11windowed_backend.h
@@ -91,6 +91,7 @@ private:
struct Output {
xcb_window_t window = XCB_WINDOW_NONE;
QSize size;
+ qreal scale = 1;
QPoint xPosition;
QPoint internalPosition;
NETWinInfo *winInfo = nullptr;