开发者

C++ - change the cursor in an X Window

开发者 https://www.devze.com 2023-01-14 09:04 出处:网络
I thought this would be easy to find, but a google search has been very unhelpful. Is ther开发者_如何学JAVAe a simple api to change the mouse cursor in your X window? (I know in windows you can just c

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


#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.


Looks like the equivalent of a SetCursor call is XDefineCursor. You can get a Cursor id by calling XCreateFontCursor and passing in one of the shapes from X11/cursorfont.h.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号