/* 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;
/* TimerThread ID */
static pthread_t timer_thread;
}
+static void
+DisplayExecuteCommandNotification( void )
+{
+ /* Visual notification that the double-click was catched. */
+ copyXPMArea( EXEC_CMD_IMG_SRC_X, EXEC_CMD_IMG_SRC_Y,
+ MAILBOX_SIZE_X, MAILBOX_SIZE_Y, MAILBOX_DEST_X, MAILBOX_DEST_Y );
+ RedrawWindow();
+}
+
+
static void
ExecuteCommand( char *argv[] )
{
if( argv[0] == NULL ) {
return;
}
-
+
pid = fork(); /* fork a child process. */
if( pid < 0) {
/* Starting external mail client. */
ExecuteCommand( wmnotify_infos.mail_client_argv );
+ 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
following sequence was encountered:
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 );
ErrorLocation( __FILE__, __LINE__ );
exit( EXIT_FAILURE );
}
+
+ DisplayExecuteCommandNotification();
+ sleep(1);
+ DisplayClosedMailbox();
+
+ double_click_notif = false;
}
else {
fprintf( stderr, "%s: Warning: No email-client defined.\n", PACKAGE );
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,
{
int new_messages;
- if( manual_check == TRUE ) {
+ if( manual_check == true ) {
DisplayOpenedEmptyMailbox();
}
exit( EXIT_FAILURE );
}
- if( ( manual_check == TRUE ) && ( new_messages > 0 ) ) {
+ if( ( manual_check == true ) && ( new_messages > 0 ) ) {
animation_image = MAILBOX_FULL;
}
{
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. */
* 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 );
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 );
}
}
- 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
}
}
- 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;
- /* Before exiting, be sure to put NO MAIL image back in place... */
- DisplayClosedMailbox();
+ animation_running = false;
+ animation_stop = false;
+ if( double_click_notif == false ) {
+ /* Before exiting, be sure to put NO MAIL image back in place... */
+ DisplayClosedMailbox();
+ }
}
/* If sleep() returns because the requested time has elapsed, the value returned will be
* 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;
}
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 );
}