home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / util / blank / gblanker / source / handlers.c < prev    next >
C/C++ Source or Header  |  1994-10-17  |  3KB  |  165 lines

  1. /*
  2.  *  Copyright (c) 1994 Michael D. Bayne.
  3.  *  All rights reserved.
  4.  *
  5.  *  Please see the documentation accompanying the distribution for distribution
  6.  *  and disclaimer information.
  7.  */
  8.  
  9. #include "includes.h"
  10. #include "libraries.h"
  11. #include "protos/protos.h"
  12.  
  13. LONG BlankingDisabled = FALSE;
  14.  
  15. LONG HandleServerMsg( VOID )
  16. {
  17.     ULONG PubScreenModes;
  18.     BlankMsg *CurMsg;
  19.     
  20.     while( CurMsg = ( BlankMsg * )GetMsg( ServerPort ))
  21.     {
  22.         LONG Type = CurMsg->bm_Type;
  23.         LONG Flags = CurMsg->bm_Flags;
  24.  
  25.         if( Flags & BF_REPLY )
  26.         {
  27.             if(!( Flags & BF_INTERNAL ))
  28.                 FreeVec( CurMsg );
  29.         }
  30.         else
  31.         {
  32.             CurMsg->bm_Flags |= BF_REPLY;
  33.             ReplyMsg(( struct Message * )CurMsg );
  34.         }
  35.         
  36.         switch( Type )
  37.         {
  38.         case BM_DOBLANK:
  39.             if( Flags & BF_REPLY )
  40.             {
  41.                 if( !CheckIO(( struct IORequest * )TimeOutIO ))
  42.                 {
  43.                     AbortIO(( struct IORequest * )TimeOutIO );
  44.                     WaitIO(( struct IORequest * )TimeOutIO );
  45.                     SetSignal( 0L, SIG_TIMER );
  46.                 }
  47.                 Blanking = TRUE;
  48.             }
  49.             break;
  50.         case BM_INITMSG:
  51.             if( BlankAfterInit )
  52.             {
  53.                 BlankAfterInit = FALSE;
  54.                 MessageModule( BM_DOBLANK );
  55.             }
  56.             break;
  57.         case BM_FAILED:
  58.             Delay( 60 );
  59.             MessageModule( BM_DOBLANK );
  60.             break;
  61.         case BM_SENDBLANK:
  62.             if(( Flags & BF_REPLY )|| BlankingDisabled )
  63.                 break;
  64.             PubScreenModes = SetPubScreenModes( 0L );
  65.             if( Stricmp( Prefs->bp_Blanker, "Random" ))
  66.             {
  67.                 if( !Blanking )
  68.                     MessageModule( BM_DOBLANK );
  69.             }
  70.             else
  71.             {
  72.                 if( !Blanking || Prefs->bp_Flags & BF_REPLACE )
  73.                 {
  74.                     MessageModule( BM_DELAYEDQUIT );
  75.                     BlankAfterInit = TRUE;
  76.                     LoadModule( Prefs->bp_Dir, Prefs->bp_Blanker );
  77.                 }
  78.             }
  79.             SetPubScreenModes( PubScreenModes );
  80.             break;
  81.         case BM_SENDUNBLANK:
  82.             if( Flags & BF_REPLY )
  83.                 break;
  84.             if( ServerScr )
  85.             {
  86.                 UnblankMousePointer( Wnd );
  87.                 CloseScreen( ServerScr );
  88.                 ServerScr = 0L;
  89.             }
  90.             Blanking = FALSE;
  91.             break;
  92.         default:
  93.             break;
  94.         }
  95.     }
  96.  
  97.     return OK;
  98. }
  99.  
  100. LONG HandleMouseCheck( VOID )
  101. {
  102.     LONG MouseX, MouseY, Lock, Width, Height;
  103.  
  104.     BlankingDisabled = FALSE;
  105.  
  106.     Lock = LockIBase( 0L );
  107.  
  108.     MouseX = IntuitionBase->MouseX;
  109.     MouseY = IntuitionBase->MouseY;
  110.     if( IntuitionBase->FirstScreen )
  111.     {
  112.         Width = IntuitionBase->FirstScreen->Width - 1;
  113.         Height = IntuitionBase->FirstScreen->Height - 1;
  114.     }
  115.     else
  116.     {
  117.         Width = ~0L;
  118.         Height = ~0L;
  119.     }
  120.     
  121.     UnlockIBase( Lock );
  122.  
  123.     switch( Prefs->bp_BlankCorner )
  124.     {
  125.     case BC_UPPERLEFT:
  126.         if( !MouseX && !MouseY )
  127.             timeCount = Prefs->bp_Timeout - 5;
  128.         break;
  129.     case BC_UPPERRIGHT:
  130.         if( !MouseY && MouseX == Width )
  131.             timeCount = Prefs->bp_Timeout - 5;
  132.         break;
  133.     case BC_LOWERRIGHT:    
  134.         if( MouseX == Width && MouseY == Height )
  135.             timeCount = Prefs->bp_Timeout - 5;
  136.            break;
  137.     case BC_LOWERLEFT:
  138.         if( !MouseX && MouseY == Height )
  139.             timeCount = Prefs->bp_Timeout - 5;
  140.         break;
  141.     }
  142.  
  143.     switch( Prefs->bp_DontCorner )
  144.     {
  145.     case BC_UPPERLEFT:
  146.         if( !MouseX && !MouseY )
  147.             BlankingDisabled = TRUE;
  148.         break;
  149.     case BC_UPPERRIGHT:
  150.         if( !MouseY && MouseX == Width )
  151.             BlankingDisabled = TRUE;
  152.         break;
  153.     case BC_LOWERRIGHT:    
  154.         if( MouseX == Width && MouseY == Height )
  155.             BlankingDisabled = TRUE;
  156.            break;
  157.     case BC_LOWERLEFT:
  158.         if( !MouseX && MouseY == Height )
  159.             BlankingDisabled = TRUE;
  160.         break;
  161.     }
  162.  
  163.     return OK;
  164. }
  165.