Apply a patch for fixing TDIS-5990 (CVE-2013-1940 allow physically proximate attacker...
[framework/uifw/xorg/server/xorg-server.git] / include / input.h
1 /************************************************************
2
3 Copyright 1987, 1998  The Open Group
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 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
26
27                         All Rights Reserved
28
29 Permission to use, copy, modify, and distribute this software and its 
30 documentation for any purpose and without fee is hereby granted, 
31 provided that the above copyright notice appear in all copies and that
32 both that copyright notice and this permission notice appear in 
33 supporting documentation, and that the name of Digital not be
34 used in advertising or publicity pertaining to distribution of the
35 software without specific, written prior permission.  
36
37 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
43 SOFTWARE.
44
45 ********************************************************/
46
47 #ifndef INPUT_H
48 #define INPUT_H
49
50 #include "misc.h"
51 #include "screenint.h"
52 #include <X11/Xmd.h>
53 #include <X11/Xproto.h>
54 #include <stdint.h>
55 #include "window.h"             /* for WindowPtr */
56 #include "xkbrules.h"
57 #include "events.h"
58 #include "list.h"
59 #include <X11/extensions/XI2.h>
60
61 #define DEVICE_INIT     0
62 #define DEVICE_ON       1
63 #define DEVICE_OFF      2
64 #define DEVICE_CLOSE    3
65
66 #define POINTER_RELATIVE        (1 << 1)
67 #define POINTER_ABSOLUTE        (1 << 2)
68 #define POINTER_ACCELERATE      (1 << 3)
69 #define POINTER_SCREEN          (1 << 4)        /* Data in screen coordinates */
70 #define POINTER_NORAW           (1 << 5)        /* Don't generate RawEvents */
71 #define POINTER_EMULATED        (1 << 6)        /* Event was emulated from another event */
72
73 /* GetTouchEvent flags */
74 #define TOUCH_ACCEPT            (1 << 0)
75 #define TOUCH_REJECT            (1 << 1)
76 #define TOUCH_PENDING_END       (1 << 2)
77 #define TOUCH_CLIENT_ID         (1 << 3)        /* touch ID is the client-visible id */
78 #define TOUCH_REPLAYING         (1 << 4)        /* event is being replayed */
79 #define TOUCH_POINTER_EMULATED  (1 << 5)        /* touch event may be pointer emulated */
80 #define TOUCH_END               (1 << 6)        /* really end this touch now */
81
82 /*int constants for pointer acceleration schemes*/
83 #define PtrAccelNoOp            0
84 #define PtrAccelPredictable     1
85 #define PtrAccelLightweight     2
86 #define PtrAccelDefault         PtrAccelPredictable
87
88 #define MAX_VALUATORS 36
89 /* Maximum number of valuators, divided by six, rounded up, to get number
90  * of events. */
91 #define MAX_VALUATOR_EVENTS 6
92 #define MAX_BUTTONS 256         /* completely arbitrarily chosen */
93
94 #define NO_AXIS_LIMITS -1
95
96 #define MAP_LENGTH      256
97 #define DOWN_LENGTH     32      /* 256/8 => number of bytes to hold 256 bits */
98 #define NullGrab ((GrabPtr)NULL)
99 #define PointerRootWin ((WindowPtr)PointerRoot)
100 #define NoneWin ((WindowPtr)None)
101 #define NullDevice ((DevicePtr)NULL)
102
103 #ifndef FollowKeyboard
104 #define FollowKeyboard          3
105 #endif
106 #ifndef FollowKeyboardWin
107 #define FollowKeyboardWin  ((WindowPtr) FollowKeyboard)
108 #endif
109 #ifndef RevertToFollowKeyboard
110 #define RevertToFollowKeyboard  3
111 #endif
112
113 enum InputLevel {
114     CORE,
115     XI,
116     XI2,
117 };
118
119 typedef unsigned long Leds;
120 typedef struct _OtherClients *OtherClientsPtr;
121 typedef struct _InputClients *InputClientsPtr;
122 typedef struct _DeviceIntRec *DeviceIntPtr;
123 typedef struct _ValuatorClassRec *ValuatorClassPtr;
124 typedef struct _ClassesRec *ClassesPtr;
125 typedef struct _SpriteRec *SpritePtr;
126 typedef struct _TouchClassRec *TouchClassPtr;
127 typedef struct _TouchPointInfo *TouchPointInfoPtr;
128 typedef struct _DDXTouchPointInfo *DDXTouchPointInfoPtr;
129 typedef union _GrabMask GrabMask;
130
131 typedef struct _ValuatorMask ValuatorMask;
132
133 /* The DIX stores incoming input events in this list */
134 extern InternalEvent *InputEventList;
135
136 typedef int (*DeviceProc) (DeviceIntPtr /*device */ ,
137                            int /*what */ );
138
139 typedef void (*ProcessInputProc) (InternalEvent * /*event */ ,
140                                   DeviceIntPtr /*device */ );
141
142 typedef Bool (*DeviceHandleProc) (DeviceIntPtr /*device */ ,
143                                   void *        /*data */
144     );
145
146 typedef void (*DeviceUnwrapProc) (DeviceIntPtr /*device */ ,
147                                   DeviceHandleProc /*proc */ ,
148                                   void *        /*data */
149     );
150
151 /* pointer acceleration handling */
152 typedef void (*PointerAccelSchemeProc) (DeviceIntPtr /*device */ ,
153                                         ValuatorMask * /*valuators */ ,
154                                         CARD32 /*evtime */ );
155
156 typedef void (*DeviceCallbackProc) (DeviceIntPtr /*pDev */ );
157
158 struct _ValuatorAccelerationRec;
159 typedef Bool (*PointerAccelSchemeInitProc) (DeviceIntPtr /*dev */ ,
160                                             struct _ValuatorAccelerationRec *
161                                             /*protoScheme */ );
162
163 typedef struct _DeviceRec {
164     pointer devicePrivate;
165     ProcessInputProc processInputProc;  /* current */
166     ProcessInputProc realInputProc;     /* deliver */
167     ProcessInputProc enqueueInputProc;  /* enqueue */
168     Bool on;                    /* used by DDX to keep state */
169 } DeviceRec, *DevicePtr;
170
171 typedef struct {
172     int click, bell, bell_pitch, bell_duration;
173     Bool autoRepeat;
174     unsigned char autoRepeats[32];
175     Leds leds;
176     unsigned char id;
177 } KeybdCtrl;
178
179 typedef struct {
180     KeySym *map;
181     KeyCode minKeyCode, maxKeyCode;
182     int mapWidth;
183 } KeySymsRec, *KeySymsPtr;
184
185 typedef struct {
186     int num, den, threshold;
187     unsigned char id;
188 } PtrCtrl;
189
190 typedef struct {
191     int resolution, min_value, max_value;
192     int integer_displayed;
193     unsigned char id;
194 } IntegerCtrl;
195
196 typedef struct {
197     int max_symbols, num_symbols_supported;
198     int num_symbols_displayed;
199     KeySym *symbols_supported;
200     KeySym *symbols_displayed;
201     unsigned char id;
202 } StringCtrl;
203
204 typedef struct {
205     int percent, pitch, duration;
206     unsigned char id;
207 } BellCtrl;
208
209 typedef struct {
210     Leds led_values;
211     Mask led_mask;
212     unsigned char id;
213 } LedCtrl;
214
215 extern _X_EXPORT KeybdCtrl defaultKeyboardControl;
216 extern _X_EXPORT PtrCtrl defaultPointerControl;
217
218 typedef struct _InputOption InputOption;
219 typedef struct _XI2Mask XI2Mask;
220
221 typedef struct _InputAttributes {
222     char *product;
223     char *vendor;
224     char *device;
225     char *pnp_id;
226     char *usb_id;
227     char **tags;                /* null-terminated */
228     uint32_t flags;
229 } InputAttributes;
230
231 #define ATTR_KEYBOARD (1<<0)
232 #define ATTR_POINTER (1<<1)
233 #define ATTR_JOYSTICK (1<<2)
234 #define ATTR_TABLET (1<<3)
235 #define ATTR_TOUCHPAD (1<<4)
236 #define ATTR_TOUCHSCREEN (1<<5)
237
238 /* Key/Button has been run through all input processing and events sent to clients. */
239 #define KEY_PROCESSED 1
240 #define BUTTON_PROCESSED 1
241 /* Key/Button has not been fully processed, no events have been sent. */
242 #define KEY_POSTED 2
243 #define BUTTON_POSTED 2
244
245 extern void set_key_down(DeviceIntPtr pDev, int key_code, int type);
246 extern void set_key_up(DeviceIntPtr pDev, int key_code, int type);
247 extern int key_is_down(DeviceIntPtr pDev, int key_code, int type);
248 extern void set_button_down(DeviceIntPtr pDev, int button, int type);
249 extern void set_button_up(DeviceIntPtr pDev, int button, int type);
250 extern int button_is_down(DeviceIntPtr pDev, int button, int type);
251
252 extern void InitCoreDevices(void);
253 extern void InitXTestDevices(void);
254
255 extern _X_EXPORT DeviceIntPtr AddInputDevice(ClientPtr /*client */ ,
256                                              DeviceProc /*deviceProc */ ,
257                                              Bool /*autoStart */ );
258
259 extern _X_EXPORT Bool EnableDevice(DeviceIntPtr /*device */ ,
260                                    BOOL /* sendevent */ );
261
262 extern _X_EXPORT Bool ActivateDevice(DeviceIntPtr /*device */ ,
263                                      BOOL /* sendevent */ );
264
265 extern _X_EXPORT Bool DisableDevice(DeviceIntPtr /*device */ ,
266                                     BOOL /* sendevent */ );
267 extern void DisableAllDevices(void);
268 extern int InitAndStartDevices(void);
269
270 extern void CloseDownDevices(void);
271
272 extern void UndisplayDevices(void);
273
274 extern _X_EXPORT int RemoveDevice(DeviceIntPtr /*dev */ ,
275                                   BOOL /* sendevent */ );
276
277 extern _X_EXPORT int NumMotionEvents(void);
278
279 extern _X_EXPORT int dixLookupDevice(DeviceIntPtr * /* dev */ ,
280                                      int /* id */ ,
281                                      ClientPtr /* client */ ,
282                                      Mask /* access_mode */ );
283
284 extern _X_EXPORT void QueryMinMaxKeyCodes(KeyCode * /*minCode */ ,
285                                           KeyCode * /*maxCode */ );
286
287 extern _X_EXPORT Bool SetKeySymsMap(KeySymsPtr /*dst */ ,
288                                     KeySymsPtr /*src */ );
289
290 extern _X_EXPORT Bool InitButtonClassDeviceStruct(DeviceIntPtr /*device */ ,
291                                                   int /*numButtons */ ,
292                                                   Atom * /* labels */ ,
293                                                   CARD8 * /*map */ );
294
295 extern _X_INTERNAL ValuatorClassPtr AllocValuatorClass(ValuatorClassPtr src,
296                                                        int numAxes);
297
298 extern _X_EXPORT Bool InitValuatorClassDeviceStruct(DeviceIntPtr /*device */ ,
299                                                     int /*numAxes */ ,
300                                                     Atom * /* labels */ ,
301                                                     int /*numMotionEvents */ ,
302                                                     int /*mode */ );
303
304 extern _X_EXPORT Bool InitPointerAccelerationScheme(DeviceIntPtr /*dev */ ,
305                                                     int /*scheme */ );
306
307 extern _X_EXPORT Bool InitFocusClassDeviceStruct(DeviceIntPtr /*device */ );
308
309 extern _X_EXPORT Bool InitTouchClassDeviceStruct(DeviceIntPtr /*device */ ,
310                                                  unsigned int /*max_touches */ ,
311                                                  unsigned int /*mode */ ,
312                                                  unsigned int /*numAxes */ );
313
314 typedef void (*BellProcPtr) (int /*percent */ ,
315                              DeviceIntPtr /*device */ ,
316                              pointer /*ctrl */ ,
317                              int);
318
319 typedef void (*KbdCtrlProcPtr) (DeviceIntPtr /*device */ ,
320                                 KeybdCtrl * /*ctrl */ );
321
322 typedef void (*PtrCtrlProcPtr) (DeviceIntPtr /*device */ ,
323                                 PtrCtrl * /*ctrl */ );
324
325 extern _X_EXPORT Bool InitPtrFeedbackClassDeviceStruct(DeviceIntPtr /*device */
326                                                        ,
327                                                        PtrCtrlProcPtr
328                                                        /*controlProc */ );
329
330 typedef void (*StringCtrlProcPtr) (DeviceIntPtr /*device */ ,
331                                    StringCtrl * /*ctrl */ );
332
333 extern _X_EXPORT Bool InitStringFeedbackClassDeviceStruct(DeviceIntPtr
334                                                           /*device */ ,
335                                                           StringCtrlProcPtr
336                                                           /*controlProc */ ,
337                                                           int /*max_symbols */ ,
338                                                           int
339                                                           /*num_symbols_supported */
340                                                           ,
341                                                           KeySym * /*symbols */
342                                                           );
343
344 typedef void (*BellCtrlProcPtr) (DeviceIntPtr /*device */ ,
345                                  BellCtrl * /*ctrl */ );
346
347 extern _X_EXPORT Bool InitBellFeedbackClassDeviceStruct(DeviceIntPtr /*device */
348                                                         ,
349                                                         BellProcPtr
350                                                         /*bellProc */ ,
351                                                         BellCtrlProcPtr
352                                                         /*controlProc */ );
353
354 typedef void (*LedCtrlProcPtr) (DeviceIntPtr /*device */ ,
355                                 LedCtrl * /*ctrl */ );
356
357 extern _X_EXPORT Bool InitLedFeedbackClassDeviceStruct(DeviceIntPtr /*device */
358                                                        ,
359                                                        LedCtrlProcPtr
360                                                        /*controlProc */ );
361
362 typedef void (*IntegerCtrlProcPtr) (DeviceIntPtr /*device */ ,
363                                     IntegerCtrl * /*ctrl */ );
364
365 extern _X_EXPORT Bool InitIntegerFeedbackClassDeviceStruct(DeviceIntPtr
366                                                            /*device */ ,
367                                                            IntegerCtrlProcPtr
368                                                            /*controlProc */ );
369
370 extern _X_EXPORT Bool InitPointerDeviceStruct(DevicePtr /*device */ ,
371                                               CARD8 * /*map */ ,
372                                               int /*numButtons */ ,
373                                               Atom * /* btn_labels */ ,
374                                               PtrCtrlProcPtr /*controlProc */ ,
375                                               int /*numMotionEvents */ ,
376                                               int /*numAxes */ ,
377                                               Atom * /* axes_labels */ );
378
379 extern _X_EXPORT Bool InitKeyboardDeviceStruct(DeviceIntPtr /*device */ ,
380                                                XkbRMLVOSet * /*rmlvo */ ,
381                                                BellProcPtr /*bellProc */ ,
382                                                KbdCtrlProcPtr /*controlProc */
383                                                );
384
385 extern int ApplyPointerMapping(DeviceIntPtr /* pDev */ ,
386                                CARD8 * /* map */ ,
387                                int /* len */ ,
388                                ClientPtr /* client */ );
389
390 extern Bool BadDeviceMap(BYTE * /*buff */ ,
391                          int /*length */ ,
392                          unsigned /*low */ ,
393                          unsigned /*high */ ,
394                          XID * /*errval */ );
395
396 extern void NoteLedState(DeviceIntPtr /*keybd */ ,
397                          int /*led */ ,
398                          Bool /*on */ );
399
400 extern void MaybeStopHint(DeviceIntPtr /*device */ ,
401                           ClientPtr /*client */ );
402
403 extern void ProcessPointerEvent(InternalEvent * /* ev */ ,
404                                 DeviceIntPtr /*mouse */ );
405
406 extern void ProcessKeyboardEvent(InternalEvent * /*ev */ ,
407                                  DeviceIntPtr /*keybd */ );
408
409 extern Bool LegalModifier(unsigned int /*key */ ,
410                           DeviceIntPtr /*pDev */ );
411
412 extern _X_EXPORT void ProcessInputEvents(void);
413
414 extern _X_EXPORT void InitInput(int /*argc */ ,
415                                 char ** /*argv */ );
416 extern _X_EXPORT void CloseInput(void);
417
418 extern _X_EXPORT int GetMaximumEventsNum(void);
419
420 extern _X_EXPORT InternalEvent *InitEventList(int num_events);
421 extern _X_EXPORT void FreeEventList(InternalEvent *list, int num_events);
422
423 extern void CreateClassesChangedEvent(InternalEvent *event,
424                                       DeviceIntPtr master,
425                                       DeviceIntPtr slave, int flags);
426
427 extern InternalEvent *UpdateFromMaster(InternalEvent *events,
428                                        DeviceIntPtr pDev,
429                                        int type, int *num_events);
430
431 extern _X_EXPORT int GetPointerEvents(InternalEvent *events,
432                                       DeviceIntPtr pDev,
433                                       int type,
434                                       int buttons,
435                                       int flags, const ValuatorMask *mask);
436
437 extern _X_EXPORT void QueuePointerEvents(DeviceIntPtr pDev,
438                                          int type,
439                                          int buttons,
440                                          int flags, const ValuatorMask *mask);
441
442 extern _X_EXPORT int GetKeyboardEvents(InternalEvent *events,
443                                        DeviceIntPtr pDev,
444                                        int type,
445                                        int key_code, const ValuatorMask *mask);
446
447 extern _X_EXPORT void QueueKeyboardEvents(DeviceIntPtr pDev,
448                                           int type,
449                                           int key_code,
450                                           const ValuatorMask *mask);
451
452 extern int GetTouchEvents(InternalEvent *events,
453                           DeviceIntPtr pDev,
454                           uint32_t ddx_touchid,
455                           uint16_t type,
456                           uint32_t flags, const ValuatorMask *mask);
457
458 void QueueTouchEvents(DeviceIntPtr device,
459                       int type,
460                       uint32_t ddx_touchid,
461                       int flags, const ValuatorMask *mask);
462
463 extern int GetTouchOwnershipEvents(InternalEvent *events,
464                                    DeviceIntPtr pDev,
465                                    TouchPointInfoPtr ti,
466                                    uint8_t mode, XID resource, uint32_t flags);
467
468 extern _X_EXPORT int GetProximityEvents(InternalEvent *events,
469                                         DeviceIntPtr pDev,
470                                         int type, const ValuatorMask *mask);
471
472 extern _X_EXPORT void QueueProximityEvents(DeviceIntPtr pDev,
473                                            int type, const ValuatorMask *mask);
474
475 #ifdef PANORAMIX
476 _X_EXPORT
477 #endif
478 extern void PostSyntheticMotion(DeviceIntPtr pDev,
479                                 int x, int y, int screen, unsigned long time);
480
481 extern _X_EXPORT int GetMotionHistorySize(void);
482
483 extern _X_EXPORT void AllocateMotionHistory(DeviceIntPtr pDev);
484
485 extern _X_EXPORT int GetMotionHistory(DeviceIntPtr pDev,
486                                       xTimecoord ** buff,
487                                       unsigned long start,
488                                       unsigned long stop,
489                                       ScreenPtr pScreen, BOOL core);
490
491 extern void ReleaseButtonsAndKeys(DeviceIntPtr dev);
492
493 extern int AttachDevice(ClientPtr client,
494                         DeviceIntPtr slave, DeviceIntPtr master);
495
496 extern _X_EXPORT DeviceIntPtr GetPairedDevice(DeviceIntPtr kbd);
497 extern DeviceIntPtr GetMaster(DeviceIntPtr dev, int type);
498
499 extern _X_EXPORT int AllocDevicePair(ClientPtr client,
500                                      const char *name,
501                                      DeviceIntPtr *ptr,
502                                      DeviceIntPtr *keybd,
503                                      DeviceProc ptr_proc,
504                                      DeviceProc keybd_proc, Bool master);
505 extern void DeepCopyDeviceClasses(DeviceIntPtr from,
506                                   DeviceIntPtr to, DeviceChangedEvent *dce);
507
508 /* Helper functions. */
509 extern _X_EXPORT int generate_modkeymap(ClientPtr client, DeviceIntPtr dev,
510                                         KeyCode **modkeymap,
511                                         int *max_keys_per_mod);
512 extern int change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *map,
513                          int max_keys_per_mod);
514 extern int AllocXTestDevice(ClientPtr client, const char *name,
515                             DeviceIntPtr *ptr, DeviceIntPtr *keybd,
516                             DeviceIntPtr master_ptr, DeviceIntPtr master_keybd);
517 extern BOOL IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master);
518 extern DeviceIntPtr GetXTestDevice(DeviceIntPtr master);
519 extern void SendDevicePresenceEvent(int deviceid, int type);
520 extern _X_EXPORT InputAttributes *DuplicateInputAttributes(InputAttributes *
521                                                            attrs);
522 extern _X_EXPORT void FreeInputAttributes(InputAttributes * attrs);
523
524 enum TouchListenerState {
525     LISTENER_AWAITING_BEGIN = 0,   /**< Waiting for a TouchBegin event */
526     LISTENER_AWAITING_OWNER,       /**< Waiting for a TouchOwnership event */
527     LISTENER_EARLY_ACCEPT,         /**< Waiting for ownership, has already
528                                         accepted */
529     LISTENER_IS_OWNER,             /**< Is the current owner, hasn't accepted */
530     LISTENER_HAS_ACCEPTED,         /**< Is the current owner, has accepted */
531     LISTENER_HAS_END,              /**< Has already received the end event */
532 };
533
534 enum TouchListenerType {
535     LISTENER_GRAB,
536     LISTENER_POINTER_GRAB,
537     LISTENER_REGULAR,
538     LISTENER_POINTER_REGULAR,
539 };
540
541 extern void TouchInitDDXTouchPoint(DeviceIntPtr dev,
542                                    DDXTouchPointInfoPtr ddxtouch);
543 extern DDXTouchPointInfoPtr TouchBeginDDXTouch(DeviceIntPtr dev,
544                                                uint32_t ddx_id);
545 extern void TouchEndDDXTouch(DeviceIntPtr dev, DDXTouchPointInfoPtr ti);
546 extern DDXTouchPointInfoPtr TouchFindByDDXID(DeviceIntPtr dev,
547                                              uint32_t ddx_id, Bool create);
548 extern Bool TouchInitTouchPoint(TouchClassPtr touch, ValuatorClassPtr v,
549                                 int index);
550 extern void TouchFreeTouchPoint(DeviceIntPtr dev, int index);
551 extern TouchPointInfoPtr TouchBeginTouch(DeviceIntPtr dev, int sourceid,
552                                          uint32_t touchid,
553                                          Bool emulate_pointer);
554 extern TouchPointInfoPtr TouchFindByClientID(DeviceIntPtr dev,
555                                              uint32_t client_id);
556 extern void TouchEndTouch(DeviceIntPtr dev, TouchPointInfoPtr ti);
557 extern Bool TouchEventHistoryAllocate(TouchPointInfoPtr ti);
558 extern void TouchEventHistoryFree(TouchPointInfoPtr ti);
559 extern void TouchEventHistoryPush(TouchPointInfoPtr ti, const DeviceEvent *ev);
560 extern void TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev,
561                                     XID resource);
562 extern Bool TouchResourceIsOwner(TouchPointInfoPtr ti, XID resource);
563 extern void TouchAddListener(TouchPointInfoPtr ti, XID resource, int resource_type,
564                              enum InputLevel level, enum TouchListenerType type,
565                              enum TouchListenerState state, WindowPtr window, GrabPtr grab);
566 extern Bool TouchRemoveListener(TouchPointInfoPtr ti, XID resource);
567 extern void TouchSetupListeners(DeviceIntPtr dev, TouchPointInfoPtr ti,
568                                 InternalEvent *ev);
569 extern Bool TouchBuildSprite(DeviceIntPtr sourcedev, TouchPointInfoPtr ti,
570                              InternalEvent *ev);
571 extern Bool TouchBuildDependentSpriteTrace(DeviceIntPtr dev, SpritePtr sprite);
572 extern int TouchConvertToPointerEvent(const InternalEvent *ev,
573                                       InternalEvent *motion,
574                                       InternalEvent *button);
575 extern int TouchGetPointerEventType(const InternalEvent *ev);
576 extern void TouchRemovePointerGrab(DeviceIntPtr dev);
577 extern void TouchListenerGone(XID resource);
578 extern int TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti,
579                                      int listener, int mode);
580 extern int TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
581                              uint32_t touchid, Window grab_window, XID *error);
582
583 /* misc event helpers */
584 extern Mask GetEventMask(DeviceIntPtr dev, xEvent *ev, InputClientsPtr clients);
585 extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
586 extern Bool WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent *ev);
587 extern int GetXI2MaskByte(XI2Mask *mask, DeviceIntPtr dev, int event_type);
588 void FixUpEventFromWindow(SpritePtr pSprite,
589                           xEvent *xE,
590                           WindowPtr pWin, Window child, Bool calcChild);
591 extern WindowPtr XYToWindow(SpritePtr pSprite, int x, int y);
592 extern int EventIsDeliverable(DeviceIntPtr dev, int evtype, WindowPtr win);
593 extern Bool ActivatePassiveGrab(DeviceIntPtr dev, GrabPtr grab,
594                                 InternalEvent *ev, InternalEvent *real_event);
595 /**
596  * Masks specifying the type of event to deliver for an InternalEvent; used
597  * by EventIsDeliverable.
598  * @defgroup EventIsDeliverable return flags
599  * @{
600  */
601 #define EVENT_XI1_MASK                (1 << 0) /**< XI1.x event */
602 #define EVENT_CORE_MASK               (1 << 1) /**< Core event */
603 #define EVENT_DONT_PROPAGATE_MASK     (1 << 2) /**< DontPropagate mask set */
604 #define EVENT_XI2_MASK                (1 << 3) /**< XI2 mask set on window */
605 /* @} */
606
607 enum EventDeliveryState {
608     EVENT_DELIVERED,     /**< Event has been delivered to a client  */
609     EVENT_NOT_DELIVERED, /**< Event was not delivered to any client */
610     EVENT_SKIP,          /**< Event can be discarded by the caller  */
611     EVENT_REJECTED,      /**< Event was rejected for delivery to the client */
612 };
613
614 /* Implemented by the DDX. */
615 extern _X_EXPORT int NewInputDeviceRequest(InputOption *options,
616                                            InputAttributes * attrs,
617                                            DeviceIntPtr *dev);
618 extern _X_EXPORT void DeleteInputDeviceRequest(DeviceIntPtr dev);
619
620 extern _X_EXPORT void DDXRingBell(int volume, int pitch, int duration);
621
622 #define VALUATOR_MODE_ALL_AXES -1
623 extern _X_HIDDEN int valuator_get_mode(DeviceIntPtr dev, int axis);
624 extern _X_HIDDEN void valuator_set_mode(DeviceIntPtr dev, int axis, int mode);
625
626 /* Set to TRUE by default - os/utils.c sets it to FALSE on user request,
627    xfixes/cursor.c uses it to determine if the cursor is enabled */
628 extern Bool EnableCursor;
629
630 extern _X_EXPORT ValuatorMask *valuator_mask_new(int num_valuators);
631 extern _X_EXPORT void valuator_mask_free(ValuatorMask **mask);
632 extern _X_EXPORT void valuator_mask_set_range(ValuatorMask *mask,
633                                               int first_valuator,
634                                               int num_valuators,
635                                               const int *valuators);
636 extern _X_EXPORT void valuator_mask_set(ValuatorMask *mask, int valuator,
637                                         int data);
638 extern _X_EXPORT void valuator_mask_set_double(ValuatorMask *mask, int valuator,
639                                                double data);
640 extern _X_EXPORT void valuator_mask_zero(ValuatorMask *mask);
641 extern _X_EXPORT int valuator_mask_size(const ValuatorMask *mask);
642 extern _X_EXPORT int valuator_mask_isset(const ValuatorMask *mask, int bit);
643 extern _X_EXPORT void valuator_mask_unset(ValuatorMask *mask, int bit);
644 extern _X_EXPORT int valuator_mask_num_valuators(const ValuatorMask *mask);
645 extern _X_EXPORT void valuator_mask_copy(ValuatorMask *dest,
646                                          const ValuatorMask *src);
647 extern _X_EXPORT int valuator_mask_get(const ValuatorMask *mask, int valnum);
648 extern _X_EXPORT double valuator_mask_get_double(const ValuatorMask *mask,
649                                                  int valnum);
650 extern _X_EXPORT Bool valuator_mask_fetch(const ValuatorMask *mask,
651                                           int valnum, int *val);
652 extern _X_EXPORT Bool valuator_mask_fetch_double(const ValuatorMask *mask,
653                                                  int valnum, double *val);
654
655 /* InputOption handling interface */
656 extern _X_EXPORT InputOption *input_option_new(InputOption *list,
657                                                const char *key,
658                                                const char *value);
659 extern _X_EXPORT void input_option_free_list(InputOption **opt);
660 extern _X_EXPORT InputOption *input_option_free_element(InputOption *opt,
661                                                         const char *key);
662 extern _X_EXPORT InputOption *input_option_find(InputOption *list,
663                                                 const char *key);
664 extern _X_EXPORT const char *input_option_get_key(const InputOption *opt);
665 extern _X_EXPORT const char *input_option_get_value(const InputOption *opt);
666 extern _X_EXPORT void input_option_set_key(InputOption *opt, const char *key);
667 extern _X_EXPORT void input_option_set_value(InputOption *opt,
668                                              const char *value);
669
670 extern _X_HIDDEN Bool point_on_screen(ScreenPtr pScreen, int x, int y);
671 extern _X_HIDDEN void update_desktop_dimensions(void);
672
673 #endif                          /* INPUT_H */