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