Commit 988f2fde authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Store the full visual info for the default visual.

parent 0a939842
......@@ -1195,7 +1195,7 @@ DWORD X11DRV_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
X11DRV_PDEVICE *physdev = get_x11drv_dev( dev );
DWORD ret;
XImage *image;
XVisualInfo vis;
XVisualInfo vis = default_visual;
struct gdi_image_bits dst_bits;
const XPixmapFormatValues *format;
const BYTE *opcode = BITBLT_Opcodes[(rop >> 16) & 0xff];
......@@ -1217,7 +1217,7 @@ DWORD X11DRV_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
if (!bits) return ERROR_SUCCESS; /* just querying the format */
if ((src->width != dst->width) || (src->height != dst->height)) return ERROR_TRANSFORM_NOT_SUPPORTED;
image = XCreateImage( gdi_display, visual, vis.depth, ZPixmap, 0, NULL,
image = XCreateImage( gdi_display, vis.visual, vis.depth, ZPixmap, 0, NULL,
info->bmiHeader.biWidth, src->visrect.bottom - src->visrect.top, 32, 0 );
if (!image) return ERROR_OUTOFMEMORY;
......@@ -1286,7 +1286,7 @@ DWORD X11DRV_GetImage( PHYSDEV dev, BITMAPINFO *info,
X11DRV_PDEVICE *physdev = get_x11drv_dev( dev );
DWORD ret = ERROR_SUCCESS;
XImage *image;
XVisualInfo vis;
XVisualInfo vis = default_visual;
UINT align, x, y, width, height;
struct gdi_image_bits src_bits;
const XPixmapFormatValues *format;
......@@ -1403,7 +1403,7 @@ static DWORD put_pixmap_image( Pixmap pixmap, const XVisualInfo *vis,
coords.height = abs( info->bmiHeader.biHeight );
SetRect( &coords.visrect, 0, 0, coords.width, coords.height );
image = XCreateImage( gdi_display, visual, vis->depth, ZPixmap, 0, NULL,
image = XCreateImage( gdi_display, vis->visual, vis->depth, ZPixmap, 0, NULL,
coords.width, coords.height, 32, 0 );
if (!image) return ERROR_OUTOFMEMORY;
......@@ -1870,7 +1870,7 @@ struct window_surface *create_surface( Window window, const XVisualInfo *vis, co
surface->bits.free = free_heap_bits;
surface->image = XCreateImage( gdi_display, visual, vis->depth, ZPixmap, 0, NULL,
surface->image = XCreateImage( gdi_display, vis->visual, vis->depth, ZPixmap, 0, NULL,
width, height, 32, 0 );
if (!surface->image) goto failed;
surface->gc = XCreateGC( gdi_display, window, 0, NULL );
......
......@@ -115,7 +115,7 @@ static Pixmap BRUSH_DitherColor( COLORREF color, int depth)
XLockDisplay( gdi_display );
if (!ditherImage)
{
ditherImage = XCreateImage( gdi_display, visual, depth, ZPixmap, 0,
ditherImage = XCreateImage( gdi_display, default_visual.visual, depth, ZPixmap, 0,
NULL, MATRIX_SIZE, MATRIX_SIZE, 32, 0 );
if (!ditherImage)
{
......@@ -182,7 +182,7 @@ static Pixmap BRUSH_DitherMono( COLORREF color )
static void BRUSH_SelectSolidBrush( X11DRV_PDEVICE *physDev, COLORREF color )
{
COLORREF colorRGB = X11DRV_PALETTE_GetColor( physDev, color );
if ((physDev->depth > 1) && (screen_depth <= 8) && !X11DRV_IsSolidColor( color ))
if ((physDev->depth > 1) && (default_visual.depth <= 8) && !X11DRV_IsSolidColor( color ))
{
/* Dithered brush */
physDev->brush.pixmap = BRUSH_DitherColor( colorRGB, physDev->depth );
......@@ -206,22 +206,11 @@ static void BRUSH_SelectSolidBrush( X11DRV_PDEVICE *physDev, COLORREF color )
static BOOL select_pattern_brush( X11DRV_PDEVICE *physdev, const struct brush_pattern *pattern )
{
XVisualInfo vis;
XVisualInfo vis = default_visual;
Pixmap pixmap;
const BITMAPINFO *info = pattern->info;
memset( &vis, 0, sizeof(vis) );
vis.visual = visual;
vis.visualid = visual->visualid;
if (physdev->depth > 1 && info->bmiHeader.biBitCount > 1)
{
vis.depth = screen_depth;
vis.red_mask = visual->red_mask;
vis.green_mask = visual->green_mask;
vis.blue_mask = visual->blue_mask;
}
else vis.depth = 1;
if (physdev->depth == 1 || info->bmiHeader.biBitCount == 1) vis.depth = 1;
pixmap = create_pixmap_from_image( physdev->dev.hdc, &vis, info, &pattern->bits, pattern->usage );
if (!pixmap) return FALSE;
......
......@@ -259,13 +259,8 @@ static Window thread_selection_wnd(void)
if (!w)
{
XSetWindowAttributes attr;
attr.event_mask = (ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | EnterWindowMask | PropertyChangeMask);
w = XCreateWindow(thread_data->display, root_window, 0, 0, 1, 1, 0, screen_depth,
InputOutput, CopyFromParent, CWEventMask, &attr);
w = XCreateWindow(thread_data->display, root_window, 0, 0, 1, 1, 0, CopyFromParent,
InputOnly, CopyFromParent, 0, NULL);
if (w)
thread_data->selection_wnd = w;
else
......@@ -1319,7 +1314,7 @@ static HANDLE X11DRV_CLIPBOARD_ImportXAPIXMAP(Display *display, Window w, Atom p
if (X11DRV_CLIPBOARD_ReadProperty(display, w, prop, &lpdata, &cbytes))
{
XVisualInfo vis;
XVisualInfo vis = default_visual;
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
BITMAPINFO *info = (BITMAPINFO *)buffer;
struct gdi_image_bits bits;
......@@ -1338,18 +1333,7 @@ static HANDLE X11DRV_CLIPBOARD_ImportXAPIXMAP(Display *display, Window w, Atom p
TRACE("\tPixmap properties: width=%d, height=%d, depth=%d\n",
width, height, depth);
memset( &vis, 0, sizeof(vis) );
vis.depth = depth;
if (depth == screen_depth)
{
vis.visual = visual;
vis.visualid = visual->visualid;
vis.class = visual->class;
vis.red_mask = visual->red_mask;
vis.green_mask = visual->green_mask;
vis.blue_mask = visual->blue_mask;
}
else switch (pixmap_formats[depth]->bits_per_pixel)
if (depth != vis.depth) switch (pixmap_formats[depth]->bits_per_pixel)
{
case 1:
case 4:
......@@ -1757,24 +1741,14 @@ static HANDLE X11DRV_CLIPBOARD_ExportXAPIXMAP(Display *display, Window requestor
if (!lpdata->drvData) /* If not already rendered */
{
Pixmap pixmap;
XVisualInfo vis;
LPBITMAPINFO pbmi;
struct gdi_image_bits bits;
memset( &vis, 0, sizeof(vis) );
vis.visual = visual;
vis.depth = screen_depth;
vis.visualid = visual->visualid;
vis.class = visual->class;
vis.red_mask = visual->red_mask;
vis.green_mask = visual->green_mask;
vis.blue_mask = visual->blue_mask;
pbmi = GlobalLock( lpdata->hData );
bits.ptr = (LPBYTE)pbmi + bitmap_info_size( pbmi, DIB_RGB_COLORS );
bits.free = NULL;
bits.is_copy = FALSE;
pixmap = create_pixmap_from_image( 0, &vis, pbmi, &bits, DIB_RGB_COLORS );
pixmap = create_pixmap_from_image( 0, &default_visual, pbmi, &bits, DIB_RGB_COLORS );
GlobalUnlock( lpdata->hData );
lpdata->drvData = pixmap;
}
......
......@@ -143,14 +143,14 @@ Window CDECL X11DRV_create_desktop( UINT width, UINT height )
PointerMotionMask | ButtonPressMask | ButtonReleaseMask | FocusChangeMask;
win_attr.cursor = XCreateFontCursor( display, XC_top_left_arrow );
if (visual != DefaultVisual( display, DefaultScreen(display) ))
if (default_visual.visual != DefaultVisual( display, DefaultScreen(display) ))
win_attr.colormap = XCreateColormap( display, DefaultRootWindow(display),
visual, AllocNone );
default_visual.visual, AllocNone );
else
win_attr.colormap = None;
win = XCreateWindow( display, DefaultRootWindow(display),
0, 0, width, height, 0, screen_depth, InputOutput, visual,
0, 0, width, height, 0, default_visual.depth, InputOutput, default_visual.visual,
CWEventMask | CWCursor | CWColormap, &win_attr );
if (win != None && width == screen_width && height == screen_height)
{
......
......@@ -128,7 +128,7 @@ static BOOL X11DRV_CreateDC( PHYSDEV *pdev, LPCWSTR driver, LPCWSTR device,
if (!physDev) return FALSE;
physDev->depth = screen_depth;
physDev->depth = default_visual.depth;
physDev->color_shifts = &X11DRV_PALETTE_default_shifts;
SetRect( &physDev->dc_rect, 0, 0, virtual_screen_rect.right - virtual_screen_rect.left,
virtual_screen_rect.bottom - virtual_screen_rect.top );
......@@ -236,7 +236,7 @@ static INT X11DRV_GetDeviceCaps( PHYSDEV dev, INT cap )
/* 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);
return (default_visual.depth > 8) ? -1 : (1 << default_visual.depth);
case PDEVICESIZE:
return sizeof(X11DRV_PDEVICE);
case CURVECAPS:
......
......@@ -930,7 +930,7 @@ static Cursor create_xlib_monochrome_cursor( HDC hdc, const ICONINFOEXW *icon, i
unsigned char *mask_bits = NULL;
GC gc;
XColor fg, bg;
XVisualInfo vis;
XVisualInfo vis = default_visual;
Pixmap src_pixmap, bits_pixmap, mask_pixmap;
struct gdi_image_bits bits;
Cursor cursor = 0;
......@@ -1018,7 +1018,7 @@ static Cursor create_xlib_color_cursor( HDC hdc, const ICONINFOEXW *icon, int wi
BITMAPINFO *info = (BITMAPINFO *)buffer;
XColor fg, bg;
Cursor cursor = None;
XVisualInfo vis;
XVisualInfo vis = default_visual;
Pixmap xor_pixmap, mask_pixmap;
struct gdi_image_bits bits;
unsigned int *color_bits = NULL, *ptr;
......
......@@ -983,7 +983,7 @@ static void init_pixel_formats( Display *display )
* As of the introduction of composition managers at least Nvidia now also offers ARGB visuals
* with a depth of 32 in addition to the default 24 bit. In order to prevent BadMatch errors we only
* list formats with the same depth. */
if(visinfo->depth != screen_depth)
if(visinfo->depth != default_visual.depth)
{
XFree(visinfo);
continue;
......@@ -1233,7 +1233,7 @@ BOOL set_win_format( HWND hwnd, XID fbconfig_id )
if (parent)
gl->drawable = XCreateWindow( gdi_display, parent, gl->rect.left, gl->rect.top,
gl->rect.right - gl->rect.left, gl->rect.bottom - gl->rect.top,
0, screen_depth, InputOutput, gl->visual->visual,
0, default_visual.depth, InputOutput, gl->visual->visual,
CWBitGravity | CWWinGravity | CWBackingStore | CWColormap,
&attrib );
if (gl->drawable)
......@@ -1249,8 +1249,8 @@ BOOL set_win_format( HWND hwnd, XID fbconfig_id )
attrib.override_redirect = True;
if (!dummy_parent)
{
dummy_parent = XCreateWindow( gdi_display, root_window, -1, -1, 1, 1, 0, screen_depth,
InputOutput, visual, CWOverrideRedirect, &attrib );
dummy_parent = XCreateWindow( gdi_display, root_window, -1, -1, 1, 1, 0, default_visual.depth,
InputOutput, default_visual.visual, CWOverrideRedirect, &attrib );
XMapWindow( gdi_display, dummy_parent );
}
gl->colormap = XCreateColormap(gdi_display, dummy_parent, gl->visual->visual,
......
......@@ -149,9 +149,9 @@ int X11DRV_PALETTE_Init(void)
for( mask = 1; !((white & mask)^(black & mask)); mask <<= 1 )
monoPlane++;
X11DRV_PALETTE_PaletteFlags = (white & mask) ? X11DRV_PALETTE_WHITESET : 0;
palette_size = visual->map_entries;
palette_size = default_visual.colormap_size;
switch(visual->class)
switch(default_visual.class)
{
case DirectColor:
X11DRV_PALETTE_PaletteFlags |= X11DRV_PALETTE_VIRTUAL;
......@@ -162,7 +162,7 @@ int X11DRV_PALETTE_Init(void)
XSetWindowAttributes win_attr;
X11DRV_PALETTE_PaletteXColormap = XCreateColormap( gdi_display, root_window,
visual, AllocAll );
default_visual.visual, AllocAll );
if (X11DRV_PALETTE_PaletteXColormap)
{
X11DRV_PALETTE_PaletteFlags |= (X11DRV_PALETTE_PRIVATE | X11DRV_PALETTE_WHITESET);
......@@ -179,15 +179,15 @@ int X11DRV_PALETTE_Init(void)
}
} else {
X11DRV_PALETTE_PaletteXColormap = XCreateColormap(gdi_display, root_window,
visual, AllocNone);
default_visual.visual, AllocNone);
}
break;
case StaticGray:
X11DRV_PALETTE_PaletteXColormap = XCreateColormap(gdi_display, root_window,
visual, AllocNone);
default_visual.visual, AllocNone);
X11DRV_PALETTE_PaletteFlags |= X11DRV_PALETTE_FIXED;
X11DRV_PALETTE_Graymax = (1 << screen_depth)-1;
X11DRV_PALETTE_Graymax = (1 << default_visual.depth)-1;
break;
case TrueColor:
......@@ -204,21 +204,21 @@ int X11DRV_PALETTE_Init(void)
monoPlane++;
X11DRV_PALETTE_PaletteFlags = (white & mask) ? X11DRV_PALETTE_WHITESET : 0;
X11DRV_PALETTE_PaletteXColormap = XCreateColormap(gdi_display, root_window,
visual, AllocNone);
default_visual.visual, AllocNone);
}
else
{
X11DRV_PALETTE_PaletteXColormap = XCreateColormap(gdi_display, root_window,
visual, AllocNone);
default_visual.visual, AllocNone);
X11DRV_PALETTE_PaletteFlags |= X11DRV_PALETTE_FIXED;
X11DRV_PALETTE_ComputeColorShifts(&X11DRV_PALETTE_default_shifts, visual->red_mask, visual->green_mask, visual->blue_mask);
X11DRV_PALETTE_ComputeColorShifts(&X11DRV_PALETTE_default_shifts, default_visual.red_mask, default_visual.green_mask, default_visual.blue_mask);
}
XFree(depths);
break;
}
}
TRACE(" visual class %i (%i)\n", visual->class, monoPlane);
TRACE(" visual class %i (%i)\n", default_visual.class, monoPlane);
GetPaletteEntries( GetStockObject(DEFAULT_PALETTE), 0, NB_RESERVED_COLORS, sys_pal_template );
......@@ -242,7 +242,7 @@ int X11DRV_PALETTE_Init(void)
X11DRV_PALETTE_FormatSystemPalette();
X11DRV_PALETTE_FillDefaultColors( sys_pal_template );
palette_size = visual->map_entries;
palette_size = default_visual.colormap_size;
}
return palette_size;
......@@ -424,7 +424,7 @@ static BOOL X11DRV_PALETTE_BuildSharedMap( const PALETTEENTRY *sys_pal_template
bp = BlackPixel(gdi_display, DefaultScreen(gdi_display));
wp = WhitePixel(gdi_display, DefaultScreen(gdi_display));
max = (0xffffffff)>>(32 - screen_depth);
max = 0xffffffff >> (32 - default_visual.depth);
if( max > 256 )
{
step = max/256;
......@@ -528,7 +528,7 @@ static BOOL X11DRV_PALETTE_BuildSharedMap( const PALETTEENTRY *sys_pal_template
* to maintain compatibility
*/
palette_size = 256;
TRACE("Virtual colorspace - screendepth %i\n", screen_depth);
TRACE("Virtual colorspace - screendepth %i\n", default_visual.depth);
}
else palette_size = NB_RESERVED_COLORS; /* system palette only - however we can alloc a bunch
* of colors and map to them */
......@@ -556,7 +556,7 @@ static BOOL X11DRV_PALETTE_BuildSharedMap( const PALETTEENTRY *sys_pal_template
/* setup system palette entry <-> pixel mappings and fill in 20 fixed entries */
if (screen_depth <= 8)
if (default_visual.depth <= 8)
{
X11DRV_PALETTE_XPixelToPalette = HeapAlloc( GetProcessHeap(), 0, 256 * sizeof(int) );
if(X11DRV_PALETTE_XPixelToPalette == NULL) {
......@@ -786,7 +786,7 @@ COLORREF X11DRV_PALETTE_ToLogical(X11DRV_PDEVICE *physDev, int pixel)
/* check if we can bypass X */
if ((screen_depth <= 8) && (pixel < 256) &&
if ((default_visual.depth <= 8) && (pixel < 256) &&
!(X11DRV_PALETTE_PaletteFlags & (X11DRV_PALETTE_VIRTUAL | X11DRV_PALETTE_FIXED)) ) {
COLORREF ret;
EnterCriticalSection( &palette_cs );
......
......@@ -316,13 +316,14 @@ static int get_window_attributes( struct x11drv_win_data *data, XSetWindowAttrib
attr->bit_gravity = NorthWestGravity;
attr->win_gravity = StaticGravity;
attr->backing_store = NotUseful;
attr->border_pixel = 0;
attr->event_mask = (ExposureMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
KeyPressMask | KeyReleaseMask | FocusChangeMask |
KeymapStateMask | StructureNotifyMask);
if (data->managed) attr->event_mask |= PropertyChangeMask;
return (CWOverrideRedirect | CWSaveUnder | CWColormap |
return (CWOverrideRedirect | CWSaveUnder | CWColormap | CWBorderPixel |
CWEventMask | CWBitGravity | CWBackingStore);
}
......@@ -530,7 +531,7 @@ static BOOL create_icon_pixmaps( HDC hdc, const ICONINFO *icon, Pixmap *icon_ret
{
char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
BITMAPINFO *info = (BITMAPINFO *)buffer;
XVisualInfo vis;
XVisualInfo vis = default_visual;
struct gdi_image_bits bits;
Pixmap color_pixmap = 0, mask_pixmap = 0;
int i, lines;
......@@ -545,13 +546,6 @@ static BOOL create_icon_pixmaps( HDC hdc, const ICONINFO *icon, Pixmap *icon_ret
if (!(bits.ptr = HeapAlloc( GetProcessHeap(), 0, info->bmiHeader.biSizeImage ))) goto failed;
if (!GetDIBits( hdc, icon->hbmColor, 0, lines, bits.ptr, info, DIB_RGB_COLORS )) goto failed;
vis.visual = visual;
vis.depth = screen_depth;
vis.visualid = visual->visualid;
vis.class = visual->class;
vis.red_mask = visual->red_mask;
vis.green_mask = visual->green_mask;
vis.blue_mask = visual->blue_mask;
color_pixmap = create_pixmap_from_image( hdc, &vis, info, &bits, DIB_RGB_COLORS );
HeapFree( GetProcessHeap(), 0, bits.ptr );
bits.ptr = NULL;
......@@ -941,8 +935,8 @@ void update_user_time( Time time )
{
if (!user_time_window)
{
Window win = XCreateWindow( gdi_display, root_window, -1, -1, 1, 1, 0, 0, InputOnly,
DefaultVisual(gdi_display,DefaultScreen(gdi_display)), 0, NULL );
Window win = XCreateWindow( gdi_display, root_window, -1, -1, 1, 1, 0, CopyFromParent,
InputOnly, CopyFromParent, 0, NULL );
if (InterlockedCompareExchangePointer( (void **)&user_time_window, (void *)win, 0 ))
XDestroyWindow( gdi_display, win );
TRACE( "user time window %lx\n", user_time_window );
......@@ -1384,8 +1378,8 @@ static void create_whole_window( struct x11drv_win_data *data )
data->whole_window = XCreateWindow( data->display, root_window,
data->whole_rect.left - virtual_screen_rect.left,
data->whole_rect.top - virtual_screen_rect.top,
cx, cy, 0, screen_depth, InputOutput,
visual, mask, &attr );
cx, cy, 0, default_visual.depth, InputOutput,
default_visual.visual, mask, &attr );
if (!data->whole_window) goto done;
set_initial_wm_hints( data->display, data->whole_window );
......@@ -1633,7 +1627,8 @@ BOOL CDECL X11DRV_CreateWindow( HWND hwnd )
attr.override_redirect = TRUE;
attr.event_mask = StructureNotifyMask | FocusChangeMask;
data->clip_window = XCreateWindow( data->display, root_window, 0, 0, 1, 1, 0, 0,
InputOnly, visual, CWOverrideRedirect | CWEventMask, &attr );
InputOnly, default_visual.visual,
CWOverrideRedirect | CWEventMask, &attr );
XFlush( data->display );
SetPropA( hwnd, clip_window_prop, (HANDLE)data->clip_window );
}
......@@ -2014,7 +2009,6 @@ void CDECL X11DRV_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flag
{
struct x11drv_win_data *data = get_win_data( hwnd );
RECT surface_rect;
XVisualInfo vis;
DWORD flags;
COLORREF key;
BOOL layered = GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED;
......@@ -2056,17 +2050,10 @@ void CDECL X11DRV_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flag
}
else if (!(swp_flags & SWP_SHOWWINDOW) && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) goto done;
memset( &vis, 0, sizeof(vis) );
vis.visual = visual;
vis.visualid = visual->visualid;
vis.depth = screen_depth;
vis.red_mask = visual->red_mask;
vis.green_mask = visual->green_mask;
vis.blue_mask = visual->blue_mask;
if (!layered || !GetLayeredWindowAttributes( hwnd, &key, NULL, &flags ) || !(flags & LWA_COLORKEY))
key = CLR_INVALID;
*surface = create_surface( data->whole_window, &vis, &surface_rect, key );
*surface = create_surface( data->whole_window, &default_visual, &surface_rect, key );
done:
release_win_data( data );
......
......@@ -347,14 +347,13 @@ static inline size_t get_property_size( int format, unsigned long count )
return count * (format / 8);
}
extern Visual *visual DECLSPEC_HIDDEN;
extern XVisualInfo default_visual DECLSPEC_HIDDEN;
extern XPixmapFormatValues **pixmap_formats DECLSPEC_HIDDEN;
extern Window root_window DECLSPEC_HIDDEN;
extern int clipping_cursor DECLSPEC_HIDDEN;
extern unsigned int screen_width DECLSPEC_HIDDEN;
extern unsigned int screen_height DECLSPEC_HIDDEN;
extern unsigned int screen_bpp DECLSPEC_HIDDEN;
extern unsigned int screen_depth DECLSPEC_HIDDEN;
extern RECT virtual_screen_rect DECLSPEC_HIDDEN;
extern int use_xkb DECLSPEC_HIDDEN;
extern int usexrandr DECLSPEC_HIDDEN;
......
......@@ -56,13 +56,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
WINE_DECLARE_DEBUG_CHANNEL(synchronous);
WINE_DECLARE_DEBUG_CHANNEL(winediag);
static Screen *screen;
Visual *visual;
XVisualInfo default_visual = { 0 };
XPixmapFormatValues **pixmap_formats;
unsigned int screen_width;
unsigned int screen_height;
unsigned int screen_bpp;
unsigned int screen_depth;
RECT virtual_screen_rect;
Window root_window;
int usexvidmode = 1;
......@@ -386,9 +384,8 @@ static void setup_options(void)
if (!get_config_key( hkey, appkey, "GrabFullscreen", buffer, sizeof(buffer) ))
grab_fullscreen = IS_OPTION_TRUE( buffer[0] );
screen_depth = 0;
if (!get_config_key( hkey, appkey, "ScreenDepth", buffer, sizeof(buffer) ))
screen_depth = atoi(buffer);
default_visual.depth = atoi(buffer);
if (!get_config_key( hkey, appkey, "ClientSideGraphics", buffer, sizeof(buffer) ))
client_side_graphics = IS_OPTION_TRUE( buffer[0] );
......@@ -483,6 +480,36 @@ sym_not_found:
}
#endif /* defined(SONAME_LIBXCOMPOSITE) */
static void init_visuals( Display *display, int screen )
{
int count;
XVisualInfo *info;
default_visual.screen = screen;
if (default_visual.depth) /* depth specified */
{
info = XGetVisualInfo( display, VisualScreenMask | VisualDepthMask, &default_visual, &count );
if (info)
{
default_visual = *info;
XFree( info );
}
else WARN( "no visual found for depth %d\n", default_visual.depth );
}
if (!default_visual.visual)
{
default_visual.depth = DefaultDepth( display, screen );
default_visual.visual = DefaultVisual( display, screen );
default_visual.visualid = default_visual.visual->visualid;
default_visual.class = default_visual.visual->class;
default_visual.red_mask = default_visual.visual->red_mask;
default_visual.green_mask = default_visual.visual->green_mask;
default_visual.blue_mask = default_visual.visual->blue_mask;
default_visual.colormap_size = default_visual.visual->map_entries;
default_visual.bits_per_rgb = default_visual.visual->bits_per_rgb;
}
}
/***********************************************************************
* X11DRV process initialisation routine
......@@ -514,30 +541,13 @@ static BOOL process_attach(void)
if (!(display = XOpenDisplay( NULL ))) return FALSE;
fcntl( ConnectionNumber(display), F_SETFD, 1 ); /* set close on exec flag */
screen = DefaultScreenOfDisplay( display );
visual = DefaultVisual( display, DefaultScreen(display) );
root_window = DefaultRootWindow( display );
gdi_display = display;
old_error_handler = XSetErrorHandler( error_handler );
/* Initialize screen depth */
if (screen_depth) /* depth specified */
{
int depth_count, i;
int *depth_list = XListDepths(display, DefaultScreen(display), &depth_count);
for (i = 0; i < depth_count; i++)
if (depth_list[i] == screen_depth) break;
XFree( depth_list );
if (i >= depth_count)
{
WARN( "invalid depth %d, using default\n", screen_depth );
screen_depth = 0;
}
}
if (!screen_depth) screen_depth = DefaultDepthOfScreen( screen );
init_pixmap_formats( display );
screen_bpp = pixmap_formats[screen_depth]->bits_per_pixel;
init_visuals( display, DefaultScreen( display ));
screen_bpp = pixmap_formats[default_visual.depth]->bits_per_pixel;
XInternAtoms( display, (char **)atom_names, NB_XATOMS - FIRST_XATOM, False, X11DRV_Atoms );
......@@ -547,7 +557,8 @@ static BOOL process_attach(void)
if (TRACE_ON(synchronous)) XSynchronize( display, True );
xinerama_init( WidthOfScreen(screen), HeightOfScreen(screen) );
xinerama_init( DisplayWidth( display, default_visual.screen ),
DisplayHeight( display, default_visual.screen ));
X11DRV_Settings_Init();
/* initialize XVidMode */
......
......@@ -288,19 +288,13 @@ static BOOL get_xrender_template(const WineXRenderFormatTemplate *fmt, XRenderPi
static BOOL is_wxrformat_compatible_with_default_visual(const WineXRenderFormatTemplate *fmt)
{
if(fmt->depth != screen_depth)
return FALSE;
if( (fmt->redMask << fmt->red) != visual->red_mask)
return FALSE;
if( (fmt->greenMask << fmt->green) != visual->green_mask)
return FALSE;
if( (fmt->blueMask << fmt->blue) != visual->blue_mask)
return FALSE;
if(fmt->depth != default_visual.depth) return FALSE;
if( (fmt->redMask << fmt->red) != default_visual.red_mask) return FALSE;
if( (fmt->greenMask << fmt->green) != default_visual.green_mask) return FALSE;
if( (fmt->blueMask << fmt->blue) != default_visual.blue_mask) return FALSE;
/* We never select a default ARGB visual */
if(fmt->alphaMask)
return FALSE;
if(fmt->alphaMask) return FALSE;
return TRUE;
}
......@@ -315,18 +309,18 @@ static int load_xrender_formats(void)
if(is_wxrformat_compatible_with_default_visual(&wxr_formats_template[i]))
{
pict_formats[i] = pXRenderFindVisualFormat(gdi_display, visual);
pict_formats[i] = pXRenderFindVisualFormat(gdi_display, default_visual.visual);
if (!pict_formats[i])
{
/* Xrender doesn't like DirectColor visuals, try to find a TrueColor one instead */
if (visual->class == DirectColor)
if (default_visual.class == DirectColor)
{
XVisualInfo info;
if (XMatchVisualInfo( gdi_display, DefaultScreen(gdi_display),
screen_depth, TrueColor, &info ))
if (XMatchVisualInfo( gdi_display, default_visual.screen,
default_visual.depth, TrueColor, &info ))
{
pict_formats[i] = pXRenderFindVisualFormat(gdi_display, info.visual);
if (pict_formats[i]) visual = info.visual;
if (pict_formats[i]) default_visual = info;
}
}
}
......@@ -395,7 +389,7 @@ const struct gdi_dc_funcs *X11DRV_XRender_Init(void)
return NULL;
}
if (!visual->red_mask || !visual->green_mask || !visual->blue_mask)
if (!default_visual.red_mask || !default_visual.green_mask || !default_visual.blue_mask)
{
WARN("one or more of the colour masks are 0, disabling XRENDER. Try running in 16-bit mode or higher.\n");
return NULL;
......@@ -435,7 +429,7 @@ sym_not_found:
}
glyphsetCache[i-1].next = -1;
if(screen_depth <= 8 || !client_side_antialias_with_render) antialias = 0;
if(default_visual.depth <= 8 || !client_side_antialias_with_render) antialias = 0;
return &xrender_funcs;
}
......@@ -1798,7 +1792,7 @@ static DWORD create_image_pixmap( BITMAPINFO *info, const struct gdi_image_bits
GC gc;
XImage *image;
image = XCreateImage( gdi_display, visual, depth, ZPixmap, 0, NULL,
image = XCreateImage( gdi_display, default_visual.visual, depth, ZPixmap, 0, NULL,
info->bmiHeader.biWidth, height, 32, 0 );
if (!image) return ERROR_OUTOFMEMORY;
......@@ -2330,14 +2324,13 @@ static HBRUSH xrenderdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct b
{
struct xrender_physdev *physdev = get_xrender_dev( dev );
Pixmap pixmap;
XVisualInfo vis;
XVisualInfo vis = default_visual;
XRenderPictFormat *format = physdev->pict_format;
if (!pattern) goto x11drv_fallback;
if (pattern->info->bmiHeader.biBitCount == 1) goto x11drv_fallback;
if (physdev->format == WXR_FORMAT_MONO) goto x11drv_fallback;
memset( &vis, 0, sizeof(vis) );
vis.depth = format->depth;
vis.red_mask = format->direct.redMask << format->direct.red;
vis.green_mask = format->direct.greenMask << format->direct.green;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment