Generic.Unix.X11.Mod 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. (* ETH Oberon, Copyright 2000 ETH Zürich Institut für Computersysteme, ETH Zentrum, CH-8092 Zürich.
  2. Refer to the general ETH Oberon System license contract available at: http://www.oberon.ethz.ch/ *)
  3. MODULE X11; (* 1993-95 / rc *)
  4. (* Oberon interface to X Window System Version 11 *)
  5. (* 1998.06.24 g.f. Linux PPC version *)
  6. (* 1999.04.03 g.f. support for Threads added *)
  7. (* 1999.11.03 g.f. Linux x86 version *)
  8. (* 2001.01.05 g.f. [C] - flag for new compiler *)
  9. (* 2001.08.04 g.f. made this module a pure interface to xlib,
  10. separated low level Display fumctionality into the new module Displays *)
  11. IMPORT Trace, Unix, Modules;
  12. TYPE
  13. Pixmap* = ADDRESS;
  14. Pattern* = ADDRESS (* = PatternPtr *) ;
  15. PatternPtr* = POINTER TO PatternDesc;
  16. PatternDesc* = RECORD
  17. x*, y*: LONGINT;
  18. w*, h*: INTEGER;
  19. pixmap*: Pixmap
  20. END;
  21. MetricDesc* = RECORD
  22. dx*, x*, y*, filler: INTEGER;
  23. p*: PatternDesc
  24. END;
  25. Font* = POINTER TO Bytes;
  26. Bytes* = RECORD
  27. metrics*: ARRAY 256 OF MetricDesc;
  28. xid*: LONGINT
  29. END;
  30. CONST
  31. BufferSize* = 512;
  32. TYPE
  33. Buffer* = ARRAY BufferSize OF CHAR;
  34. ComposeStatus* = RECORD
  35. opaque: ARRAY 6 OF LONGINT
  36. END;
  37. Modifiers* = ARRAY 8 OF KeySym;
  38. DisplayPtr* = ADDRESS;
  39. Window* = ADDRESS;
  40. Drawable* = ADDRESS;
  41. GC* = ADDRESS;
  42. Bool* = LONGINT;
  43. Colormap* = ADDRESS;
  44. Time* = ADDRESS;
  45. Atom* = ADDRESS;
  46. VisualID* = ADDRESS;
  47. Visual* = RECORD
  48. extData*: ADDRESS;
  49. visualid*: VisualID;
  50. class*: LONGINT;
  51. redMask*, greenMask*, blueMask*: LONGINT;
  52. bitsPerRgb*, mapEntries*: LONGINT
  53. END;
  54. VisualPtr* = POINTER TO Visual;
  55. VisualInfo* = RECORD
  56. visual*{UNTRACED}: VisualPtr;
  57. visualID*: VisualID;
  58. screen*, depth*, class*: LONGINT;
  59. redmask*, greenmask*, bluemask*: LONGINT;
  60. colomapsize*, bitsperrgb*: LONGINT
  61. END;
  62. Color* = RECORD
  63. pixel*: LONGINT;
  64. red*, green*, blue*: INTEGER;
  65. flags*, pad*: CHAR
  66. END;
  67. Point* = RECORD
  68. x*, y*: INTEGER
  69. END;
  70. Rectangle* = RECORD
  71. x*, y*, w*, h*: INTEGER
  72. END;
  73. Cursor* = ADDRESS; KeySym* = ADDRESS; KeyCode* = CHAR;
  74. Event* = RECORD
  75. typ*, serial*: LONGINT;
  76. sendEvent*: Bool;
  77. display*: DisplayPtr;
  78. window*, root*, subwindow*: Window;
  79. time*, x*, y*, xRoot*, yRoot*, state*, button*: LONGINT;
  80. sameScreen*, focus*: Bool;
  81. state2*: LONGINT;
  82. pad*: ARRAY 32 OF LONGINT
  83. END;
  84. SelectionEvent* = RECORD
  85. typ*, serial*: LONGINT;
  86. sendEvent*: Bool;
  87. display*: DisplayPtr;
  88. requestor*: Window;
  89. selection*, target*, property*: Atom;
  90. time*: Time
  91. END;
  92. SelectionRequestEvent* = RECORD
  93. typ*, serial*: LONGINT;
  94. sendEvent*: Bool;
  95. display*: DisplayPtr;
  96. owner*, requestor*: Window;
  97. selection*, target*, property*: Atom;
  98. time*: Time
  99. END;
  100. ExposeEvent* = RECORD
  101. typ*, serial*: LONGINT;
  102. sendEvent*: Bool;
  103. display*: DisplayPtr;
  104. window*: Window;
  105. x*, y*, width*, height*, count*: LONGINT;
  106. END;
  107. GraphicsExposeEvent* = RECORD
  108. typ*, serial*: LONGINT;
  109. sendEvent*: Bool;
  110. display*: DisplayPtr;
  111. drawable*: Drawable;
  112. x*, y*, width*, height*, count*, majorCode*, minorCode*: LONGINT;
  113. END;
  114. ButtonEvent* = RECORD
  115. typ*, serial*: LONGINT;
  116. sendEvent*: Bool;
  117. display*: DisplayPtr;
  118. window*, root*, subwindow*: Window;
  119. time*: Time;
  120. x*, y*, xRoot*, yRoot*, state*, button: LONGINT;
  121. sameScreen: Bool
  122. END;
  123. KeyEvent* = RECORD
  124. typ*, serial*: LONGINT;
  125. sendEvent*: Bool;
  126. display*: DisplayPtr;
  127. window*, root*, subwindow*: Window;
  128. time*: Time;
  129. x*, y*, xRoot*, yRoot*, state*, keycode*: LONGINT;
  130. sameScreen: Bool
  131. END;
  132. Image* = ADDRESS;
  133. ImagePtr* = POINTER TO ImageDesc;
  134. ImageDesc* = RECORD
  135. width*, height*: LONGINT;
  136. xoffset*, format*: LONGINT; data*: ADDRESS;
  137. byteOrder*, bitmapUnit*, bitmapBitOrder*: LONGINT;
  138. bitmapPad*, depth*, bytesPerLine*, bitsPerPixel*: LONGINT;
  139. redmask*, greenmask*, bluemask*: LONGINT;
  140. obdata*, createImage*, destroyImage*, getPixel*, putPixel*, subImage*, addPixel*: LONGINT
  141. END;
  142. ErrorEvent* = RECORD
  143. typ*: LONGINT;
  144. display*: DisplayPtr;
  145. resourceid*, serial*: LONGINT;
  146. errorCode*, requestCode*, minorCode*: CHAR
  147. END;
  148. ErrorEventPtr* = POINTER {UNSAFE,UNTRACED} TO ErrorEvent;
  149. ErrorHandler* = PROCEDURE ( d: DisplayPtr; err: ErrorEventPtr; p3, p4: LONGINT ): LONGINT;
  150. IOErrorHandler = PROCEDURE ( d: DisplayPtr; p2, p3, p4: LONGINT ): LONGINT;
  151. CONST
  152. (* X constants: <X11/X.h> *)
  153. False* = 0; True* = 1; None* = 0;
  154. (* line styles: *)
  155. LineSolid* = 0; LineOnOffDash* = 1; LineDoubleDash* = 2;
  156. (* cap styles: *)
  157. CapNotLast* = 0; CapButt* = 1; CapRound* = 2; CapProjecting* = 3;
  158. (* join styles: *)
  159. JoinMiter* = 0; JoinRound* = 1; JoinBevel* = 2;
  160. (* fill styles: *)
  161. FillSolid* = 0; FillTiled* = 1; FillStippled* = 2; FillOpaqueStippled* = 3;
  162. (* functions: *)
  163. GXand* = 1; GXcopy* = 3; GXxor* = 6; GXor* = 7; GXequiv* = 9;
  164. (* color flags: *)
  165. DoRed* = 1; DoGreen* = 2; DoBlue* = 4; DoAll* = DoRed + DoGreen + DoBlue;
  166. (* for CreateColormap : *)
  167. AllocNone* = 0; AllocAll* = 1;
  168. (* QueryBestSize Class: *)
  169. CursorShape* = 0; TileShape* = 1; StippleShape* = 2;
  170. (* visual classes: *)
  171. StaticGray* = 0; GrayScale* = 1; StaticColor* = 2; PseudoColor* = 3; TrueColor* = 4; DirectColor* = 5;
  172. (* arc modes: *)
  173. ArcChord* = 0; ArcPieSlice* = 1;
  174. (* polygone shape: *)
  175. Complex* = 0; Nonconvex* = 1; Convex* = 2;
  176. (* clip odering and origin: *)
  177. CoordModeOrigin* = 0; CoordModePrevious* = 1; Unsorted* = 0; YSorted* = 1; YXSorted* = 2;
  178. YXBanded* = 3;
  179. (* property modes: *)
  180. PropModeReplace* = 0;
  181. (* events types: *)
  182. KeyPress* = 2; KeyRelease* = 3; ButtonPress* = 4; ButtonRelease* = 5; MotionNotify* = 6;
  183. FocusIn* = 9; FocusOut* = 10;
  184. Expose* = 12; GraphicsExpose* = 13; NoExpose* = 14; UnmapNotify* = 18;
  185. MapNotify* = 19; PropertyNotify* = 28; SelectionClear* = 29; SelectionRequest* = 30;
  186. SelectionNotify* = 31; ClientMessage* = 33; MappingNotify* = 34;
  187. (* event masks: *)
  188. KeyPressMask* = 1H; KeyReleaseMask* = 2H; ButtonPressMask* = 4H; ButtonReleaseMask* = 8H;
  189. PointerMotionMask* = 40H; PointerMotionHintMask* = 80H; ButtonMotionMask* = 2000H;
  190. ExposureMask* = 8000H; StructureNotifyMask* = 20000H; FocusChangeMask* = 200000H;
  191. PropertyChangeMask* = 400000H; OwnerGrabButtonMask* = 1000000H;
  192. (* event modes: <X11/Xlib.h> *)
  193. QueuedAlready* = 0; QueuedAfterReading* = 1; QueuedAfterFlush* = 2;
  194. (* focus revert modes: <X11/X.h> *)
  195. RevertToParent* = 2;
  196. (* buttons: *)
  197. Button1* = 1; Button2* = 2; Button3* = 3;
  198. Button1Mask* = 100H; Button2Mask* = 200H; Button3Mask* = 400H;
  199. (* image format: *)
  200. XYBitmap* = 0; XYPixmap* = 1; ZPixmap* = 2;
  201. (* special keys: <X11/keysymdef.h> *)
  202. (* cursor shapes: <X11/cursorfont.h> *)
  203. XCleftptr* = 132;
  204. (* atoms: <X11/Xatom.h> *)
  205. XAPRIMARY* = 1; XASTRING* = 31;
  206. VAR
  207. ErrorText*: Buffer;
  208. ErrorFlag*: BOOLEAN; lastEventTime*: Time; ioErrors: INTEGER;
  209. (* cut and paste *)
  210. SendSelection*: PROCEDURE ( VAR event: SelectionRequestEvent );
  211. ReceiveSelection*: PROCEDURE ( VAR event: SelectionEvent );
  212. ClearSelection*: PROCEDURE;
  213. VAR
  214. (* Xlib calls: *)
  215. OpenDisplay-: PROCEDURE {C} ( name: ADDRESS ): DisplayPtr;
  216. DefaultScreen-: PROCEDURE {C} ( d: DisplayPtr ): LONGINT;
  217. DisplayWidth-,
  218. DisplayHeight-,
  219. DisplayHeightMM-,
  220. DefaultDepth-,
  221. DisplayCells-,
  222. DisplayPlanes-,
  223. BlackPixel-,
  224. WhitePixel-: PROCEDURE {C} ( d: DisplayPtr; screen: LONGINT ): LONGINT;
  225. DefaultVisual-: PROCEDURE {C} ( d: DisplayPtr; screen: LONGINT ): LONGINT;
  226. DefaultColormap-: PROCEDURE {C} ( d: DisplayPtr; screen: LONGINT ): Colormap;
  227. DefaultRootWindow-: PROCEDURE {C} ( d: DisplayPtr ): Window;
  228. CreateSimpleWindow-: PROCEDURE {C} ( d: DisplayPtr; parent: Window;
  229. x, y, width, height, borderWidth, border, background: LONGINT ): Window;
  230. TranslateCoordinates-: PROCEDURE {C} ( d: DisplayPtr; sw, dw: Window; srcx, srcy: LONGINT;
  231. VAR dstx, dsty: LONGINT; VAR child: Window );
  232. MoveResizeWindow-: PROCEDURE {C} ( d: DisplayPtr; w: Window; x, y, width, height: LONGINT );
  233. StoreName-,
  234. SetIconName-: PROCEDURE {C} ( d: DisplayPtr; w: Window; name: ADDRESS );
  235. SetCommand-: PROCEDURE {C} ( d: DisplayPtr; w: Window; argv: ADDRESS; argc: LONGINT );
  236. MapRaised-,
  237. LowerWindow-,
  238. ClearWindow-: PROCEDURE {C} ( d: DisplayPtr; w: Window );
  239. Sync-: PROCEDURE {C} ( d: DisplayPtr; discard: LONGINT );
  240. Flush-: PROCEDURE {C} ( d: DisplayPtr );
  241. StoreColor-: PROCEDURE {C} ( d: DisplayPtr; cmap: Colormap; color: ADDRESS );
  242. CreateBitmapFromData-:
  243. PROCEDURE {C} ( d: DisplayPtr; drawable: Drawable; data: ADDRESS;
  244. width, height: LONGINT ): Pixmap;
  245. CopyArea-: PROCEDURE {C} ( d: DisplayPtr; src, dest: Drawable; gc: GC;
  246. srcX, srcY, width, height, destX, destY: LONGINT );
  247. CopyPlane-: PROCEDURE {C} ( d: DisplayPtr; src, dest: Drawable; gc: GC;
  248. srcX, srcY, width, height, destX, destY, plane: LONGINT );
  249. SetStipple-: PROCEDURE {C} ( d: DisplayPtr; gc: GC; stipple: Pixmap );
  250. SetTSOrigin-: PROCEDURE {C} ( d: DisplayPtr; gc: GC; tsxorigin, tsyorigin: LONGINT );
  251. DrawPoint-: PROCEDURE {C} ( d: DisplayPtr; w: Drawable; gc: GC; x, y: LONGINT );
  252. FillRectangle-: PROCEDURE {C} ( d: DisplayPtr; w: Drawable; gc: GC; x, y, width, height: LONGINT );
  253. DrawString-: PROCEDURE {C} ( d: DisplayPtr; w: Drawable; gc: GC; x, y, string, length: LONGINT );
  254. CreateGC-: PROCEDURE {C} ( d: DisplayPtr; drawable: Drawable; valueMask, values: LONGINT ): GC;
  255. SetForeground-,
  256. SetBackground-,
  257. SetFunction-,
  258. SetFont-,
  259. SetFillStyle-: PROCEDURE {C} ( d: DisplayPtr; gc: GC; arg: LONGINT );
  260. SetPlaneMask-: PROCEDURE {C} ( d: DisplayPtr; gc: GC; mask: LONGINT );
  261. SetGraphicsExposures-:
  262. PROCEDURE {C} ( d: DisplayPtr; gc: GC; graphicsExposures: Bool );
  263. SetLineAttributes-: PROCEDURE {C} ( d: DisplayPtr; gc: GC; lineWidth, lineStyle, capStyle, joinStyle: LONGINT );
  264. AllocColorCells-: PROCEDURE {C} ( d: DisplayPtr; cmap: Colormap; contig: Bool; planeMasks: LONGINT;
  265. nplanes: LONGINT; pixels: LONGINT; ncolors: LONGINT ): LONGINT;
  266. SetWindowBackground-:
  267. PROCEDURE {C} ( d: DisplayPtr; w: Window; pixel: LONGINT );
  268. CreateFontCursor-: PROCEDURE {C} ( d: DisplayPtr; shape: LONGINT ): Cursor;
  269. CreatePixmapCursor-: PROCEDURE {C} ( d: DisplayPtr; csource, cmask: Pixmap;
  270. VAR cfore, cback: Color; xhot, yhot: LONGINT ): Cursor;
  271. RecolorCursor-: PROCEDURE {C} ( d: DisplayPtr; curs: Cursor; cfore, cback: LONGINT );
  272. DefineCursor-: PROCEDURE {C} ( d: DisplayPtr; w: Window; curs: Cursor );
  273. DrawLine-: PROCEDURE {C} ( d: DisplayPtr; w: Window; gc: GC; x1, y1, x2, y2: LONGINT );
  274. SetArcMode-: PROCEDURE {C} ( d: DisplayPtr; gc: GC; arcmode: LONGINT );
  275. DrawArc-, FillArc-: PROCEDURE {C} ( d: DisplayPtr; w: Window; gc: GC;
  276. x, y, width, height, angle1, angle2: LONGINT );
  277. FillPolygon-: PROCEDURE {C} ( d: DisplayPtr; w: Window; gc: GC;
  278. points, npoints, shape, mode: LONGINT );
  279. SetClipMask-: PROCEDURE {C} ( d: DisplayPtr; gc: GC; clipMask: Pixmap );
  280. SetClipRectangles-: PROCEDURE {C} ( d: DisplayPtr; gc: GC;
  281. clipxorigin, clipyorigin: LONGINT; rectangles: ADDRESS; n, ordering: LONGINT );
  282. ListFonts-: PROCEDURE {C} ( d: DisplayPtr; pattern, maxnames: LONGINT; VAR count: LONGINT ): LONGINT;
  283. FreeFontNames-: PROCEDURE {C} ( list: LONGINT );
  284. LoadFont-: PROCEDURE {C} ( d: DisplayPtr; name: ADDRESS ): LONGINT;
  285. SelectInput-: PROCEDURE {C} ( d: DisplayPtr; w: Window; eventMask: LONGINT );
  286. NextEvent-: PROCEDURE {C} ( d: DisplayPtr; VAR event: Event );
  287. EventsQueued-: PROCEDURE {C} ( d: DisplayPtr; mode: LONGINT ): LONGINT;
  288. SetInputFocus-: PROCEDURE {C} ( d: DisplayPtr; focus: Window; revertTo: LONGINT; time: LONGINT );
  289. LookupString-: PROCEDURE {C} ( VAR event: Event; VAR buf: Buffer; bufsize: LONGINT;
  290. VAR keysym: KeySym; VAR cstat: ComposeStatus ): LONGINT;
  291. QueryPointer-: PROCEDURE {C} ( d: DisplayPtr; w: Window; VAR rw, cw: Window;
  292. VAR xr, yr, xw, yw: LONGINT; VAR keysButtons: SET );
  293. RefreshKeyboardMapping-:
  294. PROCEDURE {C} ( event: ADDRESS );
  295. Bell-: PROCEDURE {C} ( d: DisplayPtr; percent: LONGINT );
  296. RebindKeysym-: PROCEDURE {C} ( d: DisplayPtr; reboundsym: KeySym; VAR modlist: Modifiers;
  297. modlength: LONGINT; newstring: ADDRESS; newlength: LONGINT );
  298. StringToKeysym-: PROCEDURE {C} ( string: ADDRESS ): KeySym;
  299. CopyColormapAndFree-:
  300. PROCEDURE {C} ( d: DisplayPtr; cmap: Colormap ): Colormap;
  301. CreateColormap-: PROCEDURE {C} ( d: DisplayPtr; w: Window; vis: VisualPtr; alloc: LONGINT ): Colormap;
  302. MatchVisualInfo-: PROCEDURE {C} ( d: DisplayPtr; screen, depth, class: LONGINT; VAR vinfo: VisualInfo ): LONGINT;
  303. SetWindowColormap-:
  304. PROCEDURE {C} ( d: DisplayPtr; w: Window; cmap: Colormap );
  305. QueryBestSize-: PROCEDURE {C} ( d: DisplayPtr; class: LONGINT;
  306. screen: Drawable; width, height: LONGINT; VAR w, h: LONGINT );
  307. CreatePixmap-: PROCEDURE {C} ( d: DisplayPtr; drawable: Drawable;
  308. width, height, depth: LONGINT ): Pixmap;
  309. FreePixmap-: PROCEDURE {C} ( d: DisplayPtr; pixmap: Pixmap );
  310. CreateImage-: PROCEDURE {C} ( d: DisplayPtr; visual: VisualPtr; depth, format, offset: LONGINT;
  311. data: ADDRESS; width, height, bitmapPad, bytesPerLine: LONGINT ): Image;
  312. DestroyImage-: PROCEDURE {C} ( image: Image );
  313. SubImage-: PROCEDURE {C} ( image: Image; x, y, width, height: LONGINT ): Image;
  314. GetImage-: PROCEDURE {C} ( d: DisplayPtr; drawable: Drawable;
  315. x, y, width, height, planeMask, format: LONGINT ): Image;
  316. GetSubImage-: PROCEDURE {C} ( d: DisplayPtr; drawable: Drawable;
  317. x, y, width, height, planeMask, format: LONGINT; dstImage: Image;
  318. dstX, dstY: LONGINT ): Image;
  319. PutImage-: PROCEDURE {C} ( d: DisplayPtr; drawable: Drawable; gc: GC; image: Image;
  320. srcX, srcY, dstX, dstY, width, height: LONGINT );
  321. PutPixel-: PROCEDURE {C} ( image: Image; x, y, pixel: LONGINT ): LONGINT;
  322. GetPixel-: PROCEDURE {C} ( image: Image; x, y: LONGINT ): LONGINT;
  323. AddPixel-: PROCEDURE {C} ( image: Image; value: LONGINT );
  324. Free-: PROCEDURE {C} ( data: ADDRESS );
  325. (* SetErrorHandler-: PROCEDURE {C} ( handler: ErrorHandler ); *)
  326. GetErrorText-: PROCEDURE {C} ( d: DisplayPtr; errcode: LONGINT; VAR buf: Buffer; length: LONGINT );
  327. StoreBytes-: PROCEDURE {C} ( d: DisplayPtr; bytes, nbytes: LONGINT );
  328. FetchBytes-: PROCEDURE {C} ( d: DisplayPtr; VAR nbytes: LONGINT ): LONGINT;
  329. SetSelectionOwner-: PROCEDURE {C} ( d: DisplayPtr; selection: Atom; owner: Window; time: Time );
  330. GetSelectionOwner-: PROCEDURE {C} ( d: DisplayPtr; selection: Atom ): Window;
  331. InternAtom-: PROCEDURE {C} ( d: DisplayPtr; name: LONGINT; onlyifexists: Bool ): Atom;
  332. SendEvent-: PROCEDURE {C} ( d: DisplayPtr; w: Window; propagate: Bool; eventmask, event: LONGINT );
  333. ConvertSelection-: PROCEDURE {C} ( d: DisplayPtr; selection, target, property: Atom;
  334. requestor: Window; timestamp: Time );
  335. ChangeProperty-: PROCEDURE {C} ( d: DisplayPtr; w: Window; property, typ: Atom;
  336. format, mode: LONGINT; data: ADDRESS; nelements: LONGINT );
  337. GetWindowProperty-:
  338. PROCEDURE {C} ( d: DisplayPtr; w: Window; property: Atom;
  339. offset, length: LONGINT; delete: Bool; reqtype: Atom; VAR typ: Atom;
  340. VAR format, nitems, bytesafter: LONGINT; VAR prop: ADDRESS );
  341. DeleteProperty-: PROCEDURE {C} ( d: DisplayPtr; w: Window; property: Atom );
  342. WarpPointer-: PROCEDURE {C} ( d: DisplayPtr; srcwin, dstwin: Window; srcx, srcy, srcw, srch, dstx, dsty: LONGINT );
  343. InstallColormap-: PROCEDURE {C} ( d: DisplayPtr; cmap: Colormap );
  344. GetGeometry-: PROCEDURE {C} ( d: DisplayPtr; drawable: Drawable; VAR root, x, y, width, height, orderWidth, Depth: LONGINT );
  345. ResizeWindow-: PROCEDURE {C} ( d: DisplayPtr; w: Window; x, y: LONGINT );
  346. Synchronize-: PROCEDURE {C} ( d: DisplayPtr; onoff: LONGINT );
  347. AllocColor-: PROCEDURE {C} ( d: DisplayPtr; cmap: Colormap; color: ADDRESS ): LONGINT;
  348. (* SetIOErrorHandler-: PROCEDURE {C} ( handler: IOErrorHandler ); *)
  349. InitXErrorHandlers-: PROCEDURE {C} ( eh: ErrorHandler; ioeh: IOErrorHandler );
  350. PROCEDURE LinkToX;
  351. VAR xlib: ADDRESS;
  352. BEGIN
  353. Unix.LinkToX;
  354. xlib := Unix.Dlopen( Unix.libX11name, 2 );
  355. IF xlib = 0 THEN (* try default version *)
  356. xlib := Unix.Dlopen( "libX11.so", 2 )
  357. END;
  358. IF xlib = 0 THEN
  359. Trace.StringLn( "X11.LinkToX: Unix.Dlopen( libX11.so ) failed " ); Unix.exit( 3 )
  360. END;
  361. Unix.Dlsym( xlib, "XOpenDisplay", ADDRESSOF( OpenDisplay ) );
  362. Unix.Dlsym( xlib, "XDefaultScreen", ADDRESSOF( DefaultScreen ) );
  363. Unix.Dlsym( xlib, "XDisplayWidth", ADDRESSOF( DisplayWidth ) );
  364. Unix.Dlsym( xlib, "XDisplayHeight", ADDRESSOF( DisplayHeight ) );
  365. Unix.Dlsym( xlib, "XDisplayHeightMM", ADDRESSOF( DisplayHeightMM ) );
  366. Unix.Dlsym( xlib, "XDefaultDepth", ADDRESSOF( DefaultDepth ) );
  367. Unix.Dlsym( xlib, "XDisplayCells", ADDRESSOF( DisplayCells ) );
  368. Unix.Dlsym( xlib, "XDisplayPlanes", ADDRESSOF( DisplayPlanes ) );
  369. Unix.Dlsym( xlib, "XBlackPixel", ADDRESSOF( BlackPixel ) );
  370. Unix.Dlsym( xlib, "XWhitePixel", ADDRESSOF( WhitePixel ) );
  371. Unix.Dlsym( xlib, "XDefaultVisual", ADDRESSOF( DefaultVisual ) );
  372. Unix.Dlsym( xlib, "XDefaultColormap", ADDRESSOF( DefaultColormap ) );
  373. Unix.Dlsym( xlib, "XDefaultRootWindow", ADDRESSOF( DefaultRootWindow ) );
  374. Unix.Dlsym( xlib, "XCreateSimpleWindow", ADDRESSOF( CreateSimpleWindow ) );
  375. Unix.Dlsym( xlib, "XTranslateCoordinates", ADDRESSOF( TranslateCoordinates ) );
  376. Unix.Dlsym( xlib, "XMoveResizeWindow", ADDRESSOF( MoveResizeWindow ) );
  377. Unix.Dlsym( xlib, "XStoreName", ADDRESSOF( StoreName ) );
  378. Unix.Dlsym( xlib, "XSetIconName", ADDRESSOF( SetIconName ) );
  379. Unix.Dlsym( xlib, "XSetCommand", ADDRESSOF( SetCommand ) );
  380. Unix.Dlsym( xlib, "XMapRaised", ADDRESSOF( MapRaised ) );
  381. Unix.Dlsym( xlib, "XLowerWindow", ADDRESSOF( LowerWindow ) );
  382. Unix.Dlsym( xlib, "XClearWindow", ADDRESSOF( ClearWindow ) );
  383. Unix.Dlsym( xlib, "XSync", ADDRESSOF( Sync ) ); Unix.Dlsym( xlib, "XFlush", ADDRESSOF( Flush ) );
  384. Unix.Dlsym( xlib, "XStoreColor", ADDRESSOF( StoreColor ) );
  385. Unix.Dlsym( xlib, "XCreateBitmapFromData", ADDRESSOF( CreateBitmapFromData ) );
  386. Unix.Dlsym( xlib, "XCopyArea", ADDRESSOF( CopyArea ) );
  387. Unix.Dlsym( xlib, "XCopyPlane", ADDRESSOF( CopyPlane ) );
  388. Unix.Dlsym( xlib, "XSetStipple", ADDRESSOF( SetStipple ) );
  389. Unix.Dlsym( xlib, "XSetTSOrigin", ADDRESSOF( SetTSOrigin ) );
  390. Unix.Dlsym( xlib, "XFillRectangle", ADDRESSOF( FillRectangle ) );
  391. Unix.Dlsym( xlib, "XDrawPoint", ADDRESSOF( DrawPoint ) );
  392. Unix.Dlsym( xlib, "XDrawString", ADDRESSOF( DrawString ) );
  393. Unix.Dlsym( xlib, "XCreateGC", ADDRESSOF( CreateGC ) );
  394. Unix.Dlsym( xlib, "XSetForeground", ADDRESSOF( SetForeground ) );
  395. Unix.Dlsym( xlib, "XSetBackground", ADDRESSOF( SetBackground ) );
  396. Unix.Dlsym( xlib, "XSetPlaneMask", ADDRESSOF( SetPlaneMask ) );
  397. Unix.Dlsym( xlib, "XSetLineAttributes", ADDRESSOF( SetLineAttributes ) );
  398. Unix.Dlsym( xlib, "XSetFunction", ADDRESSOF( SetFunction ) );
  399. Unix.Dlsym( xlib, "XSetFont", ADDRESSOF( SetFont ) );
  400. Unix.Dlsym( xlib, "XSetFillStyle", ADDRESSOF( SetFillStyle ) );
  401. Unix.Dlsym( xlib, "XSetGraphicsExposures", ADDRESSOF( SetGraphicsExposures ) );
  402. Unix.Dlsym( xlib, "XAllocColorCells", ADDRESSOF( AllocColorCells ) );
  403. Unix.Dlsym( xlib, "XSetWindowBackground", ADDRESSOF( SetWindowBackground ) );
  404. Unix.Dlsym( xlib, "XCreateFontCursor", ADDRESSOF( CreateFontCursor ) );
  405. Unix.Dlsym( xlib, "XCreatePixmapCursor", ADDRESSOF( CreatePixmapCursor ) );
  406. Unix.Dlsym( xlib, "XRecolorCursor", ADDRESSOF( RecolorCursor ) );
  407. Unix.Dlsym( xlib, "XDefineCursor", ADDRESSOF( DefineCursor ) );
  408. Unix.Dlsym( xlib, "XDrawLine", ADDRESSOF( DrawLine ) );
  409. Unix.Dlsym( xlib, "XSetArcMode", ADDRESSOF( SetArcMode ) );
  410. Unix.Dlsym( xlib, "XDrawArc", ADDRESSOF( DrawArc ) );
  411. Unix.Dlsym( xlib, "XFillArc", ADDRESSOF( FillArc ) );
  412. Unix.Dlsym( xlib, "XFillPolygon", ADDRESSOF( FillPolygon ) );
  413. Unix.Dlsym( xlib, "XSetClipMask", ADDRESSOF( SetClipMask ) );
  414. Unix.Dlsym( xlib, "XSetClipRectangles", ADDRESSOF( SetClipRectangles ) );
  415. Unix.Dlsym( xlib, "XListFonts", ADDRESSOF( ListFonts ) );
  416. Unix.Dlsym( xlib, "XFreeFontNames", ADDRESSOF( FreeFontNames ) );
  417. Unix.Dlsym( xlib, "XLoadFont", ADDRESSOF( LoadFont ) );
  418. Unix.Dlsym( xlib, "XSelectInput", ADDRESSOF( SelectInput ) );
  419. Unix.Dlsym( xlib, "XSync", ADDRESSOF( Sync ) );
  420. Unix.Dlsym( xlib, "XNextEvent", ADDRESSOF( NextEvent ) );
  421. Unix.Dlsym( xlib, "XEventsQueued", ADDRESSOF( EventsQueued ) );
  422. Unix.Dlsym( xlib, "XSetInputFocus", ADDRESSOF( SetInputFocus ) );
  423. Unix.Dlsym( xlib, "XLookupString", ADDRESSOF( LookupString ) );
  424. Unix.Dlsym( xlib, "XQueryPointer", ADDRESSOF( QueryPointer ) );
  425. Unix.Dlsym( xlib, "XRefreshKeyboardMapping", ADDRESSOF( RefreshKeyboardMapping ) );
  426. Unix.Dlsym( xlib, "XBell", ADDRESSOF( Bell ) );
  427. Unix.Dlsym( xlib, "XRebindKeysym", ADDRESSOF( RebindKeysym ) );
  428. Unix.Dlsym( xlib, "XStringToKeysym", ADDRESSOF( StringToKeysym ) );
  429. Unix.Dlsym( xlib, "XCopyColormapAndFree", ADDRESSOF( CopyColormapAndFree ) );
  430. Unix.Dlsym( xlib, "XCreateColormap", ADDRESSOF( CreateColormap ) );
  431. Unix.Dlsym( xlib, "XMatchVisualInfo", ADDRESSOF( MatchVisualInfo ) );
  432. Unix.Dlsym( xlib, "XSetWindowColormap", ADDRESSOF( SetWindowColormap ) );
  433. Unix.Dlsym( xlib, "XQueryBestSize", ADDRESSOF( QueryBestSize ) );
  434. Unix.Dlsym( xlib, "XCreatePixmap", ADDRESSOF( CreatePixmap ) );
  435. Unix.Dlsym( xlib, "XFreePixmap", ADDRESSOF( FreePixmap ) );
  436. Unix.Dlsym( xlib, "XCreateImage", ADDRESSOF( CreateImage ) );
  437. Unix.Dlsym( xlib, "XDestroyImage", ADDRESSOF( DestroyImage ) );
  438. Unix.Dlsym( xlib, "XSubImage", ADDRESSOF( SubImage ) );
  439. Unix.Dlsym( xlib, "XGetImage", ADDRESSOF( GetImage ) );
  440. Unix.Dlsym( xlib, "XGetSubImage", ADDRESSOF( GetSubImage ) );
  441. Unix.Dlsym( xlib, "XPutImage", ADDRESSOF( PutImage ) );
  442. Unix.Dlsym( xlib, "XPutPixel", ADDRESSOF( PutPixel ) );
  443. Unix.Dlsym( xlib, "XGetPixel", ADDRESSOF( GetPixel ) );
  444. Unix.Dlsym( xlib, "XAddPixel", ADDRESSOF( AddPixel ) );
  445. Unix.Dlsym( xlib, "XFree", ADDRESSOF( Free ) );
  446. (* Unix.Dlsym( xlib, "XSetErrorHandler", ADDRESSOF( SetErrorHandler ) ) *)
  447. (* Unix.Dlsym( xlib, "XSetIOErrorHandler", ADDRESSOF( SetIOErrorHandler ) ); *)
  448. Unix.Dlsym( xlib, "XGetErrorText", ADDRESSOF( GetErrorText ) );
  449. Unix.Dlsym( xlib, "XStoreBytes", ADDRESSOF( StoreBytes ) );
  450. Unix.Dlsym( xlib, "XFetchBytes", ADDRESSOF( FetchBytes ) );
  451. Unix.Dlsym( xlib, "XSetSelectionOwner", ADDRESSOF( SetSelectionOwner ) );
  452. Unix.Dlsym( xlib, "XGetSelectionOwner", ADDRESSOF( GetSelectionOwner ) );
  453. Unix.Dlsym( xlib, "XInternAtom", ADDRESSOF( InternAtom ) );
  454. Unix.Dlsym( xlib, "XSendEvent", ADDRESSOF( SendEvent ) );
  455. Unix.Dlsym( xlib, "XConvertSelection", ADDRESSOF( ConvertSelection ) );
  456. Unix.Dlsym( xlib, "XChangeProperty", ADDRESSOF( ChangeProperty ) );
  457. Unix.Dlsym( xlib, "XGetWindowProperty", ADDRESSOF( GetWindowProperty ) );
  458. Unix.Dlsym( xlib, "XDeleteProperty", ADDRESSOF( DeleteProperty ) );
  459. Unix.Dlsym( xlib, "XWarpPointer", ADDRESSOF( WarpPointer ) );
  460. Unix.Dlsym( xlib, "XInstallColormap", ADDRESSOF( InstallColormap ) );
  461. Unix.Dlsym( xlib, "XGetGeometry", ADDRESSOF( GetGeometry ) );
  462. Unix.Dlsym( xlib, "XResizeWindow", ADDRESSOF( ResizeWindow ) );
  463. Unix.Dlsym( xlib, "XSynchronize", ADDRESSOF( Synchronize ) );
  464. Unix.Dlsym( xlib, "XAllocColor", ADDRESSOF( AllocColor ) );
  465. END LinkToX;
  466. PROCEDURE MyErrorHandler( d: DisplayPtr; err {UNTRACED}: ErrorEventPtr ): LONGINT;
  467. BEGIN
  468. ErrorFlag := TRUE;
  469. GetErrorText( d, ORD( err.errorCode ), ErrorText, BufferSize );
  470. Trace.StringLn( ErrorText );
  471. RETURN 0
  472. END MyErrorHandler;
  473. PROCEDURE MyIOErrorHandler( d: DisplayPtr): LONGINT;
  474. BEGIN
  475. ErrorFlag := TRUE; ErrorText := "X11 I/O Error";
  476. Trace.StringLn( ErrorText );
  477. INC( ioErrors );
  478. IF ioErrors > 100 THEN Modules.Shutdown( 0 ) END ;
  479. RETURN 0
  480. END MyIOErrorHandler;
  481. BEGIN
  482. ioErrors := 0; LinkToX; ErrorFlag := FALSE;
  483. (*SetIOErrorHandler( MyIOErrorHandler );*)
  484. (*SetErrorHandler( MyErrorHandler );*)
  485. (* Oberon procedures cannot be used as callback procedures because of
  486. incompatibilities between the PPC Oberon ABI and the PPC SYSV ABI.
  487. PPC Oberon follows the old MAC and IBM AIX ABI *)
  488. Unix.InitXErrorHandlers( MyErrorHandler, MyIOErrorHandler );
  489. END X11.