Xlib.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. // Permission is hereby granted, free of charge, to any person obtaining
  2. // a copy of this software and associated documentation files (the
  3. // "Software"), to deal in the Software without restriction, including
  4. // without limitation the rights to use, copy, modify, merge, publish,
  5. // distribute, sublicense, and/or sell copies of the Software, and to
  6. // permit persons to whom the Software is furnished to do so, subject to
  7. // the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be
  10. // included in all copies or substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  15. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  16. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  17. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  18. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. //
  20. // Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
  21. //
  22. //
  23. using System;
  24. using System.Text;
  25. using System.Runtime.InteropServices;
  26. namespace System.Windows.Forms.X11Internal {
  27. internal class Xlib {
  28. const string libX11 = "X11";
  29. [DllImport (libX11)]
  30. public extern static IntPtr XOpenDisplay(IntPtr display);
  31. [DllImport (libX11)]
  32. public extern static int XCloseDisplay(IntPtr display);
  33. [DllImport (libX11)]
  34. public extern static IntPtr XSynchronize(IntPtr display, bool onoff);
  35. [DllImport (libX11)]
  36. public extern static IntPtr XCreateWindow(IntPtr display, IntPtr parent, int x, int y, int width, int height, int border_width, int depth, int xclass, IntPtr visual, UIntPtr valuemask, ref XSetWindowAttributes attributes);
  37. [DllImport (libX11)]
  38. public extern static IntPtr XCreateSimpleWindow(IntPtr display, IntPtr parent, int x, int y, int width, int height, int border_width, UIntPtr border, UIntPtr background);
  39. [DllImport (libX11)]
  40. public extern static int XMapWindow(IntPtr display, IntPtr window);
  41. [DllImport (libX11)]
  42. public extern static int XUnmapWindow(IntPtr display, IntPtr window);
  43. [DllImport (libX11)]
  44. public extern static int XMapSubindows(IntPtr display, IntPtr window);
  45. [DllImport (libX11)]
  46. public extern static int XUnmapSubwindows(IntPtr display, IntPtr window);
  47. [DllImport (libX11)]
  48. public extern static IntPtr XRootWindow(IntPtr display, int screen_number);
  49. [DllImport (libX11)]
  50. public extern static IntPtr XNextEvent(IntPtr display, ref XEvent xevent);
  51. [DllImport (libX11)]
  52. public extern static int XConnectionNumber (IntPtr diplay);
  53. [DllImport (libX11)]
  54. public extern static int XPending (IntPtr diplay);
  55. [DllImport (libX11)]
  56. public extern static IntPtr XSelectInput(IntPtr display, IntPtr window, IntPtr mask);
  57. [DllImport (libX11)]
  58. public extern static int XDestroyWindow(IntPtr display, IntPtr window);
  59. [DllImport (libX11)]
  60. public extern static int XReparentWindow(IntPtr display, IntPtr window, IntPtr parent, int x, int y);
  61. [DllImport (libX11)]
  62. public extern static int XMoveResizeWindow(IntPtr display, IntPtr window, int x, int y, int width, int height);
  63. [DllImport (libX11)]
  64. public extern static int XResizeWindow(IntPtr display, IntPtr window, int width, int height);
  65. [DllImport (libX11)]
  66. public extern static int XGetWindowAttributes(IntPtr display, IntPtr window, ref XWindowAttributes attributes);
  67. [DllImport (libX11)]
  68. public extern static int XFlush(IntPtr display);
  69. [DllImport (libX11)]
  70. public extern static int XSetWMName(IntPtr display, IntPtr window, ref XTextProperty text_prop);
  71. [DllImport (libX11)]
  72. public extern static int XStoreName(IntPtr display, IntPtr window, string window_name);
  73. [DllImport (libX11)]
  74. public extern static int XFetchName(IntPtr display, IntPtr window, ref IntPtr window_name);
  75. [DllImport (libX11)]
  76. public extern static int XSendEvent(IntPtr display, IntPtr window, bool propagate, IntPtr event_mask, ref XEvent send_event);
  77. [DllImport (libX11)]
  78. public extern static int XQueryTree(IntPtr display, IntPtr window, out IntPtr root_return, out IntPtr parent_return, out IntPtr children_return, out int nchildren_return);
  79. [DllImport (libX11)]
  80. public extern static int XFree(IntPtr data);
  81. [DllImport (libX11)]
  82. public extern static int XRaiseWindow(IntPtr display, IntPtr window);
  83. [DllImport (libX11)]
  84. public extern static uint XLowerWindow(IntPtr display, IntPtr window);
  85. [DllImport (libX11)]
  86. public extern static uint XConfigureWindow(IntPtr display, IntPtr window, ChangeWindowFlags value_mask, ref XWindowChanges values);
  87. [DllImport (libX11)]
  88. public extern static IntPtr XInternAtom(IntPtr display, string atom_name, bool only_if_exists);
  89. [DllImport (libX11)]
  90. public extern static int XInternAtoms(IntPtr display, string[] atom_names, int atom_count, bool only_if_exists, IntPtr[] atoms);
  91. [DllImport (libX11)]
  92. public extern static int XSetWMProtocols(IntPtr display, IntPtr window, IntPtr[] protocols, int count);
  93. [DllImport (libX11)]
  94. public extern static int XGrabPointer(IntPtr display, IntPtr window, bool owner_events, EventMask event_mask, GrabMode pointer_mode, GrabMode keyboard_mode, IntPtr confine_to, IntPtr cursor, IntPtr timestamp);
  95. [DllImport (libX11)]
  96. public extern static int XUngrabPointer(IntPtr display, IntPtr timestamp);
  97. [DllImport (libX11)]
  98. public extern static bool XQueryPointer(IntPtr display, IntPtr window, out IntPtr root, out IntPtr child, out int root_x, out int root_y, out int win_x, out int win_y, out int keys_buttons);
  99. [DllImport (libX11)]
  100. public extern static bool XTranslateCoordinates (IntPtr display, IntPtr src_w, IntPtr dest_w, int src_x, int src_y, out int intdest_x_return, out int dest_y_return, out IntPtr child_return);
  101. [DllImport (libX11)]
  102. public extern static bool XGetGeometry(IntPtr display, IntPtr window, out IntPtr root, out int x, out int y, out int width, out int height, out int border_width, out int depth);
  103. [DllImport (libX11)]
  104. public extern static bool XGetGeometry(IntPtr display, IntPtr window, IntPtr root, out int x, out int y, out int width, out int height, IntPtr border_width, IntPtr depth);
  105. [DllImport (libX11)]
  106. public extern static bool XGetGeometry(IntPtr display, IntPtr window, IntPtr root, out int x, out int y, IntPtr width, IntPtr height, IntPtr border_width, IntPtr depth);
  107. [DllImport (libX11)]
  108. public extern static bool XGetGeometry(IntPtr display, IntPtr window, IntPtr root, IntPtr x, IntPtr y, out int width, out int height, IntPtr border_width, IntPtr depth);
  109. [DllImport (libX11)]
  110. public extern static uint XWarpPointer(IntPtr display, IntPtr src_w, IntPtr dest_w, int src_x, int src_y, uint src_width, uint src_height, int dest_x, int dest_y);
  111. [DllImport (libX11)]
  112. public extern static int XClearWindow(IntPtr display, IntPtr window);
  113. [DllImport (libX11)]
  114. public extern static int XClearArea(IntPtr display, IntPtr window, int x, int y, int width, int height, bool exposures);
  115. // Colormaps
  116. [DllImport (libX11)]
  117. public extern static IntPtr XDefaultScreenOfDisplay(IntPtr display);
  118. [DllImport (libX11)]
  119. public extern static int XScreenNumberOfScreen(IntPtr display, IntPtr Screen);
  120. [DllImport (libX11)]
  121. public extern static IntPtr XDefaultVisual(IntPtr display, int screen_number);
  122. [DllImport (libX11)]
  123. public extern static uint XDefaultDepth(IntPtr display, int screen_number);
  124. [DllImport (libX11)]
  125. public extern static int XDefaultScreen(IntPtr display);
  126. [DllImport (libX11)]
  127. public extern static IntPtr XDefaultColormap(IntPtr display, int screen_number);
  128. [DllImport (libX11)]
  129. public extern static int XLookupColor(IntPtr display, IntPtr Colormap, string Coloranem, ref XColor exact_def_color, ref XColor screen_def_color);
  130. [DllImport (libX11)]
  131. public extern static int XAllocColor(IntPtr display, IntPtr Colormap, ref XColor colorcell_def);
  132. [DllImport (libX11)]
  133. public extern static int XSetTransientForHint(IntPtr display, IntPtr window, IntPtr prop_window);
  134. [DllImport (libX11)]
  135. public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, ref MotifWmHints data, int nelements);
  136. [DllImport (libX11)]
  137. public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, ref uint value, int nelements);
  138. [DllImport (libX11)]
  139. public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, ref IntPtr value, int nelements);
  140. [DllImport (libX11)]
  141. public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, uint[] data, int nelements);
  142. [DllImport (libX11)]
  143. public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, int[] data, int nelements);
  144. [DllImport (libX11)]
  145. public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, IntPtr[] data, int nelements);
  146. [DllImport (libX11)]
  147. public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, IntPtr atoms, int nelements);
  148. [DllImport (libX11, CharSet=CharSet.Ansi)]
  149. public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, string text, int text_length);
  150. [DllImport (libX11)]
  151. public extern static int XDeleteProperty(IntPtr display, IntPtr window, IntPtr property);
  152. // Drawing
  153. [DllImport (libX11)]
  154. public extern static IntPtr XCreateGC(IntPtr display, IntPtr window, IntPtr valuemask, ref XGCValues values);
  155. [DllImport (libX11)]
  156. public extern static int XFreeGC(IntPtr display, IntPtr gc);
  157. [DllImport (libX11)]
  158. public extern static int XSetFunction(IntPtr display, IntPtr gc, GXFunction function);
  159. [DllImport (libX11)]
  160. internal extern static int XSetLineAttributes(IntPtr display, IntPtr gc, int line_width, GCLineStyle line_style, GCCapStyle cap_style, GCJoinStyle join_style);
  161. [DllImport (libX11)]
  162. public extern static int XDrawLine(IntPtr display, IntPtr drawable, IntPtr gc, int x1, int y1, int x2, int y2);
  163. [DllImport (libX11)]
  164. public extern static int XDrawRectangle(IntPtr display, IntPtr drawable, IntPtr gc, int x1, int y1, int width, int height);
  165. [DllImport (libX11)]
  166. public extern static int XFillRectangle(IntPtr display, IntPtr drawable, IntPtr gc, int x1, int y1, int width, int height);
  167. [DllImport (libX11)]
  168. public extern static int XSetWindowBackground(IntPtr display, IntPtr window, IntPtr background);
  169. [DllImport (libX11)]
  170. public extern static int XCopyArea(IntPtr display, IntPtr src, IntPtr dest, IntPtr gc, int src_x, int src_y, int width, int height, int dest_x, int dest_y);
  171. [DllImport (libX11)]
  172. public extern static int XGetWindowProperty(IntPtr display, IntPtr window, IntPtr atom, IntPtr long_offset, IntPtr long_length, bool delete, IntPtr req_type, out IntPtr actual_type, out int actual_format, out IntPtr nitems, out IntPtr bytes_after, ref IntPtr prop);
  173. [DllImport (libX11)]
  174. public extern static int XSetInputFocus(IntPtr display, IntPtr window, RevertTo revert_to, IntPtr time);
  175. [DllImport (libX11)]
  176. public extern static int XIconifyWindow(IntPtr display, IntPtr window, int screen_number);
  177. [DllImport (libX11)]
  178. public extern static int XDefineCursor(IntPtr display, IntPtr window, IntPtr cursor);
  179. [DllImport (libX11)]
  180. public extern static int XUndefineCursor(IntPtr display, IntPtr window);
  181. [DllImport (libX11)]
  182. public extern static int XFreeCursor(IntPtr display, IntPtr cursor);
  183. [DllImport (libX11)]
  184. public extern static IntPtr XCreateFontCursor(IntPtr display, CursorFontShape shape);
  185. [DllImport (libX11)]
  186. public extern static IntPtr XCreatePixmapCursor(IntPtr display, IntPtr source, IntPtr mask, ref XColor foreground_color, ref XColor background_color, int x_hot, int y_hot);
  187. [DllImport (libX11)]
  188. public extern static IntPtr XCreatePixmapFromBitmapData(IntPtr display, IntPtr drawable, byte[] data, int width, int height, IntPtr fg, IntPtr bg, int depth);
  189. [DllImport (libX11)]
  190. public extern static IntPtr XCreatePixmap(IntPtr display, IntPtr d, int width, int height, int depth);
  191. [DllImport (libX11)]
  192. public extern static IntPtr XFreePixmap(IntPtr display, IntPtr pixmap);
  193. [DllImport (libX11)]
  194. public extern static int XQueryBestCursor(IntPtr display, IntPtr drawable, int width, int height, out int best_width, out int best_height);
  195. [DllImport (libX11)]
  196. public extern static IntPtr XWhitePixel(IntPtr display, int screen_no);
  197. [DllImport (libX11)]
  198. public extern static IntPtr XBlackPixel(IntPtr display, int screen_no);
  199. [DllImport (libX11)]
  200. public extern static void XGrabServer(IntPtr display);
  201. [DllImport (libX11)]
  202. public extern static void XUngrabServer(IntPtr display);
  203. [DllImport (libX11)]
  204. public extern static void XGetWMNormalHints(IntPtr display, IntPtr window, ref XSizeHints hints, out IntPtr supplied_return);
  205. [DllImport (libX11)]
  206. public extern static void XSetWMNormalHints(IntPtr display, IntPtr window, ref XSizeHints hints);
  207. [DllImport (libX11)]
  208. public extern static void XSetZoomHints(IntPtr display, IntPtr window, ref XSizeHints hints);
  209. [DllImport (libX11)]
  210. public extern static void XSetWMHints(IntPtr display, IntPtr window, ref XWMHints wmhints);
  211. [DllImport (libX11)]
  212. public extern static int XGetIconSizes(IntPtr display, IntPtr window, out IntPtr size_list, out int count);
  213. [DllImport (libX11)]
  214. public extern static IntPtr XSetErrorHandler(XErrorHandler error_handler);
  215. [DllImport (libX11)]
  216. public extern static IntPtr XGetErrorText(IntPtr display, byte code, StringBuilder buffer, int length);
  217. [DllImport (libX11)]
  218. public extern static int XInitThreads();
  219. [DllImport (libX11)]
  220. public extern static int XConvertSelection(IntPtr display, IntPtr selection, IntPtr target, IntPtr property, IntPtr requestor, IntPtr time);
  221. [DllImport (libX11)]
  222. public extern static IntPtr XGetSelectionOwner(IntPtr display, IntPtr selection);
  223. [DllImport (libX11)]
  224. public extern static int XSetSelectionOwner(IntPtr display, IntPtr selection, IntPtr owner, IntPtr time);
  225. [DllImport (libX11)]
  226. public extern static int XSetPlaneMask(IntPtr display, IntPtr gc, IntPtr mask);
  227. [DllImport (libX11)]
  228. public extern static int XSetForeground(IntPtr display, IntPtr gc, UIntPtr foreground);
  229. [DllImport (libX11)]
  230. public extern static int XSetBackground(IntPtr display, IntPtr gc, UIntPtr background);
  231. [DllImport (libX11)]
  232. public extern static int XBell(IntPtr display, int percent);
  233. [DllImport (libX11)]
  234. public extern static int XChangeActivePointerGrab (IntPtr display, EventMask event_mask, IntPtr cursor, IntPtr time);
  235. [DllImport (libX11)]
  236. public extern static bool XFilterEvent(ref XEvent xevent, IntPtr window);
  237. [DllImport (libX11)]
  238. public extern static void XkbSetDetectableAutoRepeat (IntPtr display, bool detectable, IntPtr supported);
  239. [DllImport (libX11)]
  240. public extern static void XPeekEvent (IntPtr display, ref XEvent xevent);
  241. }
  242. }