ibus: support high dpi for cursor rectangle
on both X11/xcb and Wayland. Following similar approach in QFcitxPlatformInputContext::cursorRectChanged() https://github.com/fcitx/fcitx5-qt/blob/master/qt5/platforminputcontext/qfcitxplatforminputcontext.cpp#L490-L532 Tested with following configurations: * GNOME on xorg, 100%/125%/150%/200% scale, 1 and 2 monitors * KDE/Plasma X11, 100%/150%/200% scale, 1 monitor * GNOME on Wayland, 100%/200% scale, 1 and 2 monitors Enable fractional scale on GNOME: gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer']" Pick-to: 6.5 6.4 6.2 5.15 Fixes: QTBUG-103393 Change-Id: Idfd3153e4cd9f9530b4db6f089830ec47451a19e Reviewed-by: Ilya Fedin <fedin-ilja2010@ya.ru> Reviewed-by: Weng Xuetian <wengxt@gmail.com> Reviewed-by: Liang Qi <liang.qi@qt.io>
This commit is contained in:
parent
54002671bd
commit
3790821b22
@ -222,10 +222,31 @@ void QIBusPlatformInputContext::cursorRectChanged()
|
||||
QWindow *inputWindow = qApp->focusWindow();
|
||||
if (!inputWindow)
|
||||
return;
|
||||
r.moveTopLeft(inputWindow->mapToGlobal(r.topLeft()));
|
||||
if (!inputWindow->screen())
|
||||
return;
|
||||
|
||||
if (QGuiApplication::platformName().startsWith("wayland"_L1)) {
|
||||
auto margins = inputWindow->frameMargins();
|
||||
r.translate(margins.left(), margins.top());
|
||||
qreal scale = inputWindow->devicePixelRatio();
|
||||
QRect newRect = QRect(r.x() * scale, r.y() * scale, r.width() * scale, r.height() * scale);
|
||||
if (debug)
|
||||
qDebug() << "microFocus" << r;
|
||||
d->context->SetCursorLocation(r.x(), r.y(), r.width(), r.height());
|
||||
qDebug() << "microFocus" << newRect;
|
||||
d->context->SetCursorLocationRelative(newRect.x(), newRect.y(),
|
||||
newRect.width(), newRect.height());
|
||||
return;
|
||||
}
|
||||
|
||||
// x11/xcb
|
||||
auto screenGeometry = inputWindow->screen()->geometry();
|
||||
auto point = inputWindow->mapToGlobal(r.topLeft());
|
||||
qreal scale = inputWindow->devicePixelRatio();
|
||||
auto native = (point - screenGeometry.topLeft()) * scale + screenGeometry.topLeft();
|
||||
QRect newRect(native, r.size() * scale);
|
||||
if (debug)
|
||||
qDebug() << "microFocus" << newRect;
|
||||
d->context->SetCursorLocation(newRect.x(), newRect.y(),
|
||||
newRect.width(), newRect.height());
|
||||
}
|
||||
|
||||
void QIBusPlatformInputContext::setFocusObject(QObject *object)
|
||||
|
Loading…
Reference in New Issue
Block a user