Release 970112
[wine.git] / graphics / x11drv / init.c
blob799dec8a813a818db09538221c66c62bc7f1a97f
1 /*
2 * X11 graphics driver initialisation functions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #include <string.h>
8 #include "x11drv.h"
9 #include "bitmap.h"
10 #include "gdi.h"
13 static BOOL32 X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
14 LPCSTR output, const DEVMODE16* initData );
15 static BOOL32 X11DRV_DeleteDC( DC *dc );
17 static const DC_FUNCTIONS X11DRV_Funcs =
19 X11DRV_Arc, /* pArc */
20 X11DRV_BitBlt, /* pBitBlt */
21 X11DRV_Chord, /* pChord */
22 X11DRV_CreateDC, /* pCreateDC */
23 X11DRV_DeleteDC, /* pDeleteDC */
24 NULL, /* pDeleteObject */
25 X11DRV_Ellipse, /* pEllipse */
26 NULL, /* pEscape */
27 NULL, /* pExcludeClipRect */
28 NULL, /* pExcludeVisRect */
29 X11DRV_ExtFloodFill, /* pExtFloodFill */
30 X11DRV_ExtTextOut, /* pExtTextOut */
31 X11DRV_GetPixel, /* pGetPixel */
32 X11DRV_GetTextExtentPoint, /* pGetTextExtentPoint */
33 NULL, /* pGetTextMetrics */
34 NULL, /* pIntersectClipRect */
35 NULL, /* pIntersectVisRect */
36 X11DRV_LineTo, /* pLineTo */
37 X11DRV_MoveToEx, /* pMoveToEx */
38 NULL, /* pOffsetClipRgn */
39 NULL, /* pOffsetViewportOrg (optional) */
40 NULL, /* pOffsetWindowOrg (optional) */
41 X11DRV_PaintRgn, /* pPaintRgn */
42 X11DRV_PatBlt, /* pPatBlt */
43 X11DRV_Pie, /* pPie */
44 X11DRV_PolyPolygon, /* pPolyPolygon */
45 X11DRV_Polygon, /* pPolygon */
46 X11DRV_Polyline, /* pPolyline */
47 NULL, /* pRealizePalette */
48 X11DRV_Rectangle, /* pRectangle */
49 NULL, /* pRestoreDC */
50 X11DRV_RoundRect, /* pRoundRect */
51 NULL, /* pSaveDC */
52 NULL, /* pScaleViewportExt (optional) */
53 NULL, /* pScaleWindowExt (optional) */
54 NULL, /* pSelectClipRgn */
55 NULL, /* pSelectObject */
56 NULL, /* pSelectPalette */
57 NULL, /* pSetBkColor */
58 NULL, /* pSetBkMode */
59 X11DRV_SetDeviceClipping, /* pSetDeviceClipping */
60 NULL, /* pSetDIBitsToDevice */
61 NULL, /* pSetMapMode (optional) */
62 NULL, /* pSetMapperFlags */
63 X11DRV_SetPixel, /* pSetPixel */
64 NULL, /* pSetPolyFillMode */
65 NULL, /* pSetROP2 */
66 NULL, /* pSetRelAbs */
67 NULL, /* pSetStretchBltMode */
68 NULL, /* pSetTextAlign */
69 NULL, /* pSetTextCharacterExtra */
70 NULL, /* pSetTextColor */
71 NULL, /* pSetTextJustification */
72 NULL, /* pSetViewportExt (optional) */
73 NULL, /* pSetViewportOrg (optional) */
74 NULL, /* pSetWindowExt (optional) */
75 NULL, /* pSetWindowOrg (optional) */
76 X11DRV_StretchBlt, /* pStretchBlt */
77 NULL /* pStretchDIBits */
80 static DeviceCaps X11DRV_DevCaps;
82 /**********************************************************************
83 * X11DRV_Init
85 BOOL32 X11DRV_Init(void)
87 return DRIVER_RegisterDriver( "DISPLAY", &X11DRV_Funcs );
91 /**********************************************************************
92 * X11DRV_CreateDC
94 static BOOL32 X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
95 LPCSTR output, const DEVMODE16* initData )
97 X11DRV_PDEVICE *physDev;
99 if (!X11DRV_DevCaps.version) DC_FillDevCaps( &X11DRV_DevCaps );
101 physDev = &dc->u.x; /* for now */
103 memset( physDev, 0, sizeof(*physDev) );
104 dc->physDev = physDev;
105 dc->w.devCaps = &X11DRV_DevCaps;
106 if (dc->w.flags & DC_MEMORY)
108 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( dc->w.hBitmap,
109 BITMAP_MAGIC );
110 physDev->drawable = bmp->pixmap;
111 physDev->gc = XCreateGC( display, physDev->drawable, 0, NULL );
112 dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
113 dc->w.hVisRgn = CreateRectRgn32( 0, 0, bmp->bitmap.bmWidth,
114 bmp->bitmap.bmHeight );
116 else
118 physDev->drawable = rootWindow;
119 physDev->gc = XCreateGC( display, physDev->drawable, 0, NULL );
120 dc->w.bitsPerPixel = screenDepth;
121 dc->w.hVisRgn = CreateRectRgn32( 0, 0, screenWidth, screenHeight);
124 if (!dc->w.hVisRgn)
126 XFreeGC( display, physDev->gc );
127 return FALSE;
130 XSetGraphicsExposures( display, physDev->gc, False );
131 XSetSubwindowMode( display, physDev->gc, IncludeInferiors );
133 return TRUE;
137 /**********************************************************************
138 * X11DRV_DeleteDC
140 static BOOL32 X11DRV_DeleteDC( DC *dc )
142 X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
143 XFreeGC( display, physDev->gc );
144 return TRUE;