Xrandr.h revision 8bd17e5f
1/* 2 * Copyright © 2000 Compaq Computer Corporation, Inc. 3 * Copyright © 2002 Hewlett-Packard Company, Inc. 4 * Copyright © 2006 Intel Corporation 5 * Copyright © 2008 Red Hat, Inc. 6 * 7 * Permission to use, copy, modify, distribute, and sell this software and its 8 * documentation for any purpose is hereby granted without fee, provided that 9 * the above copyright notice appear in all copies and that both that copyright 10 * notice and this permission notice appear in supporting documentation, and 11 * that the name of the copyright holders not be used in advertising or 12 * publicity pertaining to distribution of the software without specific, 13 * written prior permission. The copyright holders make no representations 14 * about the suitability of this software for any purpose. It is provided "as 15 * is" without express or implied warranty. 16 * 17 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 19 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 20 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 21 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 22 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 23 * OF THIS SOFTWARE. 24 * 25 * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc. 26 * Keith Packard, Intel Corporation 27 */ 28 29#ifndef _XRANDR_H_ 30#define _XRANDR_H_ 31 32#include <X11/extensions/randr.h> 33#include <X11/extensions/Xrender.h> 34 35#include <X11/Xfuncproto.h> 36 37_XFUNCPROTOBEGIN 38 39typedef XID RROutput; 40typedef XID RRCrtc; 41typedef XID RRMode; 42typedef XID RRProvider; 43 44typedef struct { 45 int width, height; 46 int mwidth, mheight; 47} XRRScreenSize; 48 49/* 50 * Events. 51 */ 52 53typedef struct { 54 int type; /* event base */ 55 unsigned long serial; /* # of last request processed by server */ 56 Bool send_event; /* true if this came from a SendEvent request */ 57 Display *display; /* Display the event was read from */ 58 Window window; /* window which selected for this event */ 59 Window root; /* Root window for changed screen */ 60 Time timestamp; /* when the screen change occurred */ 61 Time config_timestamp; /* when the last configuration change */ 62 SizeID size_index; 63 SubpixelOrder subpixel_order; 64 Rotation rotation; 65 int width; 66 int height; 67 int mwidth; 68 int mheight; 69} XRRScreenChangeNotifyEvent; 70 71typedef struct { 72 int type; /* event base */ 73 unsigned long serial; /* # of last request processed by server */ 74 Bool send_event; /* true if this came from a SendEvent request */ 75 Display *display; /* Display the event was read from */ 76 Window window; /* window which selected for this event */ 77 int subtype; /* RRNotify_ subtype */ 78} XRRNotifyEvent; 79 80typedef struct { 81 int type; /* event base */ 82 unsigned long serial; /* # of last request processed by server */ 83 Bool send_event; /* true if this came from a SendEvent request */ 84 Display *display; /* Display the event was read from */ 85 Window window; /* window which selected for this event */ 86 int subtype; /* RRNotify_OutputChange */ 87 RROutput output; /* affected output */ 88 RRCrtc crtc; /* current crtc (or None) */ 89 RRMode mode; /* current mode (or None) */ 90 Rotation rotation; /* current rotation of associated crtc */ 91 Connection connection; /* current connection status */ 92 SubpixelOrder subpixel_order; 93} XRROutputChangeNotifyEvent; 94 95typedef struct { 96 int type; /* event base */ 97 unsigned long serial; /* # of last request processed by server */ 98 Bool send_event; /* true if this came from a SendEvent request */ 99 Display *display; /* Display the event was read from */ 100 Window window; /* window which selected for this event */ 101 int subtype; /* RRNotify_CrtcChange */ 102 RRCrtc crtc; /* current crtc (or None) */ 103 RRMode mode; /* current mode (or None) */ 104 Rotation rotation; /* current rotation of associated crtc */ 105 int x, y; /* position */ 106 unsigned int width, height; /* size */ 107} XRRCrtcChangeNotifyEvent; 108 109typedef struct { 110 int type; /* event base */ 111 unsigned long serial; /* # of last request processed by server */ 112 Bool send_event; /* true if this came from a SendEvent request */ 113 Display *display; /* Display the event was read from */ 114 Window window; /* window which selected for this event */ 115 int subtype; /* RRNotify_OutputProperty */ 116 RROutput output; /* related output */ 117 Atom property; /* changed property */ 118 Time timestamp; /* time of change */ 119 int state; /* NewValue, Deleted */ 120} XRROutputPropertyNotifyEvent; 121 122typedef struct { 123 int type; /* event base */ 124 unsigned long serial; /* # of last request processed by server */ 125 Bool send_event; /* true if this came from a SendEvent request */ 126 Display *display; /* Display the event was read from */ 127 Window window; /* window which selected for this event */ 128 int subtype; /* RRNotify_ProviderChange */ 129 RRProvider provider; /* current provider (or None) */ 130 Time timestamp; /* time of change */ 131 unsigned int current_role; 132} XRRProviderChangeNotifyEvent; 133 134typedef struct { 135 int type; /* event base */ 136 unsigned long serial; /* # of last request processed by server */ 137 Bool send_event; /* true if this came from a SendEvent request */ 138 Display *display; /* Display the event was read from */ 139 Window window; /* window which selected for this event */ 140 int subtype; /* RRNotify_ProviderProperty */ 141 RRProvider provider; /* related provider */ 142 Atom property; /* changed property */ 143 Time timestamp; /* time of change */ 144 int state; /* NewValue, Deleted */ 145} XRRProviderPropertyNotifyEvent; 146 147typedef struct { 148 int type; /* event base */ 149 unsigned long serial; /* # of last request processed by server */ 150 Bool send_event; /* true if this came from a SendEvent request */ 151 Display *display; /* Display the event was read from */ 152 Window window; /* window which selected for this event */ 153 int subtype; /* RRNotify_ResourceChange */ 154 Time timestamp; /* time of change */ 155} XRRResourceChangeNotifyEvent; 156 157/* internal representation is private to the library */ 158typedef struct _XRRScreenConfiguration XRRScreenConfiguration; 159 160Bool XRRQueryExtension (Display *dpy, 161 int *event_base_return, 162 int *error_base_return); 163Status XRRQueryVersion (Display *dpy, 164 int *major_version_return, 165 int *minor_version_return); 166 167XRRScreenConfiguration *XRRGetScreenInfo (Display *dpy, 168 Window window); 169 170void XRRFreeScreenConfigInfo (XRRScreenConfiguration *config); 171 172/* 173 * Note that screen configuration changes are only permitted if the client can 174 * prove it has up to date configuration information. We are trying to 175 * insist that it become possible for screens to change dynamically, so 176 * we want to ensure the client knows what it is talking about when requesting 177 * changes. 178 */ 179Status XRRSetScreenConfig (Display *dpy, 180 XRRScreenConfiguration *config, 181 Drawable draw, 182 int size_index, 183 Rotation rotation, 184 Time timestamp); 185 186/* added in v1.1, sorry for the lame name */ 187Status XRRSetScreenConfigAndRate (Display *dpy, 188 XRRScreenConfiguration *config, 189 Drawable draw, 190 int size_index, 191 Rotation rotation, 192 short rate, 193 Time timestamp); 194 195 196Rotation XRRConfigRotations(XRRScreenConfiguration *config, Rotation *current_rotation); 197 198Time XRRConfigTimes (XRRScreenConfiguration *config, Time *config_timestamp); 199 200XRRScreenSize *XRRConfigSizes(XRRScreenConfiguration *config, int *nsizes); 201 202short *XRRConfigRates (XRRScreenConfiguration *config, int sizeID, int *nrates); 203 204SizeID XRRConfigCurrentConfiguration (XRRScreenConfiguration *config, 205 Rotation *rotation); 206 207short XRRConfigCurrentRate (XRRScreenConfiguration *config); 208 209int XRRRootToScreen(Display *dpy, Window root); 210 211/* 212 * returns the screen configuration for the specified screen; does a lazy 213 * evalution to delay getting the information, and caches the result. 214 * These routines should be used in preference to XRRGetScreenInfo 215 * to avoid unneeded round trips to the X server. These are new 216 * in protocol version 0.1. 217 */ 218 219 220void XRRSelectInput(Display *dpy, Window window, int mask); 221 222/* 223 * the following are always safe to call, even if RandR is not implemented 224 * on a screen 225 */ 226 227 228Rotation XRRRotations(Display *dpy, int screen, Rotation *current_rotation); 229XRRScreenSize *XRRSizes(Display *dpy, int screen, int *nsizes); 230short *XRRRates (Display *dpy, int screen, int sizeID, int *nrates); 231Time XRRTimes (Display *dpy, int screen, Time *config_timestamp); 232 233 234/* Version 1.2 additions */ 235 236/* despite returning a Status, this returns 1 for success */ 237Status 238XRRGetScreenSizeRange (Display *dpy, Window window, 239 int *minWidth, int *minHeight, 240 int *maxWidth, int *maxHeight); 241 242void 243XRRSetScreenSize (Display *dpy, Window window, 244 int width, int height, 245 int mmWidth, int mmHeight); 246 247typedef unsigned long XRRModeFlags; 248 249typedef struct _XRRModeInfo { 250 RRMode id; 251 unsigned int width; 252 unsigned int height; 253 unsigned long dotClock; 254 unsigned int hSyncStart; 255 unsigned int hSyncEnd; 256 unsigned int hTotal; 257 unsigned int hSkew; 258 unsigned int vSyncStart; 259 unsigned int vSyncEnd; 260 unsigned int vTotal; 261 char *name; 262 unsigned int nameLength; 263 XRRModeFlags modeFlags; 264} XRRModeInfo; 265 266typedef struct _XRRScreenResources { 267 Time timestamp; 268 Time configTimestamp; 269 int ncrtc; 270 RRCrtc *crtcs; 271 int noutput; 272 RROutput *outputs; 273 int nmode; 274 XRRModeInfo *modes; 275} XRRScreenResources; 276 277XRRScreenResources * 278XRRGetScreenResources (Display *dpy, Window window); 279 280void 281XRRFreeScreenResources (XRRScreenResources *resources); 282 283typedef struct _XRROutputInfo { 284 Time timestamp; 285 RRCrtc crtc; 286 char *name; 287 int nameLen; 288 unsigned long mm_width; 289 unsigned long mm_height; 290 Connection connection; 291 SubpixelOrder subpixel_order; 292 int ncrtc; 293 RRCrtc *crtcs; 294 int nclone; 295 RROutput *clones; 296 int nmode; 297 int npreferred; 298 RRMode *modes; 299} XRROutputInfo; 300 301XRROutputInfo * 302XRRGetOutputInfo (Display *dpy, XRRScreenResources *resources, RROutput output); 303 304void 305XRRFreeOutputInfo (XRROutputInfo *outputInfo); 306 307Atom * 308XRRListOutputProperties (Display *dpy, RROutput output, int *nprop); 309 310typedef struct { 311 Bool pending; 312 Bool range; 313 Bool immutable; 314 int num_values; 315 long *values; 316} XRRPropertyInfo; 317 318XRRPropertyInfo * 319XRRQueryOutputProperty (Display *dpy, RROutput output, Atom property); 320 321void 322XRRConfigureOutputProperty (Display *dpy, RROutput output, Atom property, 323 Bool pending, Bool range, int num_values, 324 long *values); 325 326void 327XRRChangeOutputProperty (Display *dpy, RROutput output, 328 Atom property, Atom type, 329 int format, int mode, 330 _Xconst unsigned char *data, int nelements); 331 332void 333XRRDeleteOutputProperty (Display *dpy, RROutput output, Atom property); 334 335int 336XRRGetOutputProperty (Display *dpy, RROutput output, 337 Atom property, long offset, long length, 338 Bool _delete, Bool pending, Atom req_type, 339 Atom *actual_type, int *actual_format, 340 unsigned long *nitems, unsigned long *bytes_after, 341 unsigned char **prop); 342 343XRRModeInfo * 344XRRAllocModeInfo (_Xconst char *name, int nameLength); 345 346RRMode 347XRRCreateMode (Display *dpy, Window window, XRRModeInfo *modeInfo); 348 349void 350XRRDestroyMode (Display *dpy, RRMode mode); 351 352void 353XRRAddOutputMode (Display *dpy, RROutput output, RRMode mode); 354 355void 356XRRDeleteOutputMode (Display *dpy, RROutput output, RRMode mode); 357 358void 359XRRFreeModeInfo (XRRModeInfo *modeInfo); 360 361typedef struct _XRRCrtcInfo { 362 Time timestamp; 363 int x, y; 364 unsigned int width, height; 365 RRMode mode; 366 Rotation rotation; 367 int noutput; 368 RROutput *outputs; 369 Rotation rotations; 370 int npossible; 371 RROutput *possible; 372} XRRCrtcInfo; 373 374XRRCrtcInfo * 375XRRGetCrtcInfo (Display *dpy, XRRScreenResources *resources, RRCrtc crtc); 376 377void 378XRRFreeCrtcInfo (XRRCrtcInfo *crtcInfo); 379 380Status 381XRRSetCrtcConfig (Display *dpy, 382 XRRScreenResources *resources, 383 RRCrtc crtc, 384 Time timestamp, 385 int x, int y, 386 RRMode mode, 387 Rotation rotation, 388 RROutput *outputs, 389 int noutputs); 390 391int 392XRRGetCrtcGammaSize (Display *dpy, RRCrtc crtc); 393 394typedef struct _XRRCrtcGamma { 395 int size; 396 unsigned short *red; 397 unsigned short *green; 398 unsigned short *blue; 399} XRRCrtcGamma; 400 401XRRCrtcGamma * 402XRRGetCrtcGamma (Display *dpy, RRCrtc crtc); 403 404XRRCrtcGamma * 405XRRAllocGamma (int size); 406 407void 408XRRSetCrtcGamma (Display *dpy, RRCrtc crtc, XRRCrtcGamma *gamma); 409 410void 411XRRFreeGamma (XRRCrtcGamma *gamma); 412 413/* Version 1.3 additions */ 414 415XRRScreenResources * 416XRRGetScreenResourcesCurrent (Display *dpy, Window window); 417 418void 419XRRSetCrtcTransform (Display *dpy, 420 RRCrtc crtc, 421 XTransform *transform, 422 _Xconst char *filter, 423 XFixed *params, 424 int nparams); 425 426typedef struct _XRRCrtcTransformAttributes { 427 XTransform pendingTransform; 428 char *pendingFilter; 429 int pendingNparams; 430 XFixed *pendingParams; 431 XTransform currentTransform; 432 char *currentFilter; 433 int currentNparams; 434 XFixed *currentParams; 435} XRRCrtcTransformAttributes; 436 437/* 438 * Get current crtc transforms and filters. 439 * Pass *attributes to XFree to free 440 */ 441Status 442XRRGetCrtcTransform (Display *dpy, 443 RRCrtc crtc, 444 XRRCrtcTransformAttributes **attributes); 445 446/* 447 * intended to take RRScreenChangeNotify, or 448 * ConfigureNotify (on the root window) 449 * returns 1 if it is an event type it understands, 0 if not 450 */ 451int XRRUpdateConfiguration(XEvent *event); 452 453typedef struct _XRRPanning { 454 Time timestamp; 455 unsigned int left; 456 unsigned int top; 457 unsigned int width; 458 unsigned int height; 459 unsigned int track_left; 460 unsigned int track_top; 461 unsigned int track_width; 462 unsigned int track_height; 463 int border_left; 464 int border_top; 465 int border_right; 466 int border_bottom; 467} XRRPanning; 468 469XRRPanning * 470XRRGetPanning (Display *dpy, XRRScreenResources *resources, RRCrtc crtc); 471 472void 473XRRFreePanning (XRRPanning *panning); 474 475Status 476XRRSetPanning (Display *dpy, 477 XRRScreenResources *resources, 478 RRCrtc crtc, 479 XRRPanning *panning); 480 481void 482XRRSetOutputPrimary(Display *dpy, 483 Window window, 484 RROutput output); 485 486RROutput 487XRRGetOutputPrimary(Display *dpy, 488 Window window); 489 490typedef struct _XRRProviderResources { 491 Time timestamp; 492 int nproviders; 493 RRProvider *providers; 494} XRRProviderResources; 495 496XRRProviderResources * 497XRRGetProviderResources(Display *dpy, Window window); 498 499void 500XRRFreeProviderResources(XRRProviderResources *resources); 501 502typedef struct _XRRProviderInfo { 503 unsigned int capabilities; 504 int ncrtcs; 505 RRCrtc *crtcs; 506 int noutputs; 507 RROutput *outputs; 508 char *name; 509 int nassociatedproviders; 510 RRProvider *associated_providers; 511 unsigned int *associated_capability; 512 int nameLen; 513} XRRProviderInfo; 514 515XRRProviderInfo * 516XRRGetProviderInfo(Display *dpy, XRRScreenResources *resources, RRProvider provider); 517 518void 519XRRFreeProviderInfo(XRRProviderInfo *provider); 520 521int 522XRRSetProviderOutputSource(Display *dpy, XID provider, XID source_provider); 523 524int 525XRRSetProviderOffloadSink(Display *dpy, XID provider, XID sink_provider); 526 527Atom * 528XRRListProviderProperties (Display *dpy, RRProvider provider, int *nprop); 529 530XRRPropertyInfo * 531XRRQueryProviderProperty (Display *dpy, RRProvider provider, Atom property); 532 533void 534XRRConfigureProviderProperty (Display *dpy, RRProvider provider, Atom property, 535 Bool pending, Bool range, int num_values, 536 long *values); 537 538void 539XRRChangeProviderProperty (Display *dpy, RRProvider provider, 540 Atom property, Atom type, 541 int format, int mode, 542 _Xconst unsigned char *data, int nelements); 543 544void 545XRRDeleteProviderProperty (Display *dpy, RRProvider provider, Atom property); 546 547int 548XRRGetProviderProperty (Display *dpy, RRProvider provider, 549 Atom property, long offset, long length, 550 Bool _delete, Bool pending, Atom req_type, 551 Atom *actual_type, int *actual_format, 552 unsigned long *nitems, unsigned long *bytes_after, 553 unsigned char **prop); 554 555_XFUNCPROTOEND 556 557#endif /* _XRANDR_H_ */ 558