2 * xicursorset - set cursor image for an XInput2 pointer
4 * Copyright (C) 2010 Antonio Ospite <ospite@studenti.unina.it>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include <X11/Xcursor/Xcursor.h>
24 #include <X11/extensions/XInput2.h>
27 int main(int argc, char *argv[])
41 if (argc < 3 || argc > 4) {
42 printf("usage: %s <ptrid> <shape> [<theme>]\n",
47 /* TODO: verify that the pointer id is sane and
48 * that it is a master pointer
50 ptrid = atoi(argv[1]);
53 shape = XcursorLibraryShape(shape_name);
55 fprintf(stderr, "Invalid shape name.\n");
59 dpy = XOpenDisplay(NULL);
62 /* TODO: check return value? */
63 screen = DefaultScreen(dpy);
65 /* TODO: check return value? */
66 win = RootWindow(dpy, screen);
68 size = XcursorGetDefaultSize(dpy);
70 fprintf(stderr, "Can't get cursor size.\n");
78 theme = XcursorGetTheme(dpy);
80 fprintf(stderr, "Can't get cursor theme.\n");
85 image = XcursorShapeLoadImage((unsigned int)shape, theme, size);
87 fprintf(stderr, "Can't get cursor image, check <shape> or <theme>.\n");
91 cursor = XcursorImageLoadCursor(dpy, image);
93 XIDefineCursor(dpy, ptrid, win, cursor);