Loop your X cursor around the screen 👉😎👉
git clone https://mcol.xyz/code/xoop
Log | Files | Refs | README | LICENSE

commit b33ae8ecbbad7be4705da00d9d7c4bf0e1847111
parent ec463d8252e42551f4270053edbd289162f4b049
Author: mcol <mcol@posteo.net>
Date:   Fri, 17 Apr 2020 22:56:48 +0100

Create WM-unmanaged InputOnly window to move mouse upon entry

Diffstat:
Mxinf.c | 43++++++++++++++++++++++++++++++++-----------
1 file changed, 32 insertions(+), 11 deletions(-)

diff --git a/xinf.c b/xinf.c @@ -1,21 +1,42 @@ -// gcc xinf.c -lX11 - #include <stdlib.h> #include <X11/Xlib.h> +#include <X11/Xatom.h> int main() { - Display *dpy; + Display *dpy; + Window root; + Window win; + XSetWindowAttributes attrs; + XEvent ev; + + if (NULL == (dpy = XOpenDisplay(NULL))) { + exit(1); + } + + root = RootWindow(dpy, DefaultScreen(dpy)); + attrs.event_mask = KeyPressMask; + Atom window_type = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); + long value = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_NOTIFICATION", False); + + win = XCreateWindow( + dpy, root, 10,10,200,200, 0, CopyFromParent, InputOnly, 0, 0, &attrs + ); + XChangeProperty(dpy, win, window_type, 4, 32, + PropModeReplace, (unsigned char *)&value, 1); - if (NULL == (dpy = XOpenDisplay(NULL))) { - exit(1); - } + XSelectInput(dpy, win, EnterWindowMask); + XMapWindow(dpy, win); + XFlush(dpy); - XWarpPointer(dpy, None, DefaultRootWindow(dpy), 0, 0, 0, 0, 0, 0); + while(1) { + XNextEvent(dpy, &ev); + XWarpPointer(dpy, None, root, 0, 0, 0, 0, 0, 0); + } - if (XCloseDisplay(dpy)) { - exit(1); - } + if (XCloseDisplay(dpy)) { + exit(1); + } - return 0; + return 0; }