1 module composite.xpresent; 2 3 import 4 x11.X, 5 x11.Xlib, 6 x11.extensions.Xrandr; 7 8 9 extern(C): 10 11 12 /* 13 * Copyright © 2013 Keith Packard 14 * 15 * Permission to use, copy, modify, distribute, and sell this software and its 16 * documentation for any purpose is hereby granted without fee, provided that 17 * the above copyright notice appear in all copies and that both that copyright 18 * notice and this permission notice appear in supporting documentation, and 19 * that the name of the copyright holders not be used in advertising or 20 * publicity pertaining to distribution of the software without specific, 21 * written prior permission. The copyright holders make no representations 22 * about the suitability of this software for any purpose. It is provided "as 23 * is" without express or implied warranty. 24 * 25 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 26 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 27 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 28 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 29 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 30 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 31 * OF THIS SOFTWARE. 32 */ 33 34 /* 35 * This revision number also appears in configure.ac, they have 36 * to be manually synchronized 37 */ 38 enum PRESENT_MAJOR = 1; 39 enum PRESENT_MINOR = 2; 40 enum PRESENT_REVISION = 0; 41 enum PRESENT_VERSION = ((PRESENT_MAJOR * 10_000) + (PRESENT_MINOR * 100) + (PRESENT_REVISION)); 42 43 /** 44 * Generic Present event. All Present events have the same header. 45 */ 46 47 private alias uint8_t = ubyte; 48 private alias uint32_t = uint; 49 private alias uint64_t = ulong; 50 private alias XSyncFence = uint32_t; 51 private alias XserverRegion = XID; 52 53 enum PresentNumberErrors = 0; 54 enum PresentNumberEvents = 0; 55 56 /* Requests */ 57 enum X_PresentQueryVersion = 0; 58 enum X_PresentPixmap = 1; 59 enum X_PresentNotifyMSC = 2; 60 enum X_PresentSelectInput = 3; 61 enum X_PresentQueryCapabilities = 4; 62 63 enum PresentNumberRequests = 5; 64 65 /* Present operation options */ 66 enum PresentOptionNone = 0; 67 enum PresentOptionAsync = (1 << 0); 68 enum PresentOptionCopy = (1 << 1); 69 enum PresentOptionUST = (1 << 2); 70 enum PresentOptionSuboptimal = (1 << 3); 71 72 enum PresentAllOptions = (PresentOptionAsync | 73 PresentOptionCopy | 74 PresentOptionUST | 75 PresentOptionSuboptimal); 76 77 /* Present capabilities */ 78 79 enum PresentCapabilityNone = 0; 80 enum PresentCapabilityAsync = 1; 81 enum PresentCapabilityFence = 2; 82 enum PresentCapabilityUST = 4; 83 84 enum PresentAllCapabilities = (PresentCapabilityAsync | 85 PresentCapabilityFence | 86 PresentCapabilityUST); 87 88 /* Events */ 89 90 enum PresentConfigureNotify = 0; 91 enum PresentCompleteNotify = 1; 92 enum PresentIdleNotify = 2; 93 version(PRESENT_FUTURE_VERSION) 94 enum PresentRedirectNotify = 3; 95 96 97 98 /* Event Masks */ 99 enum PresentConfigureNotifyMask = 1; 100 enum PresentCompleteNotifyMask = 2; 101 enum PresentIdleNotifyMask = 4; 102 version(PRESENT_FUTURE_VERSION) 103 enum PresentRedirectNotifyMask = 8; 104 105 106 107 version(PRESENT_FUTURE_VERSION) 108 enum PRESENT_REDIRECT_NOTIFY_MASK = PresentRedirectNotifyMask; 109 else 110 enum PRESENT_REDIRECT_NOTIFY_MASK = 0; 111 112 enum PresentAllEvents = (PresentConfigureNotifyMask | 113 PresentCompleteNotifyMask | 114 PresentIdleNotifyMask | 115 PRESENT_REDIRECT_NOTIFY_MASK); 116 117 /* Complete Kinds */ 118 119 enum PresentCompleteKindPixmap = 0; 120 enum PresentCompleteKindNotifyMSC = 1; 121 122 /* Complete Modes */ 123 124 enum PresentCompleteModeCopy = 0; 125 enum PresentCompleteModeFlip = 1; 126 enum PresentCompleteModeSkip = 2; 127 enum PresentCompleteModeSuboptimalCopy = 3; 128 129 130 struct XPresentNotify { 131 Window window; 132 uint32_t serial; 133 } 134 135 struct XPresentEvent { 136 int type; /* event base */ 137 ulong serial; 138 Bool send_event; 139 Display *display; 140 int extension; 141 int evtype; 142 } 143 144 struct XPresentConfigureNotifyEvent { 145 int type; /* event base */ 146 ulong serial; 147 Bool send_event; 148 Display *display; 149 int extension; 150 int evtype; 151 152 uint32_t eid; 153 Window window; 154 int x,y; 155 uint width, height; 156 int off_x, off_y; 157 int pixmap_width, pixmap_height; 158 long pixmap_flags; 159 } 160 161 struct XPresentCompleteNotifyEvent { 162 int type; /* event base */ 163 ulong serial; 164 Bool send_event; 165 Display *display; 166 int extension; 167 int evtype; 168 169 uint32_t eid; 170 Window window; 171 uint32_t serial_number; 172 uint64_t ust; 173 uint64_t msc; 174 uint8_t kind; 175 uint8_t mode; 176 } 177 178 struct XPresentIdleNotifyEvent { 179 int type; /* event base */ 180 ulong serial; 181 Bool send_event; 182 Display *display; 183 int extension; 184 int evtype; 185 186 uint32_t eid; 187 Window window; 188 uint32_t serial_number; 189 Pixmap pixmap; 190 XSyncFence idle_fence; 191 } 192 193 version(PRESENT_FUTURE_VERSION){ 194 195 struct XPresentRedirectNotifyEvent { 196 int type; /* event base */ 197 ulong serial; 198 Bool send_event; 199 Display *display; 200 int extension; 201 int evtype; 202 203 uint32_t eid; 204 Window event_window; 205 206 Window window; 207 Pixmap pixmap; 208 uint32_t serial_number; 209 210 XserverRegion valid_region; 211 XserverRegion update_region; 212 213 XRectangle valid_rect; 214 XRectangle update_rect; 215 216 int x_off, y_off; 217 218 RRCrtc target_crtc; 219 220 XSyncFence wait_fence; 221 XSyncFence idle_fence; 222 223 uint32_t options; 224 225 uint64_t target_msc; 226 uint64_t divisor; 227 uint64_t remainder; 228 XPresentNotify *notifies; 229 int nnotifies; 230 } 231 232 } 233 234 Bool XPresentQueryExtension (Display *dpy, 235 int *major_opcode_return, 236 int *event_base_return, 237 int *error_base_return); 238 239 Status XPresentQueryVersion (Display *dpy, 240 int *major_version_return, 241 int *minor_version_return); 242 243 int XPresentVersion(); 244 245 void 246 XPresentPixmap(Display *dpy, 247 Window window, 248 Pixmap pixmap, 249 uint32_t serial, 250 XserverRegion valid, 251 XserverRegion update, 252 int x_off, 253 int y_off, 254 RRCrtc target_crtc, 255 XSyncFence wait_fence, 256 XSyncFence idle_fence, 257 uint32_t options, 258 uint64_t target_msc, 259 uint64_t divisor, 260 uint64_t remainder, 261 XPresentNotify *notifies, 262 int nnotifies); 263 264 void 265 XPresentNotifyMSC(Display *dpy, 266 Window window, 267 uint32_t serial, 268 uint64_t target_msc, 269 uint64_t divisor, 270 uint64_t remainder); 271 272 XID 273 XPresentSelectInput(Display *dpy, 274 Window window, 275 uint event_mask); 276 277 void 278 XPresentFreeInput(Display *dpy, 279 Window window, 280 XID event_id); 281 282 uint32_t 283 XPresentQueryCapabilities(Display *dpy, 284 XID target);