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::{c_char, c_int, c_long, c_uchar, c_uint, c_ulong}; |
6 | |
7 | use crate::xlib::{Bool, Display, Drawable, Status, Time, XID}; |
8 | |
9 | // |
10 | // functions |
11 | // |
12 | |
13 | x11_link! { Xext, xext, ["libXext.so.6" , "libXext.so" ], 38, |
14 | pub fn XSyncQueryExtension(dpy: *mut Display, event_base: *mut c_int, error_base: *mut c_int) -> Status, |
15 | pub fn XSyncInitialize(dpy: *mut Display, major_version: *mut c_int, minor_version: *mut c_int) -> Status, |
16 | pub fn XSyncListSystemCounters(dpy: *mut Display, n_counters: *mut c_int) -> *mut XSyncSystemCounter, |
17 | pub fn XSyncFreeSystemCounterList(list: *mut XSyncSystemCounter) -> (), |
18 | pub fn XSyncCreateCounter(dpy: *mut Display, initial_value: XSyncValue) -> XSyncCounter, |
19 | pub fn XSyncSetCounter(dpy: *mut Display, counter: XSyncCounter, value: XSyncValue) -> Status, |
20 | pub fn XSyncChangeCounter(dpy: *mut Display, counter: XSyncCounter, value: XSyncValue) -> Status, |
21 | pub fn XSyncDestroyCounter(dpy: *mut Display, value: XSyncCounter) -> Status, |
22 | pub fn XSyncQueryCounter(dpy: *mut Display, counter: XSyncCounter, value: *mut XSyncValue) -> Status, |
23 | pub fn XSyncAwait(dpy: *mut Display, wait_list: *mut XSyncWaitCondition, n_conditions: c_int) -> Status, |
24 | pub fn XSyncCreateAlarm(dpy: *mut Display, values_mask: c_ulong, values: *mut XSyncAlarmAttributes) -> XSyncAlarm, |
25 | pub fn XSyncDestroyAlarm(dpy: *mut Display, alarm: XSyncAlarm) -> Status, |
26 | pub fn XSyncQueryAlarm(dpy: *mut Display, alarm: XSyncAlarm, values: *mut XSyncAlarmAttributes) -> Status, |
27 | pub fn XSyncChangeAlarm(dpy: *mut Display, alarm: XSyncAlarm, values_mask: c_ulong, values: *mut XSyncAlarmAttributes) -> Status, |
28 | pub fn XSyncSetPriority(dpy: *mut Display, client_resource_id: XID, priority: c_int) -> Status, |
29 | pub fn XSyncGetPriority(dpy: *mut Display, client_resource_id: XID, priority: *mut c_int) -> Status, |
30 | pub fn XSyncCreateFence(dpy: *mut Display, d: Drawable, initially_triggered: Bool) -> XSyncFence, |
31 | pub fn XSyncTriggerFence(dpy: *mut Display, fence: XSyncFence) -> Bool, |
32 | pub fn XSyncResetFence(dpy: *mut Display, fence: XSyncFence) -> Bool, |
33 | pub fn XSyncDestroyFence(dpy: *mut Display, fence: XSyncFence) -> Bool, |
34 | pub fn XSyncQueryFence(dpy: *mut Display, fence: XSyncFence, triggered: *mut Bool) -> Bool, |
35 | pub fn XSyncAwaitFence(dpy: *mut Display, fence_list: *const XSyncFence, n_fences: c_int) -> Bool, |
36 | pub fn XSyncIntToValue(pv: *mut XSyncValue, i: c_int) -> (), |
37 | pub fn XSyncIntsToValue(pv: *mut XSyncValue, l: c_uint, h: c_int) -> (), |
38 | pub fn XSyncValueGreaterThan(a: XSyncValue, b: XSyncValue) -> Bool, |
39 | pub fn XSyncValueLessThan(a: XSyncValue, b: XSyncValue) -> Bool, |
40 | pub fn XSyncValueGreaterOrEqual(a: XSyncValue, b: XSyncValue) -> Bool, |
41 | pub fn XSyncValueLessOrEqual(a: XSyncValue, b: XSyncValue) -> Bool, |
42 | pub fn XSyncValueEqual(a: XSyncValue, b: XSyncValue) -> Bool, |
43 | pub fn XSyncValueIsNegative(v: XSyncValue) -> Bool, |
44 | pub fn XSyncValueIsZero(v: XSyncValue) -> Bool, |
45 | pub fn XSyncValueIsPositive(v: XSyncValue) -> Bool, |
46 | pub fn XSyncValueLow32(v: XSyncValue) -> c_uint, |
47 | pub fn XSyncValueHigh32(v: XSyncValue) -> c_int, |
48 | pub fn XSyncValueAdd(presult: *mut XSyncValue, a: XSyncValue, b: XSyncValue, poverflow: *mut c_int) -> (), |
49 | pub fn XSyncValueSubtract(presult: *mut XSyncValue, a: XSyncValue, b: XSyncValue, poverflow: *mut c_int) -> (), |
50 | pub fn XSyncMaxValue(pv: *mut XSyncValue) -> (), |
51 | pub fn XSyncMinValue(pv: *mut XSyncValue) -> (), |
52 | variadic: |
53 | globals: |
54 | } |
55 | |
56 | // |
57 | // types |
58 | // |
59 | |
60 | pub type XSyncValueType = c_uint; |
61 | pub type XSyncTestType = c_uint; |
62 | pub type XSyncAlarmState = c_uint; |
63 | pub type XSyncCounter = XID; |
64 | pub type XSyncAlarm = XID; |
65 | pub type XSyncFence = XID; |
66 | |
67 | #[repr (C)] |
68 | #[derive (Debug, Copy, Clone)] |
69 | pub struct XSyncAlarmError { |
70 | pub type_: c_int, |
71 | pub display: *mut Display, |
72 | pub alarm: XSyncAlarm, |
73 | pub serial: c_ulong, |
74 | pub error_code: c_uchar, |
75 | pub request_code: c_uchar, |
76 | pub minor_code: c_uchar, |
77 | } |
78 | #[repr (C)] |
79 | #[derive (Debug, Copy, Clone)] |
80 | pub struct XSyncCounterError { |
81 | pub type_: c_int, |
82 | pub display: *mut Display, |
83 | pub counter: XSyncCounter, |
84 | pub serial: c_ulong, |
85 | pub error_code: c_uchar, |
86 | pub request_code: c_uchar, |
87 | pub minor_code: c_uchar, |
88 | } |
89 | |
90 | #[repr (C)] |
91 | #[derive (Debug, Copy, Clone)] |
92 | pub struct XSyncValue { |
93 | pub hi: c_int, |
94 | pub lo: c_uint, |
95 | } |
96 | |
97 | #[repr (C)] |
98 | #[derive (Debug, Copy, Clone)] |
99 | pub struct XSyncTrigger { |
100 | pub counter: XSyncCounter, |
101 | pub value_type: XSyncValueType, |
102 | pub wait_value: XSyncValue, |
103 | pub test_type: XSyncTestType, |
104 | } |
105 | #[repr (C)] |
106 | #[derive (Debug, Copy, Clone)] |
107 | pub struct XSyncWaitCondition { |
108 | pub trigger: XSyncTrigger, |
109 | pub event_threshold: XSyncValue, |
110 | } |
111 | #[repr (C)] |
112 | #[derive (Debug, Copy, Clone)] |
113 | pub struct XSyncAlarmAttributes { |
114 | pub trigger: XSyncTrigger, |
115 | pub delta: XSyncValue, |
116 | pub events: Bool, |
117 | pub state: XSyncAlarmState, |
118 | } |
119 | #[repr (C)] |
120 | #[derive (Debug, Copy, Clone)] |
121 | pub struct XSyncCounterNotifyEvent { |
122 | pub type_: c_int, |
123 | pub serial: c_ulong, |
124 | pub send_event: Bool, |
125 | pub display: *mut Display, |
126 | pub counter: XSyncCounter, |
127 | pub wait_value: XSyncValue, |
128 | pub counter_value: XSyncValue, |
129 | pub time: Time, |
130 | pub count: c_int, |
131 | pub destroyed: Bool, |
132 | } |
133 | #[repr (C)] |
134 | #[derive (Debug, Copy, Clone)] |
135 | pub struct XSyncAlarmNotifyEvent { |
136 | pub type_: c_int, |
137 | pub serial: c_ulong, |
138 | pub send_event: Bool, |
139 | pub display: *mut Display, |
140 | pub alarm: XSyncAlarm, |
141 | pub counter_value: XSyncValue, |
142 | pub alarm_value: XSyncValue, |
143 | pub time: Time, |
144 | pub state: XSyncAlarmState, |
145 | } |
146 | |
147 | #[repr (C)] |
148 | #[derive (Debug, Copy, Clone)] |
149 | pub struct XSyncSystemCounter { |
150 | pub name: *mut c_char, |
151 | pub counter: XSyncCounter, |
152 | pub resolution: XSyncValue, |
153 | } |
154 | |
155 | // |
156 | // constants |
157 | // |
158 | |
159 | pub const SYNC_NAME: &str = "SYNC" ; |
160 | |
161 | pub const SYNC_MAJOR_VERSION: c_int = 3; |
162 | pub const SYNC_MINOR_VERSION: c_int = 1; |
163 | |
164 | pub const XSyncCounterNotify: c_long = 0; |
165 | pub const XSyncAlarmNotify: c_long = 1; |
166 | pub const XSyncAlarmNotifyMask: c_long = 1 << XSyncAlarmNotify; |
167 | |
168 | pub const XSyncNumberEvents: c_long = 2; |
169 | |
170 | pub const XSyncBadCounter: c_long = 0; |
171 | pub const XSyncBadAlarm: c_long = 1; |
172 | pub const XSyncBadFence: c_long = 2; |
173 | pub const XSyncNumberErrors: c_long = XSyncBadFence + 1; |
174 | |
175 | pub const XSyncCACounter: c_long = 1 << 0; |
176 | pub const XSyncCAValueType: c_long = 1 << 1; |
177 | pub const XSyncCAValue: c_long = 1 << 2; |
178 | pub const XSyncCATestType: c_long = 1 << 3; |
179 | pub const XSyncCADelta: c_long = 1 << 4; |
180 | pub const XSyncCAEvents: c_long = 1 << 5; |
181 | |
182 | pub const XSyncValueType_XSyncAbsolute: XSyncValueType = 0; |
183 | pub const XSyncValueType_XSyncRelative: XSyncValueType = 1; |
184 | |
185 | pub const XSyncTestType_XSyncPositiveTransition: XSyncTestType = 0; |
186 | pub const XSyncTestType_XSyncNegativeTransition: XSyncTestType = 1; |
187 | pub const XSyncTestType_XSyncPositiveComparison: XSyncTestType = 2; |
188 | pub const XSyncTestType_XSyncNegativeComparison: XSyncTestType = 3; |
189 | |
190 | pub const XSyncAlarmState_XSyncAlarmActive: XSyncAlarmState = 0; |
191 | pub const XSyncAlarmState_XSyncAlarmInactive: XSyncAlarmState = 1; |
192 | pub const XSyncAlarmState_XSyncAlarmDestroyed: XSyncAlarmState = 2; |
193 | |