xrandr.nim 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. #
  2. # $XFree86: xc/lib/Xrandr/Xrandr.h,v 1.9 2002/09/29 23:39:44 keithp Exp $
  3. #
  4. # Copyright (C) 2000 Compaq Computer Corporation, Inc.
  5. # Copyright (C) 2002 Hewlett-Packard Company, 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
  10. # copyright notice and this permission notice appear in supporting
  11. # documentation, and that the name of Compaq not be used in advertising or
  12. # publicity pertaining to distribution of the software without specific,
  13. # written prior permission. HP makes no representations about the
  14. # suitability of this software for any purpose. It is provided "as is"
  15. # without express or implied warranty.
  16. #
  17. # HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  18. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL COMPAQ
  19. # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  20. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  21. # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  22. # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  23. #
  24. # Author: Jim Gettys, HP Labs, HP.
  25. #
  26. import
  27. x, xlib
  28. const
  29. libXrandr* = "libXrandr.so"
  30. # * $XFree86: xc/include/extensions/randr.h,v 1.4 2001/11/24 07:24:58 keithp Exp $
  31. # *
  32. # * Copyright (C) 2000, Compaq Computer Corporation,
  33. # * Copyright (C) 2002, Hewlett Packard, Inc.
  34. # *
  35. # * Permission to use, copy, modify, distribute, and sell this software and its
  36. # * documentation for any purpose is hereby granted without fee, provided that
  37. # * the above copyright notice appear in all copies and that both that
  38. # * copyright notice and this permission notice appear in supporting
  39. # * documentation, and that the name of Compaq or HP not be used in advertising
  40. # * or publicity pertaining to distribution of the software without specific,
  41. # * written prior permission. HP makes no representations about the
  42. # * suitability of this software for any purpose. It is provided "as is"
  43. # * without express or implied warranty.
  44. # *
  45. # * HP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  46. # * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL HP
  47. # * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  48. # * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  49. # * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  50. # * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  51. # *
  52. # * Author: Jim Gettys, HP Labs, Hewlett-Packard, Inc.
  53. # *
  54. type
  55. PRotation* = ptr TRotation
  56. TRotation* = cushort
  57. PSizeID* = ptr TSizeID
  58. TSizeID* = cushort
  59. PSubpixelOrder* = ptr TSubpixelOrder
  60. TSubpixelOrder* = cushort
  61. const
  62. RANDR_NAME* = "RANDR"
  63. RANDR_MAJOR* = 1
  64. RANDR_MINOR* = 1
  65. RRNumberErrors* = 0
  66. RRNumberEvents* = 1
  67. constX_RRQueryVersion* = 0 # we skip 1 to make old clients fail pretty immediately
  68. X_RROldGetScreenInfo* = 1
  69. X_RR1_0SetScreenConfig* = 2 # V1.0 apps share the same set screen config request id
  70. constX_RRSetScreenConfig* = 2
  71. X_RROldScreenChangeSelectInput* = 3 # 3 used to be ScreenChangeSelectInput; deprecated
  72. constX_RRSelectInput* = 4
  73. constX_RRGetScreenInfo* = 5 # used in XRRSelectInput
  74. RRScreenChangeNotifyMask* = 1 shl 0
  75. RRScreenChangeNotify* = 0 # used in the rotation field; rotation and reflection in 0.1 proto.
  76. RR_Rotate_0* = 1
  77. RR_Rotate_90* = 2
  78. RR_Rotate_180* = 4
  79. RR_Rotate_270* = 8 # new in 1.0 protocol, to allow reflection of screen
  80. RR_Reflect_X* = 16
  81. RR_Reflect_Y* = 32
  82. RRSetConfigSuccess* = 0
  83. RRSetConfigInvalidConfigTime* = 1
  84. RRSetConfigInvalidTime* = 2
  85. RRSetConfigFailed* = 3
  86. type
  87. PXRRScreenSize* = ptr TXRRScreenSize
  88. TXRRScreenSize*{.final.} = object #
  89. # Events.
  90. #
  91. width*, height*: cint
  92. mwidth*, mheight*: cint
  93. TXRRScreenChangeNotifyEvent*{.final.} = object # internal representation is private to the library
  94. typ*: cint # event base
  95. serial*: culong # # of last request processed by server
  96. send_event*: TBool # true if this came from a SendEvent request
  97. display*: PDisplay # Display the event was read from
  98. window*: TWindow # window which selected for this event
  99. root*: TWindow # Root window for changed screen
  100. timestamp*: TTime # when the screen change occurred
  101. config_timestamp*: TTime # when the last configuration change
  102. size_index*: TSizeID
  103. subpixel_order*: TSubpixelOrder
  104. rotation*: TRotation
  105. width*: cint
  106. height*: cint
  107. mwidth*: cint
  108. mheight*: cint
  109. PXRRScreenConfiguration* = ptr TXRRScreenConfiguration
  110. TXRRScreenConfiguration*{.final.} = object
  111. proc XRRQueryExtension*(dpy: PDisplay, event_basep, error_basep: Pcint): TBool{.
  112. cdecl, dynlib: libXrandr, importc.}
  113. proc XRRQueryVersion*(dpy: PDisplay, major_versionp: Pcint,
  114. minor_versionp: Pcint): TStatus{.cdecl, dynlib: libXrandr,
  115. importc.}
  116. proc XRRGetScreenInfo*(dpy: PDisplay, draw: TDrawable): PXRRScreenConfiguration{.
  117. cdecl, dynlib: libXrandr, importc.}
  118. proc XRRFreeScreenConfigInfo*(config: PXRRScreenConfiguration){.cdecl,
  119. dynlib: libXrandr, importc.}
  120. #
  121. # Note that screen configuration changes are only permitted if the client can
  122. # prove it has up to date configuration information. We are trying to
  123. # insist that it become possible for screens to change dynamically, so
  124. # we want to ensure the client knows what it is talking about when requesting
  125. # changes.
  126. #
  127. proc XRRSetScreenConfig*(dpy: PDisplay, config: PXRRScreenConfiguration,
  128. draw: TDrawable, size_index: cint, rotation: TRotation,
  129. timestamp: TTime): TStatus{.cdecl, dynlib: libXrandr,
  130. importc.}
  131. # added in v1.1, sorry for the lame name
  132. proc XRRSetScreenConfigAndRate*(dpy: PDisplay, config: PXRRScreenConfiguration,
  133. draw: TDrawable, size_index: cint,
  134. rotation: TRotation, rate: cshort,
  135. timestamp: TTime): TStatus{.cdecl,
  136. dynlib: libXrandr, importc.}
  137. proc XRRConfigRotations*(config: PXRRScreenConfiguration,
  138. current_rotation: PRotation): TRotation{.cdecl,
  139. dynlib: libXrandr, importc.}
  140. proc XRRConfigTimes*(config: PXRRScreenConfiguration, config_timestamp: PTime): TTime{.
  141. cdecl, dynlib: libXrandr, importc.}
  142. proc XRRConfigSizes*(config: PXRRScreenConfiguration, nsizes: Pcint): PXRRScreenSize{.
  143. cdecl, dynlib: libXrandr, importc.}
  144. proc XRRConfigRates*(config: PXRRScreenConfiguration, sizeID: cint,
  145. nrates: Pcint): ptr int16{.cdecl, dynlib: libXrandr, importc.}
  146. proc XRRConfigCurrentConfiguration*(config: PXRRScreenConfiguration,
  147. rotation: PRotation): TSizeID{.cdecl,
  148. dynlib: libXrandr, importc.}
  149. proc XRRConfigCurrentRate*(config: PXRRScreenConfiguration): cshort{.cdecl,
  150. dynlib: libXrandr, importc.}
  151. proc XRRRootToScreen*(dpy: PDisplay, root: TWindow): cint{.cdecl,
  152. dynlib: libXrandr, importc.}
  153. #
  154. # returns the screen configuration for the specified screen; does a lazy
  155. # evalution to delay getting the information, and caches the result.
  156. # These routines should be used in preference to XRRGetScreenInfo
  157. # to avoid unneeded round trips to the X server. These are new
  158. # in protocol version 0.1.
  159. #
  160. proc XRRScreenConfig*(dpy: PDisplay, screen: cint): PXRRScreenConfiguration{.
  161. cdecl, dynlib: libXrandr, importc.}
  162. proc XRRConfig*(screen: PScreen): PXRRScreenConfiguration{.cdecl,
  163. dynlib: libXrandr, importc.}
  164. proc XRRSelectInput*(dpy: PDisplay, window: TWindow, mask: cint){.cdecl,
  165. dynlib: libXrandr, importc.}
  166. #
  167. # the following are always safe to call, even if RandR is not implemented
  168. # on a screen
  169. #
  170. proc XRRRotations*(dpy: PDisplay, screen: cint, current_rotation: PRotation): TRotation{.
  171. cdecl, dynlib: libXrandr, importc.}
  172. proc XRRSizes*(dpy: PDisplay, screen: cint, nsizes: Pcint): PXRRScreenSize{.
  173. cdecl, dynlib: libXrandr, importc.}
  174. proc XRRRates*(dpy: PDisplay, screen: cint, sizeID: cint, nrates: Pcint): ptr int16{.
  175. cdecl, dynlib: libXrandr, importc.}
  176. proc XRRTimes*(dpy: PDisplay, screen: cint, config_timestamp: PTime): TTime{.
  177. cdecl, dynlib: libXrandr, importc.}
  178. #
  179. # intended to take RRScreenChangeNotify, or
  180. # ConfigureNotify (on the root window)
  181. # returns 1 if it is an event type it understands, 0 if not
  182. #
  183. proc XRRUpdateConfiguration*(event: PXEvent): cint{.cdecl, dynlib: libXrandr,
  184. importc.}
  185. # implementation