Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ - change the cursor in an X Window

I thought this would be easy to find, but a google search has been very unhelpful. Is there a simple api to change the mouse cursor in your X window? (I know in windows you can just call "SetCursor")

like image 823
Chris Avatar asked Aug 27 '10 11:08

Chris


1 Answers

#include <X11/cursorfont.h>

/* ... */

Cursor c;

c = XCreateFontCursor(dpy, XC_xterm); 
XDefineCursor(dpy, w, c);

Where dpy is your display, w is your window and XC_xterm is a constant defining the shape of your cursor. Here's a list of available cursor shape, along with images.

like image 134
knarf Avatar answered Sep 30 '22 00:09

knarf