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
#![allow(unused_unsafe)]
use base;
use ffi::base::*;
use ffi::xc_misc::*;
use libc::{self, c_char, c_int, c_uint, c_void};
use std;
use std::iter::Iterator;
pub fn id() -> &'static mut base::Extension {
unsafe {
&mut xcb_xc_misc_id
}
}
pub const MAJOR_VERSION: u32 = 1;
pub const MINOR_VERSION: u32 = 1;
pub const GET_VERSION: u8 = 0;
pub type GetVersionCookie<'a> = base::Cookie<'a, xcb_xc_misc_get_version_cookie_t>;
impl<'a> GetVersionCookie<'a> {
pub fn get_reply(&self) -> Result<GetVersionReply, base::GenericError> {
unsafe {
if self.checked {
let mut err: *mut xcb_generic_error_t = std::ptr::null_mut();
let reply = GetVersionReply {
ptr: xcb_xc_misc_get_version_reply (self.conn.get_raw_conn(), self.cookie, &mut err)
};
if err.is_null() { Ok (reply) }
else { Err(base::GenericError { ptr: err }) }
} else {
Ok( GetVersionReply {
ptr: xcb_xc_misc_get_version_reply (self.conn.get_raw_conn(), self.cookie,
std::ptr::null_mut())
})
}
}
}
}
pub type GetVersionReply = base::Reply<xcb_xc_misc_get_version_reply_t>;
impl GetVersionReply {
pub fn server_major_version(&self) -> u16 {
unsafe {
(*self.ptr).server_major_version
}
}
pub fn server_minor_version(&self) -> u16 {
unsafe {
(*self.ptr).server_minor_version
}
}
}
pub fn get_version<'a>(c : &'a base::Connection,
client_major_version: u16,
client_minor_version: u16)
-> GetVersionCookie<'a> {
unsafe {
let cookie = xcb_xc_misc_get_version(c.get_raw_conn(),
client_major_version as u16,
client_minor_version as u16);
GetVersionCookie {
cookie: cookie,
conn: c,
checked: true
}
}
}
pub fn get_version_unchecked<'a>(c : &'a base::Connection,
client_major_version: u16,
client_minor_version: u16)
-> GetVersionCookie<'a> {
unsafe {
let cookie = xcb_xc_misc_get_version_unchecked(c.get_raw_conn(),
client_major_version as u16,
client_minor_version as u16);
GetVersionCookie {
cookie: cookie,
conn: c,
checked: false
}
}
}
pub const GET_XID_RANGE: u8 = 1;
pub type GetXidRangeCookie<'a> = base::Cookie<'a, xcb_xc_misc_get_xid_range_cookie_t>;
impl<'a> GetXidRangeCookie<'a> {
pub fn get_reply(&self) -> Result<GetXidRangeReply, base::GenericError> {
unsafe {
if self.checked {
let mut err: *mut xcb_generic_error_t = std::ptr::null_mut();
let reply = GetXidRangeReply {
ptr: xcb_xc_misc_get_xid_range_reply (self.conn.get_raw_conn(), self.cookie, &mut err)
};
if err.is_null() { Ok (reply) }
else { Err(base::GenericError { ptr: err }) }
} else {
Ok( GetXidRangeReply {
ptr: xcb_xc_misc_get_xid_range_reply (self.conn.get_raw_conn(), self.cookie,
std::ptr::null_mut())
})
}
}
}
}
pub type GetXidRangeReply = base::Reply<xcb_xc_misc_get_xid_range_reply_t>;
impl GetXidRangeReply {
pub fn start_id(&self) -> u32 {
unsafe {
(*self.ptr).start_id
}
}
pub fn count(&self) -> u32 {
unsafe {
(*self.ptr).count
}
}
}
pub fn get_xid_range<'a>(c: &'a base::Connection)
-> GetXidRangeCookie<'a> {
unsafe {
let cookie = xcb_xc_misc_get_xid_range(c.get_raw_conn());
GetXidRangeCookie {
cookie: cookie,
conn: c,
checked: true
}
}
}
pub fn get_xid_range_unchecked<'a>(c: &'a base::Connection)
-> GetXidRangeCookie<'a> {
unsafe {
let cookie = xcb_xc_misc_get_xid_range_unchecked(c.get_raw_conn());
GetXidRangeCookie {
cookie: cookie,
conn: c,
checked: false
}
}
}
pub const GET_XID_LIST: u8 = 2;
pub type GetXidListCookie<'a> = base::Cookie<'a, xcb_xc_misc_get_xid_list_cookie_t>;
impl<'a> GetXidListCookie<'a> {
pub fn get_reply(&self) -> Result<GetXidListReply, base::GenericError> {
unsafe {
if self.checked {
let mut err: *mut xcb_generic_error_t = std::ptr::null_mut();
let reply = GetXidListReply {
ptr: xcb_xc_misc_get_xid_list_reply (self.conn.get_raw_conn(), self.cookie, &mut err)
};
if err.is_null() { Ok (reply) }
else { Err(base::GenericError { ptr: err }) }
} else {
Ok( GetXidListReply {
ptr: xcb_xc_misc_get_xid_list_reply (self.conn.get_raw_conn(), self.cookie,
std::ptr::null_mut())
})
}
}
}
}
pub type GetXidListReply = base::Reply<xcb_xc_misc_get_xid_list_reply_t>;
impl GetXidListReply {
pub fn ids_len(&self) -> u32 {
unsafe {
(*self.ptr).ids_len
}
}
pub fn ids(&self) -> &[u32] {
unsafe {
let field = self.ptr;
let len = xcb_xc_misc_get_xid_list_ids_length(field) as usize;
let data = xcb_xc_misc_get_xid_list_ids(field);
std::slice::from_raw_parts(data, len)
}
}
}
pub fn get_xid_list<'a>(c : &'a base::Connection,
count: u32)
-> GetXidListCookie<'a> {
unsafe {
let cookie = xcb_xc_misc_get_xid_list(c.get_raw_conn(),
count as u32);
GetXidListCookie {
cookie: cookie,
conn: c,
checked: true
}
}
}
pub fn get_xid_list_unchecked<'a>(c : &'a base::Connection,
count: u32)
-> GetXidListCookie<'a> {
unsafe {
let cookie = xcb_xc_misc_get_xid_list_unchecked(c.get_raw_conn(),
count as u32);
GetXidListCookie {
cookie: cookie,
conn: c,
checked: false
}
}
}