diff --git a/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.InputContext.xml b/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.InputContext.xml
index 9c67a38c5701..30c326d06fc2 100644
--- a/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.InputContext.xml
+++ b/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.InputContext.xml
@@ -14,6 +14,12 @@
       <arg name="w" direction="in" type="i"/>
       <arg name="h" direction="in" type="i"/>
     </method>
+    <method name='SetCursorLocationRelative'>
+      <arg name="x" direction="in" type="i"/>
+      <arg name="y" direction="in" type="i"/>
+      <arg name="w" direction="in" type="i"/>
+      <arg name="h" direction="in" type="i"/>
+    </method>
     <method name="FocusIn"/>
     <method name="FocusOut"/>
     <method name="Reset"/>
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", Qt::CaseInsensitive)) {
+        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)
