mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Use fallback when truecolor visual fails.
- Fixes tests.
This commit is contained in:
parent
9cc63d4948
commit
19a0ec40f8
2 changed files with 39 additions and 9 deletions
|
@ -363,6 +363,25 @@ GC gc = NULL;
|
|||
|
||||
Colormap map = None;
|
||||
XVisualInfo vinfo;
|
||||
|
||||
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.
|
||||
// Use the defaults then.
|
||||
if ( map == None ) {
|
||||
// Two fields we use.
|
||||
vinfo.visual = DefaultVisual ( display, DefaultScreen ( display ) );
|
||||
vinfo.depth = DefaultDepth ( display, DefaultScreen ( display ) );
|
||||
map = DefaultColormap ( display, DefaultScreen ( display ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a pixel value for an X named color
|
||||
*/
|
||||
|
@ -2107,8 +2126,7 @@ SwitcherMode run_switcher_window ( char **input, G_GNUC_UNUSED void *data )
|
|||
static int run_dmenu ()
|
||||
{
|
||||
// Request truecolor visual.
|
||||
XMatchVisualInfo ( display, DefaultScreen ( display ), 32, TrueColor, &vinfo );
|
||||
map = XCreateColormap ( display, DefaultRootWindow ( display ), vinfo.visual, AllocNone );
|
||||
create_visual_and_colormap ();
|
||||
int ret_state;
|
||||
textbox_setup ( &vinfo, map,
|
||||
config.menu_bg, config.menu_bg_alt, config.menu_fg,
|
||||
|
@ -2146,8 +2164,7 @@ static void run_switcher ( int do_fork, SwitcherMode mode )
|
|||
XSync ( display, True );
|
||||
}
|
||||
|
||||
XMatchVisualInfo ( display, DefaultScreen ( display ), 32, TrueColor, &vinfo );
|
||||
map = XCreateColormap ( display, DefaultRootWindow ( display ), vinfo.visual, AllocNone );
|
||||
create_visual_and_colormap ();
|
||||
|
||||
// Because of the above fork, we want to do this here.
|
||||
// Make sure this is isolated to its own thread.
|
||||
|
@ -2677,8 +2694,7 @@ int main ( int argc, char *argv[] )
|
|||
char *msg = NULL;
|
||||
if ( find_arg_str ( argc, argv, "-e", &( msg ) ) ) {
|
||||
// Request truecolor visual.
|
||||
XMatchVisualInfo ( display, DefaultScreen ( display ), 32, TrueColor, &vinfo );
|
||||
map = XCreateColormap ( display, DefaultRootWindow ( display ), vinfo.visual, AllocNone );
|
||||
create_visual_and_colormap ();
|
||||
textbox_setup ( &vinfo, map,
|
||||
config.menu_bg, config.menu_bg_alt, config.menu_fg,
|
||||
config.menu_hlbg,
|
||||
|
|
|
@ -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 ) );
|
||||
|
|
Loading…
Reference in a new issue