Added more conversion routines (rate conversion is implemented).
[wine/multimedia.git] / include / x11drv.h
blob1e5e6e2cb01f9d0f371fd4c0510e431bfe5a7794
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 extern unsigned int X11DRV_server_startticks;
88 /* Wine driver X11 functions */
90 extern const DC_FUNCTIONS X11DRV_DC_Funcs;
92 extern BOOL X11DRV_BitBlt( struct tagDC *dcDst, INT xDst, INT yDst,
93 INT width, INT height, struct tagDC *dcSrc,
94 INT xSrc, INT ySrc, DWORD rop );
95 extern BOOL X11DRV_EnumDeviceFonts( HDC hdc, LPLOGFONT16 plf,
96 DEVICEFONTENUMPROC dfeproc, LPARAM lp );
97 extern BOOL X11DRV_GetCharWidth( struct tagDC *dc, UINT firstChar,
98 UINT lastChar, LPINT buffer );
99 extern BOOL X11DRV_GetDCOrgEx( struct tagDC *dc, LPPOINT lpp );
100 extern BOOL X11DRV_GetTextExtentPoint( struct tagDC *dc, LPCWSTR str,
101 INT count, LPSIZE size );
102 extern BOOL X11DRV_GetTextMetrics(struct tagDC *dc, TEXTMETRICA *metrics);
103 extern BOOL X11DRV_PatBlt( struct tagDC *dc, INT left, INT top,
104 INT width, INT height, DWORD rop );
105 extern VOID X11DRV_SetDeviceClipping(struct tagDC *dc);
106 extern BOOL X11DRV_StretchBlt( struct tagDC *dcDst, INT xDst, INT yDst,
107 INT widthDst, INT heightDst,
108 struct tagDC *dcSrc, INT xSrc, INT ySrc,
109 INT widthSrc, INT heightSrc, DWORD rop );
110 extern BOOL X11DRV_LineTo( struct tagDC *dc, INT x, INT y);
111 extern BOOL X11DRV_Arc( struct tagDC *dc, INT left, INT top, INT right,
112 INT bottom, INT xstart, INT ystart, INT xend,
113 INT yend );
114 extern BOOL X11DRV_Pie( struct tagDC *dc, INT left, INT top, INT right,
115 INT bottom, INT xstart, INT ystart, INT xend,
116 INT yend );
117 extern BOOL X11DRV_Chord( struct tagDC *dc, INT left, INT top,
118 INT right, INT bottom, INT xstart,
119 INT ystart, INT xend, INT yend );
120 extern BOOL X11DRV_Ellipse( struct tagDC *dc, INT left, INT top,
121 INT right, INT bottom );
122 extern BOOL X11DRV_Rectangle(struct tagDC *dc, INT left, INT top,
123 INT right, INT bottom);
124 extern BOOL X11DRV_RoundRect( struct tagDC *dc, INT left, INT top,
125 INT right, INT bottom, INT ell_width,
126 INT ell_height );
127 extern COLORREF X11DRV_SetPixel( struct tagDC *dc, INT x, INT y,
128 COLORREF color );
129 extern COLORREF X11DRV_GetPixel( struct tagDC *dc, INT x, INT y);
130 extern BOOL X11DRV_PaintRgn( struct tagDC *dc, HRGN hrgn );
131 extern BOOL X11DRV_Polyline( struct tagDC *dc,const POINT* pt,INT count);
132 extern BOOL X11DRV_Polygon( struct tagDC *dc, const POINT* pt, INT count );
133 extern BOOL X11DRV_PolyPolygon( struct tagDC *dc, const POINT* pt,
134 const INT* counts, UINT polygons);
135 extern BOOL X11DRV_PolyPolyline( struct tagDC *dc, const POINT* pt,
136 const DWORD* counts, DWORD polylines);
138 extern HGDIOBJ X11DRV_SelectObject( struct tagDC *dc, HGDIOBJ handle );
140 extern COLORREF X11DRV_SetBkColor( struct tagDC *dc, COLORREF color );
141 extern COLORREF X11DRV_SetTextColor( struct tagDC *dc, COLORREF color );
142 extern BOOL X11DRV_ExtFloodFill( struct tagDC *dc, INT x, INT y,
143 COLORREF color, UINT fillType );
144 extern BOOL X11DRV_ExtTextOut( struct tagDC *dc, INT x, INT y,
145 UINT flags, const RECT *lprect,
146 LPCWSTR str, UINT count, const INT *lpDx );
147 extern BOOL X11DRV_CreateBitmap( HBITMAP hbitmap );
148 extern BOOL X11DRV_DeleteObject( HGDIOBJ handle );
149 extern LONG X11DRV_BitmapBits( HBITMAP hbitmap, void *bits, LONG count,
150 WORD flags );
151 extern INT X11DRV_SetDIBitsToDevice( struct tagDC *dc, INT xDest,
152 INT yDest, DWORD cx, DWORD cy,
153 INT xSrc, INT ySrc,
154 UINT startscan, UINT lines,
155 LPCVOID bits, const BITMAPINFO *info,
156 UINT coloruse );
157 extern INT X11DRV_DeviceBitmapBits( struct tagDC *dc, HBITMAP hbitmap,
158 WORD fGet, UINT startscan,
159 UINT lines, LPSTR bits,
160 LPBITMAPINFO info, UINT coloruse );
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_BRUSH_Init(void);
173 extern BOOL X11DRV_DIB_Init(void);
174 extern BOOL X11DRV_FONT_Init( struct tagDeviceCaps* );
175 extern BOOL X11DRV_OBM_Init(void);
177 struct tagBITMAPOBJ;
178 extern XImage *X11DRV_BITMAP_GetXImage( const struct tagBITMAPOBJ *bmp );
179 extern int X11DRV_DIB_GetXImageWidthBytes( int width, int depth );
180 extern HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap);
181 extern HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixmap);
182 extern HBITMAP X11DRV_BITMAP_CreateBitmapFromPixmap(Pixmap pixmap, BOOL bDeletePixmap);
183 extern Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc );
184 extern Pixmap X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp, HDC hdc );
186 extern BOOL X11DRV_SetupGCForPatBlt( struct tagDC *dc, GC gc,
187 BOOL fMapColors );
188 extern BOOL X11DRV_SetupGCForBrush( struct tagDC *dc );
189 extern BOOL X11DRV_SetupGCForPen( struct tagDC *dc );
190 extern BOOL X11DRV_SetupGCForText( struct tagDC *dc );
192 extern const int X11DRV_XROPfunction[];
194 /* Xlib critical section */
196 extern CRITICAL_SECTION X11DRV_CritSection;
198 extern void _XInitImageFuncPtrs(XImage *);
200 #define XCREATEIMAGE(image,width,height,bpp) \
202 int width_bytes = X11DRV_DIB_GetXImageWidthBytes( (width), (bpp) ); \
203 (image) = TSXCreateImage(display, X11DRV_GetVisual(), \
204 (bpp), ZPixmap, 0, calloc( (height), width_bytes ),\
205 (width), (height), 32, width_bytes ); \
208 /* exported dib functions for now */
210 /* Additional info for DIB section objects */
211 typedef struct
213 /* Windows DIB section */
214 DIBSECTION dibSection;
216 /* Mapping status */
217 enum { X11DRV_DIB_NoHandler, X11DRV_DIB_InSync, X11DRV_DIB_AppMod, X11DRV_DIB_GdiMod } status;
219 /* Color map info */
220 int nColorMap;
221 int *colorMap;
223 /* Cached XImage */
224 XImage *image;
226 /* Selector for 16-bit access to bits */
227 WORD selector;
229 /* Shared memory segment info */
230 XShmSegmentInfo shminfo;
232 } X11DRV_DIBSECTION;
234 /* This structure holds the arguments for DIB_SetImageBits() */
235 typedef struct
237 struct tagDC *dc;
238 LPCVOID bits;
239 XImage *image;
240 PALETTEENTRY *palentry;
241 int lines;
242 DWORD infoWidth;
243 WORD depth;
244 WORD infoBpp;
245 WORD compression;
246 RGBQUAD *colorMap;
247 int nColorMap;
248 Drawable drawable;
249 GC gc;
250 int xSrc;
251 int ySrc;
252 int xDest;
253 int yDest;
254 int width;
255 int height;
256 DWORD rMask;
257 DWORD gMask;
258 DWORD bMask;
259 BOOL useShm;
261 } X11DRV_DIB_IMAGEBITS_DESCR;
263 extern int *X11DRV_DIB_BuildColorMap( struct tagDC *dc, WORD coloruse,
264 WORD depth, const BITMAPINFO *info,
265 int *nColors );
266 extern void X11DRV_DIB_UpdateDIBSection(struct tagDC *dc, BOOL toDIB);
267 extern void X11DRV_DIB_UpdateDIBSection2(HBITMAP hbmp, BOOL toDIB);
269 extern HBITMAP X11DRV_DIB_CreateDIBSection(struct tagDC *dc, BITMAPINFO *bmi, UINT usage,
270 LPVOID *bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
271 extern HBITMAP16 X11DRV_DIB_CreateDIBSection16(struct tagDC *dc, BITMAPINFO *bmi, UINT16 usage,
272 SEGPTR *bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
274 extern struct tagBITMAP_DRIVER X11DRV_BITMAP_Driver;
276 extern INT X11DRV_DIB_SetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT startscan,
277 UINT lines, LPCVOID bits, const BITMAPINFO *info,
278 UINT coloruse, HBITMAP hbitmap);
279 extern INT X11DRV_DIB_GetDIBits(struct tagBITMAPOBJ *bmp, struct tagDC *dc, UINT startscan,
280 UINT lines, LPVOID bits, BITMAPINFO *info,
281 UINT coloruse, HBITMAP hbitmap);
282 extern void X11DRV_DIB_DeleteDIBSection(struct tagBITMAPOBJ *bmp);
284 /**************************************************************************
285 * X11 GDI driver
288 BOOL X11DRV_GDI_Initialize(void);
289 void X11DRV_GDI_Finalize(void);
291 /* X11 GDI palette driver */
293 #define X11DRV_PALETTE_FIXED 0x0001 /* read-only colormap - have to use XAllocColor (if not virtual) */
294 #define X11DRV_PALETTE_VIRTUAL 0x0002 /* no mapping needed - pixel == pixel color */
296 #define X11DRV_PALETTE_PRIVATE 0x1000 /* private colormap, identity mapping */
297 #define X11DRV_PALETTE_WHITESET 0x2000
299 extern Colormap X11DRV_PALETTE_PaletteXColormap;
300 extern UINT16 X11DRV_PALETTE_PaletteFlags;
302 extern int *X11DRV_PALETTE_PaletteToXPixel;
303 extern int *X11DRV_PALETTE_XPixelToPalette;
305 extern int X11DRV_PALETTE_mapEGAPixel[16];
307 extern BOOL X11DRV_PALETTE_Init(void);
308 extern void X11DRV_PALETTE_Cleanup(void);
310 extern COLORREF X11DRV_PALETTE_ToLogical(int pixel);
311 extern int X11DRV_PALETTE_ToPhysical(struct tagDC *dc, COLORREF color);
313 extern struct tagPALETTE_DRIVER X11DRV_PALETTE_Driver;
315 extern int X11DRV_PALETTE_SetMapping(struct tagPALETTEOBJ *palPtr, UINT uStart, UINT uNum, BOOL mapOnly);
316 extern int X11DRV_PALETTE_UpdateMapping(struct tagPALETTEOBJ *palPtr);
317 extern BOOL X11DRV_PALETTE_IsDark(int pixel);
319 /**************************************************************************
320 * X11 USER driver
323 extern Display *display;
324 extern Screen *screen;
325 extern Visual *visual;
326 extern Window root_window;
327 extern unsigned int screen_width;
328 extern unsigned int screen_height;
329 extern unsigned int screen_depth;
331 static inline Screen *X11DRV_GetXScreen(void) { return screen; }
332 static inline Visual *X11DRV_GetVisual(void) { return visual; }
333 static inline Window X11DRV_GetXRootWindow(void) { return root_window; }
334 static inline unsigned int X11DRV_GetDepth(void) { return screen_depth; }
336 /* X11 clipboard driver */
338 extern void X11DRV_CLIPBOARD_FreeResources( Atom property );
339 extern BOOL X11DRV_CLIPBOARD_RegisterPixmapResource( Atom property, Pixmap pixmap );
340 extern BOOL X11DRV_CLIPBOARD_IsNativeProperty(Atom prop);
341 extern UINT X11DRV_CLIPBOARD_MapPropertyToFormat(char *itemFmtName);
342 extern Atom X11DRV_CLIPBOARD_MapFormatToProperty(UINT id);
343 extern void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd);
344 extern BOOL X11DRV_IsSelectionOwner(void);
345 extern BOOL X11DRV_GetClipboardData(UINT wFormat);
347 /* X11 event driver */
349 extern WORD X11DRV_EVENT_XStateToKeyState( int state ) ;
351 extern BOOL X11DRV_EVENT_Init(void);
352 extern void X11DRV_Synchronize( void );
354 typedef enum {
355 X11DRV_INPUT_RELATIVE,
356 X11DRV_INPUT_ABSOLUTE
357 } INPUT_TYPE;
358 extern INPUT_TYPE X11DRV_EVENT_SetInputMethod(INPUT_TYPE type);
360 #ifdef HAVE_LIBXXF86DGA2
361 void X11DRV_EVENT_SetDGAStatus(HWND hwnd, int event_base) ;
362 #endif
365 /* X11 keyboard driver */
367 extern void X11DRV_InitKeyboard(void);
368 extern WORD X11DRV_VkKeyScan(CHAR cChar);
369 extern UINT16 X11DRV_MapVirtualKey(UINT16 wCode, UINT16 wMapType);
370 extern INT16 X11DRV_GetKeyNameText(LONG lParam, LPSTR lpBuffer, INT16 nSize);
371 extern INT16 X11DRV_ToAscii(UINT16 virtKey, UINT16 scanCode, LPBYTE lpKeyState, LPVOID lpChar, UINT16 flags);
372 extern BOOL X11DRV_GetDIState(DWORD len, LPVOID ptr);
373 extern BOOL X11DRV_GetDIData(BYTE *keystate, DWORD dodsize, struct DIDEVICEOBJECTDATA *dod, LPDWORD entries, DWORD flags);
374 extern void X11DRV_GetKeyboardConfig(struct tagKEYBOARD_CONFIG *cfg);
375 extern void X11DRV_SetKeyboardConfig(struct tagKEYBOARD_CONFIG *cfg, DWORD mask);
377 extern void X11DRV_HandleEvent(struct tagWND *pWnd, XKeyEvent *event);
379 /* X11 mouse driver */
381 extern void X11DRV_InitMouse(LPMOUSE_EVENT_PROC);
382 extern void X11DRV_SetCursor(struct tagCURSORICONINFO *lpCursor);
383 extern void X11DRV_MoveCursor(WORD wAbsX, WORD wAbsY);
384 extern void X11DRV_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY,
385 DWORD keyState, DWORD time, HWND hWnd );
387 /* X11 windows driver */
389 extern struct tagWND_DRIVER X11DRV_WND_Driver;
391 typedef struct _X11DRV_WND_DATA {
392 Window window;
393 HBITMAP hWMIconBitmap;
394 HBITMAP hWMIconMask;
395 int bit_gravity;
396 } X11DRV_WND_DATA;
398 extern Window X11DRV_WND_GetXWindow(struct tagWND *wndPtr);
399 extern Window X11DRV_WND_FindXWindow(struct tagWND *wndPtr);
401 extern void X11DRV_WND_Initialize(struct tagWND *wndPtr);
402 extern void X11DRV_WND_Finalize(struct tagWND *wndPtr);
403 extern BOOL X11DRV_WND_CreateDesktopWindow(struct tagWND *wndPtr, struct tagCLASS *classPtr, BOOL bUnicode);
404 extern BOOL X11DRV_WND_CreateWindow(struct tagWND *wndPtr, struct tagCLASS *classPtr, struct tagCREATESTRUCTA *cs, BOOL bUnicode);
405 extern BOOL X11DRV_WND_DestroyWindow(struct tagWND *pWnd);
406 extern struct tagWND *X11DRV_WND_SetParent(struct tagWND *wndPtr, struct tagWND *pWndParent);
407 extern void X11DRV_WND_ForceWindowRaise(struct tagWND *pWnd);
408 extern void X11DRV_WND_SetWindowPos(struct tagWND *wndPtr, const struct tagWINDOWPOS *winpos, BOOL bSMC_SETXPOS);
409 extern void X11DRV_WND_SetText(struct tagWND *wndPtr, LPCWSTR text);
410 extern void X11DRV_WND_SetFocus(struct tagWND *wndPtr);
411 extern void X11DRV_WND_PreSizeMove(struct tagWND *wndPtr);
412 extern void X11DRV_WND_PostSizeMove(struct tagWND *wndPtr);
413 extern void X11DRV_WND_SurfaceCopy(struct tagWND *wndPtr, HDC hdc, INT dx, INT dy, const RECT *clipRect, BOOL bUpdate);
414 extern void X11DRV_WND_SetDrawable(struct tagWND *wndPtr, HDC hdc, WORD flags, BOOL bSetClipOrigin);
415 extern BOOL X11DRV_WND_SetHostAttr(struct tagWND *wndPtr, INT haKey, INT value);
416 extern BOOL X11DRV_WND_IsSelfClipping(struct tagWND *wndPtr);
417 extern void X11DRV_WND_DockWindow(struct tagWND *wndPtr);
418 extern void X11DRV_WND_SetWindowRgn(struct tagWND *wndPtr, HRGN hrgnWnd);
420 extern int X11DRV_EVENT_PrepareShmCompletion( Drawable dw );
421 extern void X11DRV_EVENT_WaitShmCompletion( int compl );
422 extern void X11DRV_EVENT_WaitShmCompletions( Drawable dw );
423 extern void X11DRV_EVENT_WaitReplaceShmCompletion( int *compl, Drawable dw );
425 #endif /* __WINE_X11DRV_H */