Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / System.Windows.Forms.X11Internal / Xlib.cs
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
24 using System;
25 using System.Text;
26 using System.Runtime.InteropServices;
27
28 namespace System.Windows.Forms.X11Internal {
29
30         internal class Xlib {
31                 const string libX11 = "X11";
32
33                 [DllImport (libX11)]
34                 public extern static IntPtr XOpenDisplay(IntPtr display);
35
36                 [DllImport (libX11)]
37                 public extern static int XCloseDisplay(IntPtr display);
38
39                 [DllImport (libX11)]
40                 public extern static IntPtr XSynchronize(IntPtr display, bool onoff);
41
42                 [DllImport (libX11)]
43                 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);
44
45                 [DllImport (libX11)]
46                 public extern static IntPtr XCreateSimpleWindow(IntPtr display, IntPtr parent, int x, int y, int width, int height, int border_width, UIntPtr border, UIntPtr background);
47
48                 [DllImport (libX11)]
49                 public extern static int XMapWindow(IntPtr display, IntPtr window);
50
51                 [DllImport (libX11)]
52                 public extern static int XUnmapWindow(IntPtr display, IntPtr window);
53
54                 [DllImport (libX11)]
55                 public extern static int XMapSubindows(IntPtr display, IntPtr window);
56
57                 [DllImport (libX11)]
58                 public extern static int XUnmapSubwindows(IntPtr display, IntPtr window);
59
60                 [DllImport (libX11)]
61                 public extern static IntPtr XRootWindow(IntPtr display, int screen_number);
62
63                 [DllImport (libX11)]
64                 public extern static IntPtr XNextEvent(IntPtr display, ref XEvent xevent);
65
66                 [DllImport (libX11)]
67                 public extern static int XConnectionNumber (IntPtr diplay);
68
69                 [DllImport (libX11)]
70                 public extern static int XPending (IntPtr diplay);
71
72                 [DllImport (libX11)]
73                 public extern static IntPtr XSelectInput(IntPtr display, IntPtr window, IntPtr mask);
74
75                 [DllImport (libX11)]
76                 public extern static int XDestroyWindow(IntPtr display, IntPtr window);
77
78                 [DllImport (libX11)]
79                 public extern static int XReparentWindow(IntPtr display, IntPtr window, IntPtr parent, int x, int y);
80
81                 [DllImport (libX11)]
82                 public extern static int XMoveResizeWindow(IntPtr display, IntPtr window, int x, int y, int width, int height);
83
84                 [DllImport (libX11)]
85                 public extern static int XResizeWindow(IntPtr display, IntPtr window, int width, int height);
86
87                 [DllImport (libX11)]
88                 public extern static int XGetWindowAttributes(IntPtr display, IntPtr window, ref XWindowAttributes attributes);
89
90                 [DllImport (libX11)]
91                 public extern static int XFlush(IntPtr display);
92
93                 [DllImport (libX11)]
94                 public extern static int XSetWMName(IntPtr display, IntPtr window, ref XTextProperty text_prop);
95
96                 [DllImport (libX11)]
97                 public extern static int XStoreName(IntPtr display, IntPtr window, string window_name);
98
99                 [DllImport (libX11)]
100                 public extern static int XFetchName(IntPtr display, IntPtr window, ref IntPtr window_name);
101
102                 [DllImport (libX11)]
103                 public extern static int XSendEvent(IntPtr display, IntPtr window, bool propagate, IntPtr event_mask, ref XEvent send_event);
104
105                 [DllImport (libX11)]
106                 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);
107
108                 [DllImport (libX11)]
109                 public extern static int XFree(IntPtr data);
110
111                 [DllImport (libX11)]
112                 public extern static int XRaiseWindow(IntPtr display, IntPtr window);
113
114                 [DllImport (libX11)]
115                 public extern static uint XLowerWindow(IntPtr display, IntPtr window);
116
117                 [DllImport (libX11)]
118                 public extern static uint XConfigureWindow(IntPtr display, IntPtr window, ChangeWindowFlags value_mask, ref XWindowChanges values);
119
120                 [DllImport (libX11)]
121                 public extern static IntPtr XInternAtom(IntPtr display, string atom_name, bool only_if_exists);
122
123                 [DllImport (libX11)]
124                 public extern static int XInternAtoms(IntPtr display, string[] atom_names, int atom_count, bool only_if_exists, IntPtr[] atoms);
125
126                 [DllImport (libX11)]
127                 public extern static int XSetWMProtocols(IntPtr display, IntPtr window, IntPtr[] protocols, int count);
128
129                 [DllImport (libX11)]
130                 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);
131
132                 [DllImport (libX11)]
133                 public extern static int XUngrabPointer(IntPtr display, IntPtr timestamp);
134
135                 [DllImport (libX11)]
136                 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);
137
138                 [DllImport (libX11)]
139                 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);
140
141                 [DllImport (libX11)]
142                 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);
143
144                 [DllImport (libX11)]
145                 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);
146
147                 [DllImport (libX11)]
148                 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);
149
150                 [DllImport (libX11)]
151                 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);
152
153                 [DllImport (libX11)]
154                 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);
155
156                 [DllImport (libX11)]
157                 public extern static int XClearWindow(IntPtr display, IntPtr window);
158
159                 [DllImport (libX11)]
160                 public extern static int XClearArea(IntPtr display, IntPtr window, int x, int y, int width, int height, bool exposures);
161
162                 // Colormaps
163                 [DllImport (libX11)]
164                 public extern static IntPtr XDefaultScreenOfDisplay(IntPtr display);
165
166                 [DllImport (libX11)]
167                 public extern static int XScreenNumberOfScreen(IntPtr display, IntPtr Screen);
168
169                 [DllImport (libX11)]
170                 public extern static IntPtr XDefaultVisual(IntPtr display, int screen_number);
171
172                 [DllImport (libX11)]
173                 public extern static uint XDefaultDepth(IntPtr display, int screen_number);
174
175                 [DllImport (libX11)]
176                 public extern static int XDefaultScreen(IntPtr display);
177
178                 [DllImport (libX11)]
179                 public extern static IntPtr XDefaultColormap(IntPtr display, int screen_number);
180
181                 [DllImport (libX11)]
182                 public extern static int XLookupColor(IntPtr display, IntPtr Colormap, string Coloranem, ref XColor exact_def_color, ref XColor screen_def_color);
183
184                 [DllImport (libX11)]
185                 public extern static int XAllocColor(IntPtr display, IntPtr Colormap, ref XColor colorcell_def);
186
187                 [DllImport (libX11)]
188                 public extern static int XSetTransientForHint(IntPtr display, IntPtr window, IntPtr prop_window);
189
190                 [DllImport (libX11)]
191                 public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, ref MotifWmHints data, int nelements);
192
193                 [DllImport (libX11)]
194                 public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, ref uint value, int nelements);
195
196                 [DllImport (libX11)]
197                 public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, ref IntPtr value, int nelements);
198
199                 [DllImport (libX11)]
200                 public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, uint[] data, int nelements);
201
202                 [DllImport (libX11)]
203                 public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, int[] data, int nelements);
204
205                 [DllImport (libX11)]
206                 public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, IntPtr[] data, int nelements);
207
208                 [DllImport (libX11)]
209                 public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, IntPtr atoms, int nelements);
210
211                 [DllImport (libX11, CharSet=CharSet.Ansi)]
212                 public extern static int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, PropertyMode mode, string text, int text_length);
213
214                 [DllImport (libX11)]
215                 public extern static int XDeleteProperty(IntPtr display, IntPtr window, IntPtr property);
216
217                 // Drawing
218                 [DllImport (libX11)]
219                 public extern static IntPtr XCreateGC(IntPtr display, IntPtr window, IntPtr valuemask, ref XGCValues values);
220
221                 [DllImport (libX11)]
222                 public extern static int XFreeGC(IntPtr display, IntPtr gc);
223
224                 [DllImport (libX11)]
225                 public extern static int XSetFunction(IntPtr display, IntPtr gc, GXFunction function);
226
227                 [DllImport (libX11)]
228                 internal extern static int XSetLineAttributes(IntPtr display, IntPtr gc, int line_width, GCLineStyle line_style, GCCapStyle cap_style, GCJoinStyle join_style);
229
230                 [DllImport (libX11)]
231                 public extern static int XDrawLine(IntPtr display, IntPtr drawable, IntPtr gc, int x1, int y1, int x2, int y2);
232
233                 [DllImport (libX11)]
234                 public extern static int XDrawRectangle(IntPtr display, IntPtr drawable, IntPtr gc, int x1, int y1, int width, int height);
235
236                 [DllImport (libX11)]
237                 public extern static int XFillRectangle(IntPtr display, IntPtr drawable, IntPtr gc, int x1, int y1, int width, int height);
238
239                 [DllImport (libX11)]
240                 public extern static int XSetWindowBackground(IntPtr display, IntPtr window, IntPtr background);
241
242                 [DllImport (libX11)]
243                 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);
244
245                 [DllImport (libX11)]
246                 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);
247
248                 [DllImport (libX11)]
249                 public extern static int XSetInputFocus(IntPtr display, IntPtr window, RevertTo revert_to, IntPtr time);
250
251                 [DllImport (libX11)]
252                 public extern static int XIconifyWindow(IntPtr display, IntPtr window, int screen_number);
253
254                 [DllImport (libX11)]
255                 public extern static int XDefineCursor(IntPtr display, IntPtr window, IntPtr cursor);
256
257                 [DllImport (libX11)]
258                 public extern static int XUndefineCursor(IntPtr display, IntPtr window);
259
260                 [DllImport (libX11)]
261                 public extern static int XFreeCursor(IntPtr display, IntPtr cursor);
262
263                 [DllImport (libX11)]
264                 public extern static IntPtr XCreateFontCursor(IntPtr display, CursorFontShape shape);
265
266                 [DllImport (libX11)]
267                 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);
268
269                 [DllImport (libX11)]
270                 public extern static IntPtr XCreatePixmapFromBitmapData(IntPtr display, IntPtr drawable, byte[] data, int width, int height, IntPtr fg, IntPtr bg, int depth);
271
272                 [DllImport (libX11)]
273                 public extern static IntPtr XCreatePixmap(IntPtr display, IntPtr d, int width, int height, int depth);
274
275                 [DllImport (libX11)]
276                 public extern static IntPtr XFreePixmap(IntPtr display, IntPtr pixmap);
277
278                 [DllImport (libX11)]
279                 public extern static int XQueryBestCursor(IntPtr display, IntPtr drawable, int width, int height, out int best_width, out int best_height);
280
281                 [DllImport (libX11)]
282                 public extern static IntPtr XWhitePixel(IntPtr display, int screen_no);
283
284                 [DllImport (libX11)]
285                 public extern static IntPtr XBlackPixel(IntPtr display, int screen_no);
286
287                 [DllImport (libX11)]
288                 public extern static void XGrabServer(IntPtr display);
289
290                 [DllImport (libX11)]
291                 public extern static void XUngrabServer(IntPtr display);
292
293                 [DllImport (libX11)]
294                 public extern static void XGetWMNormalHints(IntPtr display, IntPtr window, ref XSizeHints hints, out IntPtr supplied_return);
295
296                 [DllImport (libX11)]
297                 public extern static void XSetWMNormalHints(IntPtr display, IntPtr window, ref XSizeHints hints);
298
299                 [DllImport (libX11)]
300                 public extern static void XSetZoomHints(IntPtr display, IntPtr window, ref XSizeHints hints);
301
302                 [DllImport (libX11)]
303                 public extern static void XSetWMHints(IntPtr display, IntPtr window, ref XWMHints wmhints);
304
305                 [DllImport (libX11)]
306                 public extern static int XGetIconSizes(IntPtr display, IntPtr window, out IntPtr size_list, out int count);
307
308                 [DllImport (libX11)]
309                 public extern static IntPtr XSetErrorHandler(XErrorHandler error_handler);
310
311                 [DllImport (libX11)]
312                 public extern static IntPtr XGetErrorText(IntPtr display, byte code, StringBuilder buffer, int length);
313
314                 [DllImport (libX11)]
315                 public extern static int XInitThreads();
316
317                 [DllImport (libX11)]
318                 public extern static int XConvertSelection(IntPtr display, IntPtr selection, IntPtr target, IntPtr property, IntPtr requestor, IntPtr time);
319
320                 [DllImport (libX11)]
321                 public extern static IntPtr XGetSelectionOwner(IntPtr display, IntPtr selection);
322
323                 [DllImport (libX11)]
324                 public extern static int XSetSelectionOwner(IntPtr display, IntPtr selection, IntPtr owner, IntPtr time);
325
326                 [DllImport (libX11)]
327                 public extern static int XSetPlaneMask(IntPtr display, IntPtr gc, IntPtr mask);
328
329                 [DllImport (libX11)]
330                 public extern static int XSetForeground(IntPtr display, IntPtr gc, UIntPtr foreground);
331
332                 [DllImport (libX11)]
333                 public extern static int XSetBackground(IntPtr display, IntPtr gc, UIntPtr background);
334
335                 [DllImport (libX11)]
336                 public extern static int XBell(IntPtr display, int percent);
337
338                 [DllImport (libX11)]
339                 public extern static int XChangeActivePointerGrab (IntPtr display, EventMask event_mask, IntPtr cursor, IntPtr time);
340
341                 [DllImport (libX11)]
342                 public extern static bool XFilterEvent(ref XEvent xevent, IntPtr window);
343
344                 [DllImport (libX11)]
345                 public extern static void XkbSetDetectableAutoRepeat (IntPtr display, bool detectable, IntPtr supported);
346
347                 [DllImport (libX11)]
348                 public extern static void XPeekEvent (IntPtr display, ref XEvent xevent);
349         }
350 }