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_int, c_long, c_uint, c_ulong}; |
6 | |
7 | use crate::sync::XSyncFence; |
8 | use crate::xfixes::XserverRegion; |
9 | use crate::xlib::{Bool, Display, Pixmap, Status, Window, XID}; |
10 | use crate::xrandr::RRCrtc; |
11 | |
12 | // |
13 | // functions |
14 | // |
15 | |
16 | x11_link! { Xpresent, xpresent, ["libXpresent.so.1.0.0" , "libXpresent.so" ], 8, |
17 | pub fn XPresentQueryExtension( dpy: *mut Display, major_opcode_return: *mut c_int, event_base_return: *mut c_int, error_base_return: *mut c_int) -> Bool, |
18 | pub fn XPresentQueryVersion( dpy: *mut Display, major_version_return: *mut c_int, minor_version_return: *mut c_int ) -> Status, |
19 | pub fn XPresentVersion() -> c_int, |
20 | pub fn XPresentPixmap( dpy: *mut Display, window: Window, pixmap: Pixmap, serial: u32, valid: XserverRegion, update: XserverRegion, x_off: c_int, y_off: c_int, target_crtc: RRCrtc, wait_fence: XSyncFence, idle_fence: XSyncFence, options: u32, target_msc: u64, divisor: u64, remainder: u64, notifies: *mut XPresentNotify, nnotifies: c_int ) -> (), |
21 | pub fn XPresentNotifyMSC( dpy: *mut Display, window: Window, serial: u32, target_msc: u64, divisor: u64, remainder: u64 ) -> (), |
22 | pub fn XPresentSelectInput( dpy: *mut Display, window: Window, event_mask: c_uint ) -> XID, |
23 | pub fn XPresentFreeInput(dpy: *mut Display, window: Window, event_id: XID) -> (), |
24 | pub fn XPresentQueryCapabilities(dpy: *mut Display, target: XID) -> u32, |
25 | variadic: |
26 | globals: |
27 | } |
28 | |
29 | // |
30 | // Types |
31 | // |
32 | |
33 | #[repr (C)] |
34 | #[derive (Debug, Copy, Clone)] |
35 | pub struct XPresentNotify { |
36 | pub window: Window, |
37 | pub serial: u32, |
38 | } |
39 | |
40 | #[repr (C)] |
41 | #[derive (Debug, Copy, Clone)] |
42 | pub struct XPresentEvent { |
43 | pub type_: c_int, |
44 | pub serial: c_ulong, |
45 | pub send_event: Bool, |
46 | pub display: *mut Display, |
47 | pub extension: c_int, |
48 | pub evtype: c_int, |
49 | } |
50 | |
51 | #[repr (C)] |
52 | #[derive (Debug, Copy, Clone)] |
53 | pub struct XPresentIdleNotifyEvent { |
54 | pub type_: c_int, |
55 | pub serial: c_ulong, |
56 | pub send_event: c_int, |
57 | pub display: *mut Display, |
58 | pub extension: c_int, |
59 | pub evtype: c_int, |
60 | pub eid: u32, |
61 | pub window: Window, |
62 | pub serial_number: u32, |
63 | pub pixmap: Pixmap, |
64 | pub idle_fence: XSyncFence, |
65 | } |
66 | |
67 | #[repr (C)] |
68 | #[derive (Debug, Copy, Clone)] |
69 | pub struct XPresentCompleteNotifyEvent { |
70 | pub type_: c_int, |
71 | pub serial: c_ulong, |
72 | pub send_event: Bool, |
73 | pub display: *mut Display, |
74 | pub extension: c_int, |
75 | pub evtype: c_int, |
76 | pub eid: u32, |
77 | pub window: Window, |
78 | pub serial_number: u32, |
79 | pub ust: u64, |
80 | pub msc: u64, |
81 | pub kind: u8, |
82 | pub mode: u8, |
83 | } |
84 | |
85 | #[repr (C)] |
86 | #[derive (Debug, Copy, Clone)] |
87 | pub struct XPresentConfigureNotifyEvent { |
88 | pub type_: c_int, |
89 | pub serial: c_ulong, |
90 | pub send_event: Bool, |
91 | pub display: *mut Display, |
92 | pub extension: c_int, |
93 | pub evtype: c_int, |
94 | pub eid: u32, |
95 | pub window: Window, |
96 | pub x: c_int, |
97 | pub y: c_int, |
98 | pub width: c_uint, |
99 | pub height: c_uint, |
100 | pub off_x: c_int, |
101 | pub off_y: c_int, |
102 | pub pixmap_width: c_int, |
103 | pub pixmap_height: c_int, |
104 | pub pixmap_flags: c_long, |
105 | } |
106 | |
107 | // |
108 | // constants |
109 | // |
110 | |
111 | pub const PRESENT_NAME: &str = "Present" ; |
112 | pub const PRESENT_MAJOR: c_int = 1; |
113 | pub const PRESENT_MINOR: c_int = 2; |
114 | |
115 | pub const PRESENT_REVISION: c_int = 0; |
116 | pub const PRESENT_VERSION: c_int = PRESENT_MAJOR * 10000 + PRESENT_MINOR * 100 + PRESENT_REVISION; |
117 | |
118 | pub const PresentNumberErrors: c_int = 0; |
119 | pub const PresentNumberEvents: c_int = 0; |
120 | |
121 | pub const X_PresentQueryVersion: c_int = 0; |
122 | pub const X_PresentPixmap: c_int = 1; |
123 | pub const X_PresentNotifyMSC: c_int = 2; |
124 | pub const X_PresentSelectInput: c_int = 3; |
125 | pub const X_PresentQueryCapabilities: c_int = 4; |
126 | |
127 | pub const PresentNumberRequests: c_int = 5; |
128 | |
129 | pub const PresentOptionNone: c_int = 0; |
130 | pub const PresentOptionAsync: c_int = 1; |
131 | pub const PresentOptionCopy: c_int = 2; |
132 | pub const PresentOptionUST: c_int = 4; |
133 | pub const PresentOptionSuboptimal: c_int = 8; |
134 | |
135 | pub const PresentAllOptions: c_int = PresentOptionNone |
136 | | PresentOptionAsync |
137 | | PresentOptionCopy |
138 | | PresentOptionUST |
139 | | PresentOptionSuboptimal; |
140 | |
141 | pub const PresentCapabilityNone: c_int = 0; |
142 | pub const PresentCapabilityAsync: c_int = 1; |
143 | pub const PresentCapabilityFence: c_int = 2; |
144 | pub const PresentCapabilityUST: c_int = 4; |
145 | |
146 | pub const PresentAllCapabilities: c_int = |
147 | PresentCapabilityAsync | PresentCapabilityFence | PresentCapabilityUST; |
148 | |
149 | pub const PresentConfigureNotify: c_int = 0; |
150 | pub const PresentCompleteNotify: c_int = 1; |
151 | pub const PresentIdleNotify: c_int = 2; |
152 | |
153 | pub const PresentConfigureNotifyMask: c_int = 1; |
154 | pub const PresentCompleteNotifyMask: c_int = 2; |
155 | pub const PresentIdleNotifyMask: c_int = 4; |
156 | |
157 | pub const PresentAllEvents: c_int = |
158 | PresentConfigureNotifyMask | PresentCompleteNotify | PresentIdleNotifyMask; |
159 | |
160 | pub const PresentCompleteKindPixmap: c_int = 0; |
161 | pub const PresentCompleteKindNotifyMSC: c_int = 1; |
162 | |
163 | pub const PresentCompleteModeCopy: c_int = 0; |
164 | pub const PresentCompleteModeFlip: c_int = 1; |
165 | pub const PresentCompleteModeSkip: c_int = 2; |
166 | pub const PresentCompleteModeSuboptimalCopy: c_int = 3; |
167 | |