Build the DC function table by using GetProcAddress on the graphics
[wine/testsucceed.git] / include / x11drv.h
bloba0a7793c42a23b6423dad47d6c3a8b49602b6abe
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"
22 #include "win.h"
23 #include "thread.h"
25 #define MAX_PIXELFORMATS 8
27 struct tagBITMAPOBJ;
28 struct tagCURSORICONINFO;
29 struct tagDC;
30 struct tagDeviceCaps;
31 struct tagPALETTEOBJ;
32 struct tagWND;
33 struct tagWINDOWPOS;
34 struct DIDEVICEOBJECTDATA;
36 /* X physical pen */
37 typedef struct
39 int style;
40 int endcap;
41 int linejoin;
42 int pixel;
43 int width;
44 char * dashes;
45 int dash_len;
46 int type; /* GEOMETRIC || COSMETIC */
47 } X_PHYSPEN;
49 /* X physical brush */
50 typedef struct
52 int style;
53 int fillStyle;
54 int pixel;
55 Pixmap pixmap;
56 } X_PHYSBRUSH;
58 /* X physical font */
59 typedef UINT X_PHYSFONT;
61 /* X physical device */
62 typedef struct
64 GC gc; /* X Window GC */
65 Drawable drawable;
66 X_PHYSFONT font;
67 X_PHYSPEN pen;
68 X_PHYSBRUSH brush;
69 int backgroundPixel;
70 int textPixel;
71 int exposures; /* count of graphics exposures operations */
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 extern unsigned int X11DRV_server_startticks;
88 /* Wine driver X11 functions */
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( HDC hdc, LPLOGFONTW 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, TEXTMETRICW *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 BOOL X11DRV_GetDeviceGammaRamp( struct tagDC *dc, LPVOID ramp );
160 extern BOOL X11DRV_SetDeviceGammaRamp( struct tagDC *dc, LPVOID ramp );
162 /* OpenGL / X11 driver functions */
163 extern int X11DRV_ChoosePixelFormat(DC *dc, const PIXELFORMATDESCRIPTOR *pppfd) ;
164 extern int X11DRV_DescribePixelFormat(DC *dc, int iPixelFormat, UINT nBytes, PIXELFORMATDESCRIPTOR *ppfd) ;
165 extern int X11DRV_GetPixelFormat(DC *dc) ;
166 extern BOOL X11DRV_SetPixelFormat(DC *dc, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd) ;
167 extern BOOL X11DRV_SwapBuffers(DC *dc) ;
169 /* X11 driver internal functions */
171 extern BOOL X11DRV_BITMAP_Init(void);
172 extern BOOL X11DRV_FONT_Init( struct tagDeviceCaps* );
173 extern BOOL X11DRV_OBM_Init(void);
175 struct tagBITMAPOBJ;
176 extern XImage *X11DRV_BITMAP_GetXImage( const struct tagBITMAPOBJ *bmp );
177 extern XImage *X11DRV_DIB_CreateXImage( int width, int height, int depth );
178 extern HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap);
179 extern HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixmap);
180 extern HBITMAP X11DRV_BITMAP_CreateBitmapFromPixmap(Pixmap pixmap, BOOL bDeletePixmap);
181 extern Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc );
182 extern Pixmap X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp, HDC hdc );
184 extern void X11DRV_SetDrawable( HDC hdc, Drawable drawable, int mode, int org_x, int org_y );
185 extern void X11DRV_StartGraphicsExposures( HDC hdc );
186 extern void X11DRV_EndGraphicsExposures( HDC hdc, HRGN hrgn );
188 extern BOOL X11DRV_SetupGCForPatBlt( struct tagDC *dc, GC gc, BOOL fMapColors );
189 extern BOOL X11DRV_SetupGCForBrush( struct tagDC *dc );
190 extern BOOL X11DRV_SetupGCForPen( struct tagDC *dc );
191 extern BOOL X11DRV_SetupGCForText( struct tagDC *dc );
193 extern const int X11DRV_XROPfunction[];
195 extern void _XInitImageFuncPtrs(XImage *);
197 /* exported dib functions for now */
199 /* Additional info for DIB section objects */
200 typedef struct
202 /* Windows DIB section */
203 DIBSECTION dibSection;
205 /* Mapping status */
206 int status, p_status;
208 /* Color map info */
209 int nColorMap;
210 int *colorMap;
212 /* Cached XImage */
213 XImage *image;
215 #ifdef HAVE_LIBXXSHM
216 /* Shared memory segment info */
217 XShmSegmentInfo shminfo;
218 #endif
220 /* Aux buffer access function */
221 void (*copy_aux)(void*ctx, int req);
222 void *aux_ctx;
224 /* GDI access lock */
225 CRITICAL_SECTION lock;
227 } X11DRV_DIBSECTION;
229 extern int *X11DRV_DIB_BuildColorMap( struct tagDC *dc, WORD coloruse,
230 WORD depth, const BITMAPINFO *info,
231 int *nColors );
232 extern INT X11DRV_CoerceDIBSection(struct tagDC *dc,INT,BOOL);
233 extern INT X11DRV_LockDIBSection(struct tagDC *dc,INT,BOOL);
234 extern void X11DRV_UnlockDIBSection(struct tagDC *dc,BOOL);
235 extern INT X11DRV_CoerceDIBSection2(HBITMAP bmp,INT,BOOL);
236 extern INT X11DRV_LockDIBSection2(HBITMAP bmp,INT,BOOL);
237 extern void X11DRV_UnlockDIBSection2(HBITMAP bmp,BOOL);
239 extern HBITMAP X11DRV_DIB_CreateDIBSection(struct tagDC *dc, BITMAPINFO *bmi, UINT usage,
240 LPVOID *bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
242 extern struct tagBITMAP_DRIVER X11DRV_BITMAP_Driver;
244 extern INT X11DRV_DIB_SetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT startscan,
245 UINT lines, LPCVOID bits, const BITMAPINFO *info,
246 UINT coloruse, HBITMAP hbitmap);
247 extern INT X11DRV_DIB_GetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT startscan,
248 UINT lines, LPVOID bits, BITMAPINFO *info,
249 UINT coloruse, HBITMAP hbitmap);
250 extern void X11DRV_DIB_DeleteDIBSection(struct tagBITMAPOBJ *bmp);
251 extern UINT X11DRV_DIB_SetDIBColorTable(struct tagBITMAPOBJ *,struct tagDC*,UINT,UINT,const RGBQUAD *);
252 extern UINT X11DRV_DIB_GetDIBColorTable(struct tagBITMAPOBJ *,struct tagDC*,UINT,UINT,RGBQUAD *);
253 extern INT X11DRV_DIB_Coerce(struct tagBITMAPOBJ *,INT,BOOL);
254 extern INT X11DRV_DIB_Lock(struct tagBITMAPOBJ *,INT,BOOL);
255 extern void X11DRV_DIB_Unlock(struct tagBITMAPOBJ *,BOOL);
256 void X11DRV_DIB_CopyDIBSection(DC *dcSrc, DC *dcDst,
257 DWORD xSrc, DWORD ySrc,
258 DWORD xDest, DWORD yDest,
259 DWORD width, DWORD height);
261 extern INT X11DRV_DCICommand(INT cbInput, LPVOID lpInData, LPVOID lpOutData);
263 /**************************************************************************
264 * X11 GDI driver
267 BOOL X11DRV_GDI_Initialize( Display *display );
268 void X11DRV_GDI_Finalize(void);
270 extern Display *gdi_display; /* display to use for all GDI functions */
272 /* X11 GDI palette driver */
274 #define X11DRV_PALETTE_FIXED 0x0001 /* read-only colormap - have to use XAllocColor (if not virtual) */
275 #define X11DRV_PALETTE_VIRTUAL 0x0002 /* no mapping needed - pixel == pixel color */
277 #define X11DRV_PALETTE_PRIVATE 0x1000 /* private colormap, identity mapping */
278 #define X11DRV_PALETTE_WHITESET 0x2000
280 extern Colormap X11DRV_PALETTE_PaletteXColormap;
281 extern UINT16 X11DRV_PALETTE_PaletteFlags;
283 extern int *X11DRV_PALETTE_PaletteToXPixel;
284 extern int *X11DRV_PALETTE_XPixelToPalette;
286 extern int X11DRV_PALETTE_mapEGAPixel[16];
288 extern BOOL X11DRV_PALETTE_Init(void);
289 extern void X11DRV_PALETTE_Cleanup(void);
291 extern COLORREF X11DRV_PALETTE_ToLogical(int pixel);
292 extern int X11DRV_PALETTE_ToPhysical(struct tagDC *dc, COLORREF color);
294 extern struct tagPALETTE_DRIVER X11DRV_PALETTE_Driver;
296 extern int X11DRV_PALETTE_SetMapping(struct tagPALETTEOBJ *palPtr, UINT uStart, UINT uNum, BOOL mapOnly);
297 extern int X11DRV_PALETTE_UpdateMapping(struct tagPALETTEOBJ *palPtr);
298 extern BOOL X11DRV_PALETTE_IsDark(int pixel);
300 /**************************************************************************
301 * X11 USER driver
304 struct x11drv_thread_data
306 Display *display;
307 HANDLE display_fd;
308 int process_event_count; /* recursion count for event processing */
311 extern struct x11drv_thread_data *x11drv_init_thread_data(void);
313 inline static struct x11drv_thread_data *x11drv_thread_data(void)
315 struct x11drv_thread_data *data = NtCurrentTeb()->driver_data;
316 if (!data) data = x11drv_init_thread_data();
317 return data;
320 inline static Display *thread_display(void) { return x11drv_thread_data()->display; }
322 extern Visual *visual;
323 extern Window root_window;
324 extern unsigned int screen_width;
325 extern unsigned int screen_height;
326 extern unsigned int screen_depth;
328 extern Atom wmProtocols;
329 extern Atom wmDeleteWindow;
330 extern Atom wmTakeFocus;
331 extern Atom dndProtocol;
332 extern Atom dndSelection;
333 extern Atom wmChangeState;
334 extern Atom kwmDockWindow;
335 extern Atom _kde_net_wm_system_tray_window_for;
337 /* X11 clipboard driver */
339 extern void X11DRV_CLIPBOARD_FreeResources( Atom property );
340 extern BOOL X11DRV_CLIPBOARD_RegisterPixmapResource( Atom property, Pixmap pixmap );
341 extern BOOL X11DRV_CLIPBOARD_IsNativeProperty(Atom prop);
342 extern UINT X11DRV_CLIPBOARD_MapPropertyToFormat(char *itemFmtName);
343 extern Atom X11DRV_CLIPBOARD_MapFormatToProperty(UINT id);
344 extern void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd);
345 extern BOOL X11DRV_IsSelectionOwner(void);
346 extern BOOL X11DRV_GetClipboardData(UINT wFormat);
348 /* X11 event driver */
350 extern WORD X11DRV_EVENT_XStateToKeyState( int state ) ;
352 typedef enum {
353 X11DRV_INPUT_RELATIVE,
354 X11DRV_INPUT_ABSOLUTE
355 } INPUT_TYPE;
356 extern INPUT_TYPE X11DRV_EVENT_SetInputMethod(INPUT_TYPE type);
358 #ifdef HAVE_LIBXXF86DGA2
359 void X11DRV_EVENT_SetDGAStatus(HWND hwnd, int event_base) ;
360 #endif
363 /* X11 keyboard driver */
365 extern void X11DRV_InitKeyboard(void);
366 extern WORD X11DRV_VkKeyScan(CHAR cChar);
367 extern UINT16 X11DRV_MapVirtualKey(UINT16 wCode, UINT16 wMapType);
368 extern INT16 X11DRV_GetKeyNameText(LONG lParam, LPSTR lpBuffer, INT16 nSize);
369 extern BOOL X11DRV_GetDIState(DWORD len, LPVOID ptr);
370 extern BOOL X11DRV_GetDIData(BYTE *keystate, DWORD dodsize, struct DIDEVICEOBJECTDATA *dod, LPDWORD entries, DWORD flags);
372 extern void X11DRV_HandleEvent(struct tagWND *pWnd, XKeyEvent *event);
374 /* X11 mouse driver */
376 extern void X11DRV_InitMouse(LPMOUSE_EVENT_PROC);
377 extern void X11DRV_SetCursor(struct tagCURSORICONINFO *lpCursor);
378 extern void X11DRV_MoveCursor(WORD wAbsX, WORD wAbsY);
379 extern void X11DRV_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY,
380 WORD keyState, DWORD data, DWORD time, HWND hWnd );
382 /* x11drv private window data */
383 struct x11drv_win_data
385 Window whole_window; /* X window for the complete window */
386 Window client_window; /* X window for the client area */
387 Window icon_window; /* X window for the icon */
388 RECT whole_rect; /* X window rectangle for the whole window relative to parent */
389 RECT client_rect; /* client area relative to whole window */
390 HBITMAP hWMIconBitmap;
391 HBITMAP hWMIconMask;
394 typedef struct x11drv_win_data X11DRV_WND_DATA;
396 extern Window X11DRV_get_client_window( HWND hwnd );
397 extern Window X11DRV_get_whole_window( HWND hwnd );
398 extern Window X11DRV_get_top_window( HWND hwnd );
400 inline static Window get_client_window( WND *wnd )
402 struct x11drv_win_data *data = wnd->pDriverData;
403 return data->client_window;
406 inline static Window get_whole_window( WND *wnd )
408 struct x11drv_win_data *data = wnd->pDriverData;
409 return data->whole_window;
412 extern void X11DRV_SetFocus( HWND hwnd );
413 extern Cursor X11DRV_GetCursor( Display *display, struct tagCURSORICONINFO *ptr );
415 extern void X11DRV_expect_error( unsigned char request, unsigned char error, XID id );
416 extern int X11DRV_check_error(void);
417 extern void X11DRV_register_window( Display *display, HWND hwnd, struct x11drv_win_data *data );
418 extern void X11DRV_set_iconic_state( WND *win );
419 extern void X11DRV_window_to_X_rect( WND *win, RECT *rect );
420 extern void X11DRV_X_to_window_rect( WND *win, RECT *rect );
421 extern void X11DRV_create_desktop_thread(void);
422 extern Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry );
423 extern int X11DRV_sync_whole_window_position( Display *display, WND *win, int zorder );
424 extern int X11DRV_sync_client_window_position( Display *display, WND *win );
426 #endif /* __WINE_X11DRV_H */