2 * X11 driver definitions
4 * Copyright 1996 Alexandre Julliard
5 * Copyright 1999 Patrik Stridvall
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef __WINE_X11DRV_H
23 #define __WINE_X11DRV_H
25 #ifndef __WINE_CONFIG_H
26 # error You must include config.h to use this header
30 #include <X11/Xresource.h>
31 #include <X11/Xutil.h>
32 #include <X11/Xatom.h>
34 # include <X11/extensions/XShm.h>
35 #endif /* defined(HAVE_LIBXXSHM) */
44 #define MAX_PIXELFORMATS 8
47 struct tagCURSORICONINFO
;
61 int type
; /* GEOMETRIC || COSMETIC */
64 /* X physical brush */
74 typedef UINT X_PHYSFONT
;
76 typedef struct tagXRENDERINFO
*XRENDERINFO
;
78 /* X physical device */
82 DC
*dc
; /* direct pointer to DC, should go away */
83 GC gc
; /* X Window GC */
90 int exposures
; /* count of graphics exposures operations */
91 XVisualInfo
*visuals
[MAX_PIXELFORMATS
];
98 /* GCs used for B&W and color bitmap operations */
99 extern GC BITMAP_monoGC
, BITMAP_colorGC
;
101 #define BITMAP_GC(bmp) \
102 (((bmp)->bitmap.bmBitsPixel == 1) ? BITMAP_monoGC : BITMAP_colorGC)
104 extern unsigned int X11DRV_server_startticks
;
106 /* Wine driver X11 functions */
108 extern BOOL
X11DRV_BitBlt( X11DRV_PDEVICE
*physDevDst
, INT xDst
, INT yDst
,
109 INT width
, INT height
, X11DRV_PDEVICE
*physDevSrc
,
110 INT xSrc
, INT ySrc
, DWORD rop
);
111 extern BOOL
X11DRV_EnumDeviceFonts( HDC hdc
, LPLOGFONTW plf
,
112 DEVICEFONTENUMPROC dfeproc
, LPARAM lp
);
113 extern BOOL
X11DRV_GetCharWidth( X11DRV_PDEVICE
*physDev
, UINT firstChar
,
114 UINT lastChar
, LPINT buffer
);
115 extern BOOL
X11DRV_GetDCOrgEx( X11DRV_PDEVICE
*physDev
, LPPOINT lpp
);
116 extern BOOL
X11DRV_GetTextExtentPoint( X11DRV_PDEVICE
*physDev
, LPCWSTR str
,
117 INT count
, LPSIZE size
);
118 extern BOOL
X11DRV_GetTextMetrics(X11DRV_PDEVICE
*physDev
, TEXTMETRICW
*metrics
);
119 extern BOOL
X11DRV_PatBlt( X11DRV_PDEVICE
*physDev
, INT left
, INT top
,
120 INT width
, INT height
, DWORD rop
);
121 extern VOID
X11DRV_SetDeviceClipping(X11DRV_PDEVICE
*physDev
);
122 extern BOOL
X11DRV_StretchBlt( X11DRV_PDEVICE
*physDevDst
, INT xDst
, INT yDst
,
123 INT widthDst
, INT heightDst
,
124 X11DRV_PDEVICE
*physDevSrc
, INT xSrc
, INT ySrc
,
125 INT widthSrc
, INT heightSrc
, DWORD rop
);
126 extern BOOL
X11DRV_LineTo( X11DRV_PDEVICE
*physDev
, INT x
, INT y
);
127 extern BOOL
X11DRV_Arc( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
,
128 INT bottom
, INT xstart
, INT ystart
, INT xend
,
130 extern BOOL
X11DRV_Pie( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
,
131 INT bottom
, INT xstart
, INT ystart
, INT xend
,
133 extern BOOL
X11DRV_Chord( X11DRV_PDEVICE
*physDev
, INT left
, INT top
,
134 INT right
, INT bottom
, INT xstart
,
135 INT ystart
, INT xend
, INT yend
);
136 extern BOOL
X11DRV_Ellipse( X11DRV_PDEVICE
*physDev
, INT left
, INT top
,
137 INT right
, INT bottom
);
138 extern BOOL
X11DRV_Rectangle(X11DRV_PDEVICE
*physDev
, INT left
, INT top
,
139 INT right
, INT bottom
);
140 extern BOOL
X11DRV_RoundRect( X11DRV_PDEVICE
*physDev
, INT left
, INT top
,
141 INT right
, INT bottom
, INT ell_width
,
143 extern COLORREF
X11DRV_SetPixel( X11DRV_PDEVICE
*physDev
, INT x
, INT y
,
145 extern COLORREF
X11DRV_GetPixel( X11DRV_PDEVICE
*physDev
, INT x
, INT y
);
146 extern BOOL
X11DRV_PaintRgn( X11DRV_PDEVICE
*physDev
, HRGN hrgn
);
147 extern BOOL
X11DRV_Polyline( X11DRV_PDEVICE
*physDev
,const POINT
* pt
,INT count
);
148 extern BOOL
X11DRV_Polygon( X11DRV_PDEVICE
*physDev
, const POINT
* pt
, INT count
);
149 extern BOOL
X11DRV_PolyPolygon( X11DRV_PDEVICE
*physDev
, const POINT
* pt
,
150 const INT
* counts
, UINT polygons
);
151 extern BOOL
X11DRV_PolyPolyline( X11DRV_PDEVICE
*physDev
, const POINT
* pt
,
152 const DWORD
* counts
, DWORD polylines
);
154 extern COLORREF
X11DRV_SetBkColor( X11DRV_PDEVICE
*physDev
, COLORREF color
);
155 extern COLORREF
X11DRV_SetTextColor( X11DRV_PDEVICE
*physDev
, COLORREF color
);
156 extern BOOL
X11DRV_ExtFloodFill( X11DRV_PDEVICE
*physDev
, INT x
, INT y
,
157 COLORREF color
, UINT fillType
);
158 extern BOOL
X11DRV_ExtTextOut( X11DRV_PDEVICE
*physDev
, INT x
, INT y
,
159 UINT flags
, const RECT
*lprect
,
160 LPCWSTR str
, UINT count
, const INT
*lpDx
);
161 extern BOOL
X11DRV_CreateBitmap( HBITMAP hbitmap
);
162 extern BOOL
X11DRV_DeleteObject( HGDIOBJ handle
);
163 extern LONG
X11DRV_BitmapBits( HBITMAP hbitmap
, void *bits
, LONG count
,
165 extern INT
X11DRV_SetDIBitsToDevice( X11DRV_PDEVICE
*physDev
, INT xDest
,
166 INT yDest
, DWORD cx
, DWORD cy
,
168 UINT startscan
, UINT lines
,
169 LPCVOID bits
, const BITMAPINFO
*info
,
171 extern INT
X11DRV_DeviceBitmapBits( X11DRV_PDEVICE
*physDev
, HBITMAP hbitmap
,
172 WORD fGet
, UINT startscan
,
173 UINT lines
, LPSTR bits
,
174 LPBITMAPINFO info
, UINT coloruse
);
175 extern BOOL
X11DRV_GetDeviceGammaRamp( X11DRV_PDEVICE
*physDev
, LPVOID ramp
);
176 extern BOOL
X11DRV_SetDeviceGammaRamp( X11DRV_PDEVICE
*physDev
, LPVOID ramp
);
178 /* OpenGL / X11 driver functions */
179 extern int X11DRV_ChoosePixelFormat(DC
*dc
, const PIXELFORMATDESCRIPTOR
*pppfd
) ;
180 extern int X11DRV_DescribePixelFormat(DC
*dc
, int iPixelFormat
, UINT nBytes
, PIXELFORMATDESCRIPTOR
*ppfd
) ;
181 extern int X11DRV_GetPixelFormat(DC
*dc
) ;
182 extern BOOL
X11DRV_SetPixelFormat(DC
*dc
, int iPixelFormat
, const PIXELFORMATDESCRIPTOR
*ppfd
) ;
183 extern BOOL
X11DRV_SwapBuffers(DC
*dc
) ;
185 /* X11 driver internal functions */
187 extern BOOL
X11DRV_BITMAP_Init(void);
188 extern int X11DRV_FONT_Init( int *log_pixels_x
, int *log_pixels_y
);
189 extern BOOL
X11DRV_BITMAP_DeleteObject( HBITMAP hbitmap
);
192 extern XImage
*X11DRV_BITMAP_GetXImage( const struct tagBITMAPOBJ
*bmp
);
193 extern XImage
*X11DRV_DIB_CreateXImage( int width
, int height
, int depth
);
194 extern HBITMAP
X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap
);
195 extern HGLOBAL
X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap
, HDC hdc
, BOOL bDeletePixmap
);
196 extern HBITMAP
X11DRV_BITMAP_CreateBitmapFromPixmap(Pixmap pixmap
, BOOL bDeletePixmap
);
197 extern Pixmap
X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB
, HDC hdc
);
198 extern Pixmap
X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp
, HDC hdc
);
200 extern void X11DRV_SetDrawable( HDC hdc
, Drawable drawable
, int mode
, int org_x
, int org_y
);
201 extern void X11DRV_StartGraphicsExposures( HDC hdc
);
202 extern void X11DRV_EndGraphicsExposures( HDC hdc
, HRGN hrgn
);
204 extern BOOL
X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE
*physDev
, GC gc
, BOOL fMapColors
);
205 extern BOOL
X11DRV_SetupGCForBrush( X11DRV_PDEVICE
*physDev
);
206 extern BOOL
X11DRV_SetupGCForPen( X11DRV_PDEVICE
*physDev
);
207 extern BOOL
X11DRV_SetupGCForText( X11DRV_PDEVICE
*physDev
);
209 extern const int X11DRV_XROPfunction
[];
211 extern void _XInitImageFuncPtrs(XImage
*);
213 extern BOOL X11DRV_XRender_Installed
;
214 extern void X11DRV_XRender_Init(void);
215 extern void X11DRV_XRender_Finalize(void);
216 extern BOOL
X11DRV_XRender_SelectFont(X11DRV_PDEVICE
*, HFONT
);
217 extern void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE
*);
218 extern BOOL
X11DRV_XRender_ExtTextOut(X11DRV_PDEVICE
*physDev
, INT x
, INT y
, UINT flags
,
219 const RECT
*lprect
, LPCWSTR wstr
,
220 UINT count
, const INT
*lpDx
);
221 extern void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE
*physDev
);
223 /* exported dib functions for now */
225 /* Additional info for DIB section objects */
228 /* Windows DIB section */
229 DIBSECTION dibSection
;
232 int status
, p_status
;
242 /* Shared memory segment info */
243 XShmSegmentInfo shminfo
;
246 /* Aux buffer access function */
247 void (*copy_aux
)(void*ctx
, int req
);
250 /* GDI access lock */
251 CRITICAL_SECTION lock
;
255 extern int *X11DRV_DIB_BuildColorMap( X11DRV_PDEVICE
*physDev
, WORD coloruse
,
256 WORD depth
, const BITMAPINFO
*info
,
258 extern INT
X11DRV_CoerceDIBSection(X11DRV_PDEVICE
*physDev
,INT
,BOOL
);
259 extern INT
X11DRV_LockDIBSection(X11DRV_PDEVICE
*physDev
,INT
,BOOL
);
260 extern void X11DRV_UnlockDIBSection(X11DRV_PDEVICE
*physDev
,BOOL
);
261 extern INT
X11DRV_CoerceDIBSection2(HBITMAP bmp
,INT
,BOOL
);
262 extern INT
X11DRV_LockDIBSection2(HBITMAP bmp
,INT
,BOOL
);
263 extern void X11DRV_UnlockDIBSection2(HBITMAP bmp
,BOOL
);
265 extern HBITMAP
X11DRV_DIB_CreateDIBSection(X11DRV_PDEVICE
*physDev
, BITMAPINFO
*bmi
, UINT usage
,
266 LPVOID
*bits
, HANDLE section
, DWORD offset
, DWORD ovr_pitch
);
267 extern void X11DRV_DIB_DeleteDIBSection(struct tagBITMAPOBJ
*bmp
);
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(X11DRV_PDEVICE
*physDevSrc
, X11DRV_PDEVICE
*physDevDst
,
272 DWORD xSrc
, DWORD ySrc
, DWORD xDest
, DWORD yDest
,
273 DWORD width
, DWORD height
);
275 extern INT
X11DRV_DCICommand(INT cbInput
, const struct _DCICMD
*lpCmd
, LPVOID lpOutData
);
277 /**************************************************************************
281 BOOL
X11DRV_GDI_Initialize( Display
*display
);
282 void X11DRV_GDI_Finalize(void);
284 extern Display
*gdi_display
; /* display to use for all GDI functions */
286 /* X11 GDI palette driver */
288 #define X11DRV_PALETTE_FIXED 0x0001 /* read-only colormap - have to use XAllocColor (if not virtual) */
289 #define X11DRV_PALETTE_VIRTUAL 0x0002 /* no mapping needed - pixel == pixel color */
291 #define X11DRV_PALETTE_PRIVATE 0x1000 /* private colormap, identity mapping */
292 #define X11DRV_PALETTE_WHITESET 0x2000
294 extern Colormap X11DRV_PALETTE_PaletteXColormap
;
295 extern UINT16 X11DRV_PALETTE_PaletteFlags
;
297 extern int *X11DRV_PALETTE_PaletteToXPixel
;
298 extern int *X11DRV_PALETTE_XPixelToPalette
;
300 extern int X11DRV_PALETTE_mapEGAPixel
[16];
302 extern int X11DRV_PALETTE_Init(void);
303 extern void X11DRV_PALETTE_Cleanup(void);
305 extern COLORREF
X11DRV_PALETTE_ToLogical(int pixel
);
306 extern int X11DRV_PALETTE_ToPhysical(X11DRV_PDEVICE
*physDev
, COLORREF color
);
308 extern struct tagPALETTE_DRIVER X11DRV_PALETTE_Driver
;
310 extern int X11DRV_PALETTE_SetMapping(struct tagPALETTEOBJ
*palPtr
, UINT uStart
, UINT uNum
, BOOL mapOnly
);
311 extern int X11DRV_PALETTE_UpdateMapping(struct tagPALETTEOBJ
*palPtr
);
312 extern BOOL
X11DRV_PALETTE_IsDark(int pixel
);
316 #define X11DRV_ESCAPE 6789
317 enum x11drv_escape_codes
319 X11DRV_GET_DISPLAY
, /* get X11 display for a DC */
320 X11DRV_GET_DRAWABLE
, /* get current drawable for a DC */
321 X11DRV_GET_FONT
, /* get current X font for a DC */
324 /**************************************************************************
328 struct x11drv_thread_data
332 int process_event_count
; /* recursion count for event processing */
335 extern struct x11drv_thread_data
*x11drv_init_thread_data(void);
337 inline static struct x11drv_thread_data
*x11drv_thread_data(void)
339 struct x11drv_thread_data
*data
= NtCurrentTeb()->driver_data
;
340 if (!data
) data
= x11drv_init_thread_data();
344 inline static Display
*thread_display(void) { return x11drv_thread_data()->display
; }
346 extern Visual
*visual
;
347 extern Window root_window
;
348 extern unsigned int screen_width
;
349 extern unsigned int screen_height
;
350 extern unsigned int screen_depth
;
352 extern Atom wmProtocols
;
353 extern Atom wmDeleteWindow
;
354 extern Atom wmTakeFocus
;
355 extern Atom dndProtocol
;
356 extern Atom dndSelection
;
357 extern Atom wmChangeState
;
358 extern Atom kwmDockWindow
;
359 extern Atom _kde_net_wm_system_tray_window_for
;
361 /* X11 clipboard driver */
363 extern void X11DRV_CLIPBOARD_FreeResources( Atom property
);
364 extern BOOL
X11DRV_CLIPBOARD_RegisterPixmapResource( Atom property
, Pixmap pixmap
);
365 extern BOOL
X11DRV_CLIPBOARD_IsNativeProperty(Atom prop
);
366 extern UINT
X11DRV_CLIPBOARD_MapPropertyToFormat(char *itemFmtName
);
367 extern Atom
X11DRV_CLIPBOARD_MapFormatToProperty(UINT id
);
368 extern void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType
, Window w
, HWND hwnd
);
369 extern BOOL
X11DRV_IsSelectionOwner(void);
370 extern BOOL
X11DRV_GetClipboardData(UINT wFormat
);
372 /* X11 event driver */
375 X11DRV_INPUT_RELATIVE
,
376 X11DRV_INPUT_ABSOLUTE
378 extern INPUT_TYPE
X11DRV_EVENT_SetInputMethod(INPUT_TYPE type
);
380 #ifdef HAVE_LIBXXF86DGA2
381 void X11DRV_EVENT_SetDGAStatus(HWND hwnd
, int event_base
) ;
384 /* x11drv private window data */
385 struct x11drv_win_data
387 Window whole_window
; /* X window for the complete window */
388 Window client_window
; /* X window for the client area */
389 Window icon_window
; /* X window for the icon */
390 RECT whole_rect
; /* X window rectangle for the whole window relative to parent */
391 RECT client_rect
; /* client area relative to whole window */
392 HBITMAP hWMIconBitmap
;
396 typedef struct x11drv_win_data X11DRV_WND_DATA
;
398 extern Window
X11DRV_get_client_window( HWND hwnd
);
399 extern Window
X11DRV_get_whole_window( HWND hwnd
);
401 inline static Window
get_client_window( WND
*wnd
)
403 struct x11drv_win_data
*data
= wnd
->pDriverData
;
404 return data
->client_window
;
407 inline static Window
get_whole_window( WND
*wnd
)
409 struct x11drv_win_data
*data
= wnd
->pDriverData
;
410 return data
->whole_window
;
413 extern void X11DRV_SetFocus( HWND hwnd
);
414 extern Cursor
X11DRV_GetCursor( Display
*display
, struct tagCURSORICONINFO
*ptr
);
416 extern void X11DRV_expect_error( unsigned char request
, unsigned char error
, XID id
);
417 extern int X11DRV_check_error(void);
418 extern void X11DRV_register_window( Display
*display
, HWND hwnd
, struct x11drv_win_data
*data
);
419 extern void X11DRV_set_iconic_state( WND
*win
);
420 extern void X11DRV_window_to_X_rect( WND
*win
, RECT
*rect
);
421 extern void X11DRV_X_to_window_rect( WND
*win
, RECT
*rect
);
422 extern void X11DRV_create_desktop_thread(void);
423 extern Window
X11DRV_create_desktop( XVisualInfo
*desktop_vi
, const char *geometry
);
424 extern int X11DRV_sync_whole_window_position( Display
*display
, WND
*win
, int zorder
);
425 extern int X11DRV_sync_client_window_position( Display
*display
, WND
*win
);
427 #endif /* __WINE_X11DRV_H */