1 /************************************************************
2
3 Copyright 2006 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 * XIWarpPointer - Warp the pointer of an extension input device.
30 *
31 */
32 #ifdef HAVE_CONFIG_H
33 #include <config.h>
34 #endif
35
36 #include <stdint.h>
37 #include <X11/extensions/XI2proto.h>
38 #include <X11/Xlibint.h>
39 #include <X11/extensions/XInput2.h>
40 #include <X11/extensions/extutil.h>
41 #include "XIint.h"
42
43 int
XIWarpPointer(Display * dpy,int deviceid,Window src_win,Window dst_win,double src_x,double src_y,unsigned int src_width,unsigned int src_height,double dst_x,double dst_y)44 XIWarpPointer(Display *dpy,
45 int deviceid,
46 Window src_win,
47 Window dst_win,
48 double src_x,
49 double src_y,
50 unsigned int src_width,
51 unsigned int src_height,
52 double dst_x,
53 double dst_y)
54 {
55 xXIWarpPointerReq *req;
56
57 XExtDisplayInfo *info = XInput_find_display(dpy);
58
59 LockDisplay(dpy);
60 if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1)
61 return (NoSuchExtension);
62
63 GetReq(XIWarpPointer, req);
64 req->reqType = info->codes->major_opcode;
65 req->ReqType = X_XIWarpPointer;
66 req->deviceid = deviceid;
67 req->src_win = src_win;
68 req->dst_win = dst_win;
69 req->src_x = (int)(src_x * 65536.0);
70 req->src_y = (int)(src_y * 65536.0);
71 req->src_width = src_width;
72 req->src_height = src_height;
73 req->dst_x = (int)(dst_x * 65536.0);
74 req->dst_y = (int)(dst_y * 65536.0);
75
76
77 UnlockDisplay(dpy);
78 SyncHandle();
79 return Success;
80 }
81