summaryrefslogtreecommitdiff
path: root/lib/libXi/include/X11/extensions/XInput2.h
blob: 2722142b30290892f02b47130a41280812bfed9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
/*
 * Copyright © 2009 Red Hat, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 */

/* Definitions used by the library and client */

#ifndef _XINPUT2_H_
#define _XINPUT2_H_

#include <X11/Xlib.h>
#include <X11/extensions/XI2.h>
#include <X11/extensions/Xge.h>
#include <X11/extensions/Xfixes.h> /* PointerBarrier */

/*******************************************************************
 *
 */
typedef struct {
    int                 type;
    char*               name;
    Bool                send_core;
    Bool                enable;
} XIAddMasterInfo;

typedef struct {
    int                 type;
    int                 deviceid;
    int                 return_mode; /* AttachToMaster, Floating */
    int                 return_pointer;
    int                 return_keyboard;
} XIRemoveMasterInfo;

typedef struct {
    int                 type;
    int                 deviceid;
    int                 new_master;
} XIAttachSlaveInfo;

typedef struct {
    int                 type;
    int                 deviceid;
} XIDetachSlaveInfo;

typedef union {
    int                   type; /* must be first element */
    XIAddMasterInfo       add;
    XIRemoveMasterInfo    remove;
    XIAttachSlaveInfo     attach;
    XIDetachSlaveInfo     detach;
} XIAnyHierarchyChangeInfo;

typedef struct
{
    int    base;
    int    latched;
    int    locked;
    int    effective;
} XIModifierState;

typedef XIModifierState XIGroupState;

typedef struct {
    int           mask_len;
    unsigned char *mask;
} XIButtonState;

typedef struct {
    int           mask_len;
    unsigned char *mask;
    double        *values;
} XIValuatorState;


typedef struct
{
    int                 deviceid;
    int                 mask_len;
    unsigned char*      mask;
} XIEventMask;

typedef struct
{
    int         type;
    int         sourceid;
} XIAnyClassInfo;

typedef struct
{
    int         type;
    int         sourceid;
    int         num_buttons;
    Atom        *labels;
    XIButtonState state;
} XIButtonClassInfo;

typedef struct
{
    int         type;
    int         sourceid;
    int         num_keycodes;
    int         *keycodes;
} XIKeyClassInfo;

typedef struct
{
    int         type;
    int         sourceid;
    int         number;
    Atom        label;
    double      min;
    double      max;
    double      value;
    int         resolution;
    int         mode;
} XIValuatorClassInfo;

/* new in XI 2.1 */
typedef struct
{
    int         type;
    int         sourceid;
    int         number;
    int         scroll_type;
    double      increment;
    int         flags;
} XIScrollClassInfo;

typedef struct
{
    int         type;
    int         sourceid;
    int         mode;
    int         num_touches;
} XITouchClassInfo;

/* new in XI 2.4 */
typedef struct
{
    int         type;
    int         sourceid;
    int         num_touches;
} XIGestureClassInfo;

typedef struct
{
    int                 deviceid;
    char                *name;
    int                 use;
    int                 attachment;
    Bool                enabled;
    int                 num_classes;
    XIAnyClassInfo      **classes;
} XIDeviceInfo;

typedef struct
{
    int                 modifiers;
    int                 status;
} XIGrabModifiers;

typedef unsigned int BarrierEventID;

typedef struct
{
    int                 deviceid;
    PointerBarrier      barrier;
    BarrierEventID      eventid;
} XIBarrierReleasePointerInfo;

/**
 * Generic XI2 event. All XI2 events have the same header.
 */
typedef struct {
    int           type;         /* GenericEvent */
    unsigned long serial;       /* # of last request processed by server */
    Bool          send_event;   /* true if this came from a SendEvent request */
    Display       *display;     /* Display the event was read from */
    int           extension;    /* XI extension offset */
    int           evtype;
    Time          time;
} XIEvent;


typedef struct {
    int           deviceid;
    int           attachment;
    int           use;
    Bool          enabled;
    int           flags;
} XIHierarchyInfo;

/*
 * Notifies the client that the device hierarchy has been changed. The client
 * is expected to re-query the server for the device hierarchy.
 */
typedef struct {
    int           type;         /* GenericEvent */
    unsigned long serial;       /* # of last request processed by server */
    Bool          send_event;   /* true if this came from a SendEvent request */
    Display       *display;     /* Display the event was read from */
    int           extension;    /* XI extension offset */
    int           evtype;       /* XI_HierarchyChanged */
    Time          time;
    int           flags;
    int           num_info;
    XIHierarchyInfo *info;
} XIHierarchyEvent;

/*
 * Notifies the client that the classes have been changed. This happens when
 * the slave device that sends through the master changes.
 */
typedef struct {
    int           type;         /* GenericEvent */
    unsigned long serial;       /* # of last request processed by server */
    Bool          send_event;   /* true if this came from a SendEvent request */
    Display       *display;     /* Display the event was read from */
    int           extension;    /* XI extension offset */
    int           evtype;       /* XI_DeviceChanged */
    Time          time;
    int           deviceid;     /* id of the device that changed */
    int           sourceid;     /* Source for the new classes. */
    int           reason;       /* Reason for the change */
    int           num_classes;
    XIAnyClassInfo **classes; /* same as in XIDeviceInfo */
} XIDeviceChangedEvent;

typedef struct {
    int           type;         /* GenericEvent */
    unsigned long serial;       /* # of last request processed by server */
    Bool          send_event;   /* true if this came from a SendEvent request */
    Display       *display;     /* Display the event was read from */
    int           extension;    /* XI extension offset */
    int           evtype;
    Time          time;
    int           deviceid;
    int           sourceid;
    int           detail;
    Window        root;
    Window        event;
    Window        child;
    double        root_x;
    double        root_y;
    double        event_x;
    double        event_y;
    int           flags;
    XIButtonState       buttons;
    XIValuatorState     valuators;
    XIModifierState     mods;
    XIGroupState        group;
} XIDeviceEvent;

typedef struct {
    int           type;         /* GenericEvent */
    unsigned long serial;       /* # of last request processed by server */
    Bool          send_event;   /* true if this came from a SendEvent request */
    Display       *display;     /* Display the event was read from */
    int           extension;    /* XI extension offset */
    int           evtype;       /* XI_RawKeyPress, XI_RawKeyRelease, etc. */
    Time          time;
    int           deviceid;
    int           sourceid;     /* Bug: Always 0. https://bugs.freedesktop.org//show_bug.cgi?id=34240 */
    int           detail;
    int           flags;
    XIValuatorState valuators;
    double        *raw_values;
} XIRawEvent;

typedef struct {
    int           type;         /* GenericEvent */
    unsigned long serial;       /* # of last request processed by server */
    Bool          send_event;   /* true if this came from a SendEvent request */
    Display       *display;     /* Display the event was read from */
    int           extension;    /* XI extension offset */
    int           evtype;
    Time          time;
    int           deviceid;
    int           sourceid;
    int           detail;
    Window        root;
    Window        event;
    Window        child;
    double        root_x;
    double        root_y;
    double        event_x;
    double        event_y;
    int           mode;
    Bool          focus;
    Bool          same_screen;
    XIButtonState       buttons;
    XIModifierState     mods;
    XIGroupState        group;
} XIEnterEvent;

typedef XIEnterEvent XILeaveEvent;
typedef XIEnterEvent XIFocusInEvent;
typedef XIEnterEvent XIFocusOutEvent;

typedef struct {
    int           type;         /* GenericEvent */
    unsigned long serial;       /* # of last request processed by server */
    Bool          send_event;   /* true if this came from a SendEvent request */
    Display       *display;     /* Display the event was read from */
    int           extension;    /* XI extension offset */
    int           evtype;       /* XI_PropertyEvent */
    Time          time;
    int           deviceid;     /* id of the device that changed */
    Atom          property;
    int           what;
} XIPropertyEvent;

typedef struct {
    int           type;         /* GenericEvent */
    unsigned long serial;       /* # of last request processed by server */
    Bool          send_event;   /* true if this came from a SendEvent request */
    Display       *display;     /* Display the event was read from */
    int           extension;    /* XI extension offset */
    int           evtype;
    Time          time;
    int           deviceid;
    int           sourceid;
    unsigned int  touchid;
    Window        root;
    Window        event;
    Window        child;
    int           flags;
} XITouchOwnershipEvent;

typedef struct {
    int           type;         /* GenericEvent */
    unsigned long serial;       /* # of last request processed by server */
    Bool          send_event;   /* true if this came from a SendEvent request */
    Display       *display;     /* Display the event was read from */
    int           extension;    /* XI extension offset */
    int           evtype;
    Time          time;
    int           deviceid;
    int           sourceid;
    Window        event;
    Window        root;
    double        root_x;
    double        root_y;
    double        dx;
    double        dy;
    int           dtime;
    int           flags;
    PointerBarrier barrier;
    BarrierEventID eventid;
} XIBarrierEvent;

typedef struct {
    int           type;         /* GenericEvent */
    unsigned long serial;       /* # of last request processed by server */
    Bool          send_event;   /* true if this came from a SendEvent request */
    Display       *display;     /* Display the event was read from */
    int           extension;    /* XI extension offset */
    int           evtype;
    Time          time;
    int           deviceid;
    int           sourceid;
    int           detail;
    Window        root;
    Window        event;
    Window        child;
    double        root_x;
    double        root_y;
    double        event_x;
    double        event_y;
    double        delta_x;
    double        delta_y;
    double        delta_unaccel_x;
    double        delta_unaccel_y;
    double        scale;
    double        delta_angle;
    int           flags;
    XIModifierState     mods;
    XIGroupState        group;
} XIGesturePinchEvent;

typedef struct {
    int           type;         /* GenericEvent */
    unsigned long serial;       /* # of last request processed by server */
    Bool          send_event;   /* true if this came from a SendEvent request */
    Display       *display;     /* Display the event was read from */
    int           extension;    /* XI extension offset */
    int           evtype;
    Time          time;
    int           deviceid;
    int           sourceid;
    int           detail;
    Window        root;
    Window        event;
    Window        child;
    double        root_x;
    double        root_y;
    double        event_x;
    double        event_y;
    double        delta_x;
    double        delta_y;
    double        delta_unaccel_x;
    double        delta_unaccel_y;
    int           flags;
    XIModifierState     mods;
    XIGroupState        group;
} XIGestureSwipeEvent;

_XFUNCPROTOBEGIN

extern Bool     XIQueryPointer(
    Display*            display,
    int                 deviceid,
    Window              win,
    Window*             root,
    Window*             child,
    double*             root_x,
    double*             root_y,
    double*             win_x,
    double*             win_y,
    XIButtonState       *buttons,
    XIModifierState     *mods,
    XIGroupState        *group
);

extern Bool     XIWarpPointer(
    Display*            display,
    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
);

extern Status   XIDefineCursor(
    Display*            display,
    int                 deviceid,
    Window              win,
    Cursor              cursor
);

extern Status   XIUndefineCursor(
    Display*            display,
    int                 deviceid,
    Window              win
);

extern Status   XIChangeHierarchy(
    Display*            display,
    XIAnyHierarchyChangeInfo*  changes,
    int                 num_changes
);

extern Status   XISetClientPointer(
    Display*            dpy,
    Window              win,
    int                 deviceid
);

extern Bool     XIGetClientPointer(
    Display*            dpy,
    Window              win,
    int*                deviceid
);

extern int      XISelectEvents(
     Display*            dpy,
     Window              win,
     XIEventMask         *masks,
     int                 num_masks
);

extern XIEventMask *XIGetSelectedEvents(
     Display*            dpy,
     Window              win,
     int                 *num_masks_return
);

extern Status XIQueryVersion(
     Display*           dpy,
     int*               major_version_inout,
     int*               minor_version_inout
);

extern XIDeviceInfo* XIQueryDevice(
     Display*           dpy,
     int                deviceid,
     int*               ndevices_return
);

extern Status XISetFocus(
     Display*           dpy,
     int                deviceid,
     Window             focus,
     Time               time
);

extern Status XIGetFocus(
     Display*           dpy,
     int                deviceid,
     Window             *focus_return);

extern Status XIGrabDevice(
     Display*           dpy,
     int                deviceid,
     Window             grab_window,
     Time               time,
     Cursor             cursor,
     int                grab_mode,
     int                paired_device_mode,
     Bool               owner_events,
     XIEventMask        *mask
);

extern Status XIUngrabDevice(
     Display*           dpy,
     int                deviceid,
     Time               time
);

extern Status XIAllowEvents(
    Display*            display,
    int                 deviceid,
    int                 event_mode,
    Time                time
);

extern Status XIAllowTouchEvents(
    Display*            display,
    int                 deviceid,
    unsigned int        touchid,
    Window              grab_window,
    int                 event_mode
);

extern int XIGrabButton(
    Display*            display,
    int                 deviceid,
    int                 button,
    Window              grab_window,
    Cursor              cursor,
    int                 grab_mode,
    int                 paired_device_mode,
    int                 owner_events,
    XIEventMask         *mask,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers_inout
);

extern int XIGrabKeycode(
    Display*            display,
    int                 deviceid,
    int                 keycode,
    Window              grab_window,
    int                 grab_mode,
    int                 paired_device_mode,
    int                 owner_events,
    XIEventMask         *mask,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers_inout
);

extern int XIGrabEnter(
    Display*            display,
    int                 deviceid,
    Window              grab_window,
    Cursor              cursor,
    int                 grab_mode,
    int                 paired_device_mode,
    int                 owner_events,
    XIEventMask         *mask,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers_inout
);

extern int XIGrabFocusIn(
    Display*            display,
    int                 deviceid,
    Window              grab_window,
    int                 grab_mode,
    int                 paired_device_mode,
    int                 owner_events,
    XIEventMask         *mask,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers_inout
);

extern int XIGrabTouchBegin(
    Display*            display,
    int                 deviceid,
    Window              grab_window,
    int                 owner_events,
    XIEventMask         *mask,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers_inout
);

extern int XIGrabPinchGestureBegin(
    Display*            display,
    int                 deviceid,
    Window              grab_window,
    int                 grab_mode,
    int                 paired_device_mode,
    int                 owner_events,
    XIEventMask         *mask,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers_inout
);

extern int XIGrabSwipeGestureBegin(
    Display*            display,
    int                 deviceid,
    Window              grab_window,
    int                 grab_mode,
    int                 paired_device_mode,
    int                 owner_events,
    XIEventMask         *mask,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers_inout
);

extern Status XIUngrabButton(
    Display*            display,
    int                 deviceid,
    int                 button,
    Window              grab_window,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers
);

extern Status XIUngrabKeycode(
    Display*            display,
    int                 deviceid,
    int                 keycode,
    Window              grab_window,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers
);

extern Status XIUngrabEnter(
    Display*            display,
    int                 deviceid,
    Window              grab_window,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers
);

extern Status XIUngrabFocusIn(
    Display*            display,
    int                 deviceid,
    Window              grab_window,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers
);

extern Status XIUngrabTouchBegin(
    Display*            display,
    int                 deviceid,
    Window              grab_window,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers
);

extern Status XIUngrabPinchGestureBegin(
    Display*            display,
    int                 deviceid,
    Window              grab_window,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers
);

extern Status XIUngrabSwipeGestureBegin(
    Display*            display,
    int                 deviceid,
    Window              grab_window,
    int                 num_modifiers,
    XIGrabModifiers     *modifiers
);

extern Atom *XIListProperties(
    Display*            display,
    int                 deviceid,
    int                 *num_props_return
);

extern void XIChangeProperty(
    Display*            display,
    int                 deviceid,
    Atom                property,
    Atom                type,
    int                 format,
    int                 mode,
    unsigned char       *data,
    int                 num_items
);

extern void
XIDeleteProperty(
    Display*            display,
    int                 deviceid,
    Atom                property
);

extern Status
XIGetProperty(
    Display*            display,
    int                 deviceid,
    Atom                property,
    long                offset,
    long                length,
    Bool                delete_property,
    Atom                type,
    Atom                *type_return,
    int                 *format_return,
    unsigned long       *num_items_return,
    unsigned long       *bytes_after_return,
    unsigned char       **data
);

extern void
XIBarrierReleasePointers(
    Display*                    display,
    XIBarrierReleasePointerInfo *barriers,
    int                         num_barriers
);

extern void
XIBarrierReleasePointer(
    Display*                    display,
    int                         deviceid,
    PointerBarrier              barrier,
    BarrierEventID              eventid
);

extern void XIFreeDeviceInfo(XIDeviceInfo       *info);

_XFUNCPROTOEND

#endif /* XINPUT2_H */