Convert DOS (MZ) binary loader to the new DOS process model.
[wine/testsucceed.git] / include / x11drv.h
blobc15c356559a3f2f1d190cb846227527fe1c83e98
1 /*
2 * X11 driver definitions
3 */
5 #ifndef __WINE_X11DRV_H
6 #define __WINE_X11DRV_H
8 #include "config.h"
10 #include <X11/Xlib.h>
11 #include <X11/Xresource.h>
12 #include <X11/Xutil.h>
13 #include <X11/Xatom.h>
14 #ifdef HAVE_LIBXXSHM
15 # include <X11/extensions/XShm.h>
16 #endif /* defined(HAVE_LIBXXSHM) */
18 #include "windef.h"
19 #include "winbase.h"
20 #include "gdi.h"
21 #include "user.h"
23 #define MAX_PIXELFORMATS 8
25 struct tagBITMAPOBJ;
26 struct tagCLASS;
27 struct tagCREATESTRUCTA;
28 struct tagCURSORICONINFO;
29 struct tagDC;
30 struct tagDeviceCaps;
31 struct tagPALETTEOBJ;
32 struct tagWND;
33 struct tagWINDOWPOS;
34 struct tagKEYBOARD_CONFIG;
35 struct DIDEVICEOBJECTDATA;
37 /* X physical pen */
38 typedef struct
40 int style;
41 int endcap;
42 int linejoin;
43 int pixel;
44 int width;
45 char * dashes;
46 int dash_len;
47 int type; /* GEOMETRIC || COSMETIC */
48 } X_PHYSPEN;
50 /* X physical brush */
51 typedef struct
53 int style;
54 int fillStyle;
55 int pixel;
56 Pixmap pixmap;
57 } X_PHYSBRUSH;
59 /* X physical font */
60 typedef UINT X_PHYSFONT;
62 /* X physical device */
63 typedef struct
65 GC gc; /* X Window GC */
66 Drawable drawable;
67 X_PHYSFONT font;
68 X_PHYSPEN pen;
69 X_PHYSBRUSH brush;
70 int backgroundPixel;
71 int textPixel;
72 XVisualInfo *visuals[MAX_PIXELFORMATS];
73 int used_visuals;
74 int current_pf;
75 } X11DRV_PDEVICE;
78 /* GCs used for B&W and color bitmap operations */
79 extern GC BITMAP_monoGC, BITMAP_colorGC;
81 #define BITMAP_GC(bmp) \
82 (((bmp)->bitmap.bmBitsPixel == 1) ? BITMAP_monoGC : BITMAP_colorGC)
84 extern DeviceCaps X11DRV_DevCaps;
86 /* Wine driver X11 functions */
88 extern const DC_FUNCTIONS X11DRV_DC_Funcs;
90 extern BOOL X11DRV_BitBlt( struct tagDC *dcDst, INT xDst, INT yDst,
91 INT width, INT height, struct tagDC *dcSrc,
92 INT xSrc, INT ySrc, DWORD rop );
93 extern BOOL X11DRV_EnumDeviceFonts( struct tagDC *dc, LPLOGFONT16 plf,
94 DEVICEFONTENUMPROC dfeproc, LPARAM lp );
95 extern BOOL X11DRV_GetCharWidth( struct tagDC *dc, UINT firstChar,
96 UINT lastChar, LPINT buffer );
97 extern BOOL X11DRV_GetDCOrgEx( struct tagDC *dc, LPPOINT lpp );
98 extern BOOL X11DRV_GetTextExtentPoint( struct tagDC *dc, LPCWSTR str,
99 INT count, LPSIZE size );
100 extern BOOL X11DRV_GetTextMetrics(struct tagDC *dc, TEXTMETRICA *metrics);
101 extern BOOL X11DRV_PatBlt( struct tagDC *dc, INT left, INT top,
102 INT width, INT height, DWORD rop );
103 extern VOID X11DRV_SetDeviceClipping(struct tagDC *dc);
104 extern BOOL X11DRV_StretchBlt( struct tagDC *dcDst, INT xDst, INT yDst,
105 INT widthDst, INT heightDst,
106 struct tagDC *dcSrc, INT xSrc, INT ySrc,
107 INT widthSrc, INT heightSrc, DWORD rop );
108 extern BOOL X11DRV_LineTo( struct tagDC *dc, INT x, INT y);
109 extern BOOL X11DRV_Arc( struct tagDC *dc, INT left, INT top, INT right,
110 INT bottom, INT xstart, INT ystart, INT xend,
111 INT yend );
112 extern BOOL X11DRV_Pie( struct tagDC *dc, INT left, INT top, INT right,
113 INT bottom, INT xstart, INT ystart, INT xend,
114 INT yend );
115 extern BOOL X11DRV_Chord( struct tagDC *dc, INT left, INT top,
116 INT right, INT bottom, INT xstart,
117 INT ystart, INT xend, INT yend );
118 extern BOOL X11DRV_Ellipse( struct tagDC *dc, INT left, INT top,
119 INT right, INT bottom );
120 extern BOOL X11DRV_Rectangle(struct tagDC *dc, INT left, INT top,
121 INT right, INT bottom);
122 extern BOOL X11DRV_RoundRect( struct tagDC *dc, INT left, INT top,
123 INT right, INT bottom, INT ell_width,
124 INT ell_height );
125 extern COLORREF X11DRV_SetPixel( struct tagDC *dc, INT x, INT y,
126 COLORREF color );
127 extern COLORREF X11DRV_GetPixel( struct tagDC *dc, INT x, INT y);
128 extern BOOL X11DRV_PaintRgn( struct tagDC *dc, HRGN hrgn );
129 extern BOOL X11DRV_Polyline( struct tagDC *dc,const POINT* pt,INT count);
130 extern BOOL X11DRV_Polygon( struct tagDC *dc, const POINT* pt, INT count );
131 extern BOOL X11DRV_PolyPolygon( struct tagDC *dc, const POINT* pt,
132 const INT* counts, UINT polygons);
133 extern BOOL X11DRV_PolyPolyline( struct tagDC *dc, const POINT* pt,
134 const DWORD* counts, DWORD polylines);
136 extern HGDIOBJ X11DRV_SelectObject( struct tagDC *dc, HGDIOBJ handle );
138 extern COLORREF X11DRV_SetBkColor( struct tagDC *dc, COLORREF color );
139 extern COLORREF X11DRV_SetTextColor( struct tagDC *dc, COLORREF color );
140 extern BOOL X11DRV_ExtFloodFill( struct tagDC *dc, INT x, INT y,
141 COLORREF color, UINT fillType );
142 extern BOOL X11DRV_ExtTextOut( struct tagDC *dc, INT x, INT y,
143 UINT flags, const RECT *lprect,
144 LPCWSTR str, UINT count, const INT *lpDx );
145 extern BOOL X11DRV_CreateBitmap( HBITMAP hbitmap );
146 extern BOOL X11DRV_DeleteObject( HGDIOBJ handle );
147 extern LONG X11DRV_BitmapBits( HBITMAP hbitmap, void *bits, LONG count,
148 WORD flags );
149 extern INT X11DRV_SetDIBitsToDevice( struct tagDC *dc, INT xDest,
150 INT yDest, DWORD cx, DWORD cy,
151 INT xSrc, INT ySrc,
152 UINT startscan, UINT lines,
153 LPCVOID bits, const BITMAPINFO *info,
154 UINT coloruse );
155 extern INT X11DRV_DeviceBitmapBits( struct tagDC *dc, HBITMAP hbitmap,
156 WORD fGet, UINT startscan,
157 UINT lines, LPSTR bits,
158 LPBITMAPINFO info, UINT coloruse );
159 extern HANDLE X11DRV_LoadOEMResource( WORD id, WORD type );
161 /* OpenGL / X11 driver functions */
162 extern int X11DRV_ChoosePixelFormat(DC *dc, const PIXELFORMATDESCRIPTOR *pppfd) ;
163 extern int X11DRV_DescribePixelFormat(DC *dc, int iPixelFormat, UINT nBytes, PIXELFORMATDESCRIPTOR *ppfd) ;
164 extern int X11DRV_GetPixelFormat(DC *dc) ;
165 extern BOOL X11DRV_SetPixelFormat(DC *dc, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd) ;
166 extern BOOL X11DRV_SwapBuffers(DC *dc) ;
168 /* X11 driver internal functions */
170 extern BOOL X11DRV_BITMAP_Init(void);
171 extern BOOL X11DRV_BRUSH_Init(void);
172 extern BOOL X11DRV_DIB_Init(void);
173 extern BOOL X11DRV_FONT_Init( struct tagDeviceCaps* );
174 extern BOOL X11DRV_OBM_Init(void);
176 struct tagBITMAPOBJ;
177 extern XImage *X11DRV_BITMAP_GetXImage( const struct tagBITMAPOBJ *bmp );
178 extern int X11DRV_DIB_GetXImageWidthBytes( int width, int depth );
179 extern HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap);
180 extern HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixmap);
181 extern HBITMAP X11DRV_BITMAP_CreateBitmapFromPixmap(Pixmap pixmap, BOOL bDeletePixmap);
182 extern Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc );
183 extern Pixmap X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp, HDC hdc );
185 extern BOOL X11DRV_SetupGCForPatBlt( struct tagDC *dc, GC gc,
186 BOOL fMapColors );
187 extern BOOL X11DRV_SetupGCForBrush( struct tagDC *dc );
188 extern BOOL X11DRV_SetupGCForPen( struct tagDC *dc );
189 extern BOOL X11DRV_SetupGCForText( struct tagDC *dc );
191 extern const int X11DRV_XROPfunction[];
193 /* Xlib critical section */
195 extern CRITICAL_SECTION X11DRV_CritSection;
197 extern void _XInitImageFuncPtrs(XImage *);
199 #define XCREATEIMAGE(image,width,height,bpp) \
201 int width_bytes = X11DRV_DIB_GetXImageWidthBytes( (width), (bpp) ); \
202 (image) = TSXCreateImage(display, X11DRV_GetVisual(), \
203 (bpp), ZPixmap, 0, calloc( (height), width_bytes ),\
204 (width), (height), 32, width_bytes ); \
207 /* exported dib functions for now */
209 /* Additional info for DIB section objects */
210 typedef struct
212 /* Windows DIB section */
213 DIBSECTION dibSection;
215 /* Mapping status */
216 enum { X11DRV_DIB_NoHandler, X11DRV_DIB_InSync, X11DRV_DIB_AppMod, X11DRV_DIB_GdiMod } status;
218 /* Color map info */
219 int nColorMap;
220 int *colorMap;
222 /* Cached XImage */
223 XImage *image;
225 /* Selector for 16-bit access to bits */
226 WORD selector;
228 /* Shared memory segment info */
229 XShmSegmentInfo shminfo;
231 } X11DRV_DIBSECTION;
233 /* This structure holds the arguments for DIB_SetImageBits() */
234 typedef struct
236 struct tagDC *dc;
237 LPCVOID bits;
238 XImage *image;
239 PALETTEENTRY *palentry;
240 int lines;
241 DWORD infoWidth;
242 WORD depth;
243 WORD infoBpp;
244 WORD compression;
245 RGBQUAD *colorMap;
246 int nColorMap;
247 Drawable drawable;
248 GC gc;
249 int xSrc;
250 int ySrc;
251 int xDest;
252 int yDest;
253 int width;
254 int height;
255 DWORD rMask;
256 DWORD gMask;
257 DWORD bMask;
258 BOOL useShm;
260 } X11DRV_DIB_IMAGEBITS_DESCR;
262 extern int *X11DRV_DIB_BuildColorMap( struct tagDC *dc, WORD coloruse,
263 WORD depth, const BITMAPINFO *info,
264 int *nColors );
265 extern void X11DRV_DIB_UpdateDIBSection(struct tagDC *dc, BOOL toDIB);
266 extern void X11DRV_DIB_UpdateDIBSection2(HBITMAP hbmp, BOOL toDIB);
268 extern HBITMAP X11DRV_DIB_CreateDIBSection(struct tagDC *dc, BITMAPINFO *bmi, UINT usage,
269 LPVOID *bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
270 extern HBITMAP16 X11DRV_DIB_CreateDIBSection16(struct tagDC *dc, BITMAPINFO *bmi, UINT16 usage,
271 SEGPTR *bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
273 extern struct tagBITMAP_DRIVER X11DRV_BITMAP_Driver;
275 extern INT X11DRV_DIB_SetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT startscan,
276 UINT lines, LPCVOID bits, const BITMAPINFO *info,
277 UINT coloruse, HBITMAP hbitmap);
278 extern INT X11DRV_DIB_GetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT startscan,
279 UINT lines, LPVOID bits, BITMAPINFO *info,
280 UINT coloruse, HBITMAP hbitmap);
281 extern void X11DRV_DIB_DeleteDIBSection(struct tagBITMAPOBJ *bmp);
283 /**************************************************************************
284 * X11 GDI driver
287 BOOL X11DRV_GDI_Initialize(void);
288 void X11DRV_GDI_Finalize(void);
290 /* X11 GDI palette driver */
292 #define X11DRV_PALETTE_FIXED 0x0001 /* read-only colormap - have to use XAllocColor (if not virtual)*/
293 #define X11DRV_PALETTE_VIRTUAL 0x0002 /* no mapping needed - pixel == pixel color */
295 #define X11DRV_PALETTE_PRIVATE 0x1000 /* private colormap, identity mapping */
296 #define X11DRV_PALETTE_WHITESET 0x2000
298 extern Colormap X11DRV_PALETTE_PaletteXColormap;
299 extern UINT16 X11DRV_PALETTE_PaletteFlags;
301 extern int *X11DRV_PALETTE_PaletteToXPixel;
302 extern int *X11DRV_PALETTE_XPixelToPalette;
304 extern int X11DRV_PALETTE_mapEGAPixel[16];
306 extern BOOL X11DRV_PALETTE_Init(void);
307 extern void X11DRV_PALETTE_Cleanup(void);
309 extern COLORREF X11DRV_PALETTE_ToLogical(int pixel);
310 extern int X11DRV_PALETTE_ToPhysical(struct tagDC *dc, COLORREF color);
312 extern struct tagPALETTE_DRIVER X11DRV_PALETTE_Driver;
314 extern int X11DRV_PALETTE_SetMapping(struct tagPALETTEOBJ *palPtr, UINT uStart, UINT uNum, BOOL mapOnly);
315 extern int X11DRV_PALETTE_UpdateMapping(struct tagPALETTEOBJ *palPtr);
316 extern BOOL X11DRV_PALETTE_IsDark(int pixel);
318 /**************************************************************************
319 * X11 USER driver
322 extern Display *display;
323 extern Screen *screen;
324 extern Visual *visual;
325 extern Window root_window;
326 extern int screen_depth;
328 static inline Screen *X11DRV_GetXScreen(void) { return screen; }
329 static inline Visual *X11DRV_GetVisual(void) { return visual; }
330 static inline Window X11DRV_GetXRootWindow(void) { return root_window; }
331 static inline int X11DRV_GetDepth(void) { return screen_depth; }
333 extern BOOL X11DRV_GetScreenSaveActive(void);
334 extern void X11DRV_SetScreenSaveActive(BOOL bActivate);
335 extern int X11DRV_GetScreenSaveTimeout(void);
336 extern void X11DRV_SetScreenSaveTimeout(int nTimeout);
337 extern BOOL X11DRV_IsSingleWindow(void);
339 /* X11 clipboard driver */
341 extern struct tagCLIPBOARD_DRIVER X11DRV_CLIPBOARD_Driver;
343 extern void X11DRV_CLIPBOARD_FreeResources( Atom property );
344 extern BOOL X11DRV_CLIPBOARD_RegisterPixmapResource( Atom property, Pixmap pixmap );
346 extern void X11DRV_CLIPBOARD_Acquire(void);
347 extern void X11DRV_CLIPBOARD_Release(void);
348 extern void X11DRV_CLIPBOARD_SetData(UINT wFormat);
349 extern BOOL X11DRV_CLIPBOARD_GetData(UINT wFormat);
350 extern BOOL X11DRV_CLIPBOARD_IsFormatAvailable(UINT wFormat);
351 extern BOOL X11DRV_CLIPBOARD_IsNativeProperty(Atom prop);
352 extern BOOL X11DRV_CLIPBOARD_RegisterFormat( LPCSTR FormatName );
353 extern BOOL X11DRV_CLIPBOARD_IsSelectionowner();
354 extern UINT X11DRV_CLIPBOARD_MapPropertyToFormat(char *itemFmtName);
355 extern Atom X11DRV_CLIPBOARD_MapFormatToProperty(UINT id);
356 extern void X11DRV_CLIPBOARD_ResetOwner(struct tagWND *pWnd, BOOL bFooBar);
357 extern void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd);
359 /* X11 event driver */
361 extern WORD X11DRV_EVENT_XStateToKeyState( int state ) ;
363 extern BOOL X11DRV_EVENT_Init(void);
364 extern void X11DRV_EVENT_Synchronize( void );
365 extern BOOL X11DRV_EVENT_CheckFocus( void );
366 extern void X11DRV_EVENT_UserRepaintDisable( BOOL bDisable );
368 typedef enum {
369 X11DRV_INPUT_RELATIVE,
370 X11DRV_INPUT_ABSOLUTE
371 } INPUT_TYPE;
372 extern INPUT_TYPE X11DRV_EVENT_SetInputMethod(INPUT_TYPE type);
374 #ifdef HAVE_LIBXXF86DGA2
375 void X11DRV_EVENT_SetDGAStatus(HWND hwnd, int event_base) ;
376 #endif
379 /* X11 keyboard driver */
381 extern void X11DRV_KEYBOARD_Init(void);
382 extern WORD X11DRV_KEYBOARD_VkKeyScan(CHAR cChar);
383 extern UINT16 X11DRV_KEYBOARD_MapVirtualKey(UINT16 wCode, UINT16 wMapType);
384 extern INT16 X11DRV_KEYBOARD_GetKeyNameText(LONG lParam, LPSTR lpBuffer, INT16 nSize);
385 extern INT16 X11DRV_KEYBOARD_ToAscii(UINT16 virtKey, UINT16 scanCode, LPBYTE lpKeyState, LPVOID lpChar, UINT16 flags);
386 extern BOOL X11DRV_KEYBOARD_GetBeepActive(void);
387 extern void X11DRV_KEYBOARD_SetBeepActive(BOOL bActivate);
388 extern void X11DRV_KEYBOARD_Beep(void);
389 extern BOOL X11DRV_KEYBOARD_GetDIState(DWORD len, LPVOID ptr);
390 extern BOOL X11DRV_KEYBOARD_GetDIData(BYTE *keystate, DWORD dodsize, struct DIDEVICEOBJECTDATA *dod, LPDWORD entries, DWORD flags);
391 extern void X11DRV_KEYBOARD_GetKeyboardConfig(struct tagKEYBOARD_CONFIG *cfg);
392 extern void X11DRV_KEYBOARD_SetKeyboardConfig(struct tagKEYBOARD_CONFIG *cfg, DWORD mask);
394 extern void X11DRV_KEYBOARD_HandleEvent(struct tagWND *pWnd, XKeyEvent *event);
396 /* X11 mouse driver */
398 extern void X11DRV_MOUSE_Init(LPMOUSE_EVENT_PROC);
399 extern void X11DRV_MOUSE_SetCursor(struct tagCURSORICONINFO *lpCursor);
400 extern void X11DRV_MOUSE_MoveCursor(WORD wAbsX, WORD wAbsY);
401 extern void X11DRV_MOUSE_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY,
402 DWORD keyState, DWORD time, HWND hWnd );
404 /* X11 windows driver */
406 extern struct tagWND_DRIVER X11DRV_WND_Driver;
408 typedef struct _X11DRV_WND_DATA {
409 Window window;
410 HBITMAP hWMIconBitmap;
411 HBITMAP hWMIconMask;
412 int bit_gravity;
413 } X11DRV_WND_DATA;
415 extern Window X11DRV_WND_GetXWindow(struct tagWND *wndPtr);
416 extern Window X11DRV_WND_FindXWindow(struct tagWND *wndPtr);
418 extern void X11DRV_WND_Initialize(struct tagWND *wndPtr);
419 extern void X11DRV_WND_Finalize(struct tagWND *wndPtr);
420 extern BOOL X11DRV_WND_CreateDesktopWindow(struct tagWND *wndPtr, struct tagCLASS *classPtr, BOOL bUnicode);
421 extern BOOL X11DRV_WND_CreateWindow(struct tagWND *wndPtr, struct tagCLASS *classPtr, struct tagCREATESTRUCTA *cs, BOOL bUnicode);
422 extern BOOL X11DRV_WND_DestroyWindow(struct tagWND *pWnd);
423 extern struct tagWND *X11DRV_WND_SetParent(struct tagWND *wndPtr, struct tagWND *pWndParent);
424 extern void X11DRV_WND_ForceWindowRaise(struct tagWND *pWnd);
425 extern void X11DRV_WND_SetWindowPos(struct tagWND *wndPtr, const struct tagWINDOWPOS *winpos, BOOL bSMC_SETXPOS);
426 extern void X11DRV_WND_SetText(struct tagWND *wndPtr, LPCWSTR text);
427 extern void X11DRV_WND_SetFocus(struct tagWND *wndPtr);
428 extern void X11DRV_WND_PreSizeMove(struct tagWND *wndPtr);
429 extern void X11DRV_WND_PostSizeMove(struct tagWND *wndPtr);
430 extern void X11DRV_WND_SurfaceCopy(struct tagWND *wndPtr, struct tagDC *dcPtr, INT dx, INT dy, const RECT *clipRect, BOOL bUpdate);
431 extern void X11DRV_WND_SetDrawable(struct tagWND *wndPtr, struct tagDC *dc, WORD flags, BOOL bSetClipOrigin);
432 extern BOOL X11DRV_WND_SetHostAttr(struct tagWND *wndPtr, INT haKey, INT value);
433 extern BOOL X11DRV_WND_IsSelfClipping(struct tagWND *wndPtr);
434 extern void X11DRV_WND_DockWindow(struct tagWND *wndPtr);
435 extern void X11DRV_WND_SetWindowRgn(struct tagWND *wndPtr, HRGN hrgnWnd);
437 extern int X11DRV_EVENT_PrepareShmCompletion( Drawable dw );
438 extern void X11DRV_EVENT_WaitShmCompletion( int compl );
439 extern void X11DRV_EVENT_WaitShmCompletions( Drawable dw );
440 extern void X11DRV_EVENT_WaitReplaceShmCompletion( int *compl, Drawable dw );
442 #endif /* __WINE_X11DRV_H */