1 // x11-rs: Rust bindings for X11 libraries
2 // The X11 libraries are available under the MIT license.
3 // These bindings are public domain.
4 
5 use std::os::raw::{
6   c_char,
7   c_int,
8   c_uchar,
9   c_ulong,
10   c_ushort,
11 };
12 
13 use ::xlib::{
14   Bool,
15   Display,
16   Time,
17   XID,
18 };
19 
20 
21 //
22 // functions
23 //
24 
25 
26 x11_link! { Xf86vmode, xtst, ["libXtst.so.6", "libXtst.so"], 14,
27   pub fn XRecordAllocRange () -> *mut XRecordRange,
28   pub fn XRecordCreateContext (_6: *mut Display, _5: c_int, _4: *mut c_ulong, _3: c_int, _2: *mut *mut XRecordRange, _1: c_int) -> c_ulong,
29   pub fn XRecordDisableContext (_2: *mut Display, _1: c_ulong) -> c_int,
30   pub fn XRecordEnableContext (_4: *mut Display, _3: c_ulong, _2: Option<unsafe extern "C" fn (*mut c_char, *mut XRecordInterceptData)>, _1: *mut c_char) -> c_int,
31   pub fn XRecordEnableContextAsync (_4: *mut Display, _3: c_ulong, _2: Option<unsafe extern "C" fn (*mut c_char, *mut XRecordInterceptData)>, _1: *mut c_char) -> c_int,
32   pub fn XRecordFreeContext (_2: *mut Display, _1: c_ulong) -> c_int,
33   pub fn XRecordFreeData (_1: *mut XRecordInterceptData) -> (),
34   pub fn XRecordFreeState (_1: *mut XRecordState) -> (),
35   pub fn XRecordGetContext (_3: *mut Display, _2: c_ulong, _1: *mut *mut XRecordState) -> c_int,
36   pub fn XRecordIdBaseMask (_1: *mut Display) -> c_ulong,
37   pub fn XRecordProcessReplies (_1: *mut Display) -> (),
38   pub fn XRecordQueryVersion (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int,
39   pub fn XRecordRegisterClients (_7: *mut Display, _6: c_ulong, _5: c_int, _4: *mut c_ulong, _3: c_int, _2: *mut *mut XRecordRange, _1: c_int) -> c_int,
40   pub fn XRecordUnregisterClients (_4: *mut Display, _3: c_ulong, _2: *mut c_ulong, _1: c_int) -> c_int,
41 variadic:
42 globals:
43 }
44 
45 
46 //
47 // constants
48 //
49 
50 
51 pub const XRecordFromServerTime: c_int = 0x01;
52 pub const XRecordFromClientTime: c_int = 0x02;
53 pub const XRecordFromClientSequence: c_int = 0x04;
54 
55 pub const XRecordCurrentClients: c_ulong = 1;
56 pub const XRecordFutureClients: c_ulong = 2;
57 pub const XRecordAllClients: c_ulong = 3;
58 
59 pub const XRecordFromServer: c_int = 0;
60 pub const XRecordFromClient: c_int = 1;
61 pub const XRecordClientStarted: c_int = 2;
62 pub const XRecordClientDied: c_int = 3;
63 pub const XRecordStartOfData: c_int = 4;
64 pub const XRecordEndOfData: c_int = 5;
65 
66 
67 //
68 // types
69 //
70 
71 
72 pub type XRecordClientSpec = c_ulong;
73 pub type XRecordContext = c_ulong;
74 
75 #[derive(Debug, Clone, Copy, PartialEq)]
76 #[repr(C)]
77 pub struct XRecordClientInfo {
78   pub client: XRecordClientSpec,
79   pub nranges: c_ulong,
80   pub ranges: *mut *mut XRecordRange,
81 }
82 
83 #[derive(Debug, Clone, Copy, PartialEq)]
84 #[repr(C)]
85 pub struct XRecordExtRange {
86   pub ext_major: XRecordRange8,
87   pub ext_minor: XRecordRange16,
88 }
89 
90 #[derive(Debug, Clone, Copy, PartialEq)]
91 #[repr(C)]
92 pub struct XRecordInterceptData {
93   pub id_base: XID,
94   pub server_time: Time,
95   pub client_seq: c_ulong,
96   pub category: c_int,
97   pub client_swapped: Bool,
98   pub data: *mut c_uchar,
99   pub data_len: c_ulong,
100 }
101 
102 #[derive(Debug, Clone, Copy, PartialEq)]
103 #[repr(C)]
104 pub struct XRecordRange {
105   pub core_requests: XRecordRange8,
106   pub core_replies: XRecordRange8,
107   pub ext_requests: XRecordExtRange,
108   pub ext_replies: XRecordExtRange,
109   pub delivered_events: XRecordRange8,
110   pub device_events: XRecordRange8,
111   pub errors: XRecordRange8,
112   pub client_started: Bool,
113   pub client_died: Bool,
114 }
115 
116 #[derive(Debug, Clone, Copy, PartialEq)]
117 #[repr(C)]
118 pub struct XRecordRange8 {
119   pub first: c_uchar,
120   pub last: c_uchar,
121 }
122 
123 #[derive(Debug, Clone, Copy, PartialEq)]
124 #[repr(C)]
125 pub struct XRecordRange16 {
126   pub first: c_ushort,
127   pub last: c_ushort,
128 }
129 
130 #[derive(Debug, Clone, Copy, PartialEq)]
131 #[repr(C)]
132 pub struct XRecordState {
133   pub enabled: Bool,
134   pub datum_flags: c_int,
135   pub nclients: c_ulong,
136   pub client_info: *mut *mut XRecordClientInfo,
137 }
138