1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Cleanup, possibly unbreak daemon mode.

This commit is contained in:
Qball Cow 2014-05-26 09:00:14 +02:00
parent c2f06d3f92
commit 469b566614
2 changed files with 26 additions and 32 deletions

View file

@ -1723,7 +1723,12 @@ static void run_switcher ( int do_fork, SwitcherMode mode )
display = XOpenDisplay ( 0 );
XSync ( display, True );
}
// Because of the above fork, we want to do this here.
// Make sure this is isolated to its own thread.
textbox_setup ( config.menu_font, active_font,
config.menu_bg, config.menu_fg,
config.menu_hlbg,
config.menu_hlfg );
char *input = NULL;
do
@ -1759,6 +1764,9 @@ static void run_switcher ( int do_fork, SwitcherMode mode )
free ( input );
// Cleanup font setup.
textbox_cleanup ();
if ( do_fork == TRUE )
{
exit ( EXIT_SUCCESS );
@ -1997,7 +2005,6 @@ static void parse_cmd_options ( int argc, char ** argv )
static void cleanup ()
{
textbox_cleanup ();
// Cleanup
if ( display != NULL )
{
@ -2141,10 +2148,6 @@ int main ( int argc, char *argv[] )
}
textbox_setup ( config.menu_font, active_font,
config.menu_bg, config.menu_fg,
config.menu_hlbg,
config.menu_hlfg );
XFreeModifiermap ( modmap );

View file

@ -43,8 +43,10 @@
extern Display *display;
/**
* Font + font color cache.
* Avoid re-loading font on every change on every textbox.
*/
XftFont *font = NULL;
XftFont *font_active = NULL;
XftColor color_fg;
@ -442,17 +444,15 @@ void textbox_setup (
const char *hlbg, const char *hlfg
)
{
Visual *visual = DefaultVisual ( display, DefaultScreen ( display ) );
Colormap colormap = DefaultColormap ( display, DefaultScreen ( display ) );
font = XftFontOpenName ( display, DefaultScreen ( display ), font_str );
font_active = XftFontOpenName ( display, DefaultScreen ( display ), font_active_str );
XftColorAllocName ( display, DefaultVisual ( display, DefaultScreen ( display ) ),
DefaultColormap ( display, DefaultScreen ( display ) ), fg, &color_fg );
XftColorAllocName ( display, DefaultVisual ( display, DefaultScreen ( display ) ),
DefaultColormap ( display, DefaultScreen ( display ) ), bg, &color_bg );
XftColorAllocName ( display, DefaultVisual ( display, DefaultScreen ( display ) ),
DefaultColormap ( display, DefaultScreen ( display ) ), hlfg, &color_hlfg );
XftColorAllocName ( display, DefaultVisual ( display, DefaultScreen ( display ) ),
DefaultColormap ( display, DefaultScreen ( display ) ), hlbg, &color_hlbg );
XftColorAllocName ( display, visual, colormap, fg, &color_fg );
XftColorAllocName ( display, visual, colormap, bg, &color_bg );
XftColorAllocName ( display, visual, colormap, hlfg, &color_hlfg );
XftColorAllocName ( display, visual, colormap, hlbg, &color_hlbg );
}
@ -460,27 +460,18 @@ void textbox_cleanup ()
{
if ( font != NULL )
{
Visual *visual = DefaultVisual ( display, DefaultScreen ( display ) );
Colormap colormap = DefaultColormap ( display, DefaultScreen ( display ) );
XftFontClose ( display, font );
font = NULL;
XftFontClose ( display, font_active );
font_active = NULL;
XftColorFree ( display,
DefaultVisual ( display, DefaultScreen ( display ) ),
DefaultColormap ( display, DefaultScreen ( display ) ),
&color_fg );
XftColorFree ( display,
DefaultVisual ( display, DefaultScreen ( display ) ),
DefaultColormap ( display, DefaultScreen ( display ) ),
&color_bg );
XftColorFree ( display,
DefaultVisual ( display, DefaultScreen ( display ) ),
DefaultColormap ( display, DefaultScreen ( display ) ),
&color_hlfg );
XftColorFree ( display,
DefaultVisual ( display, DefaultScreen ( display ) ),
DefaultColormap ( display, DefaultScreen ( display ) ),
&color_hlbg );
XftColorFree ( display, visual, colormap, &color_fg );
XftColorFree ( display, visual, colormap, &color_bg );
XftColorFree ( display, visual, colormap, &color_hlfg );
XftColorFree ( display, visual, colormap, &color_hlbg );
}
}