Added a visual notification that a double-click has been detected
[dockapps/wmnotify.git] / src / wmnotify.c
index 74ccda1..069ce37 100644 (file)
@@ -50,6 +50,8 @@ static bool manual_check = TRUE;
 /* Used to signal TimerThread to quit. Inactive for now. */
 static bool quit = FALSE;
 
+static int double_click_notif = FALSE;
+
 /* TimerThread ID */
 static pthread_t timer_thread;
 
@@ -110,6 +112,16 @@ DisplayClosedMailbox( void )
 }
 
 
+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[] )
 {
@@ -120,7 +132,7 @@ ExecuteCommand( char *argv[] )
   if( argv[0] == NULL ) {
     return;
   }
-  
+
   pid = fork(); /* fork a child process. */
   
   if( pid < 0) {
@@ -178,6 +190,8 @@ DoubleClick( void )
     /* 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:
@@ -196,6 +210,12 @@ DoubleClick( void )
       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 );
@@ -354,8 +374,10 @@ TimerThread( /*@unused@*/ void *arg )
       }
       animation_running = FALSE;
       animation_stop = FALSE;
-      /* Before exiting, be sure to put NO MAIL image back in place... */
-      DisplayClosedMailbox();
+      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