Imported Upstream version 1.6.1
[platform/upstream/libXi.git] / src / XISetCPtr.c
1 /************************************************************
2
3 Copyright 2007 Peter Hutterer <peter@cs.unisa.edu.au>
4
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
24
25 */
26
27 /***********************************************************************
28  *
29  * XISetClientPointer - Sets the default pointer for a client. This call is
30  * important for legacy applications that may send ambiguous requests to the
31  * server where the server has to randomly pick a device.
32  * Ideally, the window manager will always send a SetClientPointer request
33  * before the client interacts with an application.
34  */
35 #ifdef HAVE_CONFIG_H
36 #include <config.h>
37 #endif
38
39 #include <stdint.h>
40 #include <X11/extensions/XI2proto.h>
41 #include <X11/Xlibint.h>
42 #include <X11/extensions/XInput2.h>
43 #include <X11/extensions/extutil.h>
44 #include "XIint.h"
45
46 Status
47 XISetClientPointer(Display* dpy, Window win, int deviceid)
48 {
49     xXISetClientPointerReq* req;
50     XExtDisplayInfo *info = XInput_find_display(dpy);
51
52     LockDisplay(dpy);
53     if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1)
54         return (NoSuchExtension);
55
56     GetReq(XISetClientPointer, req);
57     req->reqType = info->codes->major_opcode;
58     req->ReqType = X_XISetClientPointer;
59     req->win = win;
60     req->deviceid = deviceid;
61
62     UnlockDisplay(dpy);
63     SyncHandle();
64     return Success;
65 }