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
5use std::os::raw::{c_int, c_long, c_uint, c_ulong};
6
7use crate::sync::XSyncFence;
8use crate::xfixes::XserverRegion;
9use crate::xlib::{Bool, Display, Pixmap, Status, Window, XID};
10use crate::xrandr::RRCrtc;
11
12//
13// functions
14//
15
16x11_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,
25variadic:
26globals:
27}
28
29//
30// Types
31//
32
33#[repr(C)]
34#[derive(Debug, Copy, Clone)]
35pub struct XPresentNotify {
36 pub window: Window,
37 pub serial: u32,
38}
39
40#[repr(C)]
41#[derive(Debug, Copy, Clone)]
42pub 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)]
53pub 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)]
69pub 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)]
87pub 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
111pub const PRESENT_NAME: &str = "Present";
112pub const PRESENT_MAJOR: c_int = 1;
113pub const PRESENT_MINOR: c_int = 2;
114
115pub const PRESENT_REVISION: c_int = 0;
116pub const PRESENT_VERSION: c_int = PRESENT_MAJOR * 10000 + PRESENT_MINOR * 100 + PRESENT_REVISION;
117
118pub const PresentNumberErrors: c_int = 0;
119pub const PresentNumberEvents: c_int = 0;
120
121pub const X_PresentQueryVersion: c_int = 0;
122pub const X_PresentPixmap: c_int = 1;
123pub const X_PresentNotifyMSC: c_int = 2;
124pub const X_PresentSelectInput: c_int = 3;
125pub const X_PresentQueryCapabilities: c_int = 4;
126
127pub const PresentNumberRequests: c_int = 5;
128
129pub const PresentOptionNone: c_int = 0;
130pub const PresentOptionAsync: c_int = 1;
131pub const PresentOptionCopy: c_int = 2;
132pub const PresentOptionUST: c_int = 4;
133pub const PresentOptionSuboptimal: c_int = 8;
134
135pub const PresentAllOptions: c_int = PresentOptionNone
136 | PresentOptionAsync
137 | PresentOptionCopy
138 | PresentOptionUST
139 | PresentOptionSuboptimal;
140
141pub const PresentCapabilityNone: c_int = 0;
142pub const PresentCapabilityAsync: c_int = 1;
143pub const PresentCapabilityFence: c_int = 2;
144pub const PresentCapabilityUST: c_int = 4;
145
146pub const PresentAllCapabilities: c_int =
147 PresentCapabilityAsync | PresentCapabilityFence | PresentCapabilityUST;
148
149pub const PresentConfigureNotify: c_int = 0;
150pub const PresentCompleteNotify: c_int = 1;
151pub const PresentIdleNotify: c_int = 2;
152
153pub const PresentConfigureNotifyMask: c_int = 1;
154pub const PresentCompleteNotifyMask: c_int = 2;
155pub const PresentIdleNotifyMask: c_int = 4;
156
157pub const PresentAllEvents: c_int =
158 PresentConfigureNotifyMask | PresentCompleteNotify | PresentIdleNotifyMask;
159
160pub const PresentCompleteKindPixmap: c_int = 0;
161pub const PresentCompleteKindNotifyMSC: c_int = 1;
162
163pub const PresentCompleteModeCopy: c_int = 0;
164pub const PresentCompleteModeFlip: c_int = 1;
165pub const PresentCompleteModeSkip: c_int = 2;
166pub const PresentCompleteModeSuboptimalCopy: c_int = 3;
167