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