CGDisplayConfiguration.pas 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. {
  2. * CGDisplayConfiguration.h
  3. * CoreGraphics
  4. *
  5. * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
  6. *
  7. }
  8. { Pascal Translation: Peter N Lewis, <[email protected]>, August 2005 }
  9. {
  10. Modified for use with Free Pascal
  11. Version 200
  12. Please report any bugs to <[email protected]>
  13. }
  14. {$mode macpas}
  15. {$packenum 1}
  16. {$macro on}
  17. {$inline on}
  18. {$CALLING MWPASCAL}
  19. unit CGDisplayConfiguration;
  20. interface
  21. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  22. {$setc GAP_INTERFACES_VERSION := $0200}
  23. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  24. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  25. {$endc}
  26. {$ifc defined CPUPOWERPC and defined CPUI386}
  27. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  28. {$endc}
  29. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  30. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  31. {$endc}
  32. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  33. {$setc __ppc__ := 1}
  34. {$elsec}
  35. {$setc __ppc__ := 0}
  36. {$endc}
  37. {$ifc not defined __i386__ and defined CPUI386}
  38. {$setc __i386__ := 1}
  39. {$elsec}
  40. {$setc __i386__ := 0}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  43. {$error Conflicting definitions for __ppc__ and __i386__}
  44. {$endc}
  45. {$ifc defined __ppc__ and __ppc__}
  46. {$setc TARGET_CPU_PPC := TRUE}
  47. {$setc TARGET_CPU_X86 := FALSE}
  48. {$elifc defined __i386__ and __i386__}
  49. {$setc TARGET_CPU_PPC := FALSE}
  50. {$setc TARGET_CPU_X86 := TRUE}
  51. {$elsec}
  52. {$error Neither __ppc__ nor __i386__ is defined.}
  53. {$endc}
  54. {$setc TARGET_CPU_PPC_64 := FALSE}
  55. {$ifc defined FPC_BIG_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  58. {$elifc defined FPC_LITTLE_ENDIAN}
  59. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  60. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  61. {$elsec}
  62. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  63. {$endc}
  64. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  65. {$setc CALL_NOT_IN_CARBON := FALSE}
  66. {$setc OLDROUTINENAMES := FALSE}
  67. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  68. {$setc OPAQUE_UPP_TYPES := TRUE}
  69. {$setc OTCARBONAPPLICATION := TRUE}
  70. {$setc OTKERNEL := FALSE}
  71. {$setc PM_USE_SESSION_APIS := TRUE}
  72. {$setc TARGET_API_MAC_CARBON := TRUE}
  73. {$setc TARGET_API_MAC_OS8 := FALSE}
  74. {$setc TARGET_API_MAC_OSX := TRUE}
  75. {$setc TARGET_CARBON := TRUE}
  76. {$setc TARGET_CPU_68K := FALSE}
  77. {$setc TARGET_CPU_MIPS := FALSE}
  78. {$setc TARGET_CPU_SPARC := FALSE}
  79. {$setc TARGET_OS_MAC := TRUE}
  80. {$setc TARGET_OS_UNIX := FALSE}
  81. {$setc TARGET_OS_WIN32 := FALSE}
  82. {$setc TARGET_RT_MAC_68881 := FALSE}
  83. {$setc TARGET_RT_MAC_CFM := FALSE}
  84. {$setc TARGET_RT_MAC_MACHO := TRUE}
  85. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  86. {$setc TYPE_BOOL := FALSE}
  87. {$setc TYPE_EXTENDED := FALSE}
  88. {$setc TYPE_LONGLONG := TRUE}
  89. uses MacTypes,CGBase,CGDirectDisplay,CGErrors,CFDictionary,CGGeometry;
  90. {$ALIGN POWER}
  91. {
  92. * Display reconfiguration process.
  93. * Call CGBeginDisplayConfiguration to start.
  94. * Make all desired changes, for all displays.
  95. * Commit the changes using CGPerformDisplayConfiguration(), or cancel with
  96. * CGCancelDisplayConfiguration()
  97. *
  98. * The resulting layout will be adjusted so as to remove gaps or overlaps from
  99. * the requested layout, if needed.
  100. }
  101. type
  102. CGDisplayConfigRef = ^SInt32; { an opaque 32-bit type }
  103. { Get a new CGDisplayConfigRef }
  104. function CGBeginDisplayConfiguration( var pConfigRef: CGDisplayConfigRef ): CGError; external name '_CGBeginDisplayConfiguration';
  105. {
  106. * Set the origin point for a display
  107. *
  108. * Note that setting the origin of a display which is mirroring
  109. * another display will remove that display from any mirroring set.
  110. *
  111. * Any display whose origin is not explicitly set in a reconfiguration
  112. * will be repositioned to a location as close as possible to it's
  113. * current location without overlapping or leaving a gap between displays.
  114. *
  115. * The actual position a display is placed at will be as close as possible
  116. * to the requested location without overlapping or leaving a gap between
  117. * displays.
  118. }
  119. function CGConfigureDisplayOrigin( configRef: CGDisplayConfigRef; display: CGDirectDisplayID; x: CGDisplayCoord; y: CGDisplayCoord ): CGError; external name '_CGConfigureDisplayOrigin';
  120. {
  121. * Set the display mode
  122. *
  123. * The mode dictionary passed in must be a dictionary vended by other CGDirectDisplay
  124. * APIs such as CGDisplayBestModeForParameters() and CGDisplayAvailableModes().
  125. *
  126. * When changing display modes of displays in a mirroring set, other displays in
  127. * the mirroring set whose mode is not explicitly changed will be set to a display
  128. * mode capable of mirroring the bounds of the largest display being explicitly set.
  129. }
  130. function CGConfigureDisplayMode( configRef: CGDisplayConfigRef; display: CGDirectDisplayID; mode: CFDictionaryRef ): CGError; external name '_CGConfigureDisplayMode';
  131. {
  132. * Make a display a mirror of masterDisplay.
  133. *
  134. * Use a CGDirectDisplayID of kCGNullDirectDisplay for the masterDisplay to disable
  135. * mirroring.
  136. * Use a CGDirectDisplayID of CGMainDisplayID() for the masterDisplay to mirror
  137. * the main display.
  138. *
  139. * Mirroring requests will be filled with hardware mirroring when possible,
  140. * at the device driver's choice. Displays will be matted as appropriate,
  141. * using either hardware or software matte generation, again at the device driver's choice.
  142. *
  143. * Note that when hardware mirroring is in effect, the device driver may bind the hardware
  144. * accelerator, drawing engine, and 3D engine to any one of the displays in the hardware
  145. * mirroring set. That display will become the active display for drawing purposes in that
  146. * hardware mirroring set. Use CGDisplayPrimaryDisplay() to determine the correct display
  147. * device to process drawing operations in a hardware mirroring set.
  148. *
  149. * An app that uses CGGetActiveDisplayList() to determine the proper displays to draw to
  150. * (All Carbon and Cocoa apps using windows and/or DrawSprocket fall into this class)
  151. * will automatically get the correct behavior.
  152. }
  153. function CGConfigureDisplayMirrorOfDisplay( configRef: CGDisplayConfigRef; display: CGDirectDisplayID; masterDisplay: CGDirectDisplayID ): CGError; external name '_CGConfigureDisplayMirrorOfDisplay';
  154. { Cancel a reconfiguration operation, discarding the configRef }
  155. function CGCancelDisplayConfiguration( configRef: CGDisplayConfigRef ): CGError; external name '_CGCancelDisplayConfiguration';
  156. {
  157. * Perform the requested reconfigurations and discard the configRef
  158. *
  159. * A configuration change can apply for the life of an app, the life of a login session, or
  160. * permanently. If a request is made to make a change permanent, and the change
  161. * cannot be supported by the Aqua UI (resolution and pixel depth constraints apply),
  162. * then the configuration change is demoted to lasting the session.
  163. *
  164. * A permanent configuration change also becomes the current session's
  165. * configuration.
  166. *
  167. * When the system reverts confgurations at app termination, the
  168. * configuration always reverts to the session or permanent configuration setting.
  169. *
  170. * When the system reverts confgurations at session termination, the
  171. * configuration always reverts to the permanent configuration setting.
  172. *
  173. * This operation may fail if:
  174. * An unsupported display mode is requested
  175. * Another app is running in full-screen mode
  176. *
  177. }
  178. const
  179. kCGConfigureForAppOnly = 0;
  180. kCGConfigureForSession = 1;
  181. kCGConfigurePermanently = 2;
  182. type
  183. CGConfigureOption = UInt32;
  184. function CGCompleteDisplayConfiguration( configRef: CGDisplayConfigRef; option: CGConfigureOption ): CGError; external name '_CGCompleteDisplayConfiguration';
  185. { Restore the permanent display configuration from the user's display preferences settings }
  186. procedure CGRestorePermanentDisplayConfiguration; external name '_CGRestorePermanentDisplayConfiguration';
  187. {
  188. * Applications may want to register for notifications of display changes.
  189. *
  190. * Display changes are reported via a callback mechanism.
  191. *
  192. * Callbacks are invoked when the app is listening for events,
  193. * on the event processing thread, or from within the display
  194. * reconfiguration function when in the program that is driving the
  195. * reconfiguration.
  196. *
  197. * Callbacks should avoid attempting to change display configurations,
  198. * and should not raise exceptions or perform a non-local return such as
  199. * calling longjmp().
  200. *
  201. * Before display reconfiguration, a callback fires to inform
  202. * applications of a pending configuration change. The callback runs
  203. * once for each on-line display. The flags passed in are set to
  204. * kCGDisplayBeginConfigurationFlag. This callback does not
  205. * carry other per-display information, as details of how a
  206. * reconfiguration affects a particular device rely on device-specific
  207. * behaviors which may not be exposed by a device driver.
  208. *
  209. * After display reconfiguration, at the time the callback function
  210. * is invoked, all display state reported by CoreGraphics, QuickDraw,
  211. * and the Carbon Display Manager API will be up to date. This callback
  212. * runs after the Carbon Display Manager notification callbacks.
  213. * The callback runs once for each added, removed, and currently
  214. * on-line display. Note that in the case of removed displays, calls into
  215. * the CoreGraphics API with the removed display ID will fail.
  216. }
  217. const
  218. kCGDisplayBeginConfigurationFlag = 1 shl 0; { Set in pre-reconfiguration callback }
  219. kCGDisplayMovedFlag = 1 shl 1; { post-reconfiguration callback flag }
  220. kCGDisplaySetMainFlag = 1 shl 2; { post-reconfiguration callback flag }
  221. kCGDisplaySetModeFlag = 1 shl 3; { post-reconfiguration callback flag }
  222. kCGDisplayAddFlag = 1 shl 4; { post-reconfiguration callback flag }
  223. kCGDisplayRemoveFlag = 1 shl 5; { post-reconfiguration callback flag }
  224. kCGDisplayEnabledFlag = 1 shl 8; { post-reconfiguration callback flag }
  225. kCGDisplayDisabledFlag = 1 shl 9; { post-reconfiguration callback flag }
  226. kCGDisplayMirrorFlag = 1 shl 10;{ post-reconfiguration callback flag }
  227. kCGDisplayUnMirrorFlag = 1 shl 11; { post-reconfiguration callback flag }
  228. type
  229. CGDisplayChangeSummaryFlags = UInt32;
  230. type
  231. CGDisplayReconfigurationCallBack = procedure( display: CGDirectDisplayID; flags: CGDisplayChangeSummaryFlags; userInfo: UnivPtr );
  232. {
  233. * Register and remove a display reconfiguration callback procedure
  234. * The userInfo argument is passed back to the callback procedure each time
  235. * it is invoked.
  236. }
  237. function CGDisplayRegisterReconfigurationCallback( proc: CGDisplayReconfigurationCallBack; userInfo: UnivPtr ): CGError; external name '_CGDisplayRegisterReconfigurationCallback'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  238. function CGDisplayRemoveReconfigurationCallback( proc: CGDisplayReconfigurationCallBack; userInfo: UnivPtr ): CGError; external name '_CGDisplayRemoveReconfigurationCallback'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  239. {
  240. * These APIs allow applications and higher level frameworks
  241. * such as DrawSprocket to determine interesting properties
  242. * of displays, such as if a display is built-in, if a display
  243. * is the main display, if a display is being mirrored, which
  244. * display in a hardware mirror set is bound to the graphics
  245. * accelerator (important for games!) and so on.
  246. *
  247. * An app that uses CGGetActiveDisplayList() to determine the
  248. * proper displays to draw to (All Carbon and Cocoa apps using
  249. * windows and/or DrawSprocket fall into this class) will
  250. * automatically get the correct behavior without using these APIs.
  251. * These APIs are primarily of interest to specialized applications
  252. * such as movie players, integrated TV/video graphics utilities,
  253. * and similar specialized applications.
  254. }
  255. { True if the display is connected, awake, and drawable }
  256. function CGDisplayIsActive( display: CGDirectDisplayID ): boolean_t; external name '_CGDisplayIsActive';
  257. { True if the display is asleep and therefore not drawable }
  258. function CGDisplayIsAsleep( display: CGDirectDisplayID ): boolean_t; external name '_CGDisplayIsAsleep';
  259. {
  260. * True if the display is valid, with a monitor connected
  261. * (support for hot plugging of monitors)
  262. }
  263. function CGDisplayIsOnline( display: CGDirectDisplayID ): boolean_t; external name '_CGDisplayIsOnline';
  264. { True if the display is the current main display }
  265. function CGDisplayIsMain( display: CGDirectDisplayID ): boolean_t; external name '_CGDisplayIsMain';
  266. { True if the display is built in, such as the internal display in portables }
  267. function CGDisplayIsBuiltin( display: CGDirectDisplayID ): boolean_t; external name '_CGDisplayIsBuiltin';
  268. { True if the display is in a mirroring set }
  269. function CGDisplayIsInMirrorSet( display: CGDirectDisplayID ): boolean_t; external name '_CGDisplayIsInMirrorSet';
  270. { True if the display is always in a mirroring set, and cannot be unmirrored }
  271. function CGDisplayIsAlwaysInMirrorSet( display: CGDirectDisplayID ): boolean_t; external name '_CGDisplayIsAlwaysInMirrorSet';
  272. { True if the display is in a hardware mirroring set }
  273. function CGDisplayIsInHWMirrorSet( display: CGDirectDisplayID ): boolean_t; external name '_CGDisplayIsInHWMirrorSet';
  274. { Returns display being mirrored, or kCGNullDirectDisplay if master or unmirrored }
  275. function CGDisplayMirrorsDisplay( display: CGDirectDisplayID ): CGDirectDisplayID; external name '_CGDisplayMirrorsDisplay';
  276. { True if the display is using OpenGL acceleration }
  277. function CGDisplayUsesOpenGLAcceleration( display: CGDirectDisplayID ): boolean_t; external name '_CGDisplayUsesOpenGLAcceleration';
  278. {
  279. * Returns the display bound to the hardware accelerator in a HW mirror set,
  280. * or 'display' if software mirrored or unmirrored
  281. }
  282. function CGDisplayPrimaryDisplay( display: CGDirectDisplayID ): CGDirectDisplayID; external name '_CGDisplayPrimaryDisplay';
  283. {
  284. * Returns the logical unit, vendor ID, vendor model number,
  285. * and serial number for a display
  286. }
  287. function CGDisplayUnitNumber( display: CGDirectDisplayID ): UInt32; external name '_CGDisplayUnitNumber';
  288. function CGDisplayVendorNumber( display: CGDirectDisplayID ): UInt32; external name '_CGDisplayVendorNumber';
  289. function CGDisplayModelNumber( display: CGDirectDisplayID ): UInt32; external name '_CGDisplayModelNumber';
  290. function CGDisplaySerialNumber( display: CGDirectDisplayID ): UInt32; external name '_CGDisplaySerialNumber';
  291. { Returns the IOKit service port for a display device }
  292. // uncomment when IOKit translated function CGDisplayIOServicePort( display: CGDirectDisplayID ): io_service_t;
  293. {
  294. * Returns the size of the specified display in millimeters.
  295. *
  296. * If 'display' is not a valid display ID, the size returned has a width and height of 0.
  297. *
  298. * If EDID data for the display device is not available, the size is estimated based on
  299. * the device width and height in pixels from CGDisplayBounds(), with an assumed resolution
  300. * of 2.835 pixels/mm, or 72 DPI, a reasonable guess for displays predating EDID support.
  301. }
  302. function CGDisplayScreenSize( display: CGDirectDisplayID ): CGSize; external name '_CGDisplayScreenSize'; (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  303. end.