Release 970415
[wine/multimedia.git] / graphics / x11drv / init.c
blobbceeb1088a7969080dcebbc457ef136158802a4d
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, /* pEnumDeviceFonts */
27 NULL, /* pEscape */
28 NULL, /* pExcludeClipRect */
29 NULL, /* pExcludeVisRect */
30 X11DRV_ExtFloodFill, /* pExtFloodFill */
31 X11DRV_ExtTextOut, /* pExtTextOut */
32 NULL, /* pGetCharWidth */
33 X11DRV_GetPixel, /* pGetPixel */
34 X11DRV_GetTextExtentPoint, /* pGetTextExtentPoint */
35 X11DRV_GetTextMetrics, /* pGetTextMetrics */
36 NULL, /* pIntersectClipRect */
37 NULL, /* pIntersectVisRect */
38 X11DRV_LineTo, /* pLineTo */
39 X11DRV_MoveToEx, /* pMoveToEx */
40 NULL, /* pOffsetClipRgn */
41 NULL, /* pOffsetViewportOrg (optional) */
42 NULL, /* pOffsetWindowOrg (optional) */
43 X11DRV_PaintRgn, /* pPaintRgn */
44 X11DRV_PatBlt, /* pPatBlt */
45 X11DRV_Pie, /* pPie */
46 X11DRV_PolyPolygon, /* pPolyPolygon */
47 X11DRV_Polygon, /* pPolygon */
48 X11DRV_Polyline, /* pPolyline */
49 NULL, /* pRealizePalette */
50 X11DRV_Rectangle, /* pRectangle */
51 NULL, /* pRestoreDC */
52 X11DRV_RoundRect, /* pRoundRect */
53 NULL, /* pSaveDC */
54 NULL, /* pScaleViewportExt (optional) */
55 NULL, /* pScaleWindowExt (optional) */
56 NULL, /* pSelectClipRgn */
57 X11DRV_SelectObject, /* pSelectObject */
58 NULL, /* pSelectPalette */
59 NULL, /* pSetBkColor */
60 NULL, /* pSetBkMode */
61 X11DRV_SetDeviceClipping, /* pSetDeviceClipping */
62 NULL, /* pSetDIBitsToDevice */
63 NULL, /* pSetMapMode (optional) */
64 NULL, /* pSetMapperFlags */
65 X11DRV_SetPixel, /* pSetPixel */
66 NULL, /* pSetPolyFillMode */
67 NULL, /* pSetROP2 */
68 NULL, /* pSetRelAbs */
69 NULL, /* pSetStretchBltMode */
70 NULL, /* pSetTextAlign */
71 NULL, /* pSetTextCharacterExtra */
72 NULL, /* pSetTextColor */
73 NULL, /* pSetTextJustification */
74 NULL, /* pSetViewportExt (optional) */
75 NULL, /* pSetViewportOrg (optional) */
76 NULL, /* pSetWindowExt (optional) */
77 NULL, /* pSetWindowOrg (optional) */
78 X11DRV_StretchBlt, /* pStretchBlt */
79 NULL /* pStretchDIBits */
82 static DeviceCaps X11DRV_DevCaps;
84 /**********************************************************************
85 * X11DRV_Init
87 BOOL32 X11DRV_Init(void)
89 /* Create default bitmap */
91 if (!X11DRV_BITMAP_Init()) return FALSE;
93 /* Initialize brush dithering */
95 if (!X11DRV_BRUSH_Init()) return FALSE;
97 /* Initialize fonts */
99 if (!X11DRV_FONT_Init()) return FALSE;
101 return DRIVER_RegisterDriver( "DISPLAY", &X11DRV_Funcs );
105 /**********************************************************************
106 * X11DRV_CreateDC
108 static BOOL32 X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
109 LPCSTR output, const DEVMODE16* initData )
111 X11DRV_PDEVICE *physDev;
113 if (!X11DRV_DevCaps.version) DC_FillDevCaps( &X11DRV_DevCaps );
115 physDev = &dc->u.x; /* for now */
117 memset( physDev, 0, sizeof(*physDev) );
118 dc->physDev = physDev;
119 dc->w.devCaps = &X11DRV_DevCaps;
120 if (dc->w.flags & DC_MEMORY)
122 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( dc->w.hBitmap,
123 BITMAP_MAGIC );
124 physDev->drawable = bmp->pixmap;
125 physDev->gc = XCreateGC( display, physDev->drawable, 0, NULL );
126 dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
127 dc->w.hVisRgn = CreateRectRgn32( 0, 0, bmp->bitmap.bmWidth,
128 bmp->bitmap.bmHeight );
130 else
132 physDev->drawable = rootWindow;
133 physDev->gc = XCreateGC( display, physDev->drawable, 0, NULL );
134 dc->w.bitsPerPixel = screenDepth;
135 dc->w.hVisRgn = CreateRectRgn32( 0, 0, screenWidth, screenHeight);
138 if (!dc->w.hVisRgn)
140 XFreeGC( display, physDev->gc );
141 return FALSE;
144 XSetGraphicsExposures( display, physDev->gc, False );
145 XSetSubwindowMode( display, physDev->gc, IncludeInferiors );
147 return TRUE;
151 /**********************************************************************
152 * X11DRV_DeleteDC
154 static BOOL32 X11DRV_DeleteDC( DC *dc )
156 X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
157 XFreeGC( display, physDev->gc );
158 return TRUE;