• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2009 Red Hat, Inc.
3  *
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:
10  *
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
13  * Software.
14  *
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.
22  *
23  */
24 
25 /* Definitions used by the library and client */
26 
27 #ifndef _XINPUT2_H_
28 #define _XINPUT2_H_
29 
30 #include <X11/Xlib.h>
31 #include <X11/extensions/XI2.h>
32 #include <X11/extensions/Xge.h>
33 
34 /*******************************************************************
35  *
36  */
37 typedef struct {
38     int                 type;
39     char*               name;
40     Bool                send_core;
41     Bool                enable;
42 } XIAddMasterInfo;
43 
44 typedef struct {
45     int                 type;
46     int                 deviceid;
47     int                 return_mode; /* AttachToMaster, Floating */
48     int                 return_pointer;
49     int                 return_keyboard;
50 } XIRemoveMasterInfo;
51 
52 typedef struct {
53     int                 type;
54     int                 deviceid;
55     int                 new_master;
56 } XIAttachSlaveInfo;
57 
58 typedef struct {
59     int                 type;
60     int                 deviceid;
61 } XIDetachSlaveInfo;
62 
63 typedef union {
64     int                   type; /* must be first element */
65     XIAddMasterInfo       add;
66     XIRemoveMasterInfo    remove;
67     XIAttachSlaveInfo     attach;
68     XIDetachSlaveInfo     detach;
69 } XIAnyHierarchyChangeInfo;
70 
71 typedef struct
72 {
73     int    base;
74     int    latched;
75     int    locked;
76     int    effective;
77 } XIModifierState;
78 
79 typedef XIModifierState XIGroupState;
80 
81 typedef struct {
82     int           mask_len;
83     unsigned char *mask;
84 } XIButtonState;
85 
86 typedef struct {
87     int           mask_len;
88     unsigned char *mask;
89     double        *values;
90 } XIValuatorState;
91 
92 
93 typedef struct
94 {
95     int                 deviceid;
96     int                 mask_len;
97     unsigned char*      mask;
98 } XIEventMask;
99 
100 typedef struct
101 {
102     int         type;
103     int         sourceid;
104 } XIAnyClassInfo;
105 
106 typedef struct
107 {
108     int         type;
109     int         sourceid;
110     int         num_buttons;
111     Atom        *labels;
112     XIButtonState state;
113 } XIButtonClassInfo;
114 
115 typedef struct
116 {
117     int         type;
118     int         sourceid;
119     int         num_keycodes;
120     int         *keycodes;
121 } XIKeyClassInfo;
122 
123 typedef struct
124 {
125     int         type;
126     int         sourceid;
127     int         number;
128     Atom        label;
129     double      min;
130     double      max;
131     double      value;
132     int         resolution;
133     int         mode;
134 } XIValuatorClassInfo;
135 
136 /* new in XI 2.1 */
137 typedef struct
138 {
139     int         type;
140     int         sourceid;
141     int         number;
142     int         scroll_type;
143     double      increment;
144     int         flags;
145 } XIScrollClassInfo;
146 
147 typedef struct
148 {
149     int         type;
150     int         sourceid;
151     int         mode;
152     int         num_touches;
153 } XITouchClassInfo;
154 
155 typedef struct
156 {
157     int                 deviceid;
158     char                *name;
159     int                 use;
160     int                 attachment;
161     Bool                enabled;
162     int                 num_classes;
163     XIAnyClassInfo      **classes;
164 } XIDeviceInfo;
165 
166 typedef struct
167 {
168     int                 modifiers;
169     int                 status;
170 } XIGrabModifiers;
171 
172 /**
173  * Generic XI2 event. All XI2 events have the same header.
174  */
175 typedef struct {
176     int           type;         /* GenericEvent */
177     unsigned long serial;       /* # of last request processed by server */
178     Bool          send_event;   /* true if this came from a SendEvent request */
179     Display       *display;     /* Display the event was read from */
180     int           extension;    /* XI extension offset */
181     int           evtype;
182     Time          time;
183 } XIEvent;
184 
185 
186 typedef struct {
187     int           deviceid;
188     int           attachment;
189     int           use;
190     Bool          enabled;
191     int           flags;
192 } XIHierarchyInfo;
193 
194 /*
195  * Notifies the client that the device hierarchy has been changed. The client
196  * is expected to re-query the server for the device hierarchy.
197  */
198 typedef struct {
199     int           type;         /* GenericEvent */
200     unsigned long serial;       /* # of last request processed by server */
201     Bool          send_event;   /* true if this came from a SendEvent request */
202     Display       *display;     /* Display the event was read from */
203     int           extension;    /* XI extension offset */
204     int           evtype;       /* XI_HierarchyChanged */
205     Time          time;
206     int           flags;
207     int           num_info;
208     XIHierarchyInfo *info;
209 } XIHierarchyEvent;
210 
211 /*
212  * Notifies the client that the classes have been changed. This happens when
213  * the slave device that sends through the master changes.
214  */
215 typedef struct {
216     int           type;         /* GenericEvent */
217     unsigned long serial;       /* # of last request processed by server */
218     Bool          send_event;   /* true if this came from a SendEvent request */
219     Display       *display;     /* Display the event was read from */
220     int           extension;    /* XI extension offset */
221     int           evtype;       /* XI_DeviceChanged */
222     Time          time;
223     int           deviceid;     /* id of the device that changed */
224     int           sourceid;     /* Source for the new classes. */
225     int           reason;       /* Reason for the change */
226     int           num_classes;
227     XIAnyClassInfo **classes; /* same as in XIDeviceInfo */
228 } XIDeviceChangedEvent;
229 
230 typedef struct {
231     int           type;         /* GenericEvent */
232     unsigned long serial;       /* # of last request processed by server */
233     Bool          send_event;   /* true if this came from a SendEvent request */
234     Display       *display;     /* Display the event was read from */
235     int           extension;    /* XI extension offset */
236     int           evtype;
237     Time          time;
238     int           deviceid;
239     int           sourceid;
240     int           detail;
241     Window        root;
242     Window        event;
243     Window        child;
244     double        root_x;
245     double        root_y;
246     double        event_x;
247     double        event_y;
248     int           flags;
249     XIButtonState       buttons;
250     XIValuatorState     valuators;
251     XIModifierState     mods;
252     XIGroupState        group;
253 } XIDeviceEvent;
254 
255 typedef struct {
256     int           type;         /* GenericEvent */
257     unsigned long serial;       /* # of last request processed by server */
258     Bool          send_event;   /* true if this came from a SendEvent request */
259     Display       *display;     /* Display the event was read from */
260     int           extension;    /* XI extension offset */
261     int           evtype;       /* XI_RawKeyPress, XI_RawKeyRelease, etc. */
262     Time          time;
263     int           deviceid;
264     int           sourceid;     /* Bug: Always 0. https://bugs.freedesktop.org//show_bug.cgi?id=34240 */
265     int           detail;
266     int           flags;
267     XIValuatorState valuators;
268     double        *raw_values;
269 } XIRawEvent;
270 
271 typedef struct {
272     int           type;         /* GenericEvent */
273     unsigned long serial;       /* # of last request processed by server */
274     Bool          send_event;   /* true if this came from a SendEvent request */
275     Display       *display;     /* Display the event was read from */
276     int           extension;    /* XI extension offset */
277     int           evtype;
278     Time          time;
279     int           deviceid;
280     int           sourceid;
281     int           detail;
282     Window        root;
283     Window        event;
284     Window        child;
285     double        root_x;
286     double        root_y;
287     double        event_x;
288     double        event_y;
289     int           mode;
290     Bool          focus;
291     Bool          same_screen;
292     XIButtonState       buttons;
293     XIModifierState     mods;
294     XIGroupState        group;
295 } XIEnterEvent;
296 
297 typedef XIEnterEvent XILeaveEvent;
298 typedef XIEnterEvent XIFocusInEvent;
299 typedef XIEnterEvent XIFocusOutEvent;
300 
301 typedef struct {
302     int           type;         /* GenericEvent */
303     unsigned long serial;       /* # of last request processed by server */
304     Bool          send_event;   /* true if this came from a SendEvent request */
305     Display       *display;     /* Display the event was read from */
306     int           extension;    /* XI extension offset */
307     int           evtype;       /* XI_PropertyEvent */
308     Time          time;
309     int           deviceid;     /* id of the device that changed */
310     Atom          property;
311     int           what;
312 } XIPropertyEvent;
313 
314 typedef struct {
315     int           type;         /* GenericEvent */
316     unsigned long serial;       /* # of last request processed by server */
317     Bool          send_event;   /* true if this came from a SendEvent request */
318     Display       *display;     /* Display the event was read from */
319     int           extension;    /* XI extension offset */
320     int           evtype;
321     Time          time;
322     int           deviceid;
323     int           sourceid;
324     unsigned int  touchid;
325     Window        root;
326     Window        event;
327     Window        child;
328     int           flags;
329 } XITouchOwnershipEvent;
330 
331 _XFUNCPROTOBEGIN
332 
333 extern Bool     XIQueryPointer(
334     Display*            display,
335     int                 deviceid,
336     Window              win,
337     Window*             root,
338     Window*             child,
339     double*             root_x,
340     double*             root_y,
341     double*             win_x,
342     double*             win_y,
343     XIButtonState       *buttons,
344     XIModifierState     *mods,
345     XIGroupState        *group
346 );
347 
348 extern Bool     XIWarpPointer(
349     Display*            display,
350     int                 deviceid,
351     Window              src_win,
352     Window              dst_win,
353     double              src_x,
354     double              src_y,
355     unsigned int        src_width,
356     unsigned int        src_height,
357     double              dst_x,
358     double              dst_y
359 );
360 
361 extern Status   XIDefineCursor(
362     Display*            display,
363     int                 deviceid,
364     Window              win,
365     Cursor              cursor
366 );
367 
368 extern Status   XIUndefineCursor(
369     Display*            display,
370     int                 deviceid,
371     Window              win
372 );
373 
374 extern Status   XIChangeHierarchy(
375     Display*            display,
376     XIAnyHierarchyChangeInfo*  changes,
377     int                 num_changes
378 );
379 
380 extern Status   XISetClientPointer(
381     Display*            dpy,
382     Window              win,
383     int                 deviceid
384 );
385 
386 extern Bool     XIGetClientPointer(
387     Display*            dpy,
388     Window              win,
389     int*                deviceid
390 );
391 
392 extern int      XISelectEvents(
393      Display*            dpy,
394      Window              win,
395      XIEventMask         *masks,
396      int                 num_masks
397 );
398 
399 extern XIEventMask *XIGetSelectedEvents(
400      Display*            dpy,
401      Window              win,
402      int                 *num_masks_return
403 );
404 
405 extern Status XIQueryVersion(
406      Display*           dpy,
407      int*               major_version_inout,
408      int*               minor_version_inout
409 );
410 
411 extern XIDeviceInfo* XIQueryDevice(
412      Display*           dpy,
413      int                deviceid,
414      int*               ndevices_return
415 );
416 
417 extern Status XISetFocus(
418      Display*           dpy,
419      int                deviceid,
420      Window             focus,
421      Time               time
422 );
423 
424 extern Status XIGetFocus(
425      Display*           dpy,
426      int                deviceid,
427      Window             *focus_return);
428 
429 extern Status XIGrabDevice(
430      Display*           dpy,
431      int                deviceid,
432      Window             grab_window,
433      Time               time,
434      Cursor             cursor,
435      int                grab_mode,
436      int                paired_device_mode,
437      Bool               owner_events,
438      XIEventMask        *mask
439 );
440 
441 extern Status XIUngrabDevice(
442      Display*           dpy,
443      int                deviceid,
444      Time               time
445 );
446 
447 extern Status XIAllowEvents(
448     Display*            display,
449     int                 deviceid,
450     int                 event_mode,
451     Time                time
452 );
453 
454 extern Status XIAllowTouchEvents(
455     Display*            display,
456     int                 deviceid,
457     unsigned int        touchid,
458     Window              grab_window,
459     int                 event_mode
460 );
461 
462 extern int XIGrabButton(
463     Display*            display,
464     int                 deviceid,
465     int                 button,
466     Window              grab_window,
467     Cursor              cursor,
468     int                 grab_mode,
469     int                 paired_device_mode,
470     int                 owner_events,
471     XIEventMask         *mask,
472     int                 num_modifiers,
473     XIGrabModifiers     *modifiers_inout
474 );
475 
476 extern int XIGrabKeycode(
477     Display*            display,
478     int                 deviceid,
479     int                 keycode,
480     Window              grab_window,
481     int                 grab_mode,
482     int                 paired_device_mode,
483     int                 owner_events,
484     XIEventMask         *mask,
485     int                 num_modifiers,
486     XIGrabModifiers     *modifiers_inout
487 );
488 
489 extern int XIGrabEnter(
490     Display*            display,
491     int                 deviceid,
492     Window              grab_window,
493     Cursor              cursor,
494     int                 grab_mode,
495     int                 paired_device_mode,
496     int                 owner_events,
497     XIEventMask         *mask,
498     int                 num_modifiers,
499     XIGrabModifiers     *modifiers_inout
500 );
501 
502 extern int XIGrabFocusIn(
503     Display*            display,
504     int                 deviceid,
505     Window              grab_window,
506     int                 grab_mode,
507     int                 paired_device_mode,
508     int                 owner_events,
509     XIEventMask         *mask,
510     int                 num_modifiers,
511     XIGrabModifiers     *modifiers_inout
512 );
513 
514 extern int XIGrabTouchBegin(
515     Display*            display,
516     int                 deviceid,
517     Window              grab_window,
518     int                 owner_events,
519     XIEventMask         *mask,
520     int                 num_modifiers,
521     XIGrabModifiers     *modifiers_inout
522 );
523 
524 extern Status XIUngrabButton(
525     Display*            display,
526     int                 deviceid,
527     int                 button,
528     Window              grab_window,
529     int                 num_modifiers,
530     XIGrabModifiers     *modifiers
531 );
532 
533 extern Status XIUngrabKeycode(
534     Display*            display,
535     int                 deviceid,
536     int                 keycode,
537     Window              grab_window,
538     int                 num_modifiers,
539     XIGrabModifiers     *modifiers
540 );
541 
542 extern Status XIUngrabEnter(
543     Display*            display,
544     int                 deviceid,
545     Window              grab_window,
546     int                 num_modifiers,
547     XIGrabModifiers     *modifiers
548 );
549 
550 extern Status XIUngrabFocusIn(
551     Display*            display,
552     int                 deviceid,
553     Window              grab_window,
554     int                 num_modifiers,
555     XIGrabModifiers     *modifiers
556 );
557 
558 extern Status XIUngrabTouchBegin(
559     Display*            display,
560     int                 deviceid,
561     Window              grab_window,
562     int                 num_modifiers,
563     XIGrabModifiers     *modifiers
564 );
565 
566 extern Atom *XIListProperties(
567     Display*            display,
568     int                 deviceid,
569     int                 *num_props_return
570 );
571 
572 extern void XIChangeProperty(
573     Display*            display,
574     int                 deviceid,
575     Atom                property,
576     Atom                type,
577     int                 format,
578     int                 mode,
579     unsigned char       *data,
580     int                 num_items
581 );
582 
583 extern void
584 XIDeleteProperty(
585     Display*            display,
586     int                 deviceid,
587     Atom                property
588 );
589 
590 extern Status
591 XIGetProperty(
592     Display*            display,
593     int                 deviceid,
594     Atom                property,
595     long                offset,
596     long                length,
597     Bool                delete_property,
598     Atom                type,
599     Atom                *type_return,
600     int                 *format_return,
601     unsigned long       *num_items_return,
602     unsigned long       *bytes_after_return,
603     unsigned char       **data
604 );
605 
606 extern void XIFreeDeviceInfo(XIDeviceInfo       *info);
607 
608 _XFUNCPROTOEND
609 
610 #endif /* XINPUT2_H */
611