2 * X11 graphics driver initialisation functions
4 * Copyright 1996 Alexandre Julliard
9 #ifndef X_DISPLAY_MISSING
23 static BOOL32 X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
24 LPCSTR output, const DEVMODE16* initData );
25 static BOOL32 X11DRV_DeleteDC( DC *dc );
27 static INT32 X11DRV_Escape( DC *dc, INT32 nEscape, INT32 cbInput,
28 SEGPTR lpInData, SEGPTR lpOutData );
30 static const DC_FUNCTIONS X11DRV_Funcs =
32 X11DRV_Arc, /* pArc */
33 X11DRV_BitBlt, /* pBitBlt */
34 X11DRV_BitmapBits, /* pBitmapBits */
35 X11DRV_Chord, /* pChord */
36 X11DRV_CreateBitmap, /* pCreateBitmap */
37 X11DRV_CreateDC, /* pCreateDC */
38 X11DRV_DeleteDC, /* pDeleteDC */
39 X11DRV_DeleteObject, /* pDeleteObject */
40 X11DRV_Ellipse, /* pEllipse */
41 X11DRV_EnumDeviceFonts, /* pEnumDeviceFonts */
42 X11DRV_Escape, /* pEscape */
43 NULL, /* pExcludeClipRect */
44 NULL, /* pExcludeVisRect */
45 X11DRV_ExtFloodFill, /* pExtFloodFill */
46 X11DRV_ExtTextOut, /* pExtTextOut */
47 X11DRV_GetCharWidth, /* pGetCharWidth */
48 X11DRV_GetPixel, /* pGetPixel */
49 X11DRV_GetTextExtentPoint, /* pGetTextExtentPoint */
50 X11DRV_GetTextMetrics, /* pGetTextMetrics */
51 NULL, /* pIntersectClipRect */
52 NULL, /* pIntersectVisRect */
53 X11DRV_LineTo, /* pLineTo */
54 X11DRV_LoadOEMResource, /* pLoadOEMResource */
55 X11DRV_MoveToEx, /* pMoveToEx */
56 NULL, /* pOffsetClipRgn */
57 NULL, /* pOffsetViewportOrg (optional) */
58 NULL, /* pOffsetWindowOrg (optional) */
59 X11DRV_PaintRgn, /* pPaintRgn */
60 X11DRV_PatBlt, /* pPatBlt */
61 X11DRV_Pie, /* pPie */
62 X11DRV_PolyPolygon, /* pPolyPolygon */
63 X11DRV_PolyPolyline, /* pPolyPolyline */
64 X11DRV_Polygon, /* pPolygon */
65 X11DRV_Polyline, /* pPolyline */
66 X11DRV_PolyBezier, /* pPolyBezier */
67 NULL, /* pRealizePalette */
68 X11DRV_Rectangle, /* pRectangle */
69 NULL, /* pRestoreDC */
70 X11DRV_RoundRect, /* pRoundRect */
72 NULL, /* pScaleViewportExt (optional) */
73 NULL, /* pScaleWindowExt (optional) */
74 NULL, /* pSelectClipRgn */
75 X11DRV_SelectObject, /* pSelectObject */
76 NULL, /* pSelectPalette */
77 X11DRV_SetBkColor, /* pSetBkColor */
78 NULL, /* pSetBkMode */
79 X11DRV_SetDeviceClipping, /* pSetDeviceClipping */
80 X11DRV_SetDIBitsToDevice, /* pSetDIBitsToDevice */
81 NULL, /* pSetMapMode (optional) */
82 NULL, /* pSetMapperFlags */
83 X11DRV_SetPixel, /* pSetPixel */
84 NULL, /* pSetPolyFillMode */
86 NULL, /* pSetRelAbs */
87 NULL, /* pSetStretchBltMode */
88 NULL, /* pSetTextAlign */
89 NULL, /* pSetTextCharacterExtra */
90 X11DRV_SetTextColor, /* pSetTextColor */
91 NULL, /* pSetTextJustification */
92 NULL, /* pSetViewportExt (optional) */
93 NULL, /* pSetViewportOrg (optional) */
94 NULL, /* pSetWindowExt (optional) */
95 NULL, /* pSetWindowOrg (optional) */
96 X11DRV_StretchBlt, /* pStretchBlt */
97 NULL /* pStretchDIBits */
100 static DeviceCaps X11DRV_DevCaps = {
102 /* technology */ DT_RASDISPLAY,
103 /* size, resolution */ 0, 0, 0, 0, 0,
104 /* device objects */ 1, 16 + 6, 16, 0, 0, 100, 0,
105 /* curve caps */ CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES |
106 CC_WIDE | CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT,
107 /* line caps */ LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
108 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS,
109 /* polygon caps */ PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON |
110 PC_SCANLINE | PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS,
112 /* regions */ CP_REGION,
113 /* raster caps */ RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 |
114 RC_DI_BITMAP | RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS,
115 /* aspects */ 36, 36, 51,
117 /* log pixels */ 0, 0,
119 /* palette size */ 0,
122 /**********************************************************************
125 BOOL32 X11DRV_Init(void)
127 /* FIXME: colormap management should be merged with the X11DRV */
129 if( !X11DRV_DIB_Init() ) return FALSE;
131 if( !COLOR_Init() ) return FALSE;
133 if( !X11DRV_OBM_Init() ) return FALSE;
135 /* Finish up device caps */
138 TRACE(x11drv, "Height = %-4i pxl, %-4i mm, Width = %-4i pxl, %-4i mm\n",
139 HeightOfScreen(X11DRV_GetXScreen()), HeightMMOfScreen(X11DRV_GetXScreen()),
140 WidthOfScreen(X11DRV_GetXScreen()), WidthMMOfScreen(X11DRV_GetXScreen()) );
143 X11DRV_DevCaps.version = 0x300;
144 X11DRV_DevCaps.horzSize = WidthMMOfScreen(X11DRV_GetXScreen()) * MONITOR_GetWidth(&MONITOR_PrimaryMonitor) / WidthOfScreen(X11DRV_GetXScreen());
145 X11DRV_DevCaps.vertSize = HeightMMOfScreen(X11DRV_GetXScreen()) * MONITOR_GetHeight(&MONITOR_PrimaryMonitor) / HeightOfScreen(X11DRV_GetXScreen());
146 X11DRV_DevCaps.horzRes = MONITOR_GetWidth(&MONITOR_PrimaryMonitor);
147 X11DRV_DevCaps.vertRes = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
148 X11DRV_DevCaps.bitsPixel = MONITOR_GetDepth(&MONITOR_PrimaryMonitor);
150 if( COLOR_GetSystemPaletteFlags() & COLOR_VIRTUAL )
151 X11DRV_DevCaps.sizePalette = 0;
154 X11DRV_DevCaps.rasterCaps |= RC_PALETTE;
155 X11DRV_DevCaps.sizePalette = DefaultVisual(display,DefaultScreen(display))->map_entries;
158 /* Resolution will be adjusted during the font init */
160 X11DRV_DevCaps.logPixelsX = (int)(X11DRV_DevCaps.horzRes * 25.4 / X11DRV_DevCaps.horzSize);
161 X11DRV_DevCaps.logPixelsY = (int)(X11DRV_DevCaps.vertRes * 25.4 / X11DRV_DevCaps.vertSize);
163 /* Create default bitmap */
165 if (!X11DRV_BITMAP_Init()) return FALSE;
167 /* Initialize brush dithering */
169 if (!X11DRV_BRUSH_Init()) return FALSE;
171 /* Initialize fonts and text caps */
173 if (!X11DRV_FONT_Init( &X11DRV_DevCaps )) return FALSE;
175 return DRIVER_RegisterDriver( "DISPLAY", &X11DRV_Funcs );
178 /**********************************************************************
181 static BOOL32 X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
182 LPCSTR output, const DEVMODE16* initData )
184 X11DRV_PDEVICE *physDev;
186 dc->physDev = physDev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
189 ERR(x11drv, "Can't allocate physDev\n");
193 dc->w.devCaps = &X11DRV_DevCaps;
194 if (dc->w.flags & DC_MEMORY)
196 X11DRV_PHYSBITMAP *pbitmap;
197 BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( dc->w.hBitmap,
199 X11DRV_CreateBitmap( dc->w.hBitmap );
200 pbitmap = bmp->DDBitmap->physBitmap;
201 physDev->drawable = pbitmap->pixmap;
202 physDev->gc = TSXCreateGC(display, physDev->drawable, 0, NULL);
203 dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
205 dc->w.totalExtent.left = 0;
206 dc->w.totalExtent.top = 0;
207 dc->w.totalExtent.right = bmp->bitmap.bmWidth;
208 dc->w.totalExtent.bottom = bmp->bitmap.bmHeight;
209 dc->w.hVisRgn = CreateRectRgnIndirect32( &dc->w.totalExtent );
211 GDI_HEAP_UNLOCK( dc->w.hBitmap );
215 physDev->drawable = X11DRV_GetXRootWindow();
216 physDev->gc = TSXCreateGC( display, physDev->drawable, 0, NULL );
217 dc->w.bitsPerPixel = MONITOR_GetDepth(&MONITOR_PrimaryMonitor);
219 dc->w.totalExtent.left = 0;
220 dc->w.totalExtent.top = 0;
221 dc->w.totalExtent.right = MONITOR_GetWidth(&MONITOR_PrimaryMonitor);
222 dc->w.totalExtent.bottom = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
223 dc->w.hVisRgn = CreateRectRgnIndirect32( &dc->w.totalExtent );
228 TSXFreeGC( display, physDev->gc );
232 TSXSetGraphicsExposures( display, physDev->gc, False );
233 TSXSetSubwindowMode( display, physDev->gc, IncludeInferiors );
239 /**********************************************************************
242 static BOOL32 X11DRV_DeleteDC( DC *dc )
244 X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
245 TSXFreeGC( display, physDev->gc );
246 HeapFree( GetProcessHeap(), 0, physDev );
251 /**********************************************************************
254 static INT32 X11DRV_Escape( DC *dc, INT32 nEscape, INT32 cbInput,
255 SEGPTR lpInData, SEGPTR lpOutData )
259 case GETSCALINGFACTOR:
262 LPPOINT16 lppt = (LPPOINT16)PTR_SEG_TO_LIN(lpOutData);
263 lppt->x = lppt->y = 0; /* no device scaling */
271 #endif /* !defined(X_DISPLAY_MISSING) */