Xrandr.h revision 706b6b52
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; 42 43typedef struct { 44 int width, height; 45 int mwidth, mheight; 46} XRRScreenSize; 47 48/* 49 * Events. 50 */ 51 52typedef struct { 53 int type; /* event base */ 54 unsigned long serial; /* # of last request processed by server */ 55 Bool send_event; /* true if this came from a SendEvent request */ 56 Display *display; /* Display the event was read from */ 57 Window window; /* window which selected for this event */ 58 Window root; /* Root window for changed screen */ 59 Time timestamp; /* when the screen change occurred */ 60 Time config_timestamp; /* when the last configuration change */ 61 SizeID size_index; 62 SubpixelOrder subpixel_order; 63 Rotation rotation; 64 int width; 65 int height; 66 int mwidth; 67 int mheight; 68} XRRScreenChangeNotifyEvent; 69 70typedef struct { 71 int type; /* event base */ 72 unsigned long serial; /* # of last request processed by server */ 73 Bool send_event; /* true if this came from a SendEvent request */ 74 Display *display; /* Display the event was read from */ 75 Window window; /* window which selected for this event */ 76 int subtype; /* RRNotify_ subtype */ 77} XRRNotifyEvent; 78 79typedef struct { 80 int type; /* event base */ 81 unsigned long serial; /* # of last request processed by server */ 82 Bool send_event; /* true if this came from a SendEvent request */ 83 Display *display; /* Display the event was read from */ 84 Window window; /* window which selected for this event */ 85 int subtype; /* RRNotify_OutputChange */ 86 RROutput output; /* affected output */ 87 RRCrtc crtc; /* current crtc (or None) */ 88 RRMode mode; /* current mode (or None) */ 89 Rotation rotation; /* current rotation of associated crtc */ 90 Connection connection; /* current connection status */ 91 SubpixelOrder subpixel_order; 92} XRROutputChangeNotifyEvent; 93 94typedef struct { 95 int type; /* event base */ 96 unsigned long serial; /* # of last request processed by server */ 97 Bool send_event; /* true if this came from a SendEvent request */ 98 Display *display; /* Display the event was read from */ 99 Window window; /* window which selected for this event */ 100 int subtype; /* RRNotify_CrtcChange */ 101 RRCrtc crtc; /* current crtc (or None) */ 102 RRMode mode; /* current mode (or None) */ 103 Rotation rotation; /* current rotation of associated crtc */ 104 int x, y; /* position */ 105 unsigned int width, height; /* size */ 106} XRRCrtcChangeNotifyEvent; 107 108typedef struct { 109 int type; /* event base */ 110 unsigned long serial; /* # of last request processed by server */ 111 Bool send_event; /* true if this came from a SendEvent request */ 112 Display *display; /* Display the event was read from */ 113 Window window; /* window which selected for this event */ 114 int subtype; /* RRNotify_OutputProperty */ 115 RROutput output; /* related output */ 116 Atom property; /* changed property */ 117 Time timestamp; /* time of change */ 118 int state; /* NewValue, Deleted */ 119} XRROutputPropertyNotifyEvent; 120 121/* internal representation is private to the library */ 122typedef struct _XRRScreenConfiguration XRRScreenConfiguration; 123 124Bool XRRQueryExtension (Display *dpy, 125 int *event_base_return, 126 int *error_base_return); 127Status XRRQueryVersion (Display *dpy, 128 int *major_version_return, 129 int *minor_version_return); 130 131XRRScreenConfiguration *XRRGetScreenInfo (Display *dpy, 132 Window window); 133 134void XRRFreeScreenConfigInfo (XRRScreenConfiguration *config); 135 136/* 137 * Note that screen configuration changes are only permitted if the client can 138 * prove it has up to date configuration information. We are trying to 139 * insist that it become possible for screens to change dynamically, so 140 * we want to ensure the client knows what it is talking about when requesting 141 * changes. 142 */ 143Status XRRSetScreenConfig (Display *dpy, 144 XRRScreenConfiguration *config, 145 Drawable draw, 146 int size_index, 147 Rotation rotation, 148 Time timestamp); 149 150/* added in v1.1, sorry for the lame name */ 151Status XRRSetScreenConfigAndRate (Display *dpy, 152 XRRScreenConfiguration *config, 153 Drawable draw, 154 int size_index, 155 Rotation rotation, 156 short rate, 157 Time timestamp); 158 159 160Rotation XRRConfigRotations(XRRScreenConfiguration *config, Rotation *current_rotation); 161 162Time XRRConfigTimes (XRRScreenConfiguration *config, Time *config_timestamp); 163 164XRRScreenSize *XRRConfigSizes(XRRScreenConfiguration *config, int *nsizes); 165 166short *XRRConfigRates (XRRScreenConfiguration *config, int sizeID, int *nrates); 167 168SizeID XRRConfigCurrentConfiguration (XRRScreenConfiguration *config, 169 Rotation *rotation); 170 171short XRRConfigCurrentRate (XRRScreenConfiguration *config); 172 173int XRRRootToScreen(Display *dpy, Window root); 174 175/* 176 * returns the screen configuration for the specified screen; does a lazy 177 * evalution to delay getting the information, and caches the result. 178 * These routines should be used in preference to XRRGetScreenInfo 179 * to avoid unneeded round trips to the X server. These are new 180 * in protocol version 0.1. 181 */ 182 183 184void XRRSelectInput(Display *dpy, Window window, int mask); 185 186/* 187 * the following are always safe to call, even if RandR is not implemented 188 * on a screen 189 */ 190 191 192Rotation XRRRotations(Display *dpy, int screen, Rotation *current_rotation); 193XRRScreenSize *XRRSizes(Display *dpy, int screen, int *nsizes); 194short *XRRRates (Display *dpy, int screen, int sizeID, int *nrates); 195Time XRRTimes (Display *dpy, int screen, Time *config_timestamp); 196 197 198/* Version 1.2 additions */ 199 200/* despite returning a Status, this returns 1 for success */ 201Status 202XRRGetScreenSizeRange (Display *dpy, Window window, 203 int *minWidth, int *minHeight, 204 int *maxWidth, int *maxHeight); 205 206void 207XRRSetScreenSize (Display *dpy, Window window, 208 int width, int height, 209 int mmWidth, int mmHeight); 210 211typedef unsigned long XRRModeFlags; 212 213typedef struct _XRRModeInfo { 214 RRMode id; 215 unsigned int width; 216 unsigned int height; 217 unsigned long dotClock; 218 unsigned int hSyncStart; 219 unsigned int hSyncEnd; 220 unsigned int hTotal; 221 unsigned int hSkew; 222 unsigned int vSyncStart; 223 unsigned int vSyncEnd; 224 unsigned int vTotal; 225 char *name; 226 unsigned int nameLength; 227 XRRModeFlags modeFlags; 228} XRRModeInfo; 229 230typedef struct _XRRScreenResources { 231 Time timestamp; 232 Time configTimestamp; 233 int ncrtc; 234 RRCrtc *crtcs; 235 int noutput; 236 RROutput *outputs; 237 int nmode; 238 XRRModeInfo *modes; 239} XRRScreenResources; 240 241XRRScreenResources * 242XRRGetScreenResources (Display *dpy, Window window); 243 244void 245XRRFreeScreenResources (XRRScreenResources *resources); 246 247typedef struct _XRROutputInfo { 248 Time timestamp; 249 RRCrtc crtc; 250 char *name; 251 int nameLen; 252 unsigned long mm_width; 253 unsigned long mm_height; 254 Connection connection; 255 SubpixelOrder subpixel_order; 256 int ncrtc; 257 RRCrtc *crtcs; 258 int nclone; 259 RROutput *clones; 260 int nmode; 261 int npreferred; 262 RRMode *modes; 263} XRROutputInfo; 264 265XRROutputInfo * 266XRRGetOutputInfo (Display *dpy, XRRScreenResources *resources, RROutput output); 267 268void 269XRRFreeOutputInfo (XRROutputInfo *outputInfo); 270 271Atom * 272XRRListOutputProperties (Display *dpy, RROutput output, int *nprop); 273 274typedef struct { 275 Bool pending; 276 Bool range; 277 Bool immutable; 278 int num_values; 279 long *values; 280} XRRPropertyInfo; 281 282XRRPropertyInfo * 283XRRQueryOutputProperty (Display *dpy, RROutput output, Atom property); 284 285void 286XRRConfigureOutputProperty (Display *dpy, RROutput output, Atom property, 287 Bool pending, Bool range, int num_values, 288 long *values); 289 290void 291XRRChangeOutputProperty (Display *dpy, RROutput output, 292 Atom property, Atom type, 293 int format, int mode, 294 _Xconst unsigned char *data, int nelements); 295 296void 297XRRDeleteOutputProperty (Display *dpy, RROutput output, Atom property); 298 299int 300XRRGetOutputProperty (Display *dpy, RROutput output, 301 Atom property, long offset, long length, 302 Bool _delete, Bool pending, Atom req_type, 303 Atom *actual_type, int *actual_format, 304 unsigned long *nitems, unsigned long *bytes_after, 305 unsigned char **prop); 306 307XRRModeInfo * 308XRRAllocModeInfo (char *name, int nameLength); 309 310RRMode 311XRRCreateMode (Display *dpy, Window window, XRRModeInfo *modeInfo); 312 313void 314XRRDestroyMode (Display *dpy, RRMode mode); 315 316void 317XRRAddOutputMode (Display *dpy, RROutput output, RRMode mode); 318 319void 320XRRDeleteOutputMode (Display *dpy, RROutput output, RRMode mode); 321 322void 323XRRFreeModeInfo (XRRModeInfo *modeInfo); 324 325typedef struct _XRRCrtcInfo { 326 Time timestamp; 327 int x, y; 328 unsigned int width, height; 329 RRMode mode; 330 Rotation rotation; 331 int noutput; 332 RROutput *outputs; 333 Rotation rotations; 334 int npossible; 335 RROutput *possible; 336} XRRCrtcInfo; 337 338XRRCrtcInfo * 339XRRGetCrtcInfo (Display *dpy, XRRScreenResources *resources, RRCrtc crtc); 340 341void 342XRRFreeCrtcInfo (XRRCrtcInfo *crtcInfo); 343 344Status 345XRRSetCrtcConfig (Display *dpy, 346 XRRScreenResources *resources, 347 RRCrtc crtc, 348 Time timestamp, 349 int x, int y, 350 RRMode mode, 351 Rotation rotation, 352 RROutput *outputs, 353 int noutputs); 354 355int 356XRRGetCrtcGammaSize (Display *dpy, RRCrtc crtc); 357 358typedef struct _XRRCrtcGamma { 359 int size; 360 unsigned short *red; 361 unsigned short *green; 362 unsigned short *blue; 363} XRRCrtcGamma; 364 365XRRCrtcGamma * 366XRRGetCrtcGamma (Display *dpy, RRCrtc crtc); 367 368XRRCrtcGamma * 369XRRAllocGamma (int size); 370 371void 372XRRSetCrtcGamma (Display *dpy, RRCrtc crtc, XRRCrtcGamma *gamma); 373 374void 375XRRFreeGamma (XRRCrtcGamma *gamma); 376 377/* Version 1.3 additions */ 378 379XRRScreenResources * 380XRRGetScreenResourcesCurrent (Display *dpy, Window window); 381 382void 383XRRSetCrtcTransform (Display *dpy, 384 RRCrtc crtc, 385 XTransform *transform, 386 char *filter, 387 XFixed *params, 388 int nparams); 389 390typedef struct _XRRCrtcTransformAttributes { 391 XTransform pendingTransform; 392 char *pendingFilter; 393 int pendingNparams; 394 XFixed *pendingParams; 395 XTransform currentTransform; 396 char *currentFilter; 397 int currentNparams; 398 XFixed *currentParams; 399} XRRCrtcTransformAttributes; 400 401/* 402 * Get current crtc transforms and filters. 403 * Pass *attributes to XFree to free 404 */ 405Status 406XRRGetCrtcTransform (Display *dpy, 407 RRCrtc crtc, 408 XRRCrtcTransformAttributes **attributes); 409 410/* 411 * intended to take RRScreenChangeNotify, or 412 * ConfigureNotify (on the root window) 413 * returns 1 if it is an event type it understands, 0 if not 414 */ 415int XRRUpdateConfiguration(XEvent *event); 416 417typedef struct _XRRPanning { 418 Time timestamp; 419 unsigned int left; 420 unsigned int top; 421 unsigned int width; 422 unsigned int height; 423 unsigned int track_left; 424 unsigned int track_top; 425 unsigned int track_width; 426 unsigned int track_height; 427 int border_left; 428 int border_top; 429 int border_right; 430 int border_bottom; 431} XRRPanning; 432 433XRRPanning * 434XRRGetPanning (Display *dpy, XRRScreenResources *resources, RRCrtc crtc); 435 436void 437XRRFreePanning (XRRPanning *panning); 438 439Status 440XRRSetPanning (Display *dpy, 441 XRRScreenResources *resources, 442 RRCrtc crtc, 443 XRRPanning *panning); 444 445void 446XRRSetOutputPrimary(Display *dpy, 447 Window window, 448 RROutput output); 449 450RROutput 451XRRGetOutputPrimary(Display *dpy, 452 Window window); 453 454_XFUNCPROTOEND 455 456#endif /* _XRANDR_H_ */ 457