1c27c18e8Smrg/************************************************************
2c27c18e8Smrg
3c27c18e8SmrgCopyright 2006 Peter Hutterer <peter@cs.unisa.edu.au>
4c27c18e8Smrg
5c27c18e8SmrgPermission to use, copy, modify, distribute, and sell this software and its
6c27c18e8Smrgdocumentation for any purpose is hereby granted without fee, provided that
7c27c18e8Smrgthe above copyright notice appear in all copies and that both that
8c27c18e8Smrgcopyright notice and this permission notice appear in supporting
9c27c18e8Smrgdocumentation.
10c27c18e8Smrg
11c27c18e8SmrgThe above copyright notice and this permission notice shall be included in
12c27c18e8Smrgall copies or substantial portions of the Software.
13c27c18e8Smrg
14c27c18e8SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15c27c18e8SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16c27c18e8SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17c27c18e8SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18c27c18e8SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19c27c18e8SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20c27c18e8Smrg
21c27c18e8SmrgExcept as contained in this notice, the name of The Open Group shall not be
22c27c18e8Smrgused in advertising or otherwise to promote the sale, use or other dealings
23c27c18e8Smrgin this Software without prior written authorization from The Open Group.
24c27c18e8Smrg
25c27c18e8Smrg*/
26c27c18e8Smrg
27c27c18e8Smrg/***********************************************************************
28c27c18e8Smrg *
29c27c18e8Smrg * XIDefineCursor - Change the cursor of an extension input device.
30c27c18e8Smrg *
31c27c18e8Smrg */
32f1ee322dSmrg#ifdef HAVE_CONFIG_H
33f1ee322dSmrg#include <config.h>
34f1ee322dSmrg#endif
35f1ee322dSmrg
36c27c18e8Smrg#include <stdint.h>
37c27c18e8Smrg#include <X11/extensions/XI2proto.h>
38c27c18e8Smrg#include <X11/Xlibint.h>
39c27c18e8Smrg#include <X11/extensions/XInput2.h>
40c27c18e8Smrg#include <X11/extensions/extutil.h>
41c27c18e8Smrg#include "XIint.h"
42c27c18e8Smrg
43c27c18e8Smrg
44c27c18e8Smrgint XIDefineCursor(Display *dpy, int deviceid, Window w, Cursor cursor)
45c27c18e8Smrg{
46c27c18e8Smrg    xXIChangeCursorReq *req;
47c27c18e8Smrg
48c27c18e8Smrg    XExtDisplayInfo *info = XInput_find_display(dpy);
49c27c18e8Smrg    LockDisplay(dpy);
50c27c18e8Smrg
51b789ec8aSmrg    if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1)
52c27c18e8Smrg	return (NoSuchExtension);
53c27c18e8Smrg
54c27c18e8Smrg    GetReq(XIChangeCursor, req);
55c27c18e8Smrg    req->reqType = info->codes->major_opcode;
56c27c18e8Smrg    req->ReqType = X_XIChangeCursor;
57c27c18e8Smrg    req->deviceid = deviceid;
58c27c18e8Smrg    req->win = w;
59c27c18e8Smrg    req->cursor = cursor;
60c27c18e8Smrg    UnlockDisplay(dpy);
61c27c18e8Smrg    SyncHandle();
62c27c18e8Smrg    return Success;
63c27c18e8Smrg}
64c27c18e8Smrg
65c27c18e8Smrgint XIUndefineCursor(Display *dpy, int deviceid, Window w)
66c27c18e8Smrg{
67c27c18e8Smrg    return XIDefineCursor(dpy, deviceid, w, None);
68c27c18e8Smrg}
69c27c18e8Smrg
70