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