1 module x11.extensions.Xrandr; 2 3 version(Posix): 4 5 /* 6 * Copyright © 2000 Compaq Computer Corporation, Inc. 7 * Copyright © 2002 Hewlett-Packard Company, Inc. 8 * Copyright © 2006 Intel Corporation 9 * Copyright © 2008 Red Hat, Inc. 10 * 11 * Permission to use, copy, modify, distribute, and sell this software and its 12 * documentation for any purpose is hereby granted without fee, provided that 13 * the above copyright notice appear in all copies and that both that copyright 14 * notice and this permission notice appear in supporting documentation, and 15 * that the name of the copyright holders not be used in advertising or 16 * publicity pertaining to distribution of the software without specific, 17 * written prior permission. The copyright holders make no representations 18 * about the suitability of this software for any purpose. It is provided "as 19 * is" without express or implied warranty. 20 * 21 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 22 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 23 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 24 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 25 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 26 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 27 * OF THIS SOFTWARE. 28 * 29 * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc. 30 * Keith Packard, Intel Corporation 31 */ 32 33 import x11.X; 34 import x11.Xlib; 35 import x11.extensions.Xrender; 36 import x11.extensions.randr; 37 //import x11.Xfuncproto; 38 39 extern (C) nothrow: 40 41 alias XID RROutput; 42 alias XID RRCrtc; 43 alias XID RRMode; 44 45 struct XRRScreenSize { 46 int width, height; 47 int mwidth, mheight; 48 } 49 50 struct XRRScreenChangeNotifyEvent { 51 int type; /* event base */ 52 ulong serial; /* # of last request processed by server */ 53 Bool send_event; /* true if this came from a SendEvent request */ 54 Display *display; /* Display the event was read from */ 55 Window window; /* window which selected for this event */ 56 Window root; /* Root window for changed screen */ 57 Time timestamp; /* when the screen change occurred */ 58 Time config_timestamp; /* when the last configuration change */ 59 SizeID size_index; 60 SubpixelOrder subpixel_order; 61 Rotation rotation; 62 int width; 63 int height; 64 int mwidth; 65 int mheight; 66 } 67 68 struct XRRNotifyEvent { 69 int type; /* event base */ 70 ulong serial; /* # of last request processed by server */ 71 Bool send_event; /* true if this came from a SendEvent request */ 72 Display *display; /* Display the event was read from */ 73 Window window; /* window which selected for this event */ 74 int subtype; /* RRNotify_ subtype */ 75 } 76 77 struct XRROutputChangeNotifyEvent { 78 int type; /* event base */ 79 ulong serial; /* # of last request processed by server */ 80 Bool send_event; /* true if this came from a SendEvent request */ 81 Display *display; /* Display the event was read from */ 82 Window window; /* window which selected for this event */ 83 int subtype; /* RRNotify_OutputChange */ 84 RROutput output; /* affected output */ 85 RRCrtc crtc; /* current crtc (or None) */ 86 RRMode mode; /* current mode (or None) */ 87 Rotation rotation; /* current rotation of associated crtc */ 88 Connection connection; /* current connection status */ 89 SubpixelOrder subpixel_order; 90 } 91 92 struct XRRCrtcChangeNotifyEvent { 93 int type; /* event base */ 94 ulong serial; /* # of last request processed by server */ 95 Bool send_event; /* true if this came from a SendEvent request */ 96 Display *display; /* Display the event was read from */ 97 Window window; /* window which selected for this event */ 98 int subtype; /* RRNotify_CrtcChange */ 99 RRCrtc crtc; /* current crtc (or None) */ 100 RRMode mode; /* current mode (or None) */ 101 Rotation rotation; /* current rotation of associated crtc */ 102 int x, y; /* position */ 103 uint width, height; /* size */ 104 } 105 106 struct XRROutputPropertyNotifyEvent { 107 int type; /* event base */ 108 ulong serial; /* # of last request processed by server */ 109 Bool send_event; /* true if this came from a SendEvent request */ 110 Display *display; /* Display the event was read from */ 111 Window window; /* window which selected for this event */ 112 int subtype; /* RRNotify_OutputProperty */ 113 RROutput output; /* related output */ 114 Atom property; /* changed property */ 115 Time timestamp; /* time of change */ 116 int state; /* NewValue, Deleted */ 117 } 118 119 struct _XRRScreenConfiguration; 120 alias _XRRScreenConfiguration XRRScreenConfiguration; 121 122 Bool XRRQueryExtension (Display *dpy, 123 int *event_base_return, 124 int *error_base_return); 125 Status XRRQueryVersion (Display *dpy, 126 int *major_version_return, 127 int *minor_version_return); 128 129 XRRScreenConfiguration *XRRGetScreenInfo (Display *dpy, 130 Window window); 131 132 void XRRFreeScreenConfigInfo (XRRScreenConfiguration *config); 133 134 Status XRRSetScreenConfig (Display *dpy, 135 XRRScreenConfiguration *config, 136 Drawable draw, 137 int size_index, 138 Rotation rotation, 139 Time timestamp); 140 141 Status XRRSetScreenConfigAndRate (Display *dpy, 142 XRRScreenConfiguration *config, 143 Drawable draw, 144 int size_index, 145 Rotation rotation, 146 short rate, 147 Time timestamp); 148 149 Rotation XRRConfigRotations(XRRScreenConfiguration *config, Rotation *current_rotation); 150 151 Time XRRConfigTimes (XRRScreenConfiguration *config, Time *config_timestamp); 152 153 XRRScreenSize *XRRConfigSizes(XRRScreenConfiguration *config, int *nsizes); 154 155 short *XRRConfigRates (XRRScreenConfiguration *config, int sizeID, int *nrates); 156 157 SizeID XRRConfigCurrentConfiguration (XRRScreenConfiguration *config, 158 Rotation *rotation); 159 160 short XRRConfigCurrentRate (XRRScreenConfiguration *config); 161 162 int XRRRootToScreen(Display *dpy, Window root); 163 164 void XRRSelectInput(Display *dpy, Window window, int mask); 165 166 Rotation XRRRotations(Display *dpy, int screen, Rotation *current_rotation); 167 XRRScreenSize *XRRSizes(Display *dpy, int screen, int *nsizes); 168 short *XRRRates (Display *dpy, int screen, int sizeID, int *nrates); 169 Time XRRTimes (Display *dpy, int screen, Time *config_timestamp); 170 171 Status 172 XRRGetScreenSizeRange (Display *dpy, Window window, 173 int *minWidth, int *minHeight, 174 int *maxWidth, int *maxHeight); 175 176 void 177 XRRSetScreenSize (Display *dpy, Window window, 178 int width, int height, 179 int mmWidth, int mmHeight); 180 181 alias ulong XRRModeFlags; 182 183 struct _XRRModeInfo { 184 RRMode id; 185 uint width; 186 uint height; 187 ulong dotClock; 188 uint hSyncStart; 189 uint hSyncEnd; 190 uint hTotal; 191 uint hSkew; 192 uint vSyncStart; 193 uint vSyncEnd; 194 uint vTotal; 195 char *name; 196 uint nameLength; 197 XRRModeFlags modeFlags; 198 } 199 alias _XRRModeInfo XRRModeInfo; 200 201 struct _XRRScreenResources { 202 Time timestamp; 203 Time configTimestamp; 204 int ncrtc; 205 RRCrtc *crtcs; 206 int noutput; 207 RROutput *outputs; 208 int nmode; 209 XRRModeInfo *modes; 210 } 211 alias _XRRScreenResources XRRScreenResources; 212 213 XRRScreenResources * 214 XRRGetScreenResources (Display *dpy, Window window); 215 216 void 217 XRRFreeScreenResources (XRRScreenResources *resources); 218 219 struct _XRROutputInfo { 220 Time timestamp; 221 RRCrtc crtc; 222 char *name; 223 int nameLen; 224 ulong mm_width; 225 ulong mm_height; 226 Connection connection; 227 SubpixelOrder subpixel_order; 228 int ncrtc; 229 RRCrtc *crtcs; 230 int nclone; 231 RROutput *clones; 232 int nmode; 233 int npreferred; 234 RRMode *modes; 235 } 236 alias _XRROutputInfo XRROutputInfo; 237 238 XRROutputInfo * 239 XRRGetOutputInfo (Display *dpy, XRRScreenResources *resources, RROutput output); 240 241 void 242 XRRFreeOutputInfo (XRROutputInfo *outputInfo); 243 244 Atom * 245 XRRListOutputProperties (Display *dpy, RROutput output, int *nprop); 246 247 struct XRRPropertyInfo { 248 Bool pending; 249 Bool range; 250 Bool immutable_; // cannot call this property immutable (D keyword). Prefixing with _. 251 int num_values; 252 long *values; 253 } 254 255 XRRPropertyInfo * 256 XRRQueryOutputProperty (Display *dpy, RROutput output, Atom property); 257 258 void 259 XRRConfigureOutputProperty (Display *dpy, RROutput output, Atom property, 260 Bool pending, Bool range, int num_values, 261 long *values); 262 263 void 264 XRRChangeOutputProperty (Display *dpy, RROutput output, 265 Atom property, Atom type, 266 int format, int mode, 267 const ubyte *data, int nelements); 268 269 void 270 XRRDeleteOutputProperty (Display *dpy, RROutput output, Atom property); 271 272 int 273 XRRGetOutputProperty (Display *dpy, RROutput output, 274 Atom property, long offset, long length, 275 Bool _delete, Bool pending, Atom req_type, 276 Atom *actual_type, int *actual_format, 277 ulong *nitems, ulong *bytes_after, 278 ubyte **prop); 279 280 XRRModeInfo * 281 XRRAllocModeInfo (char *name, int nameLength); 282 283 RRMode 284 XRRCreateMode (Display *dpy, Window window, XRRModeInfo *modeInfo); 285 286 void 287 XRRDestroyMode (Display *dpy, RRMode mode); 288 289 void 290 XRRAddOutputMode (Display *dpy, RROutput output, RRMode mode); 291 292 void 293 XRRDeleteOutputMode (Display *dpy, RROutput output, RRMode mode); 294 295 void 296 XRRFreeModeInfo (XRRModeInfo *modeInfo); 297 298 struct _XRRCrtcInfo { 299 Time timestamp; 300 int x, y; 301 uint width, height; 302 RRMode mode; 303 Rotation rotation; 304 int noutput; 305 RROutput *outputs; 306 Rotation rotations; 307 int npossible; 308 RROutput *possible; 309 } 310 alias _XRRCrtcInfo XRRCrtcInfo; 311 312 XRRCrtcInfo * 313 XRRGetCrtcInfo (Display *dpy, XRRScreenResources *resources, RRCrtc crtc); 314 315 void 316 XRRFreeCrtcInfo (XRRCrtcInfo *crtcInfo); 317 318 Status 319 XRRSetCrtcConfig (Display *dpy, 320 XRRScreenResources *resources, 321 RRCrtc crtc, 322 Time timestamp, 323 int x, int y, 324 RRMode mode, 325 Rotation rotation, 326 RROutput *outputs, 327 int noutputs); 328 329 int 330 XRRGetCrtcGammaSize (Display *dpy, RRCrtc crtc); 331 332 struct _XRRCrtcGamma { 333 int size; 334 ushort *red; 335 ushort *green; 336 ushort *blue; 337 } 338 alias _XRRCrtcGamma XRRCrtcGamma; 339 340 XRRCrtcGamma * 341 XRRGetCrtcGamma (Display *dpy, RRCrtc crtc); 342 343 XRRCrtcGamma * 344 XRRAllocGamma (int size); 345 346 void 347 XRRSetCrtcGamma (Display *dpy, RRCrtc crtc, XRRCrtcGamma *gamma); 348 349 void 350 XRRFreeGamma (XRRCrtcGamma *gamma); 351 352 XRRScreenResources * 353 XRRGetScreenResourcesCurrent (Display *dpy, Window window); 354 355 void 356 XRRSetCrtcTransform (Display *dpy, 357 RRCrtc crtc, 358 XTransform *transform, 359 char *filter, 360 XFixed *params, 361 int nparams); 362 363 struct _XRRCrtcTransformAttributes { 364 XTransform pendingTransform; 365 char *pendingFilter; 366 int pendingNparams; 367 XFixed *pendingParams; 368 XTransform currentTransform; 369 char *currentFilter; 370 int currentNparams; 371 XFixed *currentParams; 372 } 373 alias _XRRCrtcTransformAttributes XRRCrtcTransformAttributes; 374 375 Status 376 XRRGetCrtcTransform (Display *dpy, 377 RRCrtc crtc, 378 XRRCrtcTransformAttributes **attributes); 379 380 int XRRUpdateConfiguration(XEvent *event); 381 382 struct _XRRPanning { 383 Time timestamp; 384 uint left; 385 uint top; 386 uint width; 387 uint height; 388 uint track_left; 389 uint track_top; 390 uint track_width; 391 uint track_height; 392 int border_left; 393 int border_top; 394 int border_right; 395 int border_bottom; 396 } 397 alias _XRRPanning XRRPanning; 398 399 XRRPanning * 400 XRRGetPanning (Display *dpy, XRRScreenResources *resources, RRCrtc crtc); 401 402 void 403 XRRFreePanning (XRRPanning *panning); 404 405 Status 406 XRRSetPanning (Display *dpy, 407 XRRScreenResources *resources, 408 RRCrtc crtc, 409 XRRPanning *panning); 410 411 void 412 XRRSetOutputPrimary(Display *dpy, 413 Window window, 414 RROutput output); 415 416 RROutput 417 XRRGetOutputPrimary(Display *dpy, 418 Window window);