From 6982f2daaef184e7cb9ccf1f5259f971b42c3e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 29 Aug 2024 15:26:39 +0200 Subject: [PATCH] ibus-candidate-popup: Scale coordinates from IBus The coordinates are effectively in the windowing system coordinate space, which when scaling Xwayland, we need to scale these. Do this with the Meta.Window.protocol_to_stage() function on the focused window, which handles it correctly for the corresponding windowing system and configuration. Part-of: --- js/ui/ibusCandidatePopup.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/js/ui/ibusCandidatePopup.js b/js/ui/ibusCandidatePopup.js index f0f4f1a36..5e9ac853f 100644 --- a/js/ui/ibusCandidatePopup.js +++ b/js/ui/ibusCandidatePopup.js @@ -1,6 +1,7 @@ import Clutter from 'gi://Clutter'; import GObject from 'gi://GObject'; import IBus from 'gi://IBus'; +import Mtk from 'gi://Mtk'; import St from 'gi://St'; import * as BoxPointer from './boxpointer.js'; @@ -203,14 +204,29 @@ class IbusCandidatePopup extends BoxPointer.BoxPointer { return; panelService.connect('set-cursor-location', (ps, x, y, w, h) => { - this._setDummyCursorGeometry(x, y, w, h); + const focusWindow = global.display.focus_window; + let rect = new Mtk.Rectangle({x, y, width: w, height: h}); + if (!global.stage.key_focus && focusWindow) + rect = focusWindow.protocol_to_stage_rect(rect); + this._setDummyCursorGeometry( + rect.x, + rect.y, + rect.width, + rect.height); }); try { panelService.connect('set-cursor-location-relative', (ps, x, y, w, h) => { - if (!global.display.focus_window) + const focusWindow = global.display.focus_window; + if (!focusWindow) return; - let window = global.display.focus_window.get_compositor_private(); - this._setDummyCursorGeometry(window.x + x, window.y + y, w, h); + let rect = new Mtk.Rectangle({x, y, width: w, height: h}); + rect = focusWindow.protocol_to_stage_rect(rect); + const windowActor = focusWindow.get_compositor_private(); + this._setDummyCursorGeometry( + windowActor.x + rect.x, + windowActor.y + rect.y, + rect.w, + rect.h); }); } catch (e) { // Only recent IBus versions have support for this signal