2 * Copyright © 2009 Red Hat, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
23 * Author: Peter Hutterer
26 /***********************************************************************
28 * Request to allow some device events.
32 #ifdef HAVE_DIX_CONFIG_H
33 #include <dix-config.h>
36 #include "inputstr.h" /* DeviceIntPtr */
37 #include "windowstr.h" /* window structure */
40 #include <X11/extensions/XI2.h>
41 #include <X11/extensions/XI2proto.h>
43 #include "exglobals.h" /* BadDevice */
45 #include "xiallowev.h"
48 SProcXIAllowEvents(ClientPtr client
)
50 REQUEST(xXIAllowEventsReq
);
52 swaps(&stuff
->length
);
53 swaps(&stuff
->deviceid
);
55 if (stuff
->length
> 3) {
56 xXI2_2AllowEventsReq
*req_xi22
= (xXI2_2AllowEventsReq
*) stuff
;
58 swapl(&req_xi22
->touchid
);
59 swapl(&req_xi22
->grab_window
);
62 return ProcXIAllowEvents(client
);
66 ProcXIAllowEvents(ClientPtr client
)
71 XIClientPtr xi_client
;
72 Bool have_xi22
= FALSE
;
74 REQUEST(xXI2_2AllowEventsReq
);
76 xi_client
= dixLookupPrivate(&client
->devPrivates
, XIClientPrivateKey
);
78 if (version_compare(xi_client
->major_version
,
79 xi_client
->minor_version
, 2, 2) >= 0) {
80 REQUEST_AT_LEAST_SIZE(xXI2_2AllowEventsReq
);
84 REQUEST_AT_LEAST_SIZE(xXIAllowEventsReq
);
87 ret
= dixLookupDevice(&dev
, stuff
->deviceid
, client
, DixGetAttrAccess
);
91 time
= ClientTimeToServerTime(stuff
->time
);
93 switch (stuff
->mode
) {
95 AllowSome(client
, time
, dev
, NOT_GRABBED
);
98 AllowSome(client
, time
, dev
, FREEZE_NEXT_EVENT
);
101 AllowSome(client
, time
, dev
, THAWED
);
103 case XIAsyncPairedDevice
:
105 AllowSome(client
, time
, dev
, THAW_OTHERS
);
109 AllowSome(client
, time
, dev
, FREEZE_BOTH_NEXT_EVENT
);
113 AllowSome(client
, time
, dev
, THAWED_BOTH
);
124 rc
= dixLookupWindow(&win
, stuff
->grab_window
, client
, DixReadAccess
);
128 ret
= TouchAcceptReject(client
, dev
, stuff
->mode
, stuff
->touchid
,
129 stuff
->grab_window
, &client
->errorValue
);
133 client
->errorValue
= stuff
->mode
;