Search code examples
cx11xlibmouse-cursor

Set X11 cursor to arrow


I attempted the following in a call to XCreateWindow():

unsigned long ctt_attribute_mask = CWWinGravity | CWCursor;

ctt_attributes->win_gravity = NorthEastGravity;
ctt_attributes->cursor = XC_arrow;

ctt_window = XCreateWindow(dpy, parent, ctt_xpos, ctt_ypos,
             ctt_xy_size, ctt_xy_size, ctt_border,
             ctt_depth, ctt_class, ctt_visual,
             ctt_attribute_mask, ctt_attributes);

This creates the window, but it doesn't affect the pointer when it rolls over the window.

I want to use the user's desktop environment's standard pointer cursor when the mouse appears over my window.

Xlib is required, because this is a toolkit-agnostic program.

ETA: Additional context is available; see create_ctt_window starting on line 35 in the source file.


Solution

    1. ctt_attributes->cursor = XCreateFontCursor(dpy, XC_arrow);
    2. This is not the desktop environment's standard pointer cursor, this is the X11 rather ugly bitmapped cursor. If you want themed cursors, use libXcursor. I have no experience with it.