backport, IBus input method cannot set panel position correctly with DPI scaling

This commit is contained in:
Than Ngo 2023-05-05 08:38:50 +02:00
parent b68a9b31e2
commit 7a80470840
2 changed files with 48 additions and 2 deletions

View File

@ -57,7 +57,7 @@
Name: qt5-qtbase
Summary: Qt5 - QtBase components
Version: 5.15.9
Release: 1%{?dist}
Release: 2%{?dist}
# See LGPL_EXCEPTIONS.txt, for exception details
License: LGPL-3.0-only OR GPL-3.0-only WITH Qt-GPL-exception-1.0
@ -148,6 +148,9 @@ Patch101: qtbase-5.15.8-fix-missing-qtsan-include.patch
# https://bugreports.qt.io/browse/QTBUG-112136
Patch102: qtbase-QTBUG-111994.patch
Patch103: qtbase-QTBUG-112136.patch
# IBus input method cannot set panel position correctly with DPI scaling
# https://bugreports.qt.io/browse/QTBUG-103393
Patch104: qtbase-QTBUG-103393.patch
# Do not check any files in %%{_qt5_plugindir}/platformthemes/ for requires.
# Those themes are there for platform integration. If the required libraries are
@ -396,7 +399,7 @@ Qt5 libraries used for drawing widgets and OpenGL items.
## upstream fixes
%patch50 -p1 -b .QT_VERSION_CHECK
%patch -P50 -p1 -b .QT_VERSION_CHECK
# FIXME/TODO : rebase or drop -- rdieter
#patch -P51 -p1 -b .hidpi_scale_at_192
%patch -P52 -p1 -b .moc_macros
@ -425,6 +428,7 @@ Qt5 libraries used for drawing widgets and OpenGL items.
%patch -P101 -p1
%patch -P102 -p1
%patch -P103 -p1
%patch -P104 -p1
# move some bundled libs to ensure they're not accidentally used
pushd src/3rdparty
@ -1104,6 +1108,9 @@ fi
%changelog
* Fri May 05 2023 Than Ngo <than@redhat.com> - 5.15.9-2
- backport, IBus input method cannot set panel position correctly with DPI scaling
* Tue Apr 11 2023 Jan Grulich <jgrulich@redhat.com> - 5.15.9-1
- 5.15.9

39
qtbase-QTBUG-103393.patch Normal file
View File

@ -0,0 +1,39 @@
diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
index 086025472640350341768efed5206b418f324460..49a44519b6aee8cae3c04265ab5065c99005d838 100644
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
@@ -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" << 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" << r;
- d->context->SetCursorLocation(r.x(), r.y(), r.width(), r.height());
+ qDebug() << "microFocus" << newRect;
+ d->context->SetCursorLocation(newRect.x(), newRect.y(),
+ newRect.width(), newRect.height());
}
void QIBusPlatformInputContext::setFocusObject(QObject *object)