Fix for XWayland pointer warping issue

52 views
Skip to first unread message

Eduard Tudor

unread,
Oct 9, 2025, 5:37:38 AM (8 days ago) Oct 9
to plan9port-dev
Hi all,

Just sharing this to fix warping issues in xwayland. It's based on this SDL2 PR -- https://github.com/libsdl-org/SDL/issues/9539

I can't open a pull request because I have other modifications in x11-screen.c already. Here's a diff instead:

diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c
index 60683087..5e221e32 100644
--- a/src/cmd/devdraw/x11-screen.c
+++ b/src/cmd/devdraw/x11-screen.c
@@ -1382,10 +1382,34 @@ _xtoplan9mouse(Xwin *w, XEvent *e, Mouse *m)
 void
 rpc_setmouse(Client *client, Point p)
 {
+ static XCursor empty_cursor;
  Xwin *w = (Xwin*)client->view;
 
  xlock();
+ // XWayland hack - hide cursor before warping
+ // see https://github.com/libsdl-org/SDL/issues/9539
+ if (!empty_cursor) {
+ Pixmap bm;
+ XColor black;
+ char bmd[] = { 0 };
+ bm = XCreateBitmapFromData(_x.display, w->drawable, bmd, 1, 1);
+ if (bm) {
+ empty_cursor = XCreatePixmapCursor(_x.display, bm, bm, &black, &black, 0, 0);
+ XFreePixmap(_x.display, bm);
+ }
+ }
+
+ if (empty_cursor) {
+ XDefineCursor(_x.display, w->drawable, empty_cursor);
+ XFlush(_x.display);
+ }
+
  XWarpPointer(_x.display, None, w->drawable, 0, 0, 0, 0, p.x, p.y);
+
+ if (empty_cursor) {
+ XDefineCursor(_x.display, w->drawable, _x.cursor);
+ }
+
  XFlush(_x.display);
  xunlock();
 }

Russ Cox

unread,
Oct 9, 2025, 7:40:12 PM (7 days ago) Oct 9
to eduardchrist...@gmail.com, plan9port-dev
Hi Eduard,

Thanks for this. I have applied the patch and published it.

For what it's worth, I tried applying a patch from someone else last month and couldn't get it working on my Linux laptop. It seemed like, at least on the version I was running, the workaround had been closed. I hope that this patch keeps working. (I haven't tried your version on my Linux laptop. After a terrible exchange with the Wayland devs about this issue, I gave up on Linux on the desktop for another few years. It is sad that they are the gatekeepers for the whole experience.)

Best,
Russ


--

---
You received this message because you are subscribed to the Google Groups "plan9port-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plan9port-de...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/plan9port-dev/38c79c9c-37c1-40b5-ac9a-4c652cbb1a12n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages