x11drv.h 30 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1
/*
2
 * X11 driver definitions
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * Copyright 1996 Alexandre Julliard
 * Copyright 1999 Patrik Stridvall
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
Alexandre Julliard's avatar
Alexandre Julliard committed
20 21 22 23 24
 */

#ifndef __WINE_X11DRV_H
#define __WINE_X11DRV_H

25 26 27
#ifndef __WINE_CONFIG_H
# error You must include config.h to use this header
#endif
28

29
#include <stdarg.h>
30 31 32 33
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
34 35 36
#ifdef HAVE_LIBXXSHM
# include <X11/extensions/XShm.h>
#endif /* defined(HAVE_LIBXXSHM) */
37 38 39

#undef Status  /* avoid conflict with wintrnl.h */
typedef int Status;
40

41
#include "windef.h"
42
#include "winbase.h"
43
#include "win.h"
44
#include "ddrawi.h"
45
#include "thread.h"
46

Lionel Ulmer's avatar
Lionel Ulmer committed
47
#define MAX_PIXELFORMATS 8
Karl Lessard's avatar
Karl Lessard committed
48

49 50
struct tagBITMAPOBJ;
struct tagCURSORICONINFO;
Alexandre Julliard's avatar
Alexandre Julliard committed
51

52 53 54
extern void wine_tsx11_lock(void);
extern void wine_tsx11_unlock(void);

Alexandre Julliard's avatar
Alexandre Julliard committed
55 56 57 58
  /* X physical pen */
typedef struct
{
    int          style;
Alexandre Julliard's avatar
Alexandre Julliard committed
59 60
    int          endcap;
    int          linejoin;
Alexandre Julliard's avatar
Alexandre Julliard committed
61 62 63 64
    int          pixel;
    int          width;
    char *       dashes;
    int          dash_len;
Alexandre Julliard's avatar
Alexandre Julliard committed
65
    int          type;          /* GEOMETRIC || COSMETIC */
Alexandre Julliard's avatar
Alexandre Julliard committed
66 67 68 69 70 71 72 73 74 75 76 77
} X_PHYSPEN;

  /* X physical brush */
typedef struct
{
    int          style;
    int          fillStyle;
    int          pixel;
    Pixmap       pixmap;
} X_PHYSBRUSH;

  /* X physical font */
78
typedef UINT	 X_PHYSFONT;
Alexandre Julliard's avatar
Alexandre Julliard committed
79

80 81
typedef struct tagXRENDERINFO *XRENDERINFO;

Alexandre Julliard's avatar
Alexandre Julliard committed
82 83 84
  /* X physical device */
typedef struct
{
85
    HDC           hdc;
Alexandre Julliard's avatar
Alexandre Julliard committed
86 87
    GC            gc;          /* X Window GC */
    Drawable      drawable;
88 89
    POINT         org;          /* DC origin relative to drawable */
    POINT         drawable_org; /* Origin of drawable relative to screen */
90
    HRGN          region;       /* Device region (visible region & clip region) */
Alexandre Julliard's avatar
Alexandre Julliard committed
91 92 93
    X_PHYSFONT    font;
    X_PHYSPEN     pen;
    X_PHYSBRUSH   brush;
94
    BOOL          has_gdi_font; /* is current font a GDI font? */
Alexandre Julliard's avatar
Alexandre Julliard committed
95 96
    int           backgroundPixel;
    int           textPixel;
97
    int           depth;       /* bit depth of the DC */
98
    int           exposures;   /* count of graphics exposures operations */
Lionel Ulmer's avatar
Lionel Ulmer committed
99 100 101
    XVisualInfo  *visuals[MAX_PIXELFORMATS];
    int           used_visuals;
    int           current_pf;
102
    XRENDERINFO   xrender;
Alexandre Julliard's avatar
Alexandre Julliard committed
103 104
} X11DRV_PDEVICE;

105 106 107

  /* GCs used for B&W and color bitmap operations */
extern GC BITMAP_monoGC, BITMAP_colorGC;
108
extern Pixmap BITMAP_stock_pixmap;   /* pixmap for the default stock bitmap */
109 110 111 112

#define BITMAP_GC(bmp) \
  (((bmp)->bitmap.bmBitsPixel == 1) ? BITMAP_monoGC : BITMAP_colorGC)

113 114
extern unsigned int X11DRV_server_startticks;

Alexandre Julliard's avatar
Alexandre Julliard committed
115 116
/* Wine driver X11 functions */

117 118 119
extern BOOL X11DRV_AlphaBlend( X11DRV_PDEVICE *physDevDst, INT xDst, INT yDst,
                               INT widthDst, INT heightDst,
                               X11DRV_PDEVICE *physDevSrc, INT xSrc, INT ySrc,
120
                               INT widthSrc, INT heightSrc, BLENDFUNCTION blendfn );
121 122
extern BOOL X11DRV_BitBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT yDst,
                             INT width, INT height, X11DRV_PDEVICE *physDevSrc,
123
                             INT xSrc, INT ySrc, DWORD rop );
124
extern BOOL X11DRV_EnumDeviceFonts( X11DRV_PDEVICE *physDev, LPLOGFONTW plf,
125
                                    FONTENUMPROCW dfeproc, LPARAM lp );
126
extern LONG X11DRV_GetBitmapBits( HBITMAP hbitmap, void *bits, LONG count );
127
extern BOOL X11DRV_GetCharWidth( X11DRV_PDEVICE *physDev, UINT firstChar,
128
                                   UINT lastChar, LPINT buffer );
129 130
extern BOOL X11DRV_GetDCOrgEx( X11DRV_PDEVICE *physDev, LPPOINT lpp );
extern BOOL X11DRV_GetTextExtentPoint( X11DRV_PDEVICE *physDev, LPCWSTR str,
131
                                         INT count, LPSIZE size );
132 133
extern BOOL X11DRV_GetTextMetrics(X11DRV_PDEVICE *physDev, TEXTMETRICW *metrics);
extern BOOL X11DRV_PatBlt( X11DRV_PDEVICE *physDev, INT left, INT top,
134
                             INT width, INT height, DWORD rop );
135
extern BOOL X11DRV_StretchBlt( X11DRV_PDEVICE *physDevDst, INT xDst, INT yDst,
136
                                 INT widthDst, INT heightDst,
137
                                 X11DRV_PDEVICE *physDevSrc, INT xSrc, INT ySrc,
138
                                 INT widthSrc, INT heightSrc, DWORD rop );
139 140
extern BOOL X11DRV_LineTo( X11DRV_PDEVICE *physDev, INT x, INT y);
extern BOOL X11DRV_Arc( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
141 142
			  INT bottom, INT xstart, INT ystart, INT xend,
			  INT yend );
143
extern BOOL X11DRV_Pie( X11DRV_PDEVICE *physDev, INT left, INT top, INT right,
144 145
			  INT bottom, INT xstart, INT ystart, INT xend,
			  INT yend );
146
extern BOOL X11DRV_Chord( X11DRV_PDEVICE *physDev, INT left, INT top,
147 148
			    INT right, INT bottom, INT xstart,
			    INT ystart, INT xend, INT yend );
149
extern BOOL X11DRV_Ellipse( X11DRV_PDEVICE *physDev, INT left, INT top,
150
			      INT right, INT bottom );
151
extern BOOL X11DRV_Rectangle(X11DRV_PDEVICE *physDev, INT left, INT top,
152
			      INT right, INT bottom);
153
extern BOOL X11DRV_RoundRect( X11DRV_PDEVICE *physDev, INT left, INT top,
154 155
				INT right, INT bottom, INT ell_width,
				INT ell_height );
156
extern COLORREF X11DRV_SetPixel( X11DRV_PDEVICE *physDev, INT x, INT y,
Alexandre Julliard's avatar
Alexandre Julliard committed
157
				 COLORREF color );
158 159 160 161
extern COLORREF X11DRV_GetPixel( X11DRV_PDEVICE *physDev, INT x, INT y);
extern BOOL X11DRV_PaintRgn( X11DRV_PDEVICE *physDev, HRGN hrgn );
extern BOOL X11DRV_Polyline( X11DRV_PDEVICE *physDev,const POINT* pt,INT count);
extern BOOL X11DRV_Polygon( X11DRV_PDEVICE *physDev, const POINT* pt, INT count );
162
extern BOOL X11DRV_PolyPolygon( X11DRV_PDEVICE *physDev, const POINT* pt,
163
				  const INT* counts, UINT polygons);
164
extern BOOL X11DRV_PolyPolyline( X11DRV_PDEVICE *physDev, const POINT* pt,
165
				  const DWORD* counts, DWORD polylines);
Alexandre Julliard's avatar
Alexandre Julliard committed
166

167 168 169
extern COLORREF X11DRV_SetBkColor( X11DRV_PDEVICE *physDev, COLORREF color );
extern COLORREF X11DRV_SetTextColor( X11DRV_PDEVICE *physDev, COLORREF color );
extern BOOL X11DRV_ExtFloodFill( X11DRV_PDEVICE *physDev, INT x, INT y,
170
				   COLORREF color, UINT fillType );
171
extern BOOL X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y,
172
				 UINT flags, const RECT *lprect,
173
				 LPCWSTR str, UINT count, const INT *lpDx, INT breakExtra );
174
extern LONG X11DRV_SetBitmapBits( HBITMAP hbitmap, const void *bits, LONG count );
175
extern void X11DRV_SetDeviceClipping( X11DRV_PDEVICE *physDev, HRGN vis_rgn, HRGN clip_rgn );
176
extern INT X11DRV_SetDIBitsToDevice( X11DRV_PDEVICE *physDev, INT xDest,
177 178 179
				       INT yDest, DWORD cx, DWORD cy,
				       INT xSrc, INT ySrc,
				       UINT startscan, UINT lines,
180
				       LPCVOID bits, const BITMAPINFO *info,
181
				       UINT coloruse );
182 183
extern BOOL X11DRV_GetDeviceGammaRamp( X11DRV_PDEVICE *physDev, LPVOID ramp );
extern BOOL X11DRV_SetDeviceGammaRamp( X11DRV_PDEVICE *physDev, LPVOID ramp );
184

Lionel Ulmer's avatar
Lionel Ulmer committed
185
/* OpenGL / X11 driver functions */
186 187
extern int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
		                      const PIXELFORMATDESCRIPTOR *pppfd);
188
extern int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
189 190 191 192
		                        int iPixelFormat, UINT nBytes,
					PIXELFORMATDESCRIPTOR *ppfd);
extern int X11DRV_GetPixelFormat(X11DRV_PDEVICE *physDev);
extern BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev);
Lionel Ulmer's avatar
Lionel Ulmer committed
193

Alexandre Julliard's avatar
Alexandre Julliard committed
194 195
/* X11 driver internal functions */

196
extern void X11DRV_BITMAP_Init(void);
197
extern void X11DRV_FONT_Init( int log_pixels_x, int log_pixels_y );
Alexandre Julliard's avatar
Alexandre Julliard committed
198

199
extern int X11DRV_DIB_BitmapInfoSize( const BITMAPINFO * info, WORD coloruse );
200
extern XImage *X11DRV_BITMAP_GetXImage( const struct tagBITMAPOBJ *bmp );
201
extern XImage *X11DRV_DIB_CreateXImage( int width, int height, int depth );
202
extern HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(HDC hdc, Pixmap pixmap);
203
extern HGLOBAL X11DRV_DIB_CreateDIBFromBitmap(HDC hdc, HBITMAP hBmp);
204 205
extern HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixmap);
extern Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc );
206

207
extern RGNDATA *X11DRV_GetRegionData( HRGN hrgn, HDC hdc_lptodp );
208

209 210 211 212
extern BOOL X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE *physDev, GC gc, BOOL fMapColors );
extern BOOL X11DRV_SetupGCForBrush( X11DRV_PDEVICE *physDev );
extern BOOL X11DRV_SetupGCForPen( X11DRV_PDEVICE *physDev );
extern BOOL X11DRV_SetupGCForText( X11DRV_PDEVICE *physDev );
213 214
extern INT X11DRV_XWStoDS( X11DRV_PDEVICE *physDev, INT width );
extern INT X11DRV_YWStoDS( X11DRV_PDEVICE *physDev, INT height );
215 216 217

extern const int X11DRV_XROPfunction[];

Alexandre Julliard's avatar
Alexandre Julliard committed
218 219
extern void _XInitImageFuncPtrs(XImage *);

220 221 222 223 224
extern int client_side_with_core;
extern int client_side_with_render;
extern int client_side_antialias_with_core;
extern int client_side_antialias_with_render;
extern int using_client_side_fonts;
225
extern int using_wine_desktop;
226 227
extern void X11DRV_XRender_Init(void);
extern void X11DRV_XRender_Finalize(void);
228 229 230
extern BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE*, HFONT);
extern void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE*);
extern BOOL X11DRV_XRender_ExtTextOut(X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
231
				      const RECT *lprect, LPCWSTR wstr,
232
				      UINT count, const INT *lpDx, INT breakExtra);
233
extern void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev);
234

235 236 237
extern void X11DRV_OpenGL_Init(Display *display);
extern XVisualInfo *X11DRV_setup_opengl_visual(Display *display);

238 239 240 241 242
/* XIM support */
extern XIC X11DRV_CreateIC(XIM xim, Display *display, Window win);
extern XIM X11DRV_SetupXIM(Display *display, const char *input_style);
extern void X11DRV_XIMLookupChars( const char *str, DWORD count );

243 244
extern int X11DRV_XDND_Event(HWND hWnd, XClientMessageEvent *event);

245 246
/* exported dib functions for now */

247 248 249 250 251 252 253
/* Additional info for DIB section objects */
typedef struct
{
    /* Windows DIB section */
    DIBSECTION  dibSection;

    /* Mapping status */
254
    int         status, p_status;
255 256 257 258 259

    /* Color map info */
    int         nColorMap;
    int        *colorMap;

260 261 262 263
    /* Original dib color table converted to
       rgb values if usage was DIB_PAL_COLORS */
    RGBQUAD    *colorTable;

264 265 266
    /* Cached XImage */
    XImage     *image;

267
#ifdef HAVE_LIBXXSHM
Karl Lessard's avatar
Karl Lessard committed
268 269
    /* Shared memory segment info */
    XShmSegmentInfo shminfo;
270
#endif
Karl Lessard's avatar
Karl Lessard committed
271

272 273 274 275 276 277 278
    /* Aux buffer access function */
    void (*copy_aux)(void*ctx, int req);
    void *aux_ctx;

    /* GDI access lock */
    CRITICAL_SECTION lock;

279 280
} X11DRV_DIBSECTION;

281 282 283
/* DIB Section sync state */
enum { DIB_Status_None, DIB_Status_InSync, DIB_Status_GdiMod, DIB_Status_AppMod, DIB_Status_AuxMod };

284
extern int *X11DRV_DIB_BuildColorMap( X11DRV_PDEVICE *physDev, WORD coloruse,
285 286
				      WORD depth, const BITMAPINFO *info,
				      int *nColors );
287 288 289
extern INT X11DRV_CoerceDIBSection(X11DRV_PDEVICE *physDev,INT,BOOL);
extern INT X11DRV_LockDIBSection(X11DRV_PDEVICE *physDev,INT,BOOL);
extern void X11DRV_UnlockDIBSection(X11DRV_PDEVICE *physDev,BOOL);
290
extern INT X11DRV_CoerceDIBSection2(HBITMAP bmp,INT,BOOL);
291 292
extern INT X11DRV_LockDIBSection2(HBITMAP bmp,INT,BOOL);
extern void X11DRV_UnlockDIBSection2(HBITMAP bmp,BOOL);
293

294 295
extern HBITMAP X11DRV_DIB_CreateDIBSection(X11DRV_PDEVICE *physDev, const BITMAPINFO *bmi, UINT usage,
                                           VOID **bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
296
extern void X11DRV_DIB_DeleteDIBSection(struct tagBITMAPOBJ *bmp);
297 298 299
extern INT X11DRV_DIB_Coerce(struct tagBITMAPOBJ *,INT,BOOL);
extern INT X11DRV_DIB_Lock(struct tagBITMAPOBJ *,INT,BOOL);
extern void X11DRV_DIB_Unlock(struct tagBITMAPOBJ *,BOOL);
300 301 302
void X11DRV_DIB_CopyDIBSection(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physDevDst,
                               DWORD xSrc, DWORD ySrc, DWORD xDest, DWORD yDest,
                               DWORD width, DWORD height);
303 304
struct _DCICMD;
extern INT X11DRV_DCICommand(INT cbInput, const struct _DCICMD *lpCmd, LPVOID lpOutData);
305

306 307 308 309
/**************************************************************************
 * X11 GDI driver
 */

310 311
extern void X11DRV_GDI_Initialize( Display *display );
extern void X11DRV_GDI_Finalize(void);
312

313 314
extern Display *gdi_display;  /* display to use for all GDI functions */

315 316
/* X11 GDI palette driver */

317
#define X11DRV_PALETTE_FIXED    0x0001 /* read-only colormap - have to use XAllocColor (if not virtual) */
318 319 320 321 322 323 324 325 326 327 328 329 330
#define X11DRV_PALETTE_VIRTUAL  0x0002 /* no mapping needed - pixel == pixel color */

#define X11DRV_PALETTE_PRIVATE  0x1000 /* private colormap, identity mapping */
#define X11DRV_PALETTE_WHITESET 0x2000

extern Colormap X11DRV_PALETTE_PaletteXColormap;
extern UINT16 X11DRV_PALETTE_PaletteFlags;

extern int *X11DRV_PALETTE_PaletteToXPixel;
extern int *X11DRV_PALETTE_XPixelToPalette;

extern int X11DRV_PALETTE_mapEGAPixel[16];

331
extern int X11DRV_PALETTE_Init(void);
332
extern void X11DRV_PALETTE_Cleanup(void);
333
extern BOOL X11DRV_IsSolidColor(COLORREF color);
334 335

extern COLORREF X11DRV_PALETTE_ToLogical(int pixel);
336
extern int X11DRV_PALETTE_ToPhysical(X11DRV_PDEVICE *physDev, COLORREF color);
337

338 339 340 341 342
/* GDI escapes */

#define X11DRV_ESCAPE 6789
enum x11drv_escape_codes
{
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
    X11DRV_GET_DISPLAY,      /* get X11 display for a DC */
    X11DRV_GET_DRAWABLE,     /* get current drawable for a DC */
    X11DRV_GET_FONT,         /* get current X font for a DC */
    X11DRV_SET_DRAWABLE,     /* set current drawable for a DC */
    X11DRV_START_EXPOSURES,  /* start graphics exposures */
    X11DRV_END_EXPOSURES,    /* end graphics exposures */
};

struct x11drv_escape_set_drawable
{
    enum x11drv_escape_codes code;         /* escape code (X11DRV_SET_DRAWABLE) */
    Drawable                 drawable;     /* X drawable */
    int                      mode;         /* ClipByChildren or IncludeInferiors */
    POINT                    org;          /* origin of DC relative to drawable */
    POINT                    drawable_org; /* origin of drawable relative to screen */
358 359
};

360 361 362 363
/**************************************************************************
 * X11 USER driver
 */

364 365 366 367
struct x11drv_thread_data
{
    Display *display;
    HANDLE   display_fd;
368
    int      process_event_count;  /* recursion count for event processing */
369 370
    Cursor   cursor;               /* current cursor */
    Window   cursor_window;        /* current window that contains the cursor */
371
    HWND     last_focus;           /* last window that had focus */
372
    XIM      xim;                  /* input method */
373 374 375 376 377 378 379 380 381 382 383 384 385
};

extern struct x11drv_thread_data *x11drv_init_thread_data(void);

inline static struct x11drv_thread_data *x11drv_thread_data(void)
{
    struct x11drv_thread_data *data = NtCurrentTeb()->driver_data;
    if (!data) data = x11drv_init_thread_data();
    return data;
}

inline static Display *thread_display(void) { return x11drv_thread_data()->display; }

386 387
extern Visual *visual;
extern Window root_window;
388
extern DWORD desktop_tid;
389 390 391
extern unsigned int screen_width;
extern unsigned int screen_height;
extern unsigned int screen_depth;
392
extern unsigned int text_caps;
393
extern int use_xkb;
394
extern int use_take_focus;
395
extern int managed_mode;
396

397
/* atoms */
398

399
enum x11drv_atoms
400
{
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
    FIRST_XATOM = XA_LAST_PREDEFINED + 1,
    XATOM_CLIPBOARD = FIRST_XATOM,
    XATOM_COMPOUND_TEXT,
    XATOM_MULTIPLE,
    XATOM_SELECTION_DATA,
    XATOM_TARGETS,
    XATOM_TEXT,
    XATOM_UTF8_STRING,
    XATOM_RAW_ASCENT,
    XATOM_RAW_DESCENT,
    XATOM_RAW_CAP_HEIGHT,
    XATOM_WM_PROTOCOLS,
    XATOM_WM_DELETE_WINDOW,
    XATOM_WM_TAKE_FOCUS,
    XATOM_KWM_DOCKWINDOW,
    XATOM_DndProtocol,
    XATOM_DndSelection,
    XATOM__MOTIF_WM_HINTS,
    XATOM__KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR,
420
    XATOM__NET_WM_MOVERESIZE,
421 422 423
    XATOM__NET_WM_PID,
    XATOM__NET_WM_PING,
    XATOM__NET_WM_NAME,
424 425
    XATOM__NET_WM_WINDOW_TYPE,
    XATOM__NET_WM_WINDOW_TYPE_UTILITY,
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
    XATOM_XdndAware,
    XATOM_XdndEnter,
    XATOM_XdndPosition,
    XATOM_XdndStatus,
    XATOM_XdndLeave,
    XATOM_XdndFinished,
    XATOM_XdndDrop,
    XATOM_XdndActionCopy,
    XATOM_XdndActionMove,
    XATOM_XdndActionLink,
    XATOM_XdndActionAsk,
    XATOM_XdndActionPrivate,
    XATOM_XdndSelection,
    XATOM_XdndTarget,
    XATOM_XdndTypeList,
441
    XATOM_WCF_DIB,
442
    XATOM_image_gif,
443 444
    XATOM_text_html,
    XATOM_text_plain,
445 446 447 448
    XATOM_text_rtf,
    XATOM_text_richtext,
    NB_XATOMS
};
449

450 451 452 453 454
extern Atom X11DRV_Atoms[NB_XATOMS - FIRST_XATOM];

#define x11drv_atom(name) (X11DRV_Atoms[XATOM_##name - FIRST_XATOM])

/* X11 clipboard driver */
455 456 457 458 459

typedef struct tagWINE_CLIPDATA {
    UINT        wFormatID;
    HANDLE16    hData16;
    HANDLE      hData32;
460
    UINT        drvData;
461 462 463 464 465
    UINT        wFlags;
    struct tagWINE_CLIPDATA *PrevData;
    struct tagWINE_CLIPDATA *NextData;
} WINE_CLIPDATA, *LPWINE_CLIPDATA;

466 467
typedef HANDLE (*DRVEXPORTFUNC)(Window requestor, Atom aTarget, Atom rprop,
    LPWINE_CLIPDATA lpData, LPDWORD lpBytes);
468 469 470 471 472 473 474 475 476 477 478 479 480 481
typedef HANDLE (*DRVIMPORTFUNC)(LPBYTE hData, UINT cBytes);

typedef struct tagWINE_CLIPFORMAT {
    UINT        wFormatID;
    LPSTR       Name;
    UINT        drvData;
    UINT        wFlags;
    DRVIMPORTFUNC  lpDrvImportFunc;
    DRVEXPORTFUNC  lpDrvExportFunc;
    struct tagWINE_CLIPFORMAT *PrevFormat;
    struct tagWINE_CLIPFORMAT *NextFormat;
} WINE_CLIPFORMAT, *LPWINE_CLIPFORMAT;

#define CF_FLAG_BUILTINFMT   1 /* Built-in windows format */
482
#define CF_FLAG_UNOWNED      2 /* cached data is not owned */
483 484
#define CF_FLAG_SYNTHESIZED  8 /* Implicitly converted data */

485
extern void X11DRV_InitClipboard(void);
486
extern void X11DRV_CLIPBOARD_ReleaseSelection(Atom selType, Window w, HWND hwnd, Time time);
487 488 489 490 491 492 493
extern INT X11DRV_CountClipboardFormats(void);
extern UINT X11DRV_EnumClipboardFormats(UINT wFormat);
extern LPWINE_CLIPFORMAT X11DRV_CLIPBOARD_LookupFormat(WORD wID);
extern LPWINE_CLIPFORMAT X11DRV_CLIPBOARD_LookupProperty(UINT drvData);
extern LPWINE_CLIPDATA X11DRV_CLIPBOARD_LookupData(DWORD wID);
extern UINT X11DRV_CLIPBOARD_LookupPropertyAlias(UINT drvDataProperty);
extern LPWINE_CLIPFORMAT X11DRV_CLIPBOARD_LookupAliasProperty(UINT drvDataAlias);
494 495 496

/* X11 event driver */

497 498 499 500
typedef enum {
  X11DRV_INPUT_RELATIVE,
  X11DRV_INPUT_ABSOLUTE
} INPUT_TYPE;
501
extern INPUT_TYPE X11DRV_EVENT_SetInputMethod(INPUT_TYPE type);
502

503 504 505 506
#ifdef HAVE_LIBXXF86DGA2
void X11DRV_EVENT_SetDGAStatus(HWND hwnd, int event_base) ;
#endif

507 508
extern int X11DRV_ProcessTabletEvent(HWND hwnd, XEvent *event);

509 510 511 512 513 514 515 516
/* x11drv private window data */
struct x11drv_win_data
{
    Window  whole_window;   /* X window for the complete window */
    Window  client_window;  /* X window for the client area */
    Window  icon_window;    /* X window for the icon */
    RECT    whole_rect;     /* X window rectangle for the whole window relative to parent */
    RECT    client_rect;    /* client area relative to whole window */
517
    XIC     xic;            /* X input context */
518 519 520 521 522
    HBITMAP hWMIconBitmap;
    HBITMAP hWMIconMask;
};

typedef struct x11drv_win_data X11DRV_WND_DATA;
523

524 525
extern Window X11DRV_get_client_window( HWND hwnd );
extern Window X11DRV_get_whole_window( HWND hwnd );
526
extern BOOL X11DRV_is_window_rect_mapped( const RECT *rect );
527
extern XIC X11DRV_get_ic( HWND hwnd );
528 529 530 531 532 533 534 535 536 537 538 539

inline static Window get_client_window( WND *wnd )
{
    struct x11drv_win_data *data = wnd->pDriverData;
    return data->client_window;
}

inline static Window get_whole_window( WND *wnd )
{
    struct x11drv_win_data *data = wnd->pDriverData;
    return data->whole_window;
}
540

541 542 543 544 545
inline static BOOL is_window_top_level( WND *win )
{
    return (root_window == DefaultRootWindow(gdi_display) && win->parent == GetDesktopWindow());
}

546
extern void X11DRV_SetFocus( HWND hwnd );
547 548
extern Cursor X11DRV_GetCursor( Display *display, struct tagCURSORICONINFO *ptr );

549 550 551
typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void *arg );

extern void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg );
552 553 554 555 556
extern int X11DRV_check_error(void);
extern void X11DRV_register_window( Display *display, HWND hwnd, struct x11drv_win_data *data );
extern void X11DRV_set_iconic_state( WND *win );
extern void X11DRV_window_to_X_rect( WND *win, RECT *rect );
extern void X11DRV_X_to_window_rect( WND *win, RECT *rect );
557 558
extern void X11DRV_create_desktop_thread(void);
extern Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry );
559
extern void X11DRV_sync_window_style( Display *display, WND *win );
560 561
extern int X11DRV_sync_whole_window_position( Display *display, WND *win, int zorder );
extern int X11DRV_sync_client_window_position( Display *display, WND *win );
562 563
extern BOOL X11DRV_set_window_pos( HWND hwnd, HWND insert_after, const RECT *rectWindow,
                                   const RECT *rectClient, UINT swp_flags, UINT wvr_flags );
564
extern void X11DRV_set_wm_hints( Display *display, WND *win );
565

566
extern void X11DRV_handle_desktop_resize(unsigned int width, unsigned int height);
567 568 569 570 571 572 573 574 575 576 577 578 579
extern void X11DRV_Settings_AddDepthModes(void);
extern void X11DRV_Settings_AddOneMode(unsigned int width, unsigned int height, unsigned int bpp, unsigned int freq);
extern int X11DRV_Settings_CreateDriver(LPDDHALINFO info);
extern LPDDHALMODEINFO X11DRV_Settings_CreateModes(unsigned int max_modes, int reserve_depths);
unsigned int X11DRV_Settings_GetModeCount(void);
void X11DRV_Settings_Init(void);
extern void X11DRV_Settings_SetDefaultMode(int mode);
LPDDHALMODEINFO X11DRV_Settings_SetHandlers(const char *name, 
                                            int (*pNewGCM)(void), 
                                            void (*pNewSCM)(int), 
                                            unsigned int nmodes, 
                                            int reserve_depths);

580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712


typedef struct {
    void (*Convert_5x5_asis)(int width, int height,
                             const void* srcbits, int srclinebytes,
                             void* dstbits, int dstlinebytes);
    void (*Convert_555_reverse)(int width, int height,
                                const void* srcbits, int srclinebytes,
                                void* dstbits, int dstlinebytes);
    void (*Convert_555_to_565_asis)(int width, int height,
                                    const void* srcbits, int srclinebytes,
                                    void* dstbits, int dstlinebytes);
    void (*Convert_555_to_565_reverse)(int width, int height,
                                       const void* srcbits, int srclinebytes,
                                       void* dstbits, int dstlinebytes);
    void (*Convert_555_to_888_asis)(int width, int height,
                                    const void* srcbits, int srclinebytes,
                                    void* dstbits, int dstlinebytes);
    void (*Convert_555_to_888_reverse)(int width, int height,
                                       const void* srcbits, int srclinebytes,
                                       void* dstbits, int dstlinebytes);
    void (*Convert_555_to_0888_asis)(int width, int height,
                                     const void* srcbits, int srclinebytes,
                                     void* dstbits, int dstlinebytes);
    void (*Convert_555_to_0888_reverse)(int width, int height,
                                        const void* srcbits, int srclinebytes,
                                        void* dstbits, int dstlinebytes);
    void (*Convert_5x5_to_any0888)(int width, int height,
                                   const void* srcbits, int srclinebytes,
                                   WORD rsrc, WORD gsrc, WORD bsrc,
                                   void* dstbits, int dstlinebytes,
                                   DWORD rdst, DWORD gdst, DWORD bdst);
    void (*Convert_565_reverse)(int width, int height,
                                const void* srcbits, int srclinebytes,
                                void* dstbits, int dstlinebytes);
    void (*Convert_565_to_555_asis)(int width, int height,
                                    const void* srcbits, int srclinebytes,
                                    void* dstbits, int dstlinebytes);
    void (*Convert_565_to_555_reverse)(int width, int height,
                                       const void* srcbits, int srclinebytes,
                                       void* dstbits, int dstlinebytes);
    void (*Convert_565_to_888_asis)(int width, int height,
                                    const void* srcbits, int srclinebytes,
                                    void* dstbits, int dstlinebytes);
    void (*Convert_565_to_888_reverse)(int width, int height,
                                       const void* srcbits, int srclinebytes,
                                       void* dstbits, int dstlinebytes);
    void (*Convert_565_to_0888_asis)(int width, int height,
                                     const void* srcbits, int srclinebytes,
                                     void* dstbits, int dstlinebytes);
    void (*Convert_565_to_0888_reverse)(int width, int height,
                                        const void* srcbits, int srclinebytes,
                                        void* dstbits, int dstlinebytes);
    void (*Convert_888_asis)(int width, int height,
                             const void* srcbits, int srclinebytes,
                             void* dstbits, int dstlinebytes);
    void (*Convert_888_reverse)(int width, int height,
                                const void* srcbits, int srclinebytes,
                                void* dstbits, int dstlinebytes);
    void (*Convert_888_to_555_asis)(int width, int height,
                                    const void* srcbits, int srclinebytes,
                                    void* dstbits, int dstlinebytes);
    void (*Convert_888_to_555_reverse)(int width, int height,
                                       const void* srcbits, int srclinebytes,
                                       void* dstbits, int dstlinebytes);
    void (*Convert_888_to_565_asis)(int width, int height,
                                    const void* srcbits, int srclinebytes,
                                    void* dstbits, int dstlinebytes);
    void (*Convert_888_to_565_reverse)(int width, int height,
                                       const void* srcbits, int srclinebytes,
                                       void* dstbits, int dstlinebytes);
    void (*Convert_888_to_0888_asis)(int width, int height,
                                     const void* srcbits, int srclinebytes,
                                     void* dstbits, int dstlinebytes);
    void (*Convert_888_to_0888_reverse)(int width, int height,
                                        const void* srcbits, int srclinebytes,
                                        void* dstbits, int dstlinebytes);
    void (*Convert_rgb888_to_any0888)(int width, int height,
                                      const void* srcbits, int srclinebytes,
                                      void* dstbits, int dstlinebytes,
                                      DWORD rdst, DWORD gdst, DWORD bdst);
    void (*Convert_bgr888_to_any0888)(int width, int height,
                                      const void* srcbits, int srclinebytes,
                                      void* dstbits, int dstlinebytes,
                                      DWORD rdst, DWORD gdst, DWORD bdst);
    void (*Convert_0888_asis)(int width, int height,
                              const void* srcbits, int srclinebytes,
                              void* dstbits, int dstlinebytes);
    void (*Convert_0888_reverse)(int width, int height,
                                 const void* srcbits, int srclinebytes,
                                 void* dstbits, int dstlinebytes);
    void (*Convert_0888_any)(int width, int height,
                             const void* srcbits, int srclinebytes,
                             DWORD rsrc, DWORD gsrc, DWORD bsrc,
                             void* dstbits, int dstlinebytes,
                             DWORD rdst, DWORD gdst, DWORD bdst);
    void (*Convert_0888_to_555_asis)(int width, int height,
                                     const void* srcbits, int srclinebytes,
                                     void* dstbits, int dstlinebytes);
    void (*Convert_0888_to_555_reverse)(int width, int height,
                                        const void* srcbits, int srclinebytes,
                                        void* dstbits, int dstlinebytes);
    void (*Convert_0888_to_565_asis)(int width, int height,
                                     const void* srcbits, int srclinebytes,
                                     void* dstbits, int dstlinebytes);
    void (*Convert_0888_to_565_reverse)(int width, int height,
                                        const void* srcbits, int srclinebytes,
                                        void* dstbits, int dstlinebytes);
    void (*Convert_any0888_to_5x5)(int width, int height,
                                   const void* srcbits, int srclinebytes,
                                   DWORD rsrc, DWORD gsrc, DWORD bsrc,
                                   void* dstbits, int dstlinebytes,
                                   WORD rdst, WORD gdst, WORD bdst);
    void (*Convert_0888_to_888_asis)(int width, int height,
                                     const void* srcbits, int srclinebytes,
                                     void* dstbits, int dstlinebytes);
    void (*Convert_0888_to_888_reverse)(int width, int height,
                                        const void* srcbits, int srclinebytes,
                                        void* dstbits, int dstlinebytes);
    void (*Convert_any0888_to_rgb888)(int width, int height,
                                      const void* srcbits, int srclinebytes,
                                      DWORD rsrc, DWORD gsrc, DWORD bsrc,
                                      void* dstbits, int dstlinebytes);
    void (*Convert_any0888_to_bgr888)(int width, int height,
                                      const void* srcbits, int srclinebytes,
                                      DWORD rsrc, DWORD gsrc, DWORD bsrc,
                                      void* dstbits, int dstlinebytes);
} dib_conversions;

extern const dib_conversions dib_normal, dib_src_byteswap, dib_dst_byteswap;

extern INT X11DRV_DIB_MaskToShift(DWORD mask);

713
#endif  /* __WINE_X11DRV_H */