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/>.
22 #include<X11/Xcursor/Xcursor.h>
23 #include<X11/extensions/XInput2.h>
26 int main(int argc, char *argv[])
40 if (argc < 3 || argc > 4) {
41 printf("usage: xicursor <ptrid> <shape> [<theme>]\n");
45 /* TODO: verify that the pointer id is sane and
46 * that it is a master pointer
48 ptrid = atoi(argv[1]);
51 shape = XcursorLibraryShape(shape_name);
53 fprintf(stderr, "Invalid shape name.\n");
57 dpy = XOpenDisplay(NULL);
60 /* TODO: check return value? */
61 screen = DefaultScreen(dpy);
63 /* TODO: check return value? */
64 win = RootWindow(dpy, screen);
66 size = XcursorGetDefaultSize(dpy);
68 fprintf(stderr, "Can't get cursor size.\n");
76 theme = XcursorGetTheme(dpy);
78 fprintf(stderr, "Can't get cursor theme.\n");
82 image = XcursorShapeLoadImage(shape, theme, size);
84 fprintf(stderr, "Can't get cursor image, check <shape> or <theme>.\n");
88 cursor = XcursorImageLoadCursor(dpy, image);
90 XIDefineCursor(dpy, ptrid, win, cursor);