1996-08-24 20:26:35 +02:00
|
|
|
/*
|
|
|
|
* X11 graphics driver initialisation functions
|
|
|
|
*
|
|
|
|
* Copyright 1996 Alexandre Julliard
|
|
|
|
*/
|
|
|
|
|
1999-02-04 12:11:01 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-12-26 13:00:43 +01:00
|
|
|
#include "ts_xlib.h"
|
|
|
|
|
1996-08-24 20:26:35 +02:00
|
|
|
#include <string.h>
|
1999-04-01 10:16:08 +02:00
|
|
|
|
1996-08-24 20:26:35 +02:00
|
|
|
#include "bitmap.h"
|
2001-07-23 01:13:08 +02:00
|
|
|
#include "palette.h"
|
1999-06-26 21:09:08 +02:00
|
|
|
#include "debugtools.h"
|
1999-04-01 10:16:08 +02:00
|
|
|
#include "winnt.h"
|
|
|
|
#include "x11drv.h"
|
2001-04-17 19:29:59 +02:00
|
|
|
#include "ddrawi.h"
|
1998-02-15 20:40:49 +01:00
|
|
|
|
2000-08-01 01:32:47 +02:00
|
|
|
DEFAULT_DEBUG_CHANNEL(x11drv);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2001-07-27 21:37:31 +02:00
|
|
|
const DC_FUNCTIONS *X11DRV_DC_Funcs = NULL; /* hack */
|
1996-08-24 20:26:35 +02:00
|
|
|
|
1999-04-01 10:16:08 +02:00
|
|
|
BITMAP_DRIVER X11DRV_BITMAP_Driver =
|
|
|
|
{
|
|
|
|
X11DRV_DIB_SetDIBits,
|
|
|
|
X11DRV_DIB_GetDIBits,
|
2000-11-25 22:42:00 +01:00
|
|
|
X11DRV_DIB_DeleteDIBSection,
|
|
|
|
X11DRV_DIB_SetDIBColorTable,
|
2000-12-06 21:15:43 +01:00
|
|
|
X11DRV_DIB_GetDIBColorTable,
|
|
|
|
X11DRV_DIB_Lock,
|
|
|
|
X11DRV_DIB_Unlock
|
1999-04-01 10:16:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
PALETTE_DRIVER X11DRV_PALETTE_Driver =
|
|
|
|
{
|
|
|
|
X11DRV_PALETTE_SetMapping,
|
1999-04-10 18:37:43 +02:00
|
|
|
X11DRV_PALETTE_UpdateMapping,
|
|
|
|
X11DRV_PALETTE_IsDark
|
1999-04-01 10:16:08 +02:00
|
|
|
};
|
|
|
|
|
2001-05-11 02:17:47 +02:00
|
|
|
|
|
|
|
Display *gdi_display; /* display to use for all GDI functions */
|
|
|
|
|
|
|
|
|
2001-07-28 02:18:02 +02:00
|
|
|
/* a few dynamic device caps */
|
|
|
|
static int log_pixels_x; /* pixels per logical inch in x direction */
|
|
|
|
static int log_pixels_y; /* pixels per logical inch in y direction */
|
|
|
|
static int horz_size; /* horz. size of screen in millimeters */
|
|
|
|
static int vert_size; /* vert. size of screen in millimeters */
|
|
|
|
static int palette_size;
|
|
|
|
static int text_caps;
|
|
|
|
|
1996-08-24 20:26:35 +02:00
|
|
|
/**********************************************************************
|
1999-04-01 10:16:08 +02:00
|
|
|
* X11DRV_GDI_Initialize
|
1996-08-24 20:26:35 +02:00
|
|
|
*/
|
2001-05-11 02:17:47 +02:00
|
|
|
BOOL X11DRV_GDI_Initialize( Display *display )
|
1996-08-24 20:26:35 +02:00
|
|
|
{
|
2001-05-11 02:17:47 +02:00
|
|
|
Screen *screen = DefaultScreenOfDisplay(display);
|
|
|
|
|
|
|
|
gdi_display = display;
|
1999-04-01 10:16:08 +02:00
|
|
|
BITMAP_Driver = &X11DRV_BITMAP_Driver;
|
|
|
|
PALETTE_Driver = &X11DRV_PALETTE_Driver;
|
|
|
|
|
2001-07-28 02:18:02 +02:00
|
|
|
palette_size = X11DRV_PALETTE_Init();
|
1997-06-16 19:43:53 +02:00
|
|
|
|
1998-12-02 11:29:04 +01:00
|
|
|
if( !X11DRV_OBM_Init() ) return FALSE;
|
|
|
|
|
1997-02-02 20:01:52 +01:00
|
|
|
if (!X11DRV_BITMAP_Init()) return FALSE;
|
|
|
|
|
1997-06-16 19:43:53 +02:00
|
|
|
/* Initialize fonts and text caps */
|
1997-02-02 20:01:52 +01:00
|
|
|
|
2001-07-28 02:18:02 +02:00
|
|
|
log_pixels_x = MulDiv( WidthOfScreen(screen), 254, WidthMMOfScreen(screen) * 10 );
|
|
|
|
log_pixels_y = MulDiv( HeightOfScreen(screen), 254, HeightMMOfScreen(screen) * 10 );
|
|
|
|
text_caps = X11DRV_FONT_Init( &log_pixels_x, &log_pixels_y );
|
|
|
|
horz_size = MulDiv( screen_width, 254, log_pixels_x * 10 );
|
|
|
|
vert_size = MulDiv( screen_height, 254, log_pixels_y * 10 );
|
|
|
|
return TRUE;
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
|
1999-04-01 10:16:08 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_GDI_Finalize
|
|
|
|
*/
|
|
|
|
void X11DRV_GDI_Finalize(void)
|
|
|
|
{
|
2001-05-11 02:17:47 +02:00
|
|
|
X11DRV_PALETTE_Cleanup();
|
|
|
|
XCloseDisplay( gdi_display );
|
|
|
|
gdi_display = NULL;
|
1999-04-01 10:16:08 +02:00
|
|
|
}
|
|
|
|
|
1996-08-24 20:26:35 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_CreateDC
|
|
|
|
*/
|
2001-07-27 21:37:31 +02:00
|
|
|
BOOL X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
|
|
|
|
LPCSTR output, const DEVMODEA* initData )
|
1996-08-24 20:26:35 +02:00
|
|
|
{
|
|
|
|
X11DRV_PDEVICE *physDev;
|
|
|
|
|
2001-07-27 21:37:31 +02:00
|
|
|
if (!X11DRV_DC_Funcs) X11DRV_DC_Funcs = dc->funcs; /* hack */
|
|
|
|
|
1998-11-25 13:36:03 +01:00
|
|
|
dc->physDev = physDev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(*physDev) );
|
|
|
|
if(!physDev) {
|
1999-06-26 21:09:08 +02:00
|
|
|
ERR("Can't allocate physDev\n");
|
1998-11-25 13:36:03 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
1996-08-24 20:26:35 +02:00
|
|
|
|
2000-11-05 03:05:07 +01:00
|
|
|
if (dc->flags & DC_MEMORY)
|
1996-08-24 20:26:35 +02:00
|
|
|
{
|
2000-11-05 03:05:07 +01:00
|
|
|
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( dc->hBitmap, BITMAP_MAGIC );
|
2000-08-19 23:38:55 +02:00
|
|
|
if (!bmp)
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, physDev );
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-11-05 03:05:07 +01:00
|
|
|
if (!bmp->physBitmap) X11DRV_CreateBitmap( dc->hBitmap );
|
2000-03-28 15:37:50 +02:00
|
|
|
physDev->drawable = (Pixmap)bmp->physBitmap;
|
2001-05-11 02:17:47 +02:00
|
|
|
physDev->gc = TSXCreateGC( gdi_display, physDev->drawable, 0, NULL );
|
|
|
|
dc->bitsPerPixel = bmp->bitmap.bmBitsPixel;
|
2000-11-05 03:05:07 +01:00
|
|
|
dc->totalExtent.left = 0;
|
|
|
|
dc->totalExtent.top = 0;
|
|
|
|
dc->totalExtent.right = bmp->bitmap.bmWidth;
|
|
|
|
dc->totalExtent.bottom = bmp->bitmap.bmHeight;
|
|
|
|
GDI_ReleaseObj( dc->hBitmap );
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-11 02:17:47 +02:00
|
|
|
physDev->drawable = root_window;
|
|
|
|
physDev->gc = TSXCreateGC( gdi_display, physDev->drawable, 0, NULL );
|
|
|
|
dc->bitsPerPixel = screen_depth;
|
2000-11-05 03:05:07 +01:00
|
|
|
dc->totalExtent.left = 0;
|
|
|
|
dc->totalExtent.top = 0;
|
|
|
|
dc->totalExtent.right = screen_width;
|
|
|
|
dc->totalExtent.bottom = screen_height;
|
1996-08-24 20:26:35 +02:00
|
|
|
}
|
|
|
|
|
2000-05-12 22:18:14 +02:00
|
|
|
physDev->current_pf = 0;
|
|
|
|
physDev->used_visuals = 0;
|
2001-05-11 02:17:47 +02:00
|
|
|
|
|
|
|
if (!(dc->hVisRgn = CreateRectRgnIndirect( &dc->totalExtent )))
|
1996-08-24 20:26:35 +02:00
|
|
|
{
|
2001-05-11 02:17:47 +02:00
|
|
|
TSXFreeGC( gdi_display, physDev->gc );
|
2000-08-19 23:38:55 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, physDev );
|
1996-08-24 20:26:35 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-05-11 02:17:47 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XSetGraphicsExposures( gdi_display, physDev->gc, False );
|
|
|
|
XSetSubwindowMode( gdi_display, physDev->gc, IncludeInferiors );
|
|
|
|
XFlush( gdi_display );
|
|
|
|
wine_tsx11_unlock();
|
1996-08-24 20:26:35 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_DeleteDC
|
|
|
|
*/
|
2001-07-27 21:37:31 +02:00
|
|
|
BOOL X11DRV_DeleteDC( DC *dc )
|
1996-08-24 20:26:35 +02:00
|
|
|
{
|
|
|
|
X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
|
2001-05-11 02:17:47 +02:00
|
|
|
wine_tsx11_lock();
|
|
|
|
XFreeGC( gdi_display, physDev->gc );
|
2000-05-12 22:18:14 +02:00
|
|
|
while (physDev->used_visuals-- > 0)
|
2001-05-11 02:17:47 +02:00
|
|
|
XFree(physDev->visuals[physDev->used_visuals]);
|
|
|
|
wine_tsx11_unlock();
|
1998-11-25 13:36:03 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, physDev );
|
|
|
|
dc->physDev = NULL;
|
1996-08-24 20:26:35 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
1997-06-16 19:43:53 +02:00
|
|
|
|
2001-07-28 02:18:02 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetDeviceCaps (X11DRV.@)
|
|
|
|
*/
|
|
|
|
INT X11DRV_GetDeviceCaps( DC *dc, INT cap )
|
|
|
|
{
|
|
|
|
switch(cap)
|
|
|
|
{
|
|
|
|
case DRIVERVERSION:
|
|
|
|
return 0x300;
|
|
|
|
case TECHNOLOGY:
|
|
|
|
return DT_RASDISPLAY;
|
|
|
|
case HORZSIZE:
|
|
|
|
return horz_size;
|
|
|
|
case VERTSIZE:
|
|
|
|
return vert_size;
|
|
|
|
case HORZRES:
|
|
|
|
return screen_width;
|
|
|
|
case VERTRES:
|
|
|
|
return screen_height;
|
|
|
|
case BITSPIXEL:
|
|
|
|
return screen_depth;
|
|
|
|
case PLANES:
|
|
|
|
return 1;
|
|
|
|
case NUMBRUSHES:
|
|
|
|
return -1;
|
|
|
|
case NUMPENS:
|
|
|
|
return -1;
|
|
|
|
case NUMMARKERS:
|
|
|
|
return 0;
|
|
|
|
case NUMFONTS:
|
|
|
|
return 0;
|
|
|
|
case NUMCOLORS:
|
|
|
|
/* MSDN: Number of entries in the device's color table, if the device has
|
|
|
|
* a color depth of no more than 8 bits per pixel.For devices with greater
|
|
|
|
* color depths, -1 is returned. */
|
|
|
|
return (screen_depth > 8) ? -1 : (1 << screen_depth);
|
|
|
|
case PDEVICESIZE:
|
|
|
|
return sizeof(X11DRV_PDEVICE);
|
|
|
|
case CURVECAPS:
|
|
|
|
return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE |
|
|
|
|
CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT);
|
|
|
|
case LINECAPS:
|
|
|
|
return (LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
|
|
|
|
LC_STYLED | LC_WIDESTYLED | LC_INTERIORS);
|
|
|
|
case POLYGONALCAPS:
|
|
|
|
return (PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON | PC_SCANLINE |
|
|
|
|
PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS);
|
|
|
|
case TEXTCAPS:
|
|
|
|
return text_caps;
|
|
|
|
case CLIPCAPS:
|
|
|
|
return CP_REGION;
|
|
|
|
case RASTERCAPS:
|
|
|
|
return (RC_BITBLT | RC_BANDING | RC_SCALING | RC_BITMAP64 | RC_DI_BITMAP |
|
|
|
|
RC_DIBTODEV | RC_BIGFONT | RC_STRETCHBLT | RC_STRETCHDIB | RC_DEVBITS |
|
|
|
|
(palette_size ? RC_PALETTE : 0));
|
|
|
|
case ASPECTX:
|
|
|
|
case ASPECTY:
|
|
|
|
return 36;
|
|
|
|
case ASPECTXY:
|
|
|
|
return 51;
|
|
|
|
case LOGPIXELSX:
|
|
|
|
return log_pixels_x;
|
|
|
|
case LOGPIXELSY:
|
|
|
|
return log_pixels_y;
|
|
|
|
case CAPS1:
|
|
|
|
FIXME("(%04x): CAPS1 is unimplemented, will return 0\n", dc->hSelf );
|
|
|
|
/* please see wingdi.h for the possible bit-flag values that need
|
|
|
|
to be returned. also, see
|
|
|
|
http://msdn.microsoft.com/library/ddkdoc/win95ddk/graphcnt_1m0p.htm */
|
|
|
|
return 0;
|
|
|
|
case SIZEPALETTE:
|
|
|
|
return palette_size;
|
|
|
|
case NUMRESERVED:
|
|
|
|
case COLORRES:
|
|
|
|
case PHYSICALWIDTH:
|
|
|
|
case PHYSICALHEIGHT:
|
|
|
|
case PHYSICALOFFSETX:
|
|
|
|
case PHYSICALOFFSETY:
|
|
|
|
case SCALINGFACTORX:
|
|
|
|
case SCALINGFACTORY:
|
|
|
|
case VREFRESH:
|
|
|
|
case DESKTOPVERTRES:
|
|
|
|
case DESKTOPHORZRES:
|
|
|
|
case BTLALIGNMENT:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
FIXME("(%04x): unsupported capability %d, will return 0\n", dc->hSelf, cap );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-06-16 19:43:53 +02:00
|
|
|
/**********************************************************************
|
2001-07-29 22:25:14 +02:00
|
|
|
* ExtEscape (X11DRV.@)
|
1997-06-16 19:43:53 +02:00
|
|
|
*/
|
2001-07-29 22:25:14 +02:00
|
|
|
INT X11DRV_ExtEscape( DC *dc, INT escape, INT in_count, LPCVOID in_data,
|
|
|
|
INT out_count, LPVOID out_data )
|
1997-06-16 19:43:53 +02:00
|
|
|
{
|
2001-07-29 22:25:14 +02:00
|
|
|
switch(escape)
|
1997-06-16 19:43:53 +02:00
|
|
|
{
|
2001-07-29 22:25:14 +02:00
|
|
|
case QUERYESCSUPPORT:
|
|
|
|
if (in_data)
|
|
|
|
{
|
|
|
|
switch (*(INT *)in_data)
|
|
|
|
{
|
|
|
|
case DCICOMMAND:
|
|
|
|
return DD_HAL_VERSION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DCICOMMAND:
|
|
|
|
if (in_data)
|
|
|
|
{
|
|
|
|
const DCICMD *lpCmd = in_data;
|
|
|
|
if (lpCmd->dwVersion != DD_VERSION) break;
|
|
|
|
return X11DRV_DCICommand(in_count, lpCmd, out_data);
|
|
|
|
}
|
|
|
|
break;
|
1997-06-16 19:43:53 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|