Xrandr.h 17 KB

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