diff options
author | Dave Davenport <qball@gmpclient.org> | 2015-01-21 18:38:54 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2015-01-21 18:38:54 +0100 |
commit | 19a0ec40f8b8b31a545114f4aba80c65367a4933 (patch) | |
tree | c48d877ff2a16c67fb7e298374c8b01563a711d0 /test | |
parent | 9cc63d494824dda325a3d8539a94d9d149d81757 (diff) |
Use fallback when truecolor visual fails.
- Fixes tests.
Diffstat (limited to 'test')
-rw-r--r-- | test/textbox-test.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/test/textbox-test.c b/test/textbox-test.c index c6b7d802..d8d9fe48 100644 --- a/test/textbox-test.c +++ b/test/textbox-test.c @@ -37,6 +37,22 @@ static unsigned int color_get ( Display *display, const char *const name ) } } +static void create_visual_and_colormap() +{ + map = None; + // Try to create TrueColor map + if(XMatchVisualInfo ( display, DefaultScreen ( display ), 32, TrueColor, &vinfo )) { + // Visual found, lets try to create map. + map = XCreateColormap ( display, DefaultRootWindow ( display ), vinfo.visual, AllocNone ); + } + // Failed to create map. + if (map == None ) { + // Two fields we use. + vinfo.visual = DefaultVisual(display, DefaultScreen(display)); + vinfo.depth = DefaultDepth(display, DefaultScreen(display)); + map = DefaultColormap( display, DefaultScreen (display)); + } +} int main ( int argc, char **argv ) { @@ -46,9 +62,7 @@ int main ( int argc, char **argv ) fprintf ( stderr, "cannot open display!\n" ); return EXIT_FAILURE; } - XMatchVisualInfo ( display, DefaultScreen ( display ), 32, TrueColor, &vinfo ); - map = XCreateColormap ( display, DefaultRootWindow ( display ), vinfo.visual, AllocNone ); - + create_visual_and_colormap(); TASSERT( display != NULL ); Screen *screen = DefaultScreenOfDisplay ( display ); Window root = RootWindow ( display, XScreenNumberOfScreen ( screen ) ); |