mshtml: Default to previous script type if not given.
[wine] / dlls / winex11.drv / init.c
1 /*
2  * X11 graphics driver initialisation functions
3  *
4  * Copyright 1996 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "config.h"
22
23 #include <stdarg.h>
24 #include <string.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winreg.h"
29 #include "x11drv.h"
30 #include "ddrawi.h"
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
34
35 Display *gdi_display;  /* display to use for all GDI functions */
36
37 /* a few dynamic device caps */
38 static int log_pixels_x;  /* pixels per logical inch in x direction */
39 static int log_pixels_y;  /* pixels per logical inch in y direction */
40 static int horz_size;     /* horz. size of screen in millimeters */
41 static int vert_size;     /* vert. size of screen in millimeters */
42 static int palette_size;
43 static int device_init_done;
44
45 static Pixmap stock_bitmap_pixmap;  /* phys bitmap for the default stock bitmap */
46
47 static const WCHAR dpi_key_name[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s','\0'};
48 static const WCHAR dpi_value_name[] = {'L','o','g','P','i','x','e','l','s','\0'};
49
50 static const struct gdi_dc_funcs x11drv_funcs;
51 static const struct gdi_dc_funcs *xrender_funcs;
52
53 /******************************************************************************
54  *      get_dpi
55  *
56  * get the dpi from the registry
57  */
58 static DWORD get_dpi( void )
59 {
60     DWORD dpi = 96;
61     HKEY hkey;
62
63     if (RegOpenKeyW(HKEY_CURRENT_CONFIG, dpi_key_name, &hkey) == ERROR_SUCCESS)
64     {
65         DWORD type, size, new_dpi;
66
67         size = sizeof(new_dpi);
68         if(RegQueryValueExW(hkey, dpi_value_name, NULL, &type, (void *)&new_dpi, &size) == ERROR_SUCCESS)
69         {
70             if(type == REG_DWORD && new_dpi != 0)
71                 dpi = new_dpi;
72         }
73         RegCloseKey(hkey);
74     }
75     return dpi;
76 }
77
78 /**********************************************************************
79  *           device_init
80  *
81  * Perform initializations needed upon creation of the first device.
82  */
83 static void device_init(void)
84 {
85     device_init_done = TRUE;
86
87     /* Initialize XRender */
88     xrender_funcs = X11DRV_XRender_Init();
89
90     /* Init Xcursor */
91     X11DRV_Xcursor_Init();
92
93     palette_size = X11DRV_PALETTE_Init();
94
95     wine_tsx11_lock();
96     stock_bitmap_pixmap = XCreatePixmap( gdi_display, root_window, 1, 1, 1 );
97     wine_tsx11_unlock();
98
99     /* Initialize device caps */
100     log_pixels_x = log_pixels_y = get_dpi();
101     horz_size = MulDiv( screen_width, 254, log_pixels_x * 10 );
102     vert_size = MulDiv( screen_height, 254, log_pixels_y * 10 );
103 }
104
105 /**********************************************************************
106  *           X11DRV_GDI_Finalize
107  */
108 void X11DRV_GDI_Finalize(void)
109 {
110     X11DRV_PALETTE_Cleanup();
111     /* don't bother to close the display, it often triggers X bugs */
112     /* XCloseDisplay( gdi_display ); */
113 }
114
115
116 static X11DRV_PDEVICE *create_x11_physdev( Drawable drawable )
117 {
118     X11DRV_PDEVICE *physDev;
119
120     if (!device_init_done) device_init();
121
122     if (!(physDev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev) ))) return NULL;
123
124     wine_tsx11_lock();
125     physDev->drawable = drawable;
126     physDev->gc = XCreateGC( gdi_display, drawable, 0, NULL );
127     XSetGraphicsExposures( gdi_display, physDev->gc, False );
128     XSetSubwindowMode( gdi_display, physDev->gc, IncludeInferiors );
129     XFlush( gdi_display );
130     wine_tsx11_unlock();
131     return physDev;
132 }
133
134 /**********************************************************************
135  *           X11DRV_CreateDC
136  */
137 static BOOL X11DRV_CreateDC( PHYSDEV *pdev, LPCWSTR driver, LPCWSTR device,
138                              LPCWSTR output, const DEVMODEW* initData )
139 {
140     const struct gdi_dc_funcs *glx_funcs = get_glx_driver();
141     X11DRV_PDEVICE *physDev = create_x11_physdev( root_window );
142
143     if (!physDev) return FALSE;
144
145     physDev->depth         = screen_depth;
146     physDev->color_shifts  = &X11DRV_PALETTE_default_shifts;
147     SetRect( &physDev->dc_rect, 0, 0, virtual_screen_rect.right - virtual_screen_rect.left,
148              virtual_screen_rect.bottom - virtual_screen_rect.top );
149     push_dc_driver( pdev, &physDev->dev, &x11drv_funcs );
150     if (xrender_funcs && !xrender_funcs->pCreateDC( pdev, driver, device, output, initData )) return FALSE;
151     if (glx_funcs && !glx_funcs->pCreateDC( pdev, driver, device, output, initData )) return FALSE;
152     return TRUE;
153 }
154
155
156 /**********************************************************************
157  *           X11DRV_CreateCompatibleDC
158  */
159 static BOOL X11DRV_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
160 {
161     const struct gdi_dc_funcs *glx_funcs = get_glx_driver();
162     X11DRV_PDEVICE *physDev = create_x11_physdev( stock_bitmap_pixmap );
163
164     if (!physDev) return FALSE;
165
166     physDev->depth  = 1;
167     SetRect( &physDev->dc_rect, 0, 0, 1, 1 );
168     push_dc_driver( pdev, &physDev->dev, &x11drv_funcs );
169     if (orig) return TRUE;  /* we already went through Xrender if we have an orig device */
170     if (xrender_funcs && !xrender_funcs->pCreateCompatibleDC( NULL, pdev )) return FALSE;
171     if (glx_funcs && !glx_funcs->pCreateCompatibleDC( NULL, pdev )) return FALSE;
172     return TRUE;
173 }
174
175
176 /**********************************************************************
177  *           X11DRV_DeleteDC
178  */
179 static BOOL X11DRV_DeleteDC( PHYSDEV dev )
180 {
181     X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
182
183     wine_tsx11_lock();
184     XFreeGC( gdi_display, physDev->gc );
185     wine_tsx11_unlock();
186     HeapFree( GetProcessHeap(), 0, physDev );
187     return TRUE;
188 }
189
190
191 void add_device_bounds( X11DRV_PDEVICE *dev, const RECT *rect )
192 {
193     RECT rc;
194
195     if (!dev->bounds) return;
196     if (dev->region && GetRgnBox( dev->region, &rc ))
197     {
198         if (IntersectRect( &rc, &rc, rect )) add_bounds_rect( dev->bounds, &rc );
199     }
200     else add_bounds_rect( dev->bounds, rect );
201 }
202
203 /***********************************************************************
204  *           X11DRV_SetBoundsRect
205  */
206 static UINT X11DRV_SetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
207 {
208     X11DRV_PDEVICE *pdev = get_x11drv_dev( dev );
209
210     if (flags & DCB_DISABLE) pdev->bounds = NULL;
211     else if (flags & DCB_ENABLE) pdev->bounds = rect;
212     return DCB_RESET;  /* we don't have device-specific bounds */
213 }
214
215
216 /***********************************************************************
217  *           GetDeviceCaps    (X11DRV.@)
218  */
219 static INT X11DRV_GetDeviceCaps( PHYSDEV dev, INT cap )
220 {
221     switch(cap)
222     {
223     case DRIVERVERSION:
224         return 0x300;
225     case TECHNOLOGY:
226         return DT_RASDISPLAY;
227     case HORZSIZE:
228         return horz_size;
229     case VERTSIZE:
230         return vert_size;
231     case HORZRES:
232         return screen_width;
233     case VERTRES:
234         return screen_height;
235     case DESKTOPHORZRES:
236         return virtual_screen_rect.right - virtual_screen_rect.left;
237     case DESKTOPVERTRES:
238         return virtual_screen_rect.bottom - virtual_screen_rect.top;
239     case BITSPIXEL:
240         return screen_bpp;
241     case PLANES:
242         return 1;
243     case NUMBRUSHES:
244         return -1;
245     case NUMPENS:
246         return -1;
247     case NUMMARKERS:
248         return 0;
249     case NUMFONTS:
250         return 0;
251     case NUMCOLORS:
252         /* MSDN: Number of entries in the device's color table, if the device has
253          * a color depth of no more than 8 bits per pixel.For devices with greater
254          * color depths, -1 is returned. */
255         return (screen_depth > 8) ? -1 : (1 << screen_depth);
256     case PDEVICESIZE:
257         return sizeof(X11DRV_PDEVICE);
258     case CURVECAPS:
259         return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE |
260                 CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT);
261     case LINECAPS:
262         return (LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
263                 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS);
264     case POLYGONALCAPS:
265         return (PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON | PC_SCANLINE |
266                 PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS);
267     case TEXTCAPS:
268         return (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
269                 TC_CR_ANY | TC_SF_X_YINDEP | TC_SA_DOUBLE | TC_SA_INTEGER |
270                 TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE | TC_VA_ABLE);
271     case CLIPCAPS:
272         return CP_REGION;
273     case COLORRES:
274         /* The observed correspondence between BITSPIXEL and COLORRES is:
275          * BITSPIXEL: 8  -> COLORRES: 18
276          * BITSPIXEL: 16 -> COLORRES: 16
277          * BITSPIXEL: 24 -> COLORRES: 24
278          * BITSPIXEL: 32 -> COLORRES: 24 */
279         return (screen_bpp <= 8) ? 18 : min( 24, screen_bpp );
280     case RASTERCAPS:
281         return (RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 | RC_DI_BITMAP |
282                 RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS |
283                 (palette_size ? RC_PALETTE : 0));
284     case SHADEBLENDCAPS:
285         return (SB_GRAD_RECT | SB_GRAD_TRI | SB_CONST_ALPHA | SB_PIXEL_ALPHA);
286     case ASPECTX:
287     case ASPECTY:
288         return 36;
289     case ASPECTXY:
290         return 51;
291     case LOGPIXELSX:
292         return log_pixels_x;
293     case LOGPIXELSY:
294         return log_pixels_y;
295     case CAPS1:
296         FIXME("(%p): CAPS1 is unimplemented, will return 0\n", dev->hdc );
297         /* please see wingdi.h for the possible bit-flag values that need
298            to be returned. */
299         return 0;
300     case SIZEPALETTE:
301         return palette_size;
302     case NUMRESERVED:
303     case PHYSICALWIDTH:
304     case PHYSICALHEIGHT:
305     case PHYSICALOFFSETX:
306     case PHYSICALOFFSETY:
307     case SCALINGFACTORX:
308     case SCALINGFACTORY:
309     case VREFRESH:
310     case BLTALIGNMENT:
311         return 0;
312     default:
313         FIXME("(%p): unsupported capability %d, will return 0\n", dev->hdc, cap );
314         return 0;
315     }
316 }
317
318
319 /**********************************************************************
320  *           ExtEscape  (X11DRV.@)
321  */
322 static INT X11DRV_ExtEscape( PHYSDEV dev, INT escape, INT in_count, LPCVOID in_data,
323                       INT out_count, LPVOID out_data )
324 {
325     X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
326
327     switch(escape)
328     {
329     case QUERYESCSUPPORT:
330         if (in_data)
331         {
332             switch (*(const INT *)in_data)
333             {
334             case DCICOMMAND:
335                 return DD_HAL_VERSION;
336             case X11DRV_ESCAPE:
337                 return TRUE;
338             }
339         }
340         break;
341
342     case X11DRV_ESCAPE:
343         if (in_data && in_count >= sizeof(enum x11drv_escape_codes))
344         {
345             switch(*(const enum x11drv_escape_codes *)in_data)
346             {
347             case X11DRV_SET_DRAWABLE:
348                 if (in_count >= sizeof(struct x11drv_escape_set_drawable))
349                 {
350                     const struct x11drv_escape_set_drawable *data = in_data;
351                     physDev->dc_rect = data->dc_rect;
352                     physDev->drawable = data->drawable;
353                     wine_tsx11_lock();
354                     XSetSubwindowMode( gdi_display, physDev->gc, data->mode );
355                     wine_tsx11_unlock();
356                     TRACE( "SET_DRAWABLE hdc %p drawable %lx dc_rect %s\n",
357                            dev->hdc, physDev->drawable, wine_dbgstr_rect(&physDev->dc_rect) );
358                     return TRUE;
359                 }
360                 break;
361             case X11DRV_GET_DRAWABLE:
362                 if (out_count >= sizeof(struct x11drv_escape_get_drawable))
363                 {
364                     struct x11drv_escape_get_drawable *data = out_data;
365                     data->drawable = physDev->drawable;
366                     return TRUE;
367                 }
368                 break;
369             case X11DRV_START_EXPOSURES:
370                 wine_tsx11_lock();
371                 XSetGraphicsExposures( gdi_display, physDev->gc, True );
372                 wine_tsx11_unlock();
373                 physDev->exposures = 0;
374                 return TRUE;
375             case X11DRV_END_EXPOSURES:
376                 if (out_count >= sizeof(HRGN))
377                 {
378                     HRGN hrgn = 0, tmp = 0;
379
380                     wine_tsx11_lock();
381                     XSetGraphicsExposures( gdi_display, physDev->gc, False );
382                     wine_tsx11_unlock();
383                     if (physDev->exposures)
384                     {
385                         for (;;)
386                         {
387                             XEvent event;
388
389                             wine_tsx11_lock();
390                             XWindowEvent( gdi_display, physDev->drawable, ~0, &event );
391                             wine_tsx11_unlock();
392                             if (event.type == NoExpose) break;
393                             if (event.type == GraphicsExpose)
394                             {
395                                 RECT rect;
396
397                                 rect.left   = event.xgraphicsexpose.x - physDev->dc_rect.left;
398                                 rect.top    = event.xgraphicsexpose.y - physDev->dc_rect.top;
399                                 rect.right  = rect.left + event.xgraphicsexpose.width;
400                                 rect.bottom = rect.top + event.xgraphicsexpose.height;
401                                 if (GetLayout( dev->hdc ) & LAYOUT_RTL)
402                                     mirror_rect( &physDev->dc_rect, &rect );
403
404                                 TRACE( "got %s count %d\n", wine_dbgstr_rect(&rect),
405                                        event.xgraphicsexpose.count );
406
407                                 if (!tmp) tmp = CreateRectRgnIndirect( &rect );
408                                 else SetRectRgn( tmp, rect.left, rect.top, rect.right, rect.bottom );
409                                 if (hrgn) CombineRgn( hrgn, hrgn, tmp, RGN_OR );
410                                 else
411                                 {
412                                     hrgn = tmp;
413                                     tmp = 0;
414                                 }
415                                 if (!event.xgraphicsexpose.count) break;
416                             }
417                             else
418                             {
419                                 ERR( "got unexpected event %d\n", event.type );
420                                 break;
421                             }
422                         }
423                         if (tmp) DeleteObject( tmp );
424                     }
425                     *(HRGN *)out_data = hrgn;
426                     return TRUE;
427                 }
428                 break;
429             default:
430                 break;
431             }
432         }
433         break;
434     }
435     return 0;
436 }
437
438
439 static const struct gdi_dc_funcs x11drv_funcs =
440 {
441     NULL,                               /* pAbortDoc */
442     NULL,                               /* pAbortPath */
443     NULL,                               /* pAlphaBlend */
444     NULL,                               /* pAngleArc */
445     X11DRV_Arc,                         /* pArc */
446     NULL,                               /* pArcTo */
447     NULL,                               /* pBeginPath */
448     NULL,                               /* pBlendImage */
449     X11DRV_Chord,                       /* pChord */
450     NULL,                               /* pCloseFigure */
451     X11DRV_CreateCompatibleDC,          /* pCreateCompatibleDC */
452     X11DRV_CreateDC,                    /* pCreateDC */
453     X11DRV_DeleteDC,                    /* pDeleteDC */
454     NULL,                               /* pDeleteObject */
455     NULL,                               /* pDeviceCapabilities */
456     X11DRV_Ellipse,                     /* pEllipse */
457     NULL,                               /* pEndDoc */
458     NULL,                               /* pEndPage */
459     NULL,                               /* pEndPath */
460     NULL,                               /* pEnumFonts */
461     X11DRV_EnumICMProfiles,             /* pEnumICMProfiles */
462     NULL,                               /* pExcludeClipRect */
463     NULL,                               /* pExtDeviceMode */
464     X11DRV_ExtEscape,                   /* pExtEscape */
465     X11DRV_ExtFloodFill,                /* pExtFloodFill */
466     NULL,                               /* pExtSelectClipRgn */
467     NULL,                               /* pExtTextOut */
468     NULL,                               /* pFillPath */
469     NULL,                               /* pFillRgn */
470     NULL,                               /* pFlattenPath */
471     NULL,                               /* pFontIsLinked */
472     NULL,                               /* pFrameRgn */
473     NULL,                               /* pGdiComment */
474     NULL,                               /* pGdiRealizationInfo */
475     NULL,                               /* pGetBoundsRect */
476     NULL,                               /* pGetCharABCWidths */
477     NULL,                               /* pGetCharABCWidthsI */
478     NULL,                               /* pGetCharWidth */
479     X11DRV_GetDeviceCaps,               /* pGetDeviceCaps */
480     X11DRV_GetDeviceGammaRamp,          /* pGetDeviceGammaRamp */
481     NULL,                               /* pGetFontData */
482     NULL,                               /* pGetFontUnicodeRanges */
483     NULL,                               /* pGetGlyphIndices */
484     NULL,                               /* pGetGlyphOutline */
485     X11DRV_GetICMProfile,               /* pGetICMProfile */
486     X11DRV_GetImage,                    /* pGetImage */
487     NULL,                               /* pGetKerningPairs */
488     X11DRV_GetNearestColor,             /* pGetNearestColor */
489     NULL,                               /* pGetOutlineTextMetrics */
490     NULL,                               /* pGetPixel */
491     X11DRV_GetSystemPaletteEntries,     /* pGetSystemPaletteEntries */
492     NULL,                               /* pGetTextCharsetInfo */
493     NULL,                               /* pGetTextExtentExPoint */
494     NULL,                               /* pGetTextExtentExPointI */
495     NULL,                               /* pGetTextFace */
496     NULL,                               /* pGetTextMetrics */
497     X11DRV_GradientFill,                /* pGradientFill */
498     NULL,                               /* pIntersectClipRect */
499     NULL,                               /* pInvertRgn */
500     X11DRV_LineTo,                      /* pLineTo */
501     NULL,                               /* pModifyWorldTransform */
502     NULL,                               /* pMoveTo */
503     NULL,                               /* pOffsetClipRgn */
504     NULL,                               /* pOffsetViewportOrg */
505     NULL,                               /* pOffsetWindowOrg */
506     X11DRV_PaintRgn,                    /* pPaintRgn */
507     X11DRV_PatBlt,                      /* pPatBlt */
508     X11DRV_Pie,                         /* pPie */
509     NULL,                               /* pPolyBezier */
510     NULL,                               /* pPolyBezierTo */
511     NULL,                               /* pPolyDraw */
512     X11DRV_PolyPolygon,                 /* pPolyPolygon */
513     X11DRV_PolyPolyline,                /* pPolyPolyline */
514     X11DRV_Polygon,                     /* pPolygon */
515     NULL,                               /* pPolyline */
516     NULL,                               /* pPolylineTo */
517     X11DRV_PutImage,                    /* pPutImage */
518     X11DRV_RealizeDefaultPalette,       /* pRealizeDefaultPalette */
519     X11DRV_RealizePalette,              /* pRealizePalette */
520     X11DRV_Rectangle,                   /* pRectangle */
521     NULL,                               /* pResetDC */
522     NULL,                               /* pRestoreDC */
523     X11DRV_RoundRect,                   /* pRoundRect */
524     NULL,                               /* pSaveDC */
525     NULL,                               /* pScaleViewportExt */
526     NULL,                               /* pScaleWindowExt */
527     NULL,                               /* pSelectBitmap */
528     X11DRV_SelectBrush,                 /* pSelectBrush */
529     NULL,                               /* pSelectClipPath */
530     NULL,                               /* pSelectFont */
531     NULL,                               /* pSelectPalette */
532     X11DRV_SelectPen,                   /* pSelectPen */
533     NULL,                               /* pSetArcDirection */
534     NULL,                               /* pSetBkColor */
535     NULL,                               /* pSetBkMode */
536     X11DRV_SetBoundsRect,               /* pSetBoundsRect */
537     X11DRV_SetDCBrushColor,             /* pSetDCBrushColor */
538     X11DRV_SetDCPenColor,               /* pSetDCPenColor */
539     NULL,                               /* pSetDIBitsToDevice */
540     X11DRV_SetDeviceClipping,           /* pSetDeviceClipping */
541     X11DRV_SetDeviceGammaRamp,          /* pSetDeviceGammaRamp */
542     NULL,                               /* pSetLayout */
543     NULL,                               /* pSetMapMode */
544     NULL,                               /* pSetMapperFlags */
545     X11DRV_SetPixel,                    /* pSetPixel */
546     NULL,                               /* pSetPolyFillMode */
547     NULL,                               /* pSetROP2 */
548     NULL,                               /* pSetRelAbs */
549     NULL,                               /* pSetStretchBltMode */
550     NULL,                               /* pSetTextAlign */
551     NULL,                               /* pSetTextCharacterExtra */
552     NULL,                               /* pSetTextColor */
553     NULL,                               /* pSetTextJustification */
554     NULL,                               /* pSetViewportExt */
555     NULL,                               /* pSetViewportOrg */
556     NULL,                               /* pSetWindowExt */
557     NULL,                               /* pSetWindowOrg */
558     NULL,                               /* pSetWorldTransform */
559     NULL,                               /* pStartDoc */
560     NULL,                               /* pStartPage */
561     X11DRV_StretchBlt,                  /* pStretchBlt */
562     NULL,                               /* pStretchDIBits */
563     NULL,                               /* pStrokeAndFillPath */
564     NULL,                               /* pStrokePath */
565     NULL,                               /* pSwapBuffers */
566     X11DRV_UnrealizePalette,            /* pUnrealizePalette */
567     NULL,                               /* pWidenPath */
568     NULL,                               /* wine_get_wgl_driver */
569     GDI_PRIORITY_GRAPHICS_DRV           /* priority */
570 };
571
572
573 /******************************************************************************
574  *      X11DRV_get_gdi_driver
575  */
576 const struct gdi_dc_funcs * CDECL X11DRV_get_gdi_driver( unsigned int version )
577 {
578     if (version != WINE_GDI_DRIVER_VERSION)
579     {
580         ERR( "version mismatch, gdi32 wants %u but winex11 has %u\n", version, WINE_GDI_DRIVER_VERSION );
581         return NULL;
582     }
583     return &x11drv_funcs;
584 }