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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3458>
This commit is contained in:
Jonas Ådahl 2024-08-29 15:26:39 +02:00 committed by Marge Bot
parent df53f8d6f1
commit 6982f2daae

View File

@ -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