From fef3094bcfb4fae0b7409bb5270ec260b1c6ddee Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Sat, 25 May 2013 18:53:19 -0400 Subject: [PATCH] Added for standard bool definitions Updated GetArguments() to explicitely indicate that it can extract a single argument or a full line, but not in-between --- src/common.h | 8 +----- src/configfile.c | 73 ++++++++++++++++++++++++------------------------ src/dockapp.c | 8 +++--- src/imap.c | 18 ++++++------ src/network.c | 10 +++---- src/options.c | 34 +++++++++++----------- src/pop3.c | 2 +- src/wmnotify.c | 54 +++++++++++++++++------------------ src/wmnotify.h | 1 + src/xevents.c | 24 ++++++++-------- 10 files changed, 114 insertions(+), 118 deletions(-) diff --git a/src/common.h b/src/common.h index 9a3d3e8..e8ee901 100644 --- a/src/common.h +++ b/src/common.h @@ -6,6 +6,7 @@ #include #include +#include #include #if STDC_HEADERS @@ -21,13 +22,6 @@ # define EXIT_FAILURE 1 #endif -typedef int bool; -#ifndef FALSE -# define FALSE 0 -# define TRUE 1 -#endif - - /* Returns TRUE if the strings 'a' and 'b' are equal. */ #define STREQ(a, b) (strcmp((a), (b)) == 0) diff --git a/src/configfile.c b/src/configfile.c index 4bdfb9e..06c979d 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -10,6 +10,7 @@ #include #include #include +#include #if STDC_HEADERS # include @@ -120,19 +121,19 @@ ParseCommand( char *line, /*@out@*/ char *argv[] ) static char * -GetArguments( char *parameter, int number_of_arguments ) +GetArguments( char *parameter, bool single_argument ) { char *token; - if( number_of_arguments > 1 ) { + if( single_argument ) { + token = strtok( NULL, delimiter_single_arg ); + } + else { /* We search for a string terminated by either a '#' character (the rest of the line is then a comment, which is simply ignored ), or the end of line character '\n'. */ token = strtok( NULL, delimiter_multiple_arg ); } - else { - token = strtok( NULL, delimiter_single_arg ); - } if( token == NULL ) { fprintf( stderr, "%s: Missing argument for \"%s\" parameter in " @@ -164,17 +165,17 @@ ParseConfigurationFile( FILE *file ) { char line[LINE_BUFFER_LEN]; char *token; - bool protocol_found = FALSE; - bool server_found = FALSE; - bool username_found = FALSE; - bool password_found = FALSE; + bool protocol_found = false; + bool server_found = false; + bool username_found = false; + bool password_found = false; const char *err_string = NULL; /* Default values for optional parameters. */ wmnotify_infos.port = 110; wmnotify_infos.mail_check_interval = 60; /* 1 minute interval. */ - wmnotify_infos.audible_notification = FALSE; /* Disabled. */ - wmnotify_infos.use_ssl = FALSE; /* Disabled. */ + wmnotify_infos.audible_notification = false; /* Disabled. */ + wmnotify_infos.use_ssl = false; /* Disabled. */ wmnotify_infos.mail_client_argv[0] = NULL; /* No default command. */ wmnotify_infos.audiofile[0] = '\0'; /* No default audio file. */ wmnotify_infos.volume = 100; /* 100% volume. */ @@ -192,11 +193,11 @@ ParseConfigurationFile( FILE *file ) } if( STREQ( token, "protocol" ) ) { - token = GetArguments( "protocol", 1 ); - if( STREQ( token, "POP3" ) == TRUE ) { + token = GetArguments( "protocol", true ); + if( STREQ( token, "POP3" ) == true ) { wmnotify_infos.protocol = POP3_PROTOCOL; } - else if( STREQ( token, "IMAP4" ) == TRUE ) { + else if( STREQ( token, "IMAP4" ) == true ) { wmnotify_infos.protocol = IMAP4_PROTOCOL; } else { @@ -204,18 +205,18 @@ ParseConfigurationFile( FILE *file ) exit( EXIT_FAILURE ); } - protocol_found = TRUE; + protocol_found = true; } else if( STREQ( token, "use_ssl" ) ){ int number; - token = GetArguments( "use_ssl", 1 ); + token = GetArguments( "use_ssl", true ); number = GetNumber( token, "use_ssl" ); if( number == 0 ) { - wmnotify_infos.use_ssl = FALSE; + wmnotify_infos.use_ssl = false; } else if( number == 1 ) { - wmnotify_infos.use_ssl = TRUE; + wmnotify_infos.use_ssl = true; } else { fprintf( stderr, "%s: Invalid value for for parameter 'enablebeep' in\n" \ @@ -224,29 +225,29 @@ ParseConfigurationFile( FILE *file ) } } else if( STREQ( token, "server" ) ) { - token = GetArguments( "server", 1 ); + token = GetArguments( "server", true ); strncpy( wmnotify_infos.server_name, token, MAX_STR_LEN ); - server_found = TRUE; + server_found = true; } else if( STREQ( token, "port" ) ) { - token = GetArguments( "port", 1 ); + token = GetArguments( "port", true ); wmnotify_infos.port = (u_int16_t) GetNumber( token, "port" ); } else if( STREQ( token, "username" ) ) { - token = GetArguments( "username", 1 ); + token = GetArguments( "username", true ); strncpy( wmnotify_infos.username, token, MAX_STR_LEN ); - username_found = TRUE; + username_found = true; } else if( STREQ( token, "password" ) ) { - token = GetArguments( "password", 1 ); + token = GetArguments( "password", true ); strncpy( wmnotify_infos.password, token, MAX_STR_LEN ); - password_found = TRUE; + password_found = true; } else if( STREQ( token, "mailcheckdelay" ) ) { int delay; /* delay in minutes. */ - token = GetArguments( "mailcheckdelay", 1 ); + token = GetArguments( "mailcheckdelay", true ); /* GetNumber() will exit if a negative number is entered. */ delay = GetNumber( token, "mailcheckdelay" ); if( delay == 0 ) { @@ -257,7 +258,7 @@ ParseConfigurationFile( FILE *file ) wmnotify_infos.mail_check_interval = (unsigned int) delay * 60; } else if( STREQ( token, "mailclient" ) ) { - token = GetArguments( "mailclient", 2 ); /* Multiple arguments */ + token = GetArguments( "mailclient", false ); /* Multiple arguments */ strcpy( wmnotify_infos.mail_client_command, token ); ParseCommand( wmnotify_infos.mail_client_command, wmnotify_infos.mail_client_argv ); @@ -265,13 +266,13 @@ ParseConfigurationFile( FILE *file ) else if( STREQ( token, "enablebeep" ) ){ int number; - token = GetArguments( "enablebeep", 1 ); + token = GetArguments( "enablebeep", true ); number = GetNumber( token, "enablebeep" ); if( number == 0 ) { - wmnotify_infos.audible_notification = FALSE; + wmnotify_infos.audible_notification = false; } else if( number == 1 ) { - wmnotify_infos.audible_notification = TRUE; + wmnotify_infos.audible_notification = true; } else { fprintf( stderr, "%s: Invalid value for for parameter 'enablebeep' in\n" \ @@ -280,12 +281,12 @@ ParseConfigurationFile( FILE *file ) } } else if( STREQ( token, "audiofile" ) ) { - token = GetArguments( "audiofile", 1 ); + token = GetArguments( "audiofile", true ); /* Should check size before using strcpy(), or use strncopy() instead. */ strcpy( wmnotify_infos.audiofile, token ); } else if( STREQ( token, "volume" ) ) { - token = GetArguments( "volume", 1 ); + token = GetArguments( "volume", true ); wmnotify_infos.volume = GetNumber( token, "volume" ); } else { @@ -302,16 +303,16 @@ ParseConfigurationFile( FILE *file ) } } - if( protocol_found == FALSE ) { + if( protocol_found == false ) { err_string = "protocol"; } - else if( server_found == FALSE ) { + else if( server_found == false ) { err_string = "server"; } - else if( username_found == FALSE ) { + else if( username_found == false ) { err_string = "username"; } - else if( password_found == FALSE ) { + else if( password_found == false ) { err_string = "password"; } else { diff --git a/src/dockapp.c b/src/dockapp.c index 9f8994b..c4c98f5 100644 --- a/src/dockapp.c +++ b/src/dockapp.c @@ -72,14 +72,14 @@ GetColor( char *name ) color.pixel = 0; res = (bool) XParseColor( dockapp.display, attributes.colormap, name, &color ); - if( res == FALSE ) { + if( res == false ) { fprintf( stderr, "%s: Can't parse %s.\n", PACKAGE, name ); ErrorLocation( __FILE__, __LINE__ ); exit( EXIT_FAILURE ); } res = (bool) XAllocColor( dockapp.display, attributes.colormap, &color ); - if( res == FALSE ) { + if( res == false ) { fprintf( stderr, "%s: Can't allocate %s.\n", PACKAGE, name ); ErrorLocation( __FILE__, __LINE__ ); exit( EXIT_FAILURE ); @@ -93,9 +93,9 @@ static void flush_expose( Window win ) { XEvent dummy; - bool res = TRUE; + bool res = true; - while( res != FALSE ) { + while( res != false ) { res = (bool) XCheckTypedWindowEvent( dockapp.display, win, Expose, &dummy ); } } diff --git a/src/imap.c b/src/imap.c index bb80082..0e4c03e 100644 --- a/src/imap.c +++ b/src/imap.c @@ -89,7 +89,7 @@ IMAP4_ReceiveResponse( void ) /* We suppose that, if a partial response packet was sent, it is not broken in the middle of a line (to confirm). Normally, each string is terminated by CRLF. */ - if( STREQ_LEN( &rx_buffer[ len - 2 ], IMAP4_ENDL, 2 ) == FALSE ) { + if( STREQ_LEN( &rx_buffer[ len - 2 ], IMAP4_ENDL, 2 ) == false ) { /* No CRLF found at the end of the buffer --> not handled by wmnotify. */ ErrorLocation( __FILE__, __LINE__ ); fprintf( stderr, "Response buffer doesn't contain CRLF at the end.\n" ); @@ -140,24 +140,24 @@ IMAP4_ReceiveResponse( void ) if( token[0] == '*' ) { /* Untagged response. If there is a space after the SEARCH response, it means * at least 1 message is unseen. */ - if( STREQ_LEN( token, IMAP4_RSP_SEARCH_UNSEEN, strlen(IMAP4_RSP_SEARCH_UNSEEN) ) == TRUE ) { - unseen_string_found = TRUE; + if( STREQ_LEN( token, IMAP4_RSP_SEARCH_UNSEEN, strlen(IMAP4_RSP_SEARCH_UNSEEN) ) == true ) { + unseen_string_found = true; } } else { /* Must be the status... */ /* We check for the correct transaction label plus a space. */ - if( STREQ_LEN( token, tx_buffer, tlabel_len + 1 ) == TRUE ) { + if( STREQ_LEN( token, tx_buffer, tlabel_len + 1 ) == true ) { token += tlabel_len + 1; - if( STREQ_LEN( token, IMAP4_RSP_SUCCESS, strlen(IMAP4_RSP_SUCCESS) ) == TRUE ) { + if( STREQ_LEN( token, IMAP4_RSP_SUCCESS, strlen(IMAP4_RSP_SUCCESS) ) == true ) { goto end; /* OK, no errors. */ } - else if( STREQ_LEN( token, IMAP4_RSP_PROTOCOL_ERR, strlen(IMAP4_RSP_PROTOCOL_ERR) ) == TRUE ) { + else if( STREQ_LEN( token, IMAP4_RSP_PROTOCOL_ERR, strlen(IMAP4_RSP_PROTOCOL_ERR) ) == true ) { fprintf( stderr, "%s: Protocol error (%s).\n", PACKAGE, token ); goto error; } - else if( STREQ_LEN( token, IMAP4_RSP_FAILURE, strlen(IMAP4_RSP_FAILURE) ) == TRUE ) { + else if( STREQ_LEN( token, IMAP4_RSP_FAILURE, strlen(IMAP4_RSP_FAILURE) ) == true ) { fprintf( stderr, "%s: Failure (%s).\n", PACKAGE, token ); goto error; } @@ -263,7 +263,7 @@ IMAP4_CheckForNewMail( void ) * and UNSEEN will have entries. But if we recheck again later, RECENT will report zero. * RECENT, when set, simply means that there are new messages since our last visit. But, on the other hand, when using EXAMINE, no messages should lose their RECENT flag. */ - unseen_string_found = FALSE; + unseen_string_found = false; argv[0] = IMAP4_CMD_SEARCH_UNSEEN; argv[1] = ""; status = IMAP4_SendCommand( 1, argv ); @@ -272,7 +272,7 @@ IMAP4_CheckForNewMail( void ) goto imap4_logout; } - if( unseen_string_found == TRUE ) { + if( unseen_string_found == true ) { new_messages = 1; } diff --git a/src/network.c b/src/network.c index b46bce7..0863cd8 100644 --- a/src/network.c +++ b/src/network.c @@ -106,7 +106,7 @@ ConnectionEstablish( char *server_name, int port ) } #if HAVE_SSL - if( wmnotify_infos.use_ssl == TRUE ) { + if( wmnotify_infos.use_ssl == true ) { int status; status = InitSSL( wmnotify_infos.sock_fd ); if( status != EXIT_SUCCESS ) { @@ -137,7 +137,7 @@ int ConnectionTerminate( void ) { #if HAVE_SSL - if( wmnotify_infos.use_ssl == TRUE ) { + if( wmnotify_infos.use_ssl == true ) { SSL_free( ssl_infos.ssl ); /* release connection state */ } #endif @@ -145,7 +145,7 @@ ConnectionTerminate( void ) close( wmnotify_infos.sock_fd ); /* close socket */ #if HAVE_SSL - if( wmnotify_infos.use_ssl == TRUE ) { + if( wmnotify_infos.use_ssl == true ) { SSL_CTX_free( ssl_infos.ctx ); /* release context */ } #endif @@ -160,7 +160,7 @@ WmnotifySendData( char *buffer, int size ) int len; #if HAVE_SSL - if( wmnotify_infos.use_ssl == TRUE ) { + if( wmnotify_infos.use_ssl == true ) { len = SSL_write( ssl_infos.ssl, buffer, size ); /* Encrypt & send message */ if( len <= 0 ) { SSL_get_error( ssl_infos.ssl, len ); @@ -193,7 +193,7 @@ WmnotifyGetResponse( char *buffer, int max_size ) int len; #if HAVE_SSL - if( wmnotify_infos.use_ssl == TRUE ) { + if( wmnotify_infos.use_ssl == true ) { len = SSL_read( ssl_infos.ssl, buffer, max_size ); /* Get reply & decrypt. */ switch( SSL_get_error( ssl_infos.ssl, len ) ) { case SSL_ERROR_NONE: diff --git a/src/options.c b/src/options.c index 1d3e066..58bd08b 100644 --- a/src/options.c +++ b/src/options.c @@ -75,12 +75,12 @@ ParseCommandLineOptions( int argc, char *argv[] ) { int i; char *token; - bool config_file_on = FALSE; - bool display_on = FALSE; - bool geometry_on = FALSE; + bool config_file_on = false; + bool display_on = false; + bool geometry_on = false; /* Default values. */ - wmnotify_infos.debug = FALSE; + wmnotify_infos.debug = false; for( i = 1; i < argc; i++ ) { token = argv[i]; @@ -90,7 +90,7 @@ ParseCommandLineOptions( int argc, char *argv[] ) switch( token[1] ) { case 'c': if( strlen( &token[1] ) == 1 ) { - config_file_on = TRUE; + config_file_on = true; } else { InvalidOption( "invalid option", token ); @@ -98,15 +98,15 @@ ParseCommandLineOptions( int argc, char *argv[] ) break; case 'd': if( STREQ( "display", &token[1] ) ) { - display_on = TRUE; + display_on = true; } else if( strlen( &token[1] ) == 1 ) { - wmnotify_infos.debug = TRUE; + wmnotify_infos.debug = true; } break; case 'g': if( STREQ( "geometry", &token[1] ) ) { - geometry_on = TRUE; + geometry_on = true; } else { InvalidOption( "invalid option", token ); @@ -135,17 +135,17 @@ ParseCommandLineOptions( int argc, char *argv[] ) break; default: /* Processing options arguments */ - if( config_file_on != FALSE ) { + if( config_file_on != false ) { wmnotify_infos.optional_config_file = token; /*strcpy( config_file_name, token );*/ - config_file_on = FALSE; + config_file_on = false; } - else if( display_on != FALSE ) { - display_on = FALSE; + else if( display_on != false ) { + display_on = false; wmnotify_infos.display_arg = token; } - else if( geometry_on != FALSE ) { - geometry_on = FALSE; + else if( geometry_on != false ) { + geometry_on = false; wmnotify_infos.geometry_arg = token; } else { @@ -155,13 +155,13 @@ ParseCommandLineOptions( int argc, char *argv[] ) } /* end switch( token[0] ) */ } /* end for */ - if( config_file_on != FALSE ) { + if( config_file_on != false ) { InvalidOption( "missing configuration file parameter", NULL ); } - else if( display_on != FALSE ) { + else if( display_on != false ) { InvalidOption( "missing display parameter", NULL ); } - else if( geometry_on != FALSE ) { + else if( geometry_on != false ) { InvalidOption( "missing geometry parameter", NULL ); } } diff --git a/src/pop3.c b/src/pop3.c index 268647c..eed0f09 100644 --- a/src/pop3.c +++ b/src/pop3.c @@ -51,7 +51,7 @@ POP3_ReceiveResponse( void ) /* Check the status indicator returned by the POP3 server. There are currently two status indicators: positive ("+OK") and negative ("-ERR"). Servers MUST send the status indicators in upper case. */ - if( STREQ_LEN( rx_buffer, POP3_RSP_SUCCESS, strlen(POP3_RSP_SUCCESS) ) == FALSE ) { + if( STREQ_LEN( rx_buffer, POP3_RSP_SUCCESS, strlen(POP3_RSP_SUCCESS) ) == false ) { fprintf( stderr, "%s: Error, POP3 server responded:\n \"%s\"\n", PACKAGE, rx_buffer ); len = -1; } diff --git a/src/wmnotify.c b/src/wmnotify.c index 069ce37..9064ab6 100644 --- a/src/wmnotify.c +++ b/src/wmnotify.c @@ -39,18 +39,18 @@ /* Set in DoubleClick() to stop the new mail animation when the mail client is opened. */ -static bool animation_stop = FALSE; +static bool animation_stop = false; static int animation_image = MAILBOX_FULL; -/* Set in response to signal sent by SingleClick() to force mail check. Also set to TRUE at +/* Set in response to signal sent by SingleClick() to force mail check. Also set to true at * startup to force initial check. */ -static bool manual_check = TRUE; +static bool manual_check = true; /* Used to signal TimerThread to quit. Inactive for now. */ -static bool quit = FALSE; +static bool quit = false; -static int double_click_notif = FALSE; +static int double_click_notif = false; /* TimerThread ID */ static pthread_t timer_thread; @@ -190,7 +190,7 @@ DoubleClick( void ) /* Starting external mail client. */ ExecuteCommand( wmnotify_infos.mail_client_argv ); - double_click_notif = TRUE; + double_click_notif = true; /* Sending a signal to awake the TimerThread() thread. This was previously done with a mutex variable (animation_stop), but this caused a bug when the @@ -203,7 +203,7 @@ DoubleClick( void ) displayed. This was because setting the mutex variable 'animation_stop' didn't awakened the TimerThread(), but single-clicking awakened it. Since the - 'animation_stop' variable was still set to TRUE, no animation occured. */ + 'animation_stop' variable was still set to true, no animation occured. */ status = pthread_kill( timer_thread, SIGUSR2 ); if( status != EXIT_SUCCESS ) { fprintf( stderr, "%s: pthread_kill() error (%d)\n", PACKAGE, status ); @@ -215,7 +215,7 @@ DoubleClick( void ) sleep(1); DisplayClosedMailbox(); - double_click_notif = FALSE; + double_click_notif = false; } else { fprintf( stderr, "%s: Warning: No email-client defined.\n", PACKAGE ); @@ -249,11 +249,11 @@ CatchTimerSignal( int signal ) switch( signal ) { case SIGUSR1: /* Catching the signal sent by the SingleClick() function. */ - manual_check = TRUE; + manual_check = true; break; case SIGUSR2: /* Catching the signal sent by the DoubleClick() function. */ - animation_stop = TRUE; + animation_stop = true; break; default: fprintf( stderr, "%s: CatchTimerSignal(): unknown signal (%d)\n", PACKAGE, @@ -290,7 +290,7 @@ CheckForNewMail( bool manual_check ) { int new_messages; - if( manual_check == TRUE ) { + if( manual_check == true ) { DisplayOpenedEmptyMailbox(); } @@ -305,7 +305,7 @@ CheckForNewMail( bool manual_check ) exit( EXIT_FAILURE ); } - if( ( manual_check == TRUE ) && ( new_messages > 0 ) ) { + if( ( manual_check == true ) && ( new_messages > 0 ) ) { animation_image = MAILBOX_FULL; } @@ -318,7 +318,7 @@ TimerThread( /*@unused@*/ void *arg ) { int new_messages = 0; int counter = -1; - bool animation_running = FALSE; + bool animation_running = false; /* For catching the signal SIGUSR1. This signal is sent by the main program thread when the * user is issuing a single-click to manually check for new mails. */ @@ -328,13 +328,13 @@ TimerThread( /*@unused@*/ void *arg ) * user is issuing a double-click to start ther external mail client. */ (void) signal( SIGUSR2, CatchTimerSignal ); - while( quit == FALSE ) { + while( quit == false ) { if( wmnotify_infos.debug ) { printf( "%s: Timer thread iteration.\n", PACKAGE ); } - if( ( manual_check == TRUE ) || ( counter == 0 ) ) { + if( ( manual_check == true ) || ( counter == 0 ) ) { new_messages = CheckForNewMail( manual_check ); - manual_check = FALSE; + manual_check = false; if( wmnotify_infos.debug ) { printf( "%s: new messages = %d.\n", PACKAGE, new_messages ); @@ -342,9 +342,9 @@ TimerThread( /*@unused@*/ void *arg ) if( new_messages > 0 ) { /* Checking if audio notification was already produced. */ - if( animation_running == FALSE ) { + if( animation_running == false ) { /* Audible notification, if requested in configuration file. */ - if( wmnotify_infos.audible_notification != FALSE ) { + if( wmnotify_infos.audible_notification != false ) { if( strlen( wmnotify_infos.audiofile ) != 0 ) { #if defined(HAVE_SNDFILE) PlayAudioFile( wmnotify_infos.audiofile, wmnotify_infos.volume ); @@ -355,7 +355,7 @@ TimerThread( /*@unused@*/ void *arg ) } } - animation_running = TRUE; + animation_running = true; } /* Number of times to execute timer loop before checking again for new mails when the * animation is running (when the animation is running, we sleep for @@ -366,15 +366,15 @@ TimerThread( /*@unused@*/ void *arg ) } } - if( ( animation_stop == TRUE ) || ( new_messages <= 0 ) ) { + if( ( animation_stop == true ) || ( new_messages <= 0 ) ) { if( wmnotify_infos.debug ) { - if( animation_stop != FALSE ) { - printf( "%s: animation_stop is TRUE\n", PACKAGE ); + if( animation_stop != false ) { + printf( "%s: animation_stop is true\n", PACKAGE ); } } - animation_running = FALSE; - animation_stop = FALSE; - if( double_click_notif == FALSE ) { + animation_running = false; + animation_stop = false; + if( double_click_notif == false ) { /* Before exiting, be sure to put NO MAIL image back in place... */ DisplayClosedMailbox(); } @@ -385,7 +385,7 @@ TimerThread( /*@unused@*/ void *arg ) * return value will be the "unslept" amount (the requested time minus the time actually * slept) in seconds. */ - if( animation_running == FALSE ) { + if( animation_running == false ) { (void) sleep( wmnotify_infos.mail_check_interval ); counter = 0; } @@ -404,7 +404,7 @@ TimerThread( /*@unused@*/ void *arg ) printf( "%s: Error, TimerThread() exited abnormally\n", PACKAGE ); } - /* This code is never reached for now, because quit is always FALSE. */ + /* This code is never reached for now, because quit is always false. */ pthread_exit( NULL ); } diff --git a/src/wmnotify.h b/src/wmnotify.h index b1a0743..66d8e0e 100644 --- a/src/wmnotify.h +++ b/src/wmnotify.h @@ -5,6 +5,7 @@ #define WMNOTIFY_H 1 + #define POP3_PROTOCOL 0 #define IMAP4_PROTOCOL 1 diff --git a/src/xevents.c b/src/xevents.c index 4ff17df..273bed3 100644 --- a/src/xevents.c +++ b/src/xevents.c @@ -66,13 +66,13 @@ ProcessXlibEventsInit( void (*single_click_callback)( void ), void ProcessXlibEvents( void ) { - bool quit = FALSE; - bool button1_pressed = FALSE; - bool check_for_double_click = FALSE; + bool quit = false; + bool button1_pressed = false; + bool check_for_double_click = false; XEvent Event; - while( quit == FALSE ) { - if( ( check_for_double_click != FALSE ) && + while( quit == false ) { + if( ( check_for_double_click != false ) && ( XPending( dockapp.display ) == 0 ) ) { /* If no other button 1 events are received after the delay, then it is a single-click mouse event. */ @@ -80,7 +80,7 @@ ProcessXlibEvents( void ) (*SingleClickCallback)(); } - check_for_double_click = FALSE; + check_for_double_click = false; } /* XNextEvent is a blocking call: it will return only when an event is ready to be processed, thus freeing the CPU for other tasks when no @@ -95,7 +95,7 @@ ProcessXlibEvents( void ) /* Window was killed... */ /* Is this necessary ? */ (void) XCloseDisplay( dockapp.display ); - quit = TRUE; + quit = true; break; case ClientMessage: /* Doesn't seem to work... */ @@ -104,24 +104,24 @@ ProcessXlibEvents( void ) case ButtonPress: if( Event.xbutton.button == Button1 ) { /* Mouse LEFT button pressed. */ - button1_pressed = TRUE; + button1_pressed = true; } break; case ButtonRelease: if( Event.xbutton.button == Button1 ) { /* Mouse LEFT button released. */ - if( button1_pressed != FALSE ) { + if( button1_pressed != false ) { /* We act only when the button is released */ - if( check_for_double_click != FALSE ) { + if( check_for_double_click != false ) { /* Double-click */ if( DoubleClickCallback != NULL ) { (*DoubleClickCallback)(); } - check_for_double_click = FALSE; + check_for_double_click = false; } else { (void) usleep( DOUBLE_CLICK_MAX_INTERVAL_MS * 1000 ); - check_for_double_click = TRUE; + check_for_double_click = true; } } } -- 2.20.1