From: Hongchao Liu <liuhongchao@xiaomi.com>
Resend of an earlier RFC [1] which unfortunately reached qemu-devel
with a GB2312 charset (due to a corporate e-mail footer my previous
mailer silently appended in Chinese), so patchew could not parse the
patch ("error: cannot convert from gb2312 to UTF-8"). This v2 is the
same code change, re-sent via a mailer that preserves UTF-8 and does
not inject any footer; no source changes relative to v1.
v1: https://lists.nongnu.org/archive/html/qemu-devel/2026-05/msg01701.html
Summary (unchanged from v1):
SDL_SetRelativeMouseMode(SDL_TRUE), which ui/sdl2.c currently enables
on the grab paths via sdl_hide_cursor(), switches SDL on X11/XInput2
to consume only XI_RawMotion events. X servers that can only inject
MotionNotify (VNC via XTestFakeMotionEvent, nested X sessions, some
remote desktop setups) therefore never deliver input to the guest once
it enters a relative-pointer grab. The GTK backend in QEMU already
side-steps the problem by doing manual warp-to-center in gd_motion_event
(ui/gtk.c); this patch applies the same pattern to the SDL2 backend.
Points I would especially like feedback on:
1. Keeping sdl_hide_cursor() around with G_GNUC_UNUSED vs just
deleting it. I kept it for symmetry with sdl_show_cursor() and so
the XI2 rationale has an obvious place to live; I have no strong
preference.
2. Whether the edge-detection threshold (<= 0, >= size - 1) is
agreeable given SDL_SetWindowGrab clamping semantics.
3. Any concerns about the default-behavior change for local-X11
users. In my testing, local-X11 behavior is equivalent: the host
pointer just gets warped by a different code path, while xrel/yrel
delivered to the guest are unchanged.
Tested on:
- Linux/X11 (local Xorg), SDL2 2.30.x, qemu-system-arm with a
relative virtio-mouse: pointer is no longer stuck at the window
edge in grab mode; release after quick drag delivers correctly;
absolute (virtio-tablet) path unchanged.
- Same host reached via VNC: no regression; mouse input stays
functional inside grab.
Not tested: macOS Cocoa, Windows, Wayland-only setups.
Hongchao Liu (1):
ui/sdl2: replace SDL relative mouse mode with manual warp-to-center
ui/sdl2.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 61 insertions(+), 3 deletions(-)
--
2.34.1