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 */
85 POINT org
; /* DC origin relative to drawable */
86 POINT drawable_org
; /* Origin of drawable relative to screen */
92 int exposures
; /* count of graphics exposures operations */
93 XVisualInfo
*visuals
[MAX_PIXELFORMATS
];
100 /* GCs used for B&W and color bitmap operations */
101 extern GC BITMAP_monoGC
, BITMAP_colorGC
;
102 extern Pixmap BITMAP_stock_pixmap
; /* pixmap for the default stock bitmap */
104 #define BITMAP_GC(bmp) \
105 (((bmp)->bitmap.bmBitsPixel == 1) ? BITMAP_monoGC : BITMAP_colorGC)
107 extern unsigned int X11DRV_server_startticks
;
109 /* Wine driver X11 functions */
111 extern BOOL
X11DRV_BitBlt( X11DRV_PDEVICE
*physDevDst
, INT xDst
, INT yDst
,
112 INT width
, INT height
, X11DRV_PDEVICE
*physDevSrc
,
113 INT xSrc
, INT ySrc
, DWORD rop
);
114 extern BOOL
X11DRV_EnumDeviceFonts( X11DRV_PDEVICE
*physDev
, LPLOGFONTW plf
,
115 DEVICEFONTENUMPROC dfeproc
, LPARAM lp
);
116 extern LONG
X11DRV_GetBitmapBits( HBITMAP hbitmap
, void *bits
, LONG count
);
117 extern BOOL
X11DRV_GetCharWidth( X11DRV_PDEVICE
*physDev
, UINT firstChar
,
118 UINT lastChar
, LPINT buffer
);
119 extern BOOL
X11DRV_GetDCOrgEx( X11DRV_PDEVICE
*physDev
, LPPOINT lpp
);
120 extern BOOL
X11DRV_GetTextExtentPoint( X11DRV_PDEVICE
*physDev
, LPCWSTR str
,
121 INT count
, LPSIZE size
);
122 extern BOOL
X11DRV_GetTextMetrics(X11DRV_PDEVICE
*physDev
, TEXTMETRICW
*metrics
);
123 extern BOOL
X11DRV_PatBlt( X11DRV_PDEVICE
*physDev
, INT left
, INT top
,
124 INT width
, INT height
, DWORD rop
);
125 extern BOOL
X11DRV_StretchBlt( X11DRV_PDEVICE
*physDevDst
, INT xDst
, INT yDst
,
126 INT widthDst
, INT heightDst
,
127 X11DRV_PDEVICE
*physDevSrc
, INT xSrc
, INT ySrc
,
128 INT widthSrc
, INT heightSrc
, DWORD rop
);
129 extern BOOL
X11DRV_LineTo( X11DRV_PDEVICE
*physDev
, INT x
, INT y
);
130 extern BOOL
X11DRV_Arc( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
,
131 INT bottom
, INT xstart
, INT ystart
, INT xend
,
133 extern BOOL
X11DRV_Pie( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
,
134 INT bottom
, INT xstart
, INT ystart
, INT xend
,
136 extern BOOL
X11DRV_Chord( X11DRV_PDEVICE
*physDev
, INT left
, INT top
,
137 INT right
, INT bottom
, INT xstart
,
138 INT ystart
, INT xend
, INT yend
);
139 extern BOOL
X11DRV_Ellipse( X11DRV_PDEVICE
*physDev
, INT left
, INT top
,
140 INT right
, INT bottom
);
141 extern BOOL
X11DRV_Rectangle(X11DRV_PDEVICE
*physDev
, INT left
, INT top
,
142 INT right
, INT bottom
);
143 extern BOOL
X11DRV_RoundRect( X11DRV_PDEVICE
*physDev
, INT left
, INT top
,
144 INT right
, INT bottom
, INT ell_width
,
146 extern COLORREF
X11DRV_SetPixel( X11DRV_PDEVICE
*physDev
, INT x
, INT y
,
148 extern COLORREF
X11DRV_GetPixel( X11DRV_PDEVICE
*physDev
, INT x
, INT y
);
149 extern BOOL
X11DRV_PaintRgn( X11DRV_PDEVICE
*physDev
, HRGN hrgn
);
150 extern BOOL
X11DRV_Polyline( X11DRV_PDEVICE
*physDev
,const POINT
* pt
,INT count
);
151 extern BOOL
X11DRV_Polygon( X11DRV_PDEVICE
*physDev
, const POINT
* pt
, INT count
);
152 extern BOOL
X11DRV_PolyPolygon( X11DRV_PDEVICE
*physDev
, const POINT
* pt
,
153 const INT
* counts
, UINT polygons
);
154 extern BOOL
X11DRV_PolyPolyline( X11DRV_PDEVICE
*physDev
, const POINT
* pt
,
155 const DWORD
* counts
, DWORD polylines
);
157 extern COLORREF
X11DRV_SetBkColor( X11DRV_PDEVICE
*physDev
, COLORREF color
);
158 extern COLORREF
X11DRV_SetTextColor( X11DRV_PDEVICE
*physDev
, COLORREF color
);
159 extern BOOL
X11DRV_ExtFloodFill( X11DRV_PDEVICE
*physDev
, INT x
, INT y
,
160 COLORREF color
, UINT fillType
);
161 extern BOOL
X11DRV_ExtTextOut( X11DRV_PDEVICE
*physDev
, INT x
, INT y
,
162 UINT flags
, const RECT
*lprect
,
163 LPCWSTR str
, UINT count
, const INT
*lpDx
);
164 extern LONG
X11DRV_SetBitmapBits( HBITMAP hbitmap
, const 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 BOOL
X11DRV_GetDeviceGammaRamp( X11DRV_PDEVICE
*physDev
, LPVOID ramp
);
172 extern BOOL
X11DRV_SetDeviceGammaRamp( X11DRV_PDEVICE
*physDev
, LPVOID ramp
);
174 /* OpenGL / X11 driver functions */
175 extern int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE
*physDev
,
176 const PIXELFORMATDESCRIPTOR
*pppfd
);
177 extern int X11DRV_DescribePixelFormat(X11DRV_PDEVICE
*physDev
,
178 int iPixelFormat
, UINT nBytes
,
179 PIXELFORMATDESCRIPTOR
*ppfd
);
180 extern int X11DRV_GetPixelFormat(X11DRV_PDEVICE
*physDev
);
181 extern BOOL
X11DRV_SwapBuffers(X11DRV_PDEVICE
*physDev
);
183 /* X11 driver internal functions */
185 extern BOOL
X11DRV_BITMAP_Init(void);
186 extern void X11DRV_FONT_Init( int *log_pixels_x
, int *log_pixels_y
);
189 extern XImage
*X11DRV_BITMAP_GetXImage( const struct tagBITMAPOBJ
*bmp
);
190 extern XImage
*X11DRV_DIB_CreateXImage( int width
, int height
, int depth
);
191 extern HBITMAP
X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap
);
192 extern HGLOBAL
X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap
, HDC hdc
, BOOL bDeletePixmap
);
193 extern HBITMAP
X11DRV_BITMAP_CreateBitmapFromPixmap(Pixmap pixmap
, BOOL bDeletePixmap
);
194 extern Pixmap
X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB
, HDC hdc
);
195 extern Pixmap
X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp
, HDC hdc
);
197 extern RGNDATA
*X11DRV_GetRegionData( HRGN hrgn
, HDC hdc_lptodp
);
198 extern void X11DRV_SetDrawable( HDC hdc
, Drawable drawable
, int mode
, const POINT
*org
,
199 const POINT
*drawable_org
);
200 extern void X11DRV_StartGraphicsExposures( HDC hdc
);
201 extern void X11DRV_EndGraphicsExposures( HDC hdc
, HRGN hrgn
);
203 extern BOOL
X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE
*physDev
, GC gc
, BOOL fMapColors
);
204 extern BOOL
X11DRV_SetupGCForBrush( X11DRV_PDEVICE
*physDev
);
205 extern BOOL
X11DRV_SetupGCForPen( X11DRV_PDEVICE
*physDev
);
206 extern BOOL
X11DRV_SetupGCForText( X11DRV_PDEVICE
*physDev
);
208 extern const int X11DRV_XROPfunction
[];
210 extern void _XInitImageFuncPtrs(XImage
*);
212 extern BOOL X11DRV_XRender_Installed
;
213 extern void X11DRV_XRender_Init(void);
214 extern void X11DRV_XRender_Finalize(void);
215 extern BOOL
X11DRV_XRender_SelectFont(X11DRV_PDEVICE
*, HFONT
);
216 extern void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE
*);
217 extern BOOL
X11DRV_XRender_ExtTextOut(X11DRV_PDEVICE
*physDev
, INT x
, INT y
, UINT flags
,
218 const RECT
*lprect
, LPCWSTR wstr
,
219 UINT count
, const INT
*lpDx
);
220 extern void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE
*physDev
);
222 /* exported dib functions for now */
224 /* Additional info for DIB section objects */
227 /* Windows DIB section */
228 DIBSECTION dibSection
;
231 int status
, p_status
;
241 /* Shared memory segment info */
242 XShmSegmentInfo shminfo
;
245 /* Aux buffer access function */
246 void (*copy_aux
)(void*ctx
, int req
);
249 /* GDI access lock */
250 CRITICAL_SECTION lock
;
254 extern int *X11DRV_DIB_BuildColorMap( X11DRV_PDEVICE
*physDev
, WORD coloruse
,
255 WORD depth
, const BITMAPINFO
*info
,
257 extern INT
X11DRV_CoerceDIBSection(X11DRV_PDEVICE
*physDev
,INT
,BOOL
);
258 extern INT
X11DRV_LockDIBSection(X11DRV_PDEVICE
*physDev
,INT
,BOOL
);
259 extern void X11DRV_UnlockDIBSection(X11DRV_PDEVICE
*physDev
,BOOL
);
260 extern INT
X11DRV_CoerceDIBSection2(HBITMAP bmp
,INT
,BOOL
);
261 extern INT
X11DRV_LockDIBSection2(HBITMAP bmp
,INT
,BOOL
);
262 extern void X11DRV_UnlockDIBSection2(HBITMAP bmp
,BOOL
);
264 extern HBITMAP
X11DRV_DIB_CreateDIBSection(X11DRV_PDEVICE
*physDev
, BITMAPINFO
*bmi
, UINT usage
,
265 LPVOID
*bits
, HANDLE section
, DWORD offset
, DWORD ovr_pitch
);
266 extern void X11DRV_DIB_DeleteDIBSection(struct tagBITMAPOBJ
*bmp
);
267 extern INT
X11DRV_DIB_Coerce(struct tagBITMAPOBJ
*,INT
,BOOL
);
268 extern INT
X11DRV_DIB_Lock(struct tagBITMAPOBJ
*,INT
,BOOL
);
269 extern void X11DRV_DIB_Unlock(struct tagBITMAPOBJ
*,BOOL
);
270 void X11DRV_DIB_CopyDIBSection(X11DRV_PDEVICE
*physDevSrc
, X11DRV_PDEVICE
*physDevDst
,
271 DWORD xSrc
, DWORD ySrc
, DWORD xDest
, DWORD yDest
,
272 DWORD width
, DWORD height
);
274 extern INT
X11DRV_DCICommand(INT cbInput
, const struct _DCICMD
*lpCmd
, LPVOID lpOutData
);
276 /**************************************************************************
280 BOOL
X11DRV_GDI_Initialize( Display
*display
);
281 void X11DRV_GDI_Finalize(void);
283 extern Display
*gdi_display
; /* display to use for all GDI functions */
285 /* X11 GDI palette driver */
287 #define X11DRV_PALETTE_FIXED 0x0001 /* read-only colormap - have to use XAllocColor (if not virtual) */
288 #define X11DRV_PALETTE_VIRTUAL 0x0002 /* no mapping needed - pixel == pixel color */
290 #define X11DRV_PALETTE_PRIVATE 0x1000 /* private colormap, identity mapping */
291 #define X11DRV_PALETTE_WHITESET 0x2000
293 extern Colormap X11DRV_PALETTE_PaletteXColormap
;
294 extern UINT16 X11DRV_PALETTE_PaletteFlags
;
296 extern int *X11DRV_PALETTE_PaletteToXPixel
;
297 extern int *X11DRV_PALETTE_XPixelToPalette
;
299 extern int X11DRV_PALETTE_mapEGAPixel
[16];
301 extern int X11DRV_PALETTE_Init(void);
302 extern void X11DRV_PALETTE_Cleanup(void);
303 extern BOOL
X11DRV_IsSolidColor(COLORREF color
);
305 extern COLORREF
X11DRV_PALETTE_ToLogical(int pixel
);
306 extern int X11DRV_PALETTE_ToPhysical(X11DRV_PDEVICE
*physDev
, COLORREF color
);
310 #define X11DRV_ESCAPE 6789
311 enum x11drv_escape_codes
313 X11DRV_GET_DISPLAY
, /* get X11 display for a DC */
314 X11DRV_GET_DRAWABLE
, /* get current drawable for a DC */
315 X11DRV_GET_FONT
, /* get current X font for a DC */
318 /**************************************************************************
322 struct x11drv_thread_data
326 int process_event_count
; /* recursion count for event processing */
327 Cursor cursor
; /* current cursor */
328 Window cursor_window
; /* current window that contains the cursor */
331 extern struct x11drv_thread_data
*x11drv_init_thread_data(void);
333 inline static struct x11drv_thread_data
*x11drv_thread_data(void)
335 struct x11drv_thread_data
*data
= NtCurrentTeb()->driver_data
;
336 if (!data
) data
= x11drv_init_thread_data();
340 inline static Display
*thread_display(void) { return x11drv_thread_data()->display
; }
342 extern Visual
*visual
;
343 extern Window root_window
;
344 extern unsigned int screen_width
;
345 extern unsigned int screen_height
;
346 extern unsigned int screen_depth
;
347 extern unsigned int text_caps
;
348 extern int managed_mode
;
350 extern Atom wmProtocols
;
351 extern Atom wmDeleteWindow
;
352 extern Atom wmTakeFocus
;
353 extern Atom dndProtocol
;
354 extern Atom dndSelection
;
355 extern Atom wmChangeState
;
356 extern Atom kwmDockWindow
;
357 extern Atom _kde_net_wm_system_tray_window_for
;
359 /* X11 clipboard driver */
361 extern void X11DRV_CLIPBOARD_FreeResources( Atom property
);
362 extern BOOL
X11DRV_CLIPBOARD_RegisterPixmapResource( Atom property
, Pixmap pixmap
);
363 extern BOOL
X11DRV_CLIPBOARD_IsNativeProperty(Atom prop
);
364 extern UINT
X11DRV_CLIPBOARD_MapPropertyToFormat(char *itemFmtName
);
365 extern Atom
X11DRV_CLIPBOARD_MapFormatToProperty(UINT id
);
366 extern void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType
, Window w
, HWND hwnd
);
367 extern BOOL
X11DRV_IsSelectionOwner(void);
368 extern BOOL
X11DRV_GetClipboardData(UINT wFormat
);
370 /* X11 event driver */
373 X11DRV_INPUT_RELATIVE
,
374 X11DRV_INPUT_ABSOLUTE
376 extern INPUT_TYPE
X11DRV_EVENT_SetInputMethod(INPUT_TYPE type
);
378 #ifdef HAVE_LIBXXF86DGA2
379 void X11DRV_EVENT_SetDGAStatus(HWND hwnd
, int event_base
) ;
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
;
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
);
399 inline static Window
get_client_window( WND
*wnd
)
401 struct x11drv_win_data
*data
= wnd
->pDriverData
;
402 return data
->client_window
;
405 inline static Window
get_whole_window( WND
*wnd
)
407 struct x11drv_win_data
*data
= wnd
->pDriverData
;
408 return data
->whole_window
;
411 extern void X11DRV_SetFocus( HWND hwnd
);
412 extern Cursor
X11DRV_GetCursor( Display
*display
, struct tagCURSORICONINFO
*ptr
);
414 typedef int (*x11drv_error_callback
)( Display
*display
, XErrorEvent
*event
, void *arg
);
416 extern void X11DRV_expect_error( Display
*display
, x11drv_error_callback callback
, void *arg
);
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 */