diff options
| author | Russ Cox <rsc@golang.org> | 2025-10-09 19:37:22 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2025-10-09 19:37:41 -0400 |
| commit | 19263a10717840901efc6b1cc2f802e7f5173c55 (patch) | |
| tree | 090ab14934dcb12c8145d9ec185d0fd360056d16 | |
| parent | 00754b35a22d491b614fefe5149bcedad1523ef2 (diff) | |
devdraw: work around XWayland pointer warping
| -rw-r--r-- | src/cmd/devdraw/x11-screen.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c index df7cca46..79dc5c81 100644 --- a/src/cmd/devdraw/x11-screen.c +++ b/src/cmd/devdraw/x11-screen.c @@ -1342,10 +1342,33 @@ _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(); } |