mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Updates
This commit is contained in:
parent
93c01ccbd5
commit
681bd5bcbb
1 changed files with 34 additions and 22 deletions
|
@ -1479,10 +1479,6 @@ static int run_dmenu ()
|
||||||
// Cleanup font setup.
|
// Cleanup font setup.
|
||||||
textbox_cleanup ( );
|
textbox_cleanup ( );
|
||||||
|
|
||||||
if ( map != None ) {
|
|
||||||
XFreeColormap ( display, map );
|
|
||||||
map = None;
|
|
||||||
}
|
|
||||||
// Release the window.
|
// Release the window.
|
||||||
release_keyboard ( display );
|
release_keyboard ( display );
|
||||||
if ( main_window != None ) {
|
if ( main_window != None ) {
|
||||||
|
@ -1492,6 +1488,10 @@ static int run_dmenu ()
|
||||||
XFreeGC ( display, gc );
|
XFreeGC ( display, gc );
|
||||||
gc = NULL;
|
gc = NULL;
|
||||||
}
|
}
|
||||||
|
if ( map != None ) {
|
||||||
|
XFreeColormap ( display, map );
|
||||||
|
map = None;
|
||||||
|
}
|
||||||
// Cleanup pid file.
|
// Cleanup pid file.
|
||||||
if ( pidfile ) {
|
if ( pidfile ) {
|
||||||
unlink ( pidfile );
|
unlink ( pidfile );
|
||||||
|
@ -1730,10 +1730,7 @@ void show_error_message ( const char *msg, int markup )
|
||||||
textbox_setup ( &vinfo, map );
|
textbox_setup ( &vinfo, map );
|
||||||
error_dialog ( msg, markup );
|
error_dialog ( msg, markup );
|
||||||
textbox_cleanup ( );
|
textbox_cleanup ( );
|
||||||
if ( map != None ) {
|
//
|
||||||
XFreeColormap ( display, map );
|
|
||||||
map = None;
|
|
||||||
}
|
|
||||||
// Cleanup font setup.
|
// Cleanup font setup.
|
||||||
textbox_cleanup ( );
|
textbox_cleanup ( );
|
||||||
|
|
||||||
|
@ -1809,6 +1806,28 @@ static void reload_configuration ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup signal handling.
|
||||||
|
* Block all the signals, start a signal processor thread to handle these events.
|
||||||
|
*/
|
||||||
|
static GThread *setup_signal_thread ( int *fd )
|
||||||
|
{
|
||||||
|
// Block all HUP,INT,USR1 signals.
|
||||||
|
// In this and other child (they inherit mask)
|
||||||
|
sigset_t set;
|
||||||
|
sigemptyset ( &set );
|
||||||
|
sigaddset ( &set, SIGHUP );
|
||||||
|
sigaddset ( &set, SIGINT );
|
||||||
|
sigaddset ( &set, SIGUSR1 );
|
||||||
|
sigprocmask ( SIG_BLOCK, &set, NULL );
|
||||||
|
// Create signal handler process.
|
||||||
|
// This will use sigwaitinfo to read signals and forward them back to the main thread again.
|
||||||
|
return g_thread_new (
|
||||||
|
"signal_process",
|
||||||
|
pthread_signal_process,
|
||||||
|
(void *) fd );
|
||||||
|
}
|
||||||
|
|
||||||
int main ( int argc, char *argv[] )
|
int main ( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
int quiet = FALSE;
|
int quiet = FALSE;
|
||||||
|
@ -1987,23 +2006,16 @@ int main ( int argc, char *argv[] )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sigset_t set;
|
|
||||||
|
|
||||||
// Create a pipe to communicate between signal thread an main thread.
|
// Create a pipe to communicate between signal thread an main thread.
|
||||||
int pfds[2];
|
int pfds[2];
|
||||||
pipe ( pfds );
|
if ( pipe ( pfds ) != 0 ) {
|
||||||
// Block all HUP signals.
|
char * msg = g_strdup_printf ( "Failed to start rofi: '<i>%s</i>'", strerror ( errno ) );
|
||||||
// In this and other child (they inherit mask)
|
show_error_message ( msg, TRUE );
|
||||||
sigemptyset ( &set );
|
g_free ( msg );
|
||||||
sigaddset ( &set, SIGHUP );
|
exit ( EXIT_FAILURE );
|
||||||
sigaddset ( &set, SIGINT );
|
}
|
||||||
sigaddset ( &set, SIGUSR1 );
|
GThread *pid_signal_proc = setup_signal_thread ( &( pfds[1] ) );
|
||||||
sigprocmask ( SIG_BLOCK, &set, NULL );
|
|
||||||
// Create signal handler process.
|
|
||||||
GThread *pid_signal_proc = g_thread_new (
|
|
||||||
"signal_process",
|
|
||||||
pthread_signal_process,
|
|
||||||
(void *) &( pfds[1] ) );
|
|
||||||
|
|
||||||
// Application Main loop.
|
// Application Main loop.
|
||||||
// This listens in the background for any events on the Xserver
|
// This listens in the background for any events on the Xserver
|
||||||
|
|
Loading…
Reference in a new issue