C ++-在X窗口中更改光标

Chr*_*ris 4 c++ linux x11 mouse-cursor

我以为这很容易找到,但是Google搜索一直无济于事。有没有简单的api来更改X窗口中的鼠标光标?(我知道在Windows中您可以仅调用“ SetCursor”)

kna*_*arf 5

#include <X11/cursorfont.h>

/* ... */

Cursor c;

c = XCreateFontCursor(dpy, XC_xterm); 
XDefineCursor(dpy, w, c);
Run Code Online (Sandbox Code Playgroud)

其中dpy是您的显示,w是您的窗口,XC_xterm是定义光标形状的常量。这是可用光标形状的列表以及图像。