(X11 Series 1/3) Use correct visual for user-specified depth
Michael Karcher
wine at mkarcher.dialup.fu-berlin.de
Sun Mar 16 15:01:41 CDT 2008
Wine looks into the registry to find out the depth requested by the
user. The validation code just checked that this depth is supported by
the X server. This is not enough. One has to check that there really is
a visual supporting this very depth. And in that case, one has to use
that visual instead of the default one.
This patch reveals that using a non-default visual is not currently
working. This is addressed by the next patch in the series.
>From 2523b0dd68505ce0566da085cf33ff2737c9c773 Mon Sep 17 00:00:00 2001
From: Michael Karcher <wine at mkarcher.dialup.fu-berlin.de>
Date: Sun, 16 Mar 2008 20:40:39 +0100
Subject: [PATCH] Fixed validation of screen-depth parameter, including choosing
a matching visual.
---
dlls/winex11.drv/x11drv_main.c | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
index d445e64..7e84ca9 100644
--- a/dlls/winex11.drv/x11drv_main.c
+++ b/dlls/winex11.drv/x11drv_main.c
@@ -505,16 +505,26 @@ static BOOL process_attach(void)
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)
+ /* Priorities of visual classes */
+ static const int visclasses[] = {PseudoColor,TrueColor,DirectColor,StaticColor,GrayScale,StaticGray};
+ static const int classcount = sizeof(visclasses)/sizeof(visclasses[0]);
+ XVisualInfo visi;
+ int i;
+
+ for (i = 0; i < classcount; i++)
+ if (XMatchVisualInfo( display, XScreenNumberOfScreen( screen ), screen_depth, visclasses[i], &visi))
+ break;
+
+ if (i >= classcount)
{
WARN( "invalid depth %d, using default\n", screen_depth );
screen_depth = 0;
}
+ else if(visual != visi.visual)
+ {
+ WARN( "Using non-default visual. This is experimental!\n" );
+ visual = visi.visual;
+ }
}
if (!screen_depth) screen_depth = DefaultDepthOfScreen( screen );
screen_bpp = depth_to_bpp( screen_depth );
--
1.5.4.3
More information about the wine-patches
mailing list