Added support for DOS EMS memory.
[wine/wine64.git] / include / x11drv.h
blobf4cefdfe28e1bf819913b1b61fa5fdc391016975
1 /*
2 * X11 driver definitions
3 */
5 #ifndef __WINE_X11DRV_H
6 #define __WINE_X11DRV_H
8 #ifndef __WINE_CONFIG_H
9 # error You must include config.h to use this header
10 #endif
12 #include <X11/Xlib.h>
13 #include <X11/Xresource.h>
14 #include <X11/Xutil.h>
15 #include <X11/Xatom.h>
16 #ifdef HAVE_LIBXXSHM
17 # include <X11/extensions/XShm.h>
18 #endif /* defined(HAVE_LIBXXSHM) */
20 #include "windef.h"
21 #include "winbase.h"
22 #include "gdi.h"
23 #include "user.h"
24 #include "win.h"
25 #include "thread.h"
27 #define MAX_PIXELFORMATS 8
29 struct tagBITMAPOBJ;
30 struct tagCURSORICONINFO;
31 struct tagDC;
32 struct tagDeviceCaps;
33 struct tagPALETTEOBJ;
34 struct tagWINDOWPOS;
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 typedef struct tagXRENDERINFO *XRENDERINFO;
63 /* X physical device */
64 typedef struct
66 GC gc; /* X Window GC */
67 Drawable drawable;
68 X_PHYSFONT font;
69 X_PHYSPEN pen;
70 X_PHYSBRUSH brush;
71 int backgroundPixel;
72 int textPixel;
73 int exposures; /* count of graphics exposures operations */
74 XVisualInfo *visuals[MAX_PIXELFORMATS];
75 int used_visuals;
76 int current_pf;
77 XRENDERINFO xrender;
78 } X11DRV_PDEVICE;
81 /* GCs used for B&W and color bitmap operations */
82 extern GC BITMAP_monoGC, BITMAP_colorGC;
84 #define BITMAP_GC(bmp) \
85 (((bmp)->bitmap.bmBitsPixel == 1) ? BITMAP_monoGC : BITMAP_colorGC)
87 extern unsigned int X11DRV_server_startticks;
89 /* Wine driver X11 functions */
91 extern BOOL X11DRV_BitBlt( struct tagDC *dcDst, INT xDst, INT yDst,
92 INT width, INT height, struct tagDC *dcSrc,
93 INT xSrc, INT ySrc, DWORD rop );
94 extern BOOL X11DRV_EnumDeviceFonts( HDC hdc, LPLOGFONTW plf,
95 DEVICEFONTENUMPROC dfeproc, LPARAM lp );
96 extern BOOL X11DRV_GetCharWidth( struct tagDC *dc, UINT firstChar,
97 UINT lastChar, LPINT buffer );
98 extern BOOL X11DRV_GetDCOrgEx( struct tagDC *dc, LPPOINT lpp );
99 extern BOOL X11DRV_GetTextExtentPoint( struct tagDC *dc, LPCWSTR str,
100 INT count, LPSIZE size );
101 extern BOOL X11DRV_GetTextMetrics(struct tagDC *dc, TEXTMETRICW *metrics);
102 extern BOOL X11DRV_PatBlt( struct tagDC *dc, INT left, INT top,
103 INT width, INT height, DWORD rop );
104 extern VOID X11DRV_SetDeviceClipping(struct tagDC *dc);
105 extern BOOL X11DRV_StretchBlt( struct tagDC *dcDst, INT xDst, INT yDst,
106 INT widthDst, INT heightDst,
107 struct tagDC *dcSrc, INT xSrc, INT ySrc,
108 INT widthSrc, INT heightSrc, DWORD rop );
109 extern BOOL X11DRV_LineTo( struct tagDC *dc, INT x, INT y);
110 extern BOOL X11DRV_Arc( struct tagDC *dc, INT left, INT top, INT right,
111 INT bottom, INT xstart, INT ystart, INT xend,
112 INT yend );
113 extern BOOL X11DRV_Pie( struct tagDC *dc, INT left, INT top, INT right,
114 INT bottom, INT xstart, INT ystart, INT xend,
115 INT yend );
116 extern BOOL X11DRV_Chord( struct tagDC *dc, INT left, INT top,
117 INT right, INT bottom, INT xstart,
118 INT ystart, INT xend, INT yend );
119 extern BOOL X11DRV_Ellipse( struct tagDC *dc, INT left, INT top,
120 INT right, INT bottom );
121 extern BOOL X11DRV_Rectangle(struct tagDC *dc, INT left, INT top,
122 INT right, INT bottom);
123 extern BOOL X11DRV_RoundRect( struct tagDC *dc, INT left, INT top,
124 INT right, INT bottom, INT ell_width,
125 INT ell_height );
126 extern COLORREF X11DRV_SetPixel( struct tagDC *dc, INT x, INT y,
127 COLORREF color );
128 extern COLORREF X11DRV_GetPixel( struct tagDC *dc, INT x, INT y);
129 extern BOOL X11DRV_PaintRgn( struct tagDC *dc, HRGN hrgn );
130 extern BOOL X11DRV_Polyline( struct tagDC *dc,const POINT* pt,INT count);
131 extern BOOL X11DRV_Polygon( struct tagDC *dc, const POINT* pt, INT count );
132 extern BOOL X11DRV_PolyPolygon( struct tagDC *dc, const POINT* pt,
133 const INT* counts, UINT polygons);
134 extern BOOL X11DRV_PolyPolyline( struct tagDC *dc, const POINT* pt,
135 const DWORD* counts, DWORD polylines);
137 extern HGDIOBJ X11DRV_SelectObject( struct tagDC *dc, HGDIOBJ handle );
139 extern COLORREF X11DRV_SetBkColor( struct tagDC *dc, COLORREF color );
140 extern COLORREF X11DRV_SetTextColor( struct tagDC *dc, COLORREF color );
141 extern BOOL X11DRV_ExtFloodFill( struct tagDC *dc, INT x, INT y,
142 COLORREF color, UINT fillType );
143 extern BOOL X11DRV_ExtTextOut( struct tagDC *dc, INT x, INT y,
144 UINT flags, const RECT *lprect,
145 LPCWSTR str, UINT count, const INT *lpDx );
146 extern BOOL X11DRV_CreateBitmap( HBITMAP hbitmap );
147 extern BOOL X11DRV_DeleteObject( HGDIOBJ handle );
148 extern LONG X11DRV_BitmapBits( HBITMAP hbitmap, void *bits, LONG count,
149 WORD flags );
150 extern INT X11DRV_SetDIBitsToDevice( struct tagDC *dc, INT xDest,
151 INT yDest, DWORD cx, DWORD cy,
152 INT xSrc, INT ySrc,
153 UINT startscan, UINT lines,
154 LPCVOID bits, const BITMAPINFO *info,
155 UINT coloruse );
156 extern INT X11DRV_DeviceBitmapBits( struct tagDC *dc, HBITMAP hbitmap,
157 WORD fGet, UINT startscan,
158 UINT lines, LPSTR bits,
159 LPBITMAPINFO info, UINT coloruse );
160 extern BOOL X11DRV_GetDeviceGammaRamp( struct tagDC *dc, LPVOID ramp );
161 extern BOOL X11DRV_SetDeviceGammaRamp( struct tagDC *dc, LPVOID ramp );
163 /* OpenGL / X11 driver functions */
164 extern int X11DRV_ChoosePixelFormat(DC *dc, const PIXELFORMATDESCRIPTOR *pppfd) ;
165 extern int X11DRV_DescribePixelFormat(DC *dc, int iPixelFormat, UINT nBytes, PIXELFORMATDESCRIPTOR *ppfd) ;
166 extern int X11DRV_GetPixelFormat(DC *dc) ;
167 extern BOOL X11DRV_SetPixelFormat(DC *dc, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd) ;
168 extern BOOL X11DRV_SwapBuffers(DC *dc) ;
170 /* X11 driver internal functions */
172 extern BOOL X11DRV_BITMAP_Init(void);
173 extern int X11DRV_FONT_Init( int *log_pixels_x, int *log_pixels_y );
174 extern HBRUSH X11DRV_BRUSH_SelectObject( DC * dc, HBRUSH hbrush );
175 extern HFONT X11DRV_FONT_SelectObject( DC * dc, HFONT hfont );
176 extern HPEN X11DRV_PEN_SelectObject( DC * dc, HPEN hpen );
177 extern HBITMAP X11DRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap );
178 extern BOOL X11DRV_BITMAP_DeleteObject( HBITMAP hbitmap );
180 struct tagBITMAPOBJ;
181 extern XImage *X11DRV_BITMAP_GetXImage( const struct tagBITMAPOBJ *bmp );
182 extern XImage *X11DRV_DIB_CreateXImage( int width, int height, int depth );
183 extern HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap);
184 extern HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixmap);
185 extern HBITMAP X11DRV_BITMAP_CreateBitmapFromPixmap(Pixmap pixmap, BOOL bDeletePixmap);
186 extern Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc );
187 extern Pixmap X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp, HDC hdc );
189 extern void X11DRV_SetDrawable( HDC hdc, Drawable drawable, int mode, int org_x, int org_y );
190 extern void X11DRV_StartGraphicsExposures( HDC hdc );
191 extern void X11DRV_EndGraphicsExposures( HDC hdc, HRGN hrgn );
193 extern BOOL X11DRV_SetupGCForPatBlt( struct tagDC *dc, GC gc, BOOL fMapColors );
194 extern BOOL X11DRV_SetupGCForBrush( struct tagDC *dc );
195 extern BOOL X11DRV_SetupGCForPen( struct tagDC *dc );
196 extern BOOL X11DRV_SetupGCForText( struct tagDC *dc );
198 extern const int X11DRV_XROPfunction[];
200 extern void _XInitImageFuncPtrs(XImage *);
202 extern BOOL X11DRV_XRender_Installed;
203 extern void X11DRV_XRender_Init(void);
204 extern void X11DRV_XRender_Finalize(void);
205 extern BOOL X11DRV_XRender_SelectFont(struct tagDC*, HFONT);
206 extern void X11DRV_XRender_DeleteDC(struct tagDC*);
207 extern BOOL X11DRV_XRender_ExtTextOut(DC *dc, INT x, INT y, UINT flags,
208 const RECT *lprect, LPCWSTR wstr,
209 UINT count, const INT *lpDx);
210 extern void X11DRV_XRender_UpdateDrawable(DC *dc);
212 /* exported dib functions for now */
214 /* Additional info for DIB section objects */
215 typedef struct
217 /* Windows DIB section */
218 DIBSECTION dibSection;
220 /* Mapping status */
221 int status, p_status;
223 /* Color map info */
224 int nColorMap;
225 int *colorMap;
227 /* Cached XImage */
228 XImage *image;
230 #ifdef HAVE_LIBXXSHM
231 /* Shared memory segment info */
232 XShmSegmentInfo shminfo;
233 #endif
235 /* Aux buffer access function */
236 void (*copy_aux)(void*ctx, int req);
237 void *aux_ctx;
239 /* GDI access lock */
240 CRITICAL_SECTION lock;
242 } X11DRV_DIBSECTION;
244 extern int *X11DRV_DIB_BuildColorMap( struct tagDC *dc, WORD coloruse,
245 WORD depth, const BITMAPINFO *info,
246 int *nColors );
247 extern INT X11DRV_CoerceDIBSection(struct tagDC *dc,INT,BOOL);
248 extern INT X11DRV_LockDIBSection(struct tagDC *dc,INT,BOOL);
249 extern void X11DRV_UnlockDIBSection(struct tagDC *dc,BOOL);
250 extern INT X11DRV_CoerceDIBSection2(HBITMAP bmp,INT,BOOL);
251 extern INT X11DRV_LockDIBSection2(HBITMAP bmp,INT,BOOL);
252 extern void X11DRV_UnlockDIBSection2(HBITMAP bmp,BOOL);
254 extern HBITMAP X11DRV_DIB_CreateDIBSection(struct tagDC *dc, BITMAPINFO *bmi, UINT usage,
255 LPVOID *bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
257 extern struct tagBITMAP_DRIVER X11DRV_BITMAP_Driver;
259 extern INT X11DRV_DIB_SetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT startscan,
260 UINT lines, LPCVOID bits, const BITMAPINFO *info,
261 UINT coloruse, HBITMAP hbitmap);
262 extern INT X11DRV_DIB_GetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT startscan,
263 UINT lines, LPVOID bits, BITMAPINFO *info,
264 UINT coloruse, HBITMAP hbitmap);
265 extern void X11DRV_DIB_DeleteDIBSection(struct tagBITMAPOBJ *bmp);
266 extern UINT X11DRV_DIB_SetDIBColorTable(struct tagBITMAPOBJ *,struct tagDC*,UINT,UINT,const RGBQUAD *);
267 extern UINT X11DRV_DIB_GetDIBColorTable(struct tagBITMAPOBJ *,struct tagDC*,UINT,UINT,RGBQUAD *);
268 extern INT X11DRV_DIB_Coerce(struct tagBITMAPOBJ *,INT,BOOL);
269 extern INT X11DRV_DIB_Lock(struct tagBITMAPOBJ *,INT,BOOL);
270 extern void X11DRV_DIB_Unlock(struct tagBITMAPOBJ *,BOOL);
271 void X11DRV_DIB_CopyDIBSection(DC *dcSrc, DC *dcDst,
272 DWORD xSrc, DWORD ySrc,
273 DWORD xDest, DWORD yDest,
274 DWORD width, DWORD height);
275 struct _DCICMD;
276 extern INT X11DRV_DCICommand(INT cbInput, const struct _DCICMD *lpCmd, LPVOID lpOutData);
278 /**************************************************************************
279 * X11 GDI driver
282 BOOL X11DRV_GDI_Initialize( Display *display );
283 void X11DRV_GDI_Finalize(void);
285 extern Display *gdi_display; /* display to use for all GDI functions */
287 /* X11 GDI palette driver */
289 #define X11DRV_PALETTE_FIXED 0x0001 /* read-only colormap - have to use XAllocColor (if not virtual) */
290 #define X11DRV_PALETTE_VIRTUAL 0x0002 /* no mapping needed - pixel == pixel color */
292 #define X11DRV_PALETTE_PRIVATE 0x1000 /* private colormap, identity mapping */
293 #define X11DRV_PALETTE_WHITESET 0x2000
295 extern Colormap X11DRV_PALETTE_PaletteXColormap;
296 extern UINT16 X11DRV_PALETTE_PaletteFlags;
298 extern int *X11DRV_PALETTE_PaletteToXPixel;
299 extern int *X11DRV_PALETTE_XPixelToPalette;
301 extern int X11DRV_PALETTE_mapEGAPixel[16];
303 extern int X11DRV_PALETTE_Init(void);
304 extern void X11DRV_PALETTE_Cleanup(void);
306 extern COLORREF X11DRV_PALETTE_ToLogical(int pixel);
307 extern int X11DRV_PALETTE_ToPhysical(struct tagDC *dc, COLORREF color);
309 extern struct tagPALETTE_DRIVER X11DRV_PALETTE_Driver;
311 extern int X11DRV_PALETTE_SetMapping(struct tagPALETTEOBJ *palPtr, UINT uStart, UINT uNum, BOOL mapOnly);
312 extern int X11DRV_PALETTE_UpdateMapping(struct tagPALETTEOBJ *palPtr);
313 extern BOOL X11DRV_PALETTE_IsDark(int pixel);
315 /**************************************************************************
316 * X11 USER driver
319 struct x11drv_thread_data
321 Display *display;
322 HANDLE display_fd;
323 int process_event_count; /* recursion count for event processing */
326 extern struct x11drv_thread_data *x11drv_init_thread_data(void);
328 inline static struct x11drv_thread_data *x11drv_thread_data(void)
330 struct x11drv_thread_data *data = NtCurrentTeb()->driver_data;
331 if (!data) data = x11drv_init_thread_data();
332 return data;
335 inline static Display *thread_display(void) { return x11drv_thread_data()->display; }
337 extern Visual *visual;
338 extern Window root_window;
339 extern unsigned int screen_width;
340 extern unsigned int screen_height;
341 extern unsigned int screen_depth;
343 extern Atom wmProtocols;
344 extern Atom wmDeleteWindow;
345 extern Atom wmTakeFocus;
346 extern Atom dndProtocol;
347 extern Atom dndSelection;
348 extern Atom wmChangeState;
349 extern Atom kwmDockWindow;
350 extern Atom _kde_net_wm_system_tray_window_for;
352 /* X11 clipboard driver */
354 extern void X11DRV_CLIPBOARD_FreeResources( Atom property );
355 extern BOOL X11DRV_CLIPBOARD_RegisterPixmapResource( Atom property, Pixmap pixmap );
356 extern BOOL X11DRV_CLIPBOARD_IsNativeProperty(Atom prop);
357 extern UINT X11DRV_CLIPBOARD_MapPropertyToFormat(char *itemFmtName);
358 extern Atom X11DRV_CLIPBOARD_MapFormatToProperty(UINT id);
359 extern void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd);
360 extern BOOL X11DRV_IsSelectionOwner(void);
361 extern BOOL X11DRV_GetClipboardData(UINT wFormat);
363 /* X11 event driver */
365 typedef enum {
366 X11DRV_INPUT_RELATIVE,
367 X11DRV_INPUT_ABSOLUTE
368 } INPUT_TYPE;
369 extern INPUT_TYPE X11DRV_EVENT_SetInputMethod(INPUT_TYPE type);
371 #ifdef HAVE_LIBXXF86DGA2
372 void X11DRV_EVENT_SetDGAStatus(HWND hwnd, int event_base) ;
373 #endif
375 /* x11drv private window data */
376 struct x11drv_win_data
378 Window whole_window; /* X window for the complete window */
379 Window client_window; /* X window for the client area */
380 Window icon_window; /* X window for the icon */
381 RECT whole_rect; /* X window rectangle for the whole window relative to parent */
382 RECT client_rect; /* client area relative to whole window */
383 HBITMAP hWMIconBitmap;
384 HBITMAP hWMIconMask;
387 typedef struct x11drv_win_data X11DRV_WND_DATA;
389 extern Window X11DRV_get_client_window( HWND hwnd );
390 extern Window X11DRV_get_whole_window( HWND hwnd );
392 inline static Window get_client_window( WND *wnd )
394 struct x11drv_win_data *data = wnd->pDriverData;
395 return data->client_window;
398 inline static Window get_whole_window( WND *wnd )
400 struct x11drv_win_data *data = wnd->pDriverData;
401 return data->whole_window;
404 extern void X11DRV_SetFocus( HWND hwnd );
405 extern Cursor X11DRV_GetCursor( Display *display, struct tagCURSORICONINFO *ptr );
407 extern void X11DRV_expect_error( unsigned char request, unsigned char error, XID id );
408 extern int X11DRV_check_error(void);
409 extern void X11DRV_register_window( Display *display, HWND hwnd, struct x11drv_win_data *data );
410 extern void X11DRV_set_iconic_state( WND *win );
411 extern void X11DRV_window_to_X_rect( WND *win, RECT *rect );
412 extern void X11DRV_X_to_window_rect( WND *win, RECT *rect );
413 extern void X11DRV_create_desktop_thread(void);
414 extern Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry );
415 extern int X11DRV_sync_whole_window_position( Display *display, WND *win, int zorder );
416 extern int X11DRV_sync_client_window_position( Display *display, WND *win );
418 #endif /* __WINE_X11DRV_H */