home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95source / ckomou.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  57KB  |  1,616 lines

  1. char *ckomouv = "Mouse Support 8.0.093, 20 Oct 2002";
  2.  
  3. /* C K O M O U   --  Kermit mouse support for OS/2 systems */
  4.  
  5. /*
  6.   Author: Jeffrey Altman (jaltman@secure-endpoints.com)
  7.             Secure Endpoints Inc., New York City
  8.  
  9.   Copyright (C) 1985, 2004, Trustees of Columbia University in the City of New
  10.   York.
  11. */
  12.  
  13. #include "ckcdeb.h"
  14. #ifdef OS2MOUSE
  15. #ifdef NT
  16. #include <windows.h>
  17. #else /* NT */
  18. #define INCL_WINSHELLDATA
  19. #define INCL_VIO
  20. #define INCL_MOU
  21. #define INCL_ERRORS
  22. #define INCL_DOSPROCESS
  23. #define INCL_DOSSESMGR
  24. #define INCL_DOSSEMAPHORES
  25. #define INCL_DOSDEVIOCTL
  26. #define INCL_WINCLIPBOARD
  27. #define INCL_DOSDATETIME
  28. #define INCL_DOSASYNCTIMER
  29. #include <os2.h>
  30. #undef COMMENT                /* COMMENT is defined in os2.h */
  31. #endif /* NT */
  32.  
  33. #include "ckuusr.h"
  34. #include "ckcker.h"
  35. #include "ckocon.h"
  36. #include "ckokey.h"
  37.  
  38. static BOOL SelectionValid = 0 ;
  39. con_event mousemap[MMBUTTONMAX][MMSIZE] ;
  40. #ifdef NT
  41. static USHORT Vrow, Vcol, n, ShiftState, Event ;
  42. static USHORT lastrow=0, lastcol=0 ;
  43. static struct {
  44.     int state ;
  45.     USHORT row   ;
  46.     USHORT col   ;
  47.     } b1 = {0,0,0}, b2 = {0,0,0}, b3  = {0,0,0};
  48. int mouseon = 0 ;
  49. #else /* NT */
  50. static HMOU hMouse = 0 ;
  51. static int dblclickspeed = 500 ;
  52. static TID tidMouse = 0 ;
  53. #endif /* NT */
  54.  
  55. extern int tnlm;
  56. extern int tt_status[VNUM];
  57. extern vik_rec vik;                     /* Very Important Keys    */
  58.  
  59. #define THRDSTKSIZ      131072  /* Needed for Mouse Thread */
  60.  
  61. int MouseCurX, MouseCurY;
  62. int MouseDebug = 0;
  63.  
  64. /*
  65. Potential mouse events:
  66.    MOUSE_MOTION
  67.    MOUSE_MOTION_WITH_BN1_DOWN
  68.    MOUSE_BN1_DOWN
  69.    MOUSE_MOTION_WITH_BN2_DOWN
  70.    MOUSE_BN2_DOWN
  71.    MOUSE_MOTION_WITH_BN3_DOWN
  72.    MOUSE_BN3_DOWN
  73.  
  74. */
  75.  
  76. static BOOL ThreeButton = 0 ;  /* 0 -two buttons, 1 - three buttons */
  77.  
  78. int
  79. mousebuttoncount()
  80. {
  81.     return(ThreeButton?3:2);
  82. }
  83.  
  84. #ifndef NT
  85. int
  86. querydblclickspeed( void )
  87. {
  88.     CHAR data[8] ;
  89.     ULONG size = 8 ;
  90.  
  91.     if ( PrfQueryProfileData( HINI_USERPROFILE, "PM_ControlPanel",
  92.         "DoubleClickSpeed", data, &size ) )
  93.         return atoi( data ) ;
  94.     else
  95.         return 500 ;  /* the OS/2 default is 500 milliseconds */
  96. }
  97. #endif /* NT */
  98.  
  99. char *
  100. mousename( int button, int event )
  101. {
  102.     static char mousename[64] ;
  103.     char temp[17] ;
  104.  
  105.     mousename[0] = '\0' ;
  106.     strcpy(mousename, "Button ") ;
  107. #ifdef NT
  108.     ckstrncat(mousename, _itoa(button+1,temp,10), sizeof(mousename) ) ;
  109. #else /* NT */
  110.     ckstrncat(mousename, itoa(button+1,temp,10), sizeof(mousename) ) ;
  111. #endif /* NT */
  112.  
  113.     ckstrncat(mousename, " ", sizeof(mousename) ) ;
  114.     if ( event & MMCTRL )
  115.         ckstrncat( mousename, "Ctrl-", sizeof(mousename) ) ;
  116.     if ( event & MMALT )
  117.         ckstrncat( mousename, "Alt-", sizeof(mousename) ) ;
  118.     if ( event & MMSHIFT )
  119.         ckstrncat( mousename, "Shift-", sizeof(mousename) ) ;
  120.     if ( event & MMDRAG )
  121.         ckstrncat( mousename, "Drag", sizeof(mousename) ) ;
  122.     else if ( event & MMDBL )
  123.         ckstrncat( mousename, "Double-Click", sizeof(mousename) ) ;
  124.     else ckstrncat (mousename, "Click", sizeof(mousename) ) ;
  125.  
  126.     return mousename ;
  127. }
  128.  
  129.  
  130. void
  131. mousemapinit( int button, int event )
  132. {
  133.     int x,y, resetall ;
  134.  
  135.     resetall = button < 0 || event < 0 ||
  136.         button >= MMBUTTONMAX || event >= MMEVENTSIZE ;
  137.  
  138.     if ( resetall )
  139.         for ( x = 0 ; x < MMBUTTONMAX ; x++ ) {
  140.            for ( y = 0 ; y < MMSIZE ; y++ )
  141.               if ( y == MMCLICK )
  142.               {
  143.                  mousemap[x][y].type = kverb ;
  144.                  mousemap[x][y].kverb.id = F_KVERB | K_IGNORE ;
  145.               }
  146.               else mousemap[x][y].type = error ;
  147.         }
  148.  
  149.     if ( resetall || button == MMB1 && event == MMDBL ) {
  150.         /* Assign Cursor Positioning */
  151.     mousemap[MMB1][MMDBL].type = kverb ;
  152.     mousemap[MMB1][MMDBL].kverb.id = F_KVERB | K_MOUSE_CURPOS ;
  153.     if ( !resetall )
  154.         return ;
  155.     }
  156.  
  157.     if ( resetall || button == MMB1 && event == MMCTRL | MMCLICK ) {
  158.         /* Assign URL Execution */
  159.     mousemap[MMB1][MMCTRL|MMCLICK].type = kverb ;
  160.     mousemap[MMB1][MMCTRL|MMCLICK].kverb.id = F_KVERB | K_MOUSE_URL ;
  161.     if ( !resetall )
  162.         return ;
  163.     }
  164.  
  165.     if ( resetall || button == MMB1 && event == MMDRAG ) {
  166.     mousemap[MMB1][MMDRAG].type = kverb ;
  167.     mousemap[MMB1][MMDRAG].kverb.id = F_KVERB | K_MARK_COPYCLIP ;
  168.     if ( !resetall )
  169.         return ;
  170.     }
  171.  
  172.     if ( resetall || button == MMB2 && event == MMDRAG ) {
  173.     mousemap[MMB2][MMDRAG].type = kverb ;
  174.     mousemap[MMB2][MMDRAG].kverb.id = F_KVERB | K_MARK_COPYHOST ;
  175.     if ( !resetall )
  176.         return ;
  177.     }
  178.  
  179.     if ( resetall || button == MMB1 && event == MMCTRL | MMDRAG ) {
  180.     mousemap[MMB1][MMCTRL | MMDRAG].type = kverb ;
  181.     mousemap[MMB1][MMCTRL | MMDRAG].kverb.id =
  182.     F_KVERB | K_MARK_COPYHOST ;
  183.     if ( !resetall )
  184.         return ;
  185.     }
  186.  
  187.     if ( resetall || button == MMB1 && event == MMALT | MMDRAG) {
  188.     mousemap[MMB1][MMALT | MMDRAG].type = kverb ;
  189.     mousemap[MMB1][MMALT | MMDRAG].kverb.id = F_KVERB | K_MARK_COPYCLIP_NOEOL ;
  190.     if ( !resetall )
  191.         return ;
  192.     }
  193.  
  194.     if ( resetall || button == MMB2 && event == MMALT | MMDRAG ) {
  195.     mousemap[MMB2][MMALT | MMDRAG].type = kverb ;
  196.     mousemap[MMB2][MMALT | MMDRAG].kverb.id = F_KVERB | K_MARK_COPYHOST_NOEOL ;
  197.     if ( !resetall )
  198.         return ;
  199.     }
  200.  
  201.     if ( resetall || button == MMB1 && event == MMCTRL | MMALT | MMDRAG ) {
  202.     mousemap[MMB1][MMCTRL | MMALT | MMDRAG].type = kverb ;
  203.     mousemap[MMB1][MMCTRL | MMALT | MMDRAG].kverb.id = F_KVERB | K_MARK_COPYHOST_NOEOL ;
  204.     if ( !resetall )
  205.         return ;
  206.     }
  207.  
  208.     if ( resetall || button == MMB1 && event == MMSHIFT | MMCTRL | MMDRAG ) {
  209.     mousemap[MMB1][MMSHIFT | MMCTRL | MMDRAG].type = kverb ;
  210.     mousemap[MMB1][MMSHIFT | MMCTRL | MMDRAG].kverb.id =
  211.     F_KVERB | K_DUMP ;
  212.     if ( !resetall )
  213.         return ;
  214.     }
  215.  
  216.     if ( resetall || button == MMB2 && event == MMDBL ) {
  217.         mousemap[MMB2][MMDBL].type = kverb ;
  218.         mousemap[MMB2][MMDBL].kverb.id = F_KVERB | K_PASTE ;
  219.         if ( !resetall )
  220.             return ;
  221.     }
  222.     if ( resetall || button == MMB3 && event == MMDBL ) {
  223.         mousemap[MMB3][MMDBL].type = kverb ;
  224.         mousemap[MMB3][MMDBL].kverb.id = F_KVERB | K_PASTE ;
  225.         if ( !resetall )
  226.             return ;
  227.     }
  228.  
  229.     if ( !resetall ) {
  230.        if ( event == MMCLICK )
  231.        {
  232.            mousemap[button][event].type = kverb ;
  233.            mousemap[button][event].kverb.id = F_KVERB | K_IGNORE ;
  234.        }
  235.        else mousemap[button][event].type = error ;
  236.        return ;
  237.     }
  238. }
  239.  
  240. #ifndef NT
  241. APIRET
  242. os2_mouseshow( void )
  243. {
  244. APIRET rc = 0 ;
  245. NOPTRRECT PtrArea ;
  246. CK_VIDEOMODEINFO ModeData ;
  247.  
  248. if ( hMouse )
  249.     {
  250.     GetMode( &ModeData ) ;
  251.  
  252.     PtrArea.row = ModeData.row - 1 ;
  253.     PtrArea.col = 0 ;
  254.     PtrArea.cRow = ModeData.row - 1;
  255.     PtrArea.cCol = ModeData.col - 1 ;
  256.  
  257.     MouRemovePtr( &PtrArea, hMouse ) ;
  258.     }
  259. return rc ;
  260. }
  261.  
  262. APIRET
  263. os2_mousehide( void )
  264. {
  265. APIRET rc = 0 ;
  266. NOPTRRECT PtrArea ;
  267. CK_VIDEOMODEINFO ModeData ;
  268.  
  269. if (hMouse)
  270.     {
  271.     GetMode( &ModeData ) ;
  272.  
  273.     PtrArea.row = 0 ;
  274.     PtrArea.col = 0 ;
  275.     PtrArea.cRow = ModeData.row - 1;
  276.     PtrArea.cCol = ModeData.col - 1 ;
  277.  
  278.     MouRemovePtr( &PtrArea, hMouse ) ;
  279.     }
  280. return rc ;
  281. }
  282. #endif /* NT */
  283.  
  284. APIRET
  285. os2_mouseon( void )
  286. {
  287.     APIRET rc = 0 ;
  288.  
  289. #ifdef NT
  290.     extern HANDLE KbdHandle ;
  291.     DWORD mode=0, count=0 ;
  292.  
  293.     GetNumberOfConsoleMouseButtons(&count) ;
  294.     ThreeButton = ( count == 3 ) ;
  295.     debug(F101,"os2_mouseon Button Count","",count ) ;
  296.  
  297.     debug(F111,"os2_mouseon","KbdHandle",KbdHandle);
  298.     GetConsoleMode( KbdHandle, &mode ) ;
  299.     debug(F111,"os2_mouseon GetConsoleMode","mode",mode);
  300.     mode |= ENABLE_MOUSE_INPUT ;
  301.     debug(F111,"os2_mouseon","mode",mode);
  302.     rc = SetConsoleMode( KbdHandle, mode ) ;
  303.     mouseon = TRUE ;
  304.     debug(F111,"os2_mouseon SetConsoleMode","rc",rc) ;
  305.  
  306. #else /* NT */
  307. PTRLOC    PtrPos ;
  308. NOPTRRECT PtrArea ;
  309. CK_VIDEOMODEINFO ModeData ;
  310. USHORT    ButtonCount ;
  311. USHORT    EventMask ;
  312. extern    BYTE vmode ;
  313.  
  314.     if (!tidMouse) {
  315.     rc = MouOpen( 0, &hMouse ) ;
  316.     debug(F101,"Mouse On","",rc) ;
  317.     }
  318.  
  319.     if ( !rc ) {
  320.         rc = MouDrawPtr( hMouse ) ;
  321.         GetMode( &ModeData ) ;
  322.  
  323.         if ( IsOS2FullScreen() ) {
  324.             PtrPos.row = ModeData.row - 1 ;
  325.             PtrPos.col = VscrnGetWidth(vmode)-1 ;
  326.             MouSetPtrPos( &PtrPos, hMouse ) ;
  327.         }
  328.  
  329.     PtrArea.row = ModeData.row - 1 ;
  330.     PtrArea.col = 0 ;
  331.     PtrArea.cRow = ModeData.row - 1;
  332.     PtrArea.cCol = ModeData.col - 1 ;
  333.  
  334.     MouRemovePtr( &PtrArea, hMouse ) ;
  335.  
  336.     MouGetNumButtons( &ButtonCount, hMouse ) ;
  337.     debug(F101,"os2_mouseon Button Count","",ButtonCount ) ;
  338.  
  339.     if ( ButtonCount == 3 )
  340.         {
  341.         ThreeButton = 1 ;
  342.         EventMask      = MOUSE_BN1_DOWN |
  343.         MOUSE_MOTION_WITH_BN1_DOWN |
  344.         MOUSE_BN2_DOWN |
  345.         MOUSE_MOTION_WITH_BN2_DOWN |
  346.         MOUSE_BN3_DOWN |
  347.         MOUSE_MOTION_WITH_BN3_DOWN ;
  348.         }
  349.     else  /* 2 buttons */
  350.         {
  351.         ThreeButton = 0 ;
  352.         EventMask      = MOUSE_BN1_DOWN |
  353.         MOUSE_MOTION_WITH_BN1_DOWN |
  354.         MOUSE_BN2_DOWN |
  355.         MOUSE_MOTION_WITH_BN2_DOWN ;
  356.         }
  357.     MouSetEventMask( &EventMask, hMouse ) ;
  358.  
  359.     dblclickspeed = querydblclickspeed() ;
  360.  
  361.         if (!tidMouse) {
  362.         tidMouse = _beginthread( &os2_mouseevt, 0, THRDSTKSIZ, 0 ) ;
  363.         }
  364.     }
  365. #endif /* NT */
  366. return rc ;
  367. }
  368.  
  369.  
  370.  
  371. void
  372. mouseurl( int mode, USHORT row, USHORT col )
  373. {
  374. #ifdef BROWSER
  375.     extern char browsopts[];
  376.     extern char browser[];
  377.     char      cmd[1024]="", tmpbuf[1024]="";
  378.     char *s, *d;
  379.     int rc, x=0;
  380. #ifdef NT
  381.     STARTUPINFO si;
  382.     SECURITY_ATTRIBUTES sa;
  383.     PROCESS_INFORMATION pi;
  384. #else /* NT */
  385.     STARTDATA sd;
  386.     PID       pid;
  387.     ULONG     idSession;
  388. #endif /* NT */
  389.     const char * url;
  390.  
  391.     if ( VscrnURL( mode, row, col ) ) {
  392.         bleep(BP_FAIL);
  393.         return ;
  394.     }
  395.  
  396.     url = GetURL();
  397.  
  398.     if (browsopts[0]) {
  399.         x = ckindex("%1",(char *)browsopts,0,0,1);
  400.         if (x > 0)
  401.             browsopts[x] = 's';         /* x is 1-based */
  402.         else
  403.             x = ckindex("%s",(char *)browsopts,0,0,1);
  404.     }
  405.     if (x)
  406.         sprintf(tmpbuf,browsopts,url);
  407.     else
  408.         sprintf(tmpbuf,"%s %s",browsopts,url);
  409.     debug(F110,"mouseurl options and url",tmpbuf,0);
  410.  
  411. #ifdef NT
  412.     if ( (GetURLType() == HYPERLINK_UNC) || !browser[0] ) {
  413.         if ( !Win32ShellExecute(url) )
  414.             bleep(BP_FAIL);
  415.         debug(F111,"mouseurl ShellExecute",url,GetLastError());
  416.     }
  417.     else {
  418.     memset( &sa, 0, sizeof(SECURITY_ATTRIBUTES) );     //  Initialize struct
  419.     sa.nLength=sizeof(SECURITY_ATTRIBUTES);
  420.     sa.lpSecurityDescriptor=NULL;
  421.     sa.bInheritHandle=1;
  422.  
  423.     memset( &si, 0, sizeof(STARTUPINFO) );     //  Initialize struct
  424.     si.cb          = sizeof(STARTUPINFO);
  425.     si.dwFlags     = STARTF_USESHOWWINDOW;
  426.     si.wShowWindow = 1;        //  Don't show the console window (DOS box)
  427.  
  428.     sprintf(cmd,"%s %s",browser,tmpbuf);
  429.     rc = CreateProcess ( NULL, cmd, NULL, NULL, FALSE, // bInheritHandler
  430.                          CREATE_NEW_PROCESS_GROUP,
  431.                          NULL, NULL, &si, &pi);
  432.     CloseHandle(pi.hProcess);
  433.     CloseHandle(pi.hThread);
  434.     debug(F111,"mouseurl",cmd,rc?0:GetLastError());
  435.     }
  436. #else /* NT */
  437.     memset(&sd,0,sizeof(STARTDATA));
  438.     sd.Length = sizeof(STARTDATA);
  439.     sd.Related = SSF_RELATED_INDEPENDENT;
  440.     sd.FgBg = SSF_FGBG_FORE;
  441.     sd.TraceOpt = SSF_TRACEOPT_NONE;
  442.     sd.PgmTitle = "K-95 Browser";
  443.     sd.PgmName = browser;
  444.     sd.PgmInputs = tmpbuf;
  445.     sd.TermQ = 0;
  446.     sd.Environment = 0;
  447.     sd.InheritOpt = SSF_INHERTOPT_SHELL;
  448.     sd.SessionType = SSF_TYPE_DEFAULT;
  449.     sd.IconFile = 0;
  450.     sd.ObjectBuffer = cmd;
  451.     sd.ObjectBuffLen = 1024;
  452.     rc = DosStartSession( &sd, &idSession, &pid );
  453.     debug(F111,"mouseurl",cmd,rc);
  454. #endif /* NT */
  455. #endif /* BROWSER */
  456. }
  457.  
  458. void
  459. mousecurpos( int mode, USHORT orow, USHORT ocol, USHORT nrow, USHORT ncol, BOOL kverb )
  460. {
  461. #ifdef NT
  462.     extern int win32ScrollUp, win32ScrollDown;
  463. #endif /* NT */
  464.  
  465.     RequestKeyStrokeMutex( mode, SEM_INDEFINITE_WAIT);
  466. #ifdef NT
  467.     /* only set the scroll flag if we are using kverbs and not keystrokes */
  468.     if ( kverb ) {
  469.         win32ScrollUp = (nrow < 1);
  470.         win32ScrollDown = (nrow >= (VscrnGetHeight(mode)
  471.                                      -1 -(tt_status[mode]?1:0)));
  472.     }
  473. #endif /* NT */
  474.  
  475.     for (; ocol > ncol; ocol-- )
  476.     {
  477.         !kverb ?
  478.           putkey( mode, 4389 ) :
  479.               putkverb( mode, F_KVERB | K_LFARR ) ; /* LEFT */
  480.     }
  481.     for (; orow > nrow; orow-- )
  482.     {
  483.         !kverb ?
  484.           putkey( mode, 4390 ) :
  485.               putkverb( mode, F_KVERB | K_UPARR ) ; /* UP */
  486.     }
  487.     for (; orow < nrow; orow++ )
  488.     {
  489.         !kverb ?
  490.           putkey( mode, 4392 ) :
  491.           putkverb( mode, F_KVERB | K_DNARR ) ; /* DOWN */
  492.     }
  493.     for (; ocol < ncol; ocol++ )
  494.     {
  495.         !kverb ?
  496.           putkey( mode, 4391 ) :
  497.           putkverb( mode, F_KVERB | K_RTARR ) ; /* RIGHT */
  498.     }
  499.     ReleaseKeyStrokeMutex(mode) ;
  500. }
  501.  
  502. #ifdef  NT
  503. void
  504. win32MouseEvent( int mode, MOUSE_EVENT_RECORD r )
  505. {
  506. #ifdef NT
  507.     extern int win32ScrollUp, win32ScrollDown;
  508. #endif /* NT */
  509.     position   * ppos ;
  510.     char buffer[1024] ;
  511.  
  512.     if ( MouseDebug ) {
  513.         int needcomma = 0;
  514.         printf("Mouse Event: (%d,%d)",r.dwMousePosition.X,r.dwMousePosition.Y);
  515.  
  516.         if ( r.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED ) {
  517.             printf(" B1");
  518.             needcomma = 1;
  519.         }
  520.         if ( r.dwButtonState & (ThreeButton ? FROM_LEFT_2ND_BUTTON_PRESSED :
  521.                                  RIGHTMOST_BUTTON_PRESSED) ) {
  522.             if ( needcomma )
  523.                 printf(",B2");
  524.             else {
  525.                 printf(" B2");
  526.                 needcomma = 1;
  527.             }
  528.         }
  529.         if ( r.dwButtonState & (ThreeButton ? RIGHTMOST_BUTTON_PRESSED : 0) ) {
  530.             if ( needcomma )
  531.                 printf(",B3");
  532.             else {
  533.                 printf(" B3");
  534.             }
  535.         }
  536.         needcomma = 0;
  537.  
  538.  
  539.         if ( r.dwControlKeyState & CONTROL ) {
  540.             printf(" Ctrl");
  541.             needcomma = 1;
  542.         }
  543.         if ( r.dwControlKeyState & ALT ) {
  544.             if ( needcomma )
  545.                 printf("-Alt");
  546.             else {
  547.                 printf(" Alt");
  548.                 needcomma = 1;
  549.             }
  550.         }
  551.         if ( r.dwControlKeyState & SHIFT ) {
  552.             if ( needcomma )
  553.                 printf("-Shift");
  554.             else
  555.                printf(" Shift");
  556.         }
  557.         needcomma = 0;
  558.  
  559.         if ( r.dwEventFlags == 0 ) {
  560.             printf(" Click");
  561.         } else {
  562.             if ( r.dwEventFlags & DOUBLE_CLICK ) {
  563.                 printf(" Double");
  564.                 needcomma = 1;
  565.             }
  566.             if ( r.dwEventFlags & MOUSE_MOVED ) {
  567.                 if ( needcomma )
  568.                     printf("-Move");
  569.                 else {
  570.                     printf(" Move");
  571.                     needcomma = 1;
  572.                 }
  573.             }
  574. #ifdef MOUSE_WHEELED
  575.             if ( r.dwEventFlags & MOUSE_WHEELED ) {
  576.                 if ( needcomma )
  577.                     printf("-Wheel");
  578.                 else {
  579.                     printf(" Wheel");
  580.                     needcomma = 1;
  581.                 }
  582.             }
  583. #endif /* MOUSE_WHEELED */
  584.         }
  585.         printf("\n");
  586.         return;
  587.     }
  588.  
  589.     /* \V() variables */
  590.     MouseCurX = r.dwMousePosition.X;
  591.     MouseCurY = r.dwMousePosition.Y;
  592.  
  593.    if ( TRUE )
  594.    {
  595.        Event = 0 ;
  596.        if ( r.dwControlKeyState & SHIFT )
  597.            Event |= MMSHIFT ;
  598.        if ( r.dwControlKeyState & ALT )
  599.            Event |= MMALT ;
  600.        if ( r.dwControlKeyState & CONTROL )
  601.            Event |= MMCTRL ;
  602.  
  603.        sprintf(buffer, "  Event: fs:%3x row:%3d col:%3d",
  604.                 r.dwButtonState,
  605.                 r.dwMousePosition.Y, r.dwMousePosition.X) ;
  606.        debug(F110,"win32MouseEvent",buffer,0) ;
  607.  
  608.        ppos = VscrnGetCurPos(mode) ;
  609.        Vrow = ppos->y ;
  610.        Vcol = ppos->x ;
  611.  
  612.        if ( r.dwMousePosition.Y >= VscrnGetHeight(mode)
  613.             -(tt_status[mode]?1:0) )
  614.            r.dwMousePosition.Y = VscrnGetHeight(mode) -(1+(tt_status[mode]?1:0)) ;
  615.        if ( r.dwMousePosition.Y < 0 )
  616.            r.dwMousePosition.Y = 0 ;
  617.        if ( r.dwMousePosition.X >= VscrnGetWidth(mode) )
  618.            r.dwMousePosition.X = VscrnGetWidth(mode) -1 ;
  619.        if ( r.dwMousePosition.X < 0 )
  620.            r.dwMousePosition.X = 0 ;
  621.  
  622.        if ( (r.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) && b1.state == 0 ) {
  623.            if (  !SelectionValid &&
  624.                 (r.dwEventFlags & DOUBLE_CLICK) ) {
  625.                /* Double Click */
  626.                debug( F100, "mouse B1 double click", "", 0 ) ;
  627.                b1.state = 2 ;
  628.                b1.row = r.dwMousePosition.Y ;
  629.                b1.col = r.dwMousePosition.X ;
  630.            }
  631.            else {
  632.                /* Single Click */
  633.                b1.state = 1 ;
  634.                b1.row = r.dwMousePosition.Y ;
  635.                b1.col = r.dwMousePosition.X ;
  636.                debug( F100, "mouse B1 single click", "", 0 ) ;
  637.            }
  638.        }
  639.        else if ( (r.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) && (r.dwEventFlags & MOUSE_MOVED) ) {
  640.            debug( F100, "mouse B1 drag", "", 0 ) ;
  641.            if ( b1.state == 1 && !SelectionValid && (MouseCurY != b1.row || MouseCurX != b1.col)) {
  642.                SelectionValid = 1 ;
  643.                RequestKeyStrokeMutex( mode, SEM_INDEFINITE_WAIT);
  644.                putkverb( mode, F_KVERB | K_MARK_START ) ;
  645.                mousecurpos( mode, Vrow, Vcol, b1.row, b1.col, TRUE ) ;
  646.                putkverb( mode, F_KVERB | K_MARK_START ) ;
  647.                mousecurpos( mode, b1.row, b1.col, MouseCurY, MouseCurX, TRUE );
  648.                ReleaseKeyStrokeMutex(mode) ;
  649.            }
  650.            else if ( b1.state == 1 && SelectionValid &&
  651.                      ( lastrow != r.dwMousePosition.Y ||
  652.                        lastcol != r.dwMousePosition.X )
  653.                      ) {
  654.                mousecurpos( mode, lastrow, lastcol, r.dwMousePosition.Y,
  655.                             r.dwMousePosition.X, TRUE ) ;
  656.            }
  657.        }
  658.  
  659.        if ( (r.dwButtonState & (ThreeButton ? FROM_LEFT_2ND_BUTTON_PRESSED : RIGHTMOST_BUTTON_PRESSED)) && b2.state == 0 ) {
  660.            if (  !SelectionValid &&
  661.                 (r.dwEventFlags & DOUBLE_CLICK) ) {
  662.                /* Double Click */
  663.                debug( F100, "mouse B2 double click", "", 0 ) ;
  664.                b2.state = 2 ;
  665.                b2.row = r.dwMousePosition.Y ;
  666.                b2.col = r.dwMousePosition.X ;
  667.            }
  668.            else {
  669.                /* Single Click */
  670.                b2.state = 1 ;
  671.                b2.row = r.dwMousePosition.Y ;
  672.                b2.col = r.dwMousePosition.X ;
  673.                debug( F100, "mouse B2 single click", "", 0 ) ;
  674.            }
  675.        }
  676.        else if ( (r.dwButtonState & (ThreeButton ? FROM_LEFT_2ND_BUTTON_PRESSED : RIGHTMOST_BUTTON_PRESSED)) &&
  677.                  (r.dwEventFlags & MOUSE_MOVED)) {
  678.            debug( F100, "mouse B2 drag", "", 0 ) ;
  679.            if ( b2.state == 1 && !SelectionValid && (MouseCurY != b2.row || MouseCurX != b2.col) ) {
  680.                SelectionValid = 1 ;
  681.                RequestKeyStrokeMutex( mode, SEM_INDEFINITE_WAIT);
  682.                putkverb( mode, F_KVERB | K_MARK_START ) ;
  683.                mousecurpos( mode, Vrow, Vcol, b2.row, b2.col, TRUE ) ;
  684.                putkverb( mode, F_KVERB | K_MARK_START ) ;
  685.                mousecurpos( mode, b2.row, b2.col, MouseCurY, MouseCurX, TRUE );
  686.                ReleaseKeyStrokeMutex(mode) ;
  687.            }
  688.            else if ( b2.state == 1 && SelectionValid &&
  689.                      ( lastrow != r.dwMousePosition.Y ||
  690.                        lastcol != r.dwMousePosition.X )
  691.                      ) {
  692.                mousecurpos( mode, lastrow, lastcol, r.dwMousePosition.Y,
  693.                             r.dwMousePosition.X, TRUE ) ;
  694.            }
  695.        }
  696.  
  697.        if ( (r.dwButtonState & (ThreeButton ? RIGHTMOST_BUTTON_PRESSED : 0)) && b3.state == 0 ) {
  698.            if (  !SelectionValid &&
  699.                 (r.dwEventFlags & DOUBLE_CLICK) ) {
  700.                /* Double Click */
  701.                b3.state = 2 ;
  702.                debug( F100, "mouse B3 double click","",0) ;
  703.            }
  704.            else {
  705.                /* Single Click */
  706.                b3.state = 1 ;
  707.                b3.row = r.dwMousePosition.Y ;
  708.                b3.col = r.dwMousePosition.X ;
  709.                debug( F100, "mouse B3 single click","",0) ;
  710.            }
  711.        }
  712.        else if ( (r.dwButtonState & (ThreeButton ? RIGHTMOST_BUTTON_PRESSED : 0)) && (r.dwEventFlags & MOUSE_MOVED) ) {
  713.            debug( F100, "mouse B3 drag","",0) ;
  714.            if ( b3.state == 1 && !SelectionValid && (MouseCurY != b3.row || MouseCurX != b3.col) ) {
  715.                SelectionValid = 1 ;
  716.                RequestKeyStrokeMutex( mode, SEM_INDEFINITE_WAIT);
  717.                putkverb( mode, F_KVERB | K_MARK_START ) ;
  718.                mousecurpos( mode, Vrow, Vcol, b3.row, b3.col, TRUE ) ;
  719.                putkverb( mode, F_KVERB | K_MARK_START ) ;
  720.                mousecurpos( mode, b3.row, b3.col, MouseCurY, MouseCurX, TRUE );
  721.                ReleaseKeyStrokeMutex(mode) ;
  722.            }
  723.            else if ( b3.state == 1 && SelectionValid &&
  724.                      ( lastrow != r.dwMousePosition.Y ||
  725.                        lastcol != r.dwMousePosition.X )
  726.                      ) {
  727.                mousecurpos( mode, lastrow, lastcol, r.dwMousePosition.Y,
  728.                             r.dwMousePosition.X, TRUE ) ;
  729.            }
  730.        }
  731.  
  732.        if ( !(r.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) ) {
  733.            /* button 1 may have been released */
  734.            if ( b1.state == 1 ) {
  735.                debug( F100, "mouse B1 single click released", "" , 0 );
  736.                Event |= MMCLICK ;
  737.                if ( SelectionValid ) {
  738.                    Event |= MMDRAG ;
  739.                }
  740.  
  741.                /* Handle special Mouse Kverbs */
  742.                if ( mousemap[MMB1][Event].type == kverb ) {
  743.                    switch (mousemap[MMB1][Event].kverb.id & ~(F_KVERB)) {
  744.                    case K_MOUSE_CURPOS:
  745.                        putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  746.                        mousecurpos( mode, Vrow, Vcol, r.dwMousePosition.Y,
  747.                                    r.dwMousePosition.X, FALSE ) ;
  748.                        break;
  749.                    case K_MOUSE_URL:
  750.                        putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  751.                        mouseurl( mode, r.dwMousePosition.Y,
  752.                                 r.dwMousePosition.X );
  753.                        break;
  754.                    case K_MARK_COPYCLIP:
  755.                    case K_MARK_COPYHOST:
  756.                    case K_MARK_COPYCLIP_NOEOL:
  757.                    case K_MARK_COPYHOST_NOEOL:
  758.                    case K_DUMP:
  759.                        putevent( mode, mousemap[MMB1][Event] ) ;
  760.                        putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  761.                        break;
  762.                    case K_MOUSE_MARK:
  763.                    case K_IGNORE:
  764.                        break;
  765.                    default:
  766.                        putevent( mode, mousemap[MMB1][Event] ) ;
  767.                        putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  768.                    }
  769.                }
  770.                else if (mousemap[MMB1][Event].type != error) {
  771.                    putevent( mode, mousemap[MMB1][Event] ) ;
  772.                    putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  773.                }
  774.                else {
  775.                    putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  776.                }
  777.                SelectionValid = 0 ;
  778.                b1.state = 0 ;
  779.                b1.row = 0 ;
  780.                b1.col = 0 ;
  781. #ifdef NT
  782.                win32ScrollUp = win32ScrollDown = 0;
  783. #endif /* NT */
  784.            }
  785.            else if ( b1.state == 2 ) {
  786.                debug( F100, "mouse B1 double click released", "" , 0 );
  787.                Event |= MMDBL ;
  788.  
  789.                /* Handle special Mouse Kverbs */
  790.                if ( mousemap[MMB1][Event].type == kverb)
  791.                {
  792.                    switch (mousemap[MMB1][Event].kverb.id & ~(F_KVERB)) {
  793.                    case K_MOUSE_MARK:
  794.                    case K_IGNORE:
  795.                        break;
  796.                    case K_MOUSE_CURPOS:
  797.                        mousecurpos( mode, Vrow, Vcol, r.dwMousePosition.Y,
  798.                                     r.dwMousePosition.X, FALSE ) ;
  799.                        break;
  800.                    case K_MOUSE_URL:
  801.                        mouseurl( mode, r.dwMousePosition.Y,
  802.                                  r.dwMousePosition.X );
  803.                        break;
  804.                    default:
  805.                        putevent( mode, mousemap[MMB1][Event] ) ;
  806.                    }
  807.                }
  808.                else if ( mousemap[MMB1][Event].type != error ) {
  809.                    putevent( mode, mousemap[MMB1][Event] ) ;
  810.                }
  811.                SelectionValid = 0 ;
  812.                b1.state = 0 ;
  813.                b1.row = 0 ;
  814.                b1.col = 0 ;
  815. #ifdef NT
  816.                win32ScrollUp = win32ScrollDown = 0;
  817. #endif /* NT */
  818.            }
  819.        }
  820.  
  821.        if ( !(r.dwButtonState & ( ThreeButton ? FROM_LEFT_2ND_BUTTON_PRESSED : RIGHTMOST_BUTTON_PRESSED ) ) ) {
  822.            /* button 2 may have been released */
  823.            if ( b2.state == 1 ) {
  824.                debug( F100, "mouse B2 single click released", "" , 0 );
  825.                Event |= MMCLICK ;
  826.                if ( SelectionValid ) {
  827.                    Event |= MMDRAG ;
  828.                }
  829.  
  830.                /* Handle special Mouse Kverbs */
  831.                if ( mousemap[MMB2][Event].type == kverb)
  832.                {
  833.                    switch (mousemap[MMB2][Event].kverb.id & ~(F_KVERB)) {
  834.                    case K_MOUSE_MARK:
  835.                    case K_IGNORE:
  836.                        break;
  837.                    case K_MOUSE_CURPOS:
  838.                        putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  839.                        mousecurpos( mode, Vrow, Vcol, r.dwMousePosition.Y,
  840.                                     r.dwMousePosition.X, FALSE ) ;
  841.                        break;
  842.                    case K_MOUSE_URL:
  843.                        putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  844.                        mouseurl( mode, r.dwMousePosition.Y,
  845.                                    r.dwMousePosition.X );
  846.                        break;
  847.                    case K_MARK_COPYCLIP:
  848.                    case K_MARK_COPYHOST:
  849.                    case K_MARK_COPYCLIP_NOEOL:
  850.                    case K_MARK_COPYHOST_NOEOL:
  851.                    case K_DUMP:
  852.                        putevent( mode, mousemap[MMB2][Event] ) ;
  853.                        putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  854.                        break;
  855.                    default:
  856.                        putevent( mode, mousemap[MMB2][Event] ) ;
  857.                        putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  858.                    }
  859.                }
  860.                else if (mousemap[MMB2][Event].type != error ) {
  861.                    putevent( mode, mousemap[MMB2][Event] ) ;
  862.                    putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  863.                }
  864.                else {
  865.                    putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  866.                }
  867.                SelectionValid = 0 ;
  868.                b2.state = 0 ;
  869.                b2.row = 0 ;
  870.                b2.col = 0 ;
  871. #ifdef NT
  872.                win32ScrollUp = win32ScrollDown = 0;
  873. #endif /* NT */
  874.            }
  875.            else if ( b2.state == 2 ) {
  876.                debug( F100, "mouse B2 double click released", "" , 0 );
  877.                Event |= MMDBL ;
  878.  
  879.                /* Handle special Mouse Kverbs */
  880.                if ( mousemap[MMB2][Event].type == kverb ) {
  881.                    switch (mousemap[MMB2][Event].kverb.id & ~(F_KVERB)) {
  882.                    case K_MOUSE_MARK:
  883.                    case K_IGNORE:
  884.                        break;
  885.                    case K_MOUSE_CURPOS:
  886.                        mousecurpos( mode, Vrow, Vcol, r.dwMousePosition.Y,
  887.                                     r.dwMousePosition.X, FALSE ) ;
  888.                        break;
  889.                    case K_MOUSE_URL:
  890.                        mouseurl( mode, r.dwMousePosition.Y,
  891.                                  r.dwMousePosition.X );
  892.                        break;
  893.                    default:
  894.                        putevent( mode, mousemap[MMB2][Event] ) ;
  895.                    }
  896.                }
  897.                else if ( mousemap[MMB2][Event].type != error ) {
  898.                    putevent( mode, mousemap[MMB2][Event] ) ;
  899.                }
  900.                SelectionValid = 0 ;
  901.                b2.state = 0 ;
  902.                b2.row = 0 ;
  903.                b2.col = 0 ;
  904. #ifdef NT
  905.                win32ScrollUp = win32ScrollDown = 0;
  906. #endif /* NT */
  907.            }
  908.        }
  909.  
  910.        if ( !(r.dwButtonState & (ThreeButton ? RIGHTMOST_BUTTON_PRESSED : 0) ) ) {
  911.            /* button 3 may have been released */
  912.            if ( b3.state == 1 ) {
  913.                debug( F100, "mouse B3 single click released", "" , 0 );
  914.                Event |= MMCLICK ;
  915.                 if ( SelectionValid ) {
  916.                     Event |= MMDRAG ;
  917.                 }
  918.  
  919.                 /* Handle special Mouse Kverbs */
  920.                 if ( mousemap[MMB3][Event].type == kverb ) {
  921.                      switch (mousemap[MMB3][Event].kverb.id & ~(F_KVERB)) {
  922.                      case K_MOUSE_MARK:
  923.                      case K_IGNORE:
  924.                            break;
  925.                      case K_MOUSE_CURPOS:
  926.                            putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  927.                            mousecurpos( mode, Vrow, Vcol, r.dwMousePosition.Y,
  928.                            r.dwMousePosition.X, FALSE ) ;
  929.                            break;
  930.                      case K_MOUSE_URL:
  931.                          putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  932.                          mouseurl( mode, r.dwMousePosition.Y,
  933.                                    r.dwMousePosition.X );
  934.                          break;
  935.                      case K_MARK_COPYCLIP:
  936.                      case K_MARK_COPYHOST:
  937.                      case K_MARK_COPYCLIP_NOEOL:
  938.                      case K_MARK_COPYHOST_NOEOL:
  939.                      case K_DUMP:
  940.                          putevent( mode, mousemap[MMB3][Event] ) ;
  941.                          putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  942.                          break;
  943.                      default:
  944.                          putevent( mode, mousemap[MMB3][Event] ) ;
  945.                          putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  946.                      }
  947.                   }
  948.                 else if ( mousemap[MMB3][Event].type != error ) {
  949.                      putevent( mode,mousemap[MMB3][Event] ) ;
  950.                     putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  951.                 }
  952.                else {
  953.                    putkverb( mode, F_KVERB | K_MARK_CANCEL ) ;
  954.                }
  955.                   SelectionValid = 0 ;
  956.                   b3.state = 0 ;
  957.                   b3.row = 0 ;
  958.                   b3.col = 0 ;
  959. #ifdef NT
  960.                win32ScrollUp = win32ScrollDown = 0;
  961. #endif /* NT */
  962.             }
  963.             else if ( b3.state == 2 ) {
  964.                 debug( F100, "mouse B3 double click released", "" , 0 );
  965.                 Event |= MMDBL ;
  966.  
  967.                /* Handle special Mouse Kverbs */
  968.                 if ( mousemap[MMB3][Event].type == kverb ) {
  969.                switch (mousemap[MMB3][Event].kverb.id & ~(F_KVERB)) {
  970.                case K_MOUSE_MARK:
  971.                case K_IGNORE:
  972.                   break;
  973.                case K_MOUSE_CURPOS:
  974.                    mousecurpos( mode, Vrow, Vcol, r.dwMousePosition.Y,
  975.                                 r.dwMousePosition.X, FALSE ) ;
  976.                   break;
  977.                case K_MOUSE_URL:
  978.                    mouseurl( mode, r.dwMousePosition.Y,
  979.                              r.dwMousePosition.X );
  980.                    break;
  981.                default:
  982.                    putevent( mode, mousemap[MMB3][Event] ) ;
  983.                }
  984.                 }
  985.                 else if ( mousemap[MMB3][Event].type != error ) {
  986.                     putevent( mode, mousemap[MMB3][Event] ) ;
  987.                 }
  988.                 SelectionValid = 0 ;
  989.                 b3.state = 0 ;
  990.                 b3.row = 0 ;
  991.                 b3.col = 0 ;
  992. #ifdef NT
  993.                 win32ScrollUp = win32ScrollDown = 0;
  994. #endif /* NT */
  995.             }
  996.        }
  997.        lastrow = r.dwMousePosition.Y ;
  998.        lastcol = r.dwMousePosition.X ;
  999.    }
  1000.    else  /* No Mouse Event */ {
  1001.    char buffer[1024] ;
  1002.       if ( SelectionValid ) {
  1003.          ppos = VscrnGetCurPos(mode) ;
  1004.          Vrow = ppos->y ;
  1005.          Vcol = ppos->x ;
  1006.  
  1007.          if ( lastrow == 0 &&
  1008.                VscrnGetBegin(mode) != VscrnGetScrollTop(mode)+Vrow ) {
  1009.                putkverb( mode, F_KVERB | K_UPONE ) ;
  1010.                }
  1011.          else if ( lastrow == VscrnGetHeight(mode) -2 &&
  1012.                VscrnGetEnd(mode) != VscrnGetScrollTop(mode)+Vrow ) {
  1013.                putkverb( mode, F_KVERB | K_DNONE ) ;
  1014.                }
  1015.          sprintf(buffer, "AutoScroll: fs:%3x row:%3d col:%3d",
  1016.          r.dwButtonState,
  1017.          r.dwMousePosition.Y, r.dwMousePosition.X) ;
  1018.          debug(F110,"win32MouseEvent",buffer,0) ;
  1019.       }
  1020.    #ifdef COMMENT
  1021.       else {
  1022.       sprintf(buffer, "NoEvent: fs:%3x row:%3d col:%3d",
  1023.       r.dwButtonState,
  1024.       r.dwMousePosition.Y, r.dwMousePosition.X) ;
  1025.       debug(F110,"win32MouseEvent",buffer,0) ;
  1026.       }
  1027.    #endif /* COMMENT */
  1028.    }
  1029. }
  1030.  
  1031. #else /* NT */
  1032. void
  1033. os2_mouseevt(void *pArgList) {
  1034. APIRET rc ;
  1035. MOUEVENTINFO MouseEventInfo ;
  1036. USHORT       ReadType = MOU_NOWAIT ;
  1037. position   * ppos ;
  1038. USHORT Vrow, Vcol, n, ShiftState, Event ;
  1039. USHORT lastrow=0, lastcol=0 ;
  1040. ULONG postcount ;
  1041. extern BYTE vmode;
  1042.  
  1043. struct {
  1044.     int state ;
  1045.     USHORT row   ;
  1046.     USHORT col   ;
  1047.     HTIMER timer ;
  1048.     HEV    sem ;
  1049.     } b1 = {0,0,0,0,(HEV) 0}, b2 = {0,0,0,0,(HEV) 0}, b3  = {0,0,0,0,(HEV) 0};
  1050.  
  1051. ResetThreadPrty() ;
  1052.  
  1053. DosCreateEventSem( NULL, &b1.sem, DC_SEM_SHARED, FALSE ) ;
  1054. DosCreateEventSem( NULL, &b2.sem, DC_SEM_SHARED, FALSE ) ;
  1055. DosCreateEventSem( NULL, &b3.sem, DC_SEM_SHARED, FALSE ) ;
  1056.  
  1057. while (hMouse)
  1058.     {
  1059.         memset( &MouseEventInfo, 0, sizeof( MOUEVENTINFO ) ) ;
  1060.         rc = MouReadEventQue( &MouseEventInfo, &ReadType, hMouse ) ;
  1061.         if ( rc == NO_ERROR && MouseEventInfo.time ) {
  1062.             char buffer[1024] ;
  1063.             ShiftState = getshiftstate() ;
  1064.             Event = 0 ;
  1065.             if ( ShiftState & SHIFT )
  1066.                 Event |= MMSHIFT ;
  1067.             if ( ShiftState & ALT )
  1068.                 Event |= MMALT ;
  1069.             if ( ShiftState & CONTROL )
  1070.                 Event |= MMCTRL ;
  1071.  
  1072.             sprintf(buffer, "  Event: fs:%3x time:%10d row:%3d col:%3d",
  1073.                      MouseEventInfo.fs, MouseEventInfo.time,
  1074.                      MouseEventInfo.row, MouseEventInfo.col) ;
  1075.             debug(F110,"os2_mouseevt",buffer,0) ;
  1076.             if ( MouseDebug )
  1077.                 printf(buffer);
  1078.  
  1079.             /* \V() variables */
  1080.             MouseCurX = MouseEventInfo.col;
  1081.             MouseCurY = MouseEventInfo.row;
  1082.  
  1083.             ppos = VscrnGetCurPos(vmode) ;
  1084.             Vrow = ppos->y ;
  1085.             Vcol = ppos->x ;
  1086.  
  1087.         if ( MouseEventInfo.row == VscrnGetHeight(vmode)
  1088.              -(tt_status[vmode]?1:0) )
  1089.             MouseEventInfo.row-- ;
  1090.  
  1091.             if ( MouseEventInfo.fs & MOUSE_BN1_DOWN ) {
  1092.                 DosQueryEventSem( b1.sem, &postcount ) ;
  1093.             if ( b1.state == 1 &&
  1094.                 !SelectionValid &&
  1095.                 !postcount &&
  1096.                 MouseEventInfo.row == b1.row &&
  1097.                 MouseEventInfo.col == b1.col ) {
  1098.                     /* Double Click */
  1099.                 debug( F100, "mouse B1 double click", "", 0 ) ;
  1100.                 b1.state = 2 ;
  1101.                 }
  1102.                 else {
  1103.                     /* Single Click */
  1104.                 b1.state = 1 ;
  1105.                 b1.row = MouseEventInfo.row ;
  1106.                 b1.col = MouseEventInfo.col ;
  1107.                 DosResetEventSem( b1.sem, &postcount ) ;
  1108.                 debug( F100, "mouse B1 single click", "", 0 ) ;
  1109.                 }
  1110.             }
  1111.             else if ( MouseEventInfo.fs & MOUSE_MOTION_WITH_BN1_DOWN ) {
  1112.             debug( F100, "mouse B1 drag", "", 0 ) ;
  1113.                 if ( b1.state == 1 && !SelectionValid ) {
  1114.                 SelectionValid = 1 ;
  1115.                 RequestKeyStrokeMutex( vmode, SEM_INDEFINITE_WAIT);
  1116.                 putkverb( vmode, F_KVERB | K_MARK_START ) ;
  1117.                 mousecurpos( vmode, Vrow, Vcol, b1.row, b1.col, TRUE ) ;
  1118.                 putkverb( vmode, F_KVERB | K_MARK_START ) ;
  1119.                 ReleaseKeyStrokeMutex(vmode) ;
  1120.                 }
  1121.             else if ( b1.state == 1 && SelectionValid &&
  1122.                 ( lastrow != MouseEventInfo.row ||
  1123.                 lastcol != MouseEventInfo.col )
  1124.                 ) {
  1125.                 mousecurpos( vmode, lastrow, lastcol, MouseEventInfo.row,
  1126.                 MouseEventInfo.col, TRUE ) ;
  1127.                 }
  1128.             }
  1129.  
  1130.             if ( MouseEventInfo.fs & MOUSE_BN2_DOWN ) {
  1131.                 DosQueryEventSem( b2.sem, &postcount ) ;
  1132.             if ( b2.state == 1 &&
  1133.                 !SelectionValid &&
  1134.                 !postcount &&
  1135.                 MouseEventInfo.row == b2.row &&
  1136.                 MouseEventInfo.col == b2.col ) {
  1137.                     /* Double Click */
  1138.                 debug( F100, "mouse B2 double click", "", 0 ) ;
  1139.                 b2.state = 2 ;
  1140.                 }
  1141.                 else {
  1142.                     /* Single Click */
  1143.                 b2.state = 1 ;
  1144.                 b2.row = MouseEventInfo.row ;
  1145.                 b2.col = MouseEventInfo.col ;
  1146.                 DosResetEventSem( b2.sem, &postcount ) ;
  1147.                 debug( F100, "mouse B2 single click", "", 0 ) ;
  1148.                 }
  1149.             }
  1150.             else if ( MouseEventInfo.fs & MOUSE_MOTION_WITH_BN2_DOWN ) {
  1151.             debug( F100, "mouse B2 drag", "", 0 ) ;
  1152.                 if ( b2.state == 1 && !SelectionValid ) {
  1153.                 SelectionValid = 1 ;
  1154.                 RequestKeyStrokeMutex( vmode, SEM_INDEFINITE_WAIT);
  1155.                 putkverb( vmode, F_KVERB | K_MARK_START ) ;
  1156.                 mousecurpos( vmode, Vrow, Vcol, b2.row, b2.col, TRUE ) ;
  1157.                 putkverb( vmode, F_KVERB | K_MARK_START ) ;
  1158.                 ReleaseKeyStrokeMutex(vmode) ;
  1159.                 }
  1160.             else if ( b2.state == 1 && SelectionValid &&
  1161.                 ( lastrow != MouseEventInfo.row ||
  1162.                 lastcol != MouseEventInfo.col )
  1163.                 ) {
  1164.                 mousecurpos( vmode, lastrow, lastcol, MouseEventInfo.row,
  1165.                 MouseEventInfo.col, TRUE ) ;
  1166.                 }
  1167.             }
  1168.  
  1169.             if ( MouseEventInfo.fs & MOUSE_BN3_DOWN ) {
  1170.                 DosQueryEventSem( b3.sem, &postcount );
  1171.             if ( b3.state == 1 &&
  1172.                 !SelectionValid &&
  1173.                 !postcount &&
  1174.                 MouseEventInfo.row == b3.row &&
  1175.                 MouseEventInfo.col == b3.col ) {
  1176.                     /* Double Click */
  1177.                 b3.state = 2 ;
  1178.                 debug( F100, "mouse B3 double click","",0) ;
  1179.                 }
  1180.                 else {
  1181.                     /* Single Click */
  1182.                 b3.state = 1 ;
  1183.                 b3.row = MouseEventInfo.row ;
  1184.                 b3.col = MouseEventInfo.col ;
  1185.                 DosResetEventSem( b3.sem, &postcount ) ;
  1186.                 debug( F100, "mouse B3 single click","",0) ;
  1187.                 }
  1188.             }
  1189.             else if ( MouseEventInfo.fs & MOUSE_MOTION_WITH_BN3_DOWN ) {
  1190.             debug( F100, "mouse B3 drag","",0) ;
  1191.                 if ( b3.state == 1 && !SelectionValid ) {
  1192.                 SelectionValid = 1 ;
  1193.                 RequestKeyStrokeMutex( vmode, SEM_INDEFINITE_WAIT);
  1194.                 putkverb( vmode, F_KVERB | K_MARK_START ) ;
  1195.                 mousecurpos( vmode, Vrow, Vcol, b3.row, b3.col, TRUE ) ;
  1196.                 putkverb( vmode, F_KVERB | K_MARK_START ) ;
  1197.                 ReleaseKeyStrokeMutex(vmode) ;
  1198.                 }
  1199.             else if ( b3.state == 1 && SelectionValid &&
  1200.                 ( lastrow != MouseEventInfo.row ||
  1201.                 lastcol != MouseEventInfo.col )
  1202.                 ) {
  1203.                 mousecurpos( vmode, lastrow, lastcol, MouseEventInfo.row,
  1204.                 MouseEventInfo.col, TRUE ) ;
  1205.                 }
  1206.             }
  1207.  
  1208.         if ( !(MouseEventInfo.fs &
  1209.             ( MOUSE_BN1_DOWN | MOUSE_MOTION_WITH_BN1_DOWN) ) ) {
  1210.                     /* button 1 may have been released */
  1211.                 if ( b1.state == 1 ) {
  1212.                     debug( F100, "mouse B1 single click released", "" , 0 );
  1213.                     if ( SelectionValid ) {
  1214.                     Event |= MMDRAG ;
  1215.  
  1216.                         /* Handle special Mouse Kverbs */
  1217.                         if ( mousemap[MMB1][Event].type == kverb ) {
  1218.                         switch (mousemap[MMB1][Event].kverb.id & ~(F_KVERB)) {
  1219.                         case K_MOUSE_CURPOS:
  1220.                             putkverb( vmode, F_KVERB | K_MARK_CANCEL ) ;
  1221.                             mousecurpos( vmode, Vrow, Vcol, MouseEventInfo.row,
  1222.                             MouseEventInfo.col, FALSE ) ;
  1223.                             break;
  1224.                         case K_MOUSE_URL:
  1225.                             putkverb( vmode, F_KVERB | K_MARK_CANCEL ) ;
  1226.                             mouseurl( vmode, MouseEventInfo.row,
  1227.                                       MouseEventInfo.col );
  1228.                             break;
  1229.                         case K_MARK_COPYCLIP:
  1230.                         case K_MARK_COPYHOST:
  1231.                         case K_MARK_COPYCLIP_NOEOL:
  1232.                         case K_MARK_COPYHOST_NOEOL:
  1233.                         case K_DUMP:
  1234.                             putevent( vmode, mousemap[MMB1][Event] ) ;
  1235.                             break;
  1236.                         case K_MOUSE_MARK:
  1237.                             break;
  1238.                         default:
  1239.                             putkverb( vmode, F_KVERB | K_MARK_CANCEL ) ;
  1240.                             putevent( vmode, mousemap[MMB1][Event] ) ;
  1241.                         }
  1242.                     }
  1243.                         else /* if ( mousemap[MMB1][Event].type != error ) */ {
  1244.                             putkverb( vmode, F_KVERB | K_MARK_CANCEL ) ;
  1245.                             putevent( vmode, mousemap[MMB1][Event] ) ;
  1246.                         }
  1247.                     SelectionValid = 0 ;
  1248.                     b1.state = 0 ;
  1249.                     b1.row = 0 ;
  1250.                     b1.col = 0 ;
  1251.                     }
  1252.                 else {
  1253.                     DosResetEventSem( b1.sem, &postcount ) ;
  1254.                     DosAsyncTimer( dblclickspeed, (HSEM) b1.sem, &b1.timer ) ;
  1255.                     }
  1256.                 }
  1257.                 else if ( b1.state == 2 ) {
  1258.                     debug( F100, "mouse B1 double click released", "" , 0 );
  1259.                     Event |= MMDBL ;
  1260.  
  1261.                     /* Handle special Mouse Kverbs */
  1262.                     if ( mousemap[MMB1][Event].type == kverb ) {
  1263.                     switch (mousemap[MMB1][Event].kverb.id & ~(F_KVERB)) {
  1264.                     case K_MOUSE_MARK:
  1265.                         break;
  1266.                     case K_MOUSE_CURPOS:
  1267.                         mousecurpos( vmode, Vrow, Vcol, MouseEventInfo.row,
  1268.                         MouseEventInfo.col, FALSE ) ;
  1269.                         break;
  1270.                     case K_MOUSE_URL:
  1271.                         mouseurl( vmode, MouseEventInfo.row,
  1272.                                   MouseEventInfo.col );
  1273.                         break;
  1274.                     default:
  1275.                         putevent( vmode, mousemap[MMB1][Event] ) ;
  1276.                     }
  1277.                 }
  1278.                     else /* if ( mousemap[MMB1][Event].type != error ) */ {
  1279.                         putevent( vmode, mousemap[MMB1][Event] ) ;
  1280.                     }
  1281.                 b1.state = 0 ;
  1282.                 b1.row = 0 ;
  1283.                 b1.col = 0 ;
  1284.                 }
  1285.             }
  1286.  
  1287.         if ( !(MouseEventInfo.fs &
  1288.             ( MOUSE_BN2_DOWN | MOUSE_MOTION_WITH_BN2_DOWN) ) ) {
  1289.                     /* button 2 may have been released */
  1290.                 if ( b2.state == 1 ) {
  1291.                     debug( F100, "mouse B2 single click released", "" , 0 );
  1292.                     if ( SelectionValid ) {
  1293.                     Event |= MMDRAG ;
  1294.  
  1295.                         /* Handle special Mouse Kverbs */
  1296.                         if ( mousemap[MMB2][Event].type == kverb ) {
  1297.                         switch (mousemap[MMB2][Event].kverb.id & ~(F_KVERB)) {
  1298.                         case K_MOUSE_MARK:
  1299.                             break;
  1300.                         case K_MOUSE_CURPOS:
  1301.                             putkverb( vmode,F_KVERB | K_MARK_CANCEL ) ;
  1302.                             mousecurpos( vmode, Vrow, Vcol, MouseEventInfo.row,
  1303.                             MouseEventInfo.col, FALSE ) ;
  1304.                             break;
  1305.                         case K_MOUSE_URL:
  1306.                             putkverb( vmode, F_KVERB | K_MARK_CANCEL ) ;
  1307.                             mouseurl( vmode, MouseEventInfo.row,
  1308.                                       MouseEventInfo.col );
  1309.                             break;
  1310.                         case K_MARK_COPYCLIP:
  1311.                         case K_MARK_COPYHOST:
  1312.                         case K_MARK_COPYCLIP_NOEOL:
  1313.                         case K_MARK_COPYHOST_NOEOL:
  1314.                         case K_DUMP:
  1315.                             putevent( vmode, mousemap[MMB2][Event] ) ;
  1316.                             break;
  1317.                         default:
  1318.                             putkverb( vmode, F_KVERB | K_MARK_CANCEL ) ;
  1319.                             putevent( vmode, mousemap[MMB2][Event] ) ;
  1320.                         }
  1321.                     }
  1322.                         else /* if ( mousemap[MMB2][Event].type != error ) */ {
  1323.                             putkverb( vmode, F_KVERB | K_MARK_CANCEL ) ;
  1324.                             putevent( vmode, mousemap[MMB2][Event] ) ;
  1325.                         }
  1326.                     SelectionValid = 0 ;
  1327.                     b2.state = 0 ;
  1328.                     b2.row = 0 ;
  1329.                     b2.col = 0 ;
  1330.                     }
  1331.                 else {
  1332.                     DosResetEventSem( b2.sem, &postcount ) ;
  1333.                     DosAsyncTimer( dblclickspeed, (HSEM) b2.sem, &b2.timer ) ;
  1334.                     }
  1335.                 }
  1336.                 else if ( b2.state == 2 ) {
  1337.                     debug( F100, "mouse B2 double click released", "" , 0 );
  1338.                 Event |= MMDBL ;
  1339.  
  1340.                     /* Handle special Mouse Kverbs */
  1341.                     if ( mousemap[MMB2][Event].type == kverb) {
  1342.                     switch (mousemap[MMB2][Event].kverb.id & ~(F_KVERB)) {
  1343.                     case K_MOUSE_MARK:
  1344.                         break;
  1345.                     case K_MOUSE_CURPOS:
  1346.                         mousecurpos( vmode, Vrow, Vcol, MouseEventInfo.row,
  1347.                         MouseEventInfo.col, FALSE ) ;
  1348.                         break;
  1349.                     case K_MOUSE_URL:
  1350.                         mouseurl( vmode, MouseEventInfo.row,
  1351.                                   MouseEventInfo.col );
  1352.                         break;
  1353.                     default:
  1354.                         putevent( vmode, mousemap[MMB2][Event] ) ;
  1355.                     }
  1356.                 }
  1357.                     else /* if ( mousemap[MMB2][Event].type != error ) */ {
  1358.                         putevent( vmode, mousemap[MMB2][Event] ) ;
  1359.                     }
  1360.                 b2.state = 0 ;
  1361.                 b2.row = 0 ;
  1362.                 b2.col = 0 ;
  1363.                 }
  1364.             }
  1365.  
  1366.         if ( !(MouseEventInfo.fs &
  1367.             ( MOUSE_BN3_DOWN | MOUSE_MOTION_WITH_BN3_DOWN) ) ) {
  1368.                     /* button 3 may have been released */
  1369.                 if ( b3.state == 1 ) {
  1370.                     debug( F100, "mouse B3 single click released", "" , 0 );
  1371.                     if ( SelectionValid ) {
  1372.                     Event |= MMDRAG ;
  1373.  
  1374.                         /* Handle special Mouse Kverbs */
  1375.                         if ( mousemap[MMB3][Event].type == kverb ) {
  1376.                         switch (mousemap[MMB3][Event].kverb.id & ~(F_KVERB)) {
  1377.                         case K_MOUSE_MARK:
  1378.                             break;
  1379.                         case K_MOUSE_CURPOS:
  1380.                             putkverb( vmode, F_KVERB | K_MARK_CANCEL ) ;
  1381.                             mousecurpos( vmode, Vrow, Vcol, MouseEventInfo.row,
  1382.                             MouseEventInfo.col, FALSE ) ;
  1383.                             break;
  1384.                         case K_MOUSE_URL:
  1385.                             putkverb( vmode, F_KVERB | K_MARK_CANCEL ) ;
  1386.                             mouseurl( vmode, MouseEventInfo.row,
  1387.                                       MouseEventInfo.col );
  1388.                             break;
  1389.                         case K_MARK_COPYCLIP:
  1390.                         case K_MARK_COPYHOST:
  1391.                         case K_MARK_COPYCLIP_NOEOL:
  1392.                         case K_MARK_COPYHOST_NOEOL:
  1393.                         case K_DUMP:
  1394.                             putevent( vmode, mousemap[MMB3][Event] ) ;
  1395.                             break;
  1396.                         default:
  1397.                             putkverb( vmode, F_KVERB | K_MARK_CANCEL ) ;
  1398.                             putevent( vmode, mousemap[MMB3][Event] ) ;
  1399.                         }
  1400.                     }
  1401.                         else /* if ( mousemap[MMB3][Event].type != error ) */ {
  1402.                             putkverb( vmode, F_KVERB | K_MARK_CANCEL ) ;
  1403.                             putevent( vmode, mousemap[MMB3][Event] ) ;
  1404.                         }
  1405.                     SelectionValid = 0 ;
  1406.                     b3.state = 0 ;
  1407.                     b3.row = 0 ;
  1408.                     b3.col = 0 ;
  1409.                     }
  1410.                 else {
  1411.                     DosResetEventSem( b3.sem, &postcount ) ;
  1412.                     DosAsyncTimer( dblclickspeed, (HSEM) b3.sem, &b3.timer ) ;
  1413.                     }
  1414.                 }
  1415.                 else if ( b3.state == 2 ) {
  1416.                     debug( F100, "mouse B3 double click released", "" , 0 );
  1417.                 Event |= MMDBL ;
  1418.  
  1419.                     /* Handle special Mouse Kverbs */
  1420.                     if ( mousemap[MMB3][Event].type == kverb ) {
  1421.                     switch (mousemap[MMB3][Event].kverb.id & ~(F_KVERB)) {
  1422.                     case K_MOUSE_MARK:
  1423.                         break;
  1424.                     case K_MOUSE_CURPOS:
  1425.                         mousecurpos( vmode, Vrow, Vcol, MouseEventInfo.row,
  1426.                         MouseEventInfo.col, FALSE ) ;
  1427.                         break;
  1428.                     case K_MOUSE_URL:
  1429.                         mouseurl( vmode, MouseEventInfo.row,
  1430.                                   MouseEventInfo.col );
  1431.                         break;
  1432.                     default:
  1433.                         putevent( vmode, mousemap[MMB3][Event] ) ;
  1434.                     }
  1435.                 }
  1436.                     else /* if ( mousemap[MMB3][Event].type != error ) */ {
  1437.                         putevent( vmode, mousemap[MMB3][Event] ) ;
  1438.                     }
  1439.                 b3.state = 0 ;
  1440.                 b3.row = 0 ;
  1441.                 b3.col = 0 ;
  1442.                 }
  1443.             }
  1444.  
  1445.         lastrow = MouseEventInfo.row ;
  1446.         lastcol = MouseEventInfo.col ;
  1447.         }
  1448.  
  1449.         else  /* No Mouse Event */ {
  1450.         char buffer[1024] ;
  1451.             if ( SelectionValid ) {
  1452.             ppos = VscrnGetCurPos(vmode) ;
  1453.             Vrow = ppos->y ;
  1454.             Vcol = ppos->x ;
  1455.  
  1456.             if ( lastrow == 0 &&
  1457.                 VscrnGetBegin(vmode) != VscrnGetScrollTop(vmode)+Vrow ) {
  1458.                 putkverb( vmode, F_KVERB | K_UPONE ) ;
  1459.                 }
  1460.             else if ( lastrow == VscrnGetHeight(vmode) -(tt_status[vmode]?2:1) &&
  1461.                 VscrnGetEnd(vmode) != VscrnGetScrollTop(vmode)+Vrow
  1462.                        ) {
  1463.                 putkverb( vmode, F_KVERB | K_DNONE ) ;
  1464.                 }
  1465.             sprintf(buffer, "AutoScroll: fs:%3x time:%10d row:%3d col:%3d",
  1466.             MouseEventInfo.fs, MouseEventInfo.time,
  1467.             MouseEventInfo.row, MouseEventInfo.col) ;
  1468.             debug(F110,"os2_mouseevt",buffer,0) ;
  1469.             }
  1470.             else if ( b1.state == 1 &&
  1471.                 b1.timer &&
  1472.                 !DosQueryEventSem( b1.sem, &postcount ) &&
  1473.                 postcount ) {
  1474.             debug( F100, "mouse B1 timeout, must be a click", "", 0 ) ;
  1475.             Event |= MMCLICK ;
  1476.  
  1477.                 /* Handle special Mouse Kverbs */
  1478.                 if ( mousemap[MMB1][Event].type == kverb ) {
  1479.                 switch (mousemap[MMB1][Event].kverb.id & ~(F_KVERB)) {
  1480.                 case K_MOUSE_MARK:
  1481.                     break;
  1482.                 case K_MOUSE_CURPOS:
  1483.                     mousecurpos( vmode, Vrow, Vcol, lastrow, lastcol, FALSE ) ;
  1484.                     break;
  1485.                 case K_MOUSE_URL:
  1486.                     mouseurl( vmode, lastrow,
  1487.                               lastcol );
  1488.                     break;
  1489.                 default:
  1490.                     putevent( vmode, mousemap[MMB1][Event] ) ;
  1491.                 }
  1492.             }
  1493.                 else /* if ( mousemap[MMB1][Event].type != error ) */ {
  1494.                     putevent( vmode, mousemap[MMB1][Event] ) ;
  1495.                 }
  1496.             b1.state = 0 ;
  1497.             b1.row = 0 ;
  1498.             b1.col = 0 ;
  1499.             DosStopTimer( b1.timer ) ;
  1500.             b1.timer = 0 ;
  1501.             }
  1502.             else if ( b2.state == 1 &&
  1503.                 b2.timer &&
  1504.                 !DosQueryEventSem( b2.sem, &postcount ) &&
  1505.                 postcount ) {
  1506.             debug( F100, "mouse B2 timeout, must be a click", "", 0 ) ;
  1507.             Event |= MMCLICK ;
  1508.  
  1509.                 /* Handle special Mouse Kverbs */
  1510.                 if ( mousemap[MMB2][Event].type == kverb ) {
  1511.                 switch (mousemap[MMB2][Event].kverb.id & ~(F_KVERB)) {
  1512.                 case K_MOUSE_MARK:
  1513.                     break;
  1514.                 case K_MOUSE_CURPOS:
  1515.                     mousecurpos( vmode, Vrow, Vcol, lastrow, lastcol, FALSE ) ;
  1516.                     break;
  1517.                 case K_MOUSE_URL:
  1518.                     mouseurl( vmode, lastrow,
  1519.                               lastcol );
  1520.                     break;
  1521.                 default:
  1522.                     putevent( vmode, mousemap[MMB2][Event] ) ;
  1523.                 }
  1524.             }
  1525.                 else /* if ( mousemap[MMB2][Event].type != error ) */ {
  1526.                     putevent( vmode, mousemap[MMB2][Event] ) ;
  1527.                 }
  1528.             b2.state = 0 ;
  1529.             b2.row = 0 ;
  1530.             b2.col = 0 ;
  1531.             DosStopTimer( b2.timer ) ;
  1532.             b2.timer = 0 ;
  1533.             }
  1534.             else if ( b3.state == 1 &&
  1535.                 b3.timer &&
  1536.                 !DosQueryEventSem( b3.sem, &postcount ) &&
  1537.                 postcount ) {
  1538.             debug( F100, "mouse B3 timeout, must be a click", "", 0 ) ;
  1539.             Event |= MMCLICK ;
  1540.  
  1541.                 /* Handle special Mouse Kverbs */
  1542.                 if ( mousemap[MMB3][Event].type == kverb ) {
  1543.                 switch (mousemap[MMB3][Event].kverb.id & ~(F_KVERB)) {
  1544.                 case K_MOUSE_MARK:
  1545.                     break;
  1546.                 case K_MOUSE_CURPOS:
  1547.                     mousecurpos( vmode, Vrow, Vcol, lastrow, lastcol, FALSE ) ;
  1548.                     break;
  1549.                 case K_MOUSE_URL:
  1550.                     mouseurl( vmode, lastrow,
  1551.                               lastcol );
  1552.                     break;
  1553.                 default:
  1554.                     putevent( vmode, mousemap[MMB3][Event] ) ;
  1555.                 }
  1556.             }
  1557.                 else /* if ( mousemap[MMB3][Event].type != error ) */ {
  1558.                     putevent( vmode, mousemap[MMB3][Event] ) ;
  1559.                 }
  1560.             b3.state = 0 ;
  1561.             b3.row = 0 ;
  1562.             b3.col = 0 ;
  1563.             DosStopTimer( b3.timer ) ;
  1564.             b3.timer = 0 ;
  1565.             }
  1566.  
  1567. #ifdef COMMENT
  1568.             else {
  1569.             sprintf(buffer, "NoEvent: fs:%3x time:%10d row:%3d col:%3d",
  1570.             MouseEventInfo.fs, MouseEventInfo.time,
  1571.             MouseEventInfo.row, MouseEventInfo.col) ;
  1572.             debug(F110,"os2_mouseevt",buffer,0) ;
  1573.             }
  1574. #endif /* COMMENT */
  1575.         }
  1576.     msleep(1) ;
  1577.     }
  1578.  
  1579. DosCloseEventSem( b1.sem ) ;
  1580. DosCloseEventSem( b2.sem ) ;
  1581. DosCloseEventSem( b3.sem ) ;
  1582. ckThreadEnd(pArgList);
  1583. }
  1584. #endif /* NT */
  1585.  
  1586. APIRET
  1587. os2_mouseoff( void ) {
  1588. APIRET rc = 0 ;
  1589.  
  1590. #ifdef NT
  1591. extern HANDLE KbdHandle ;
  1592. DWORD mode ;
  1593.  
  1594.     mouseon = FALSE ;
  1595.     GetConsoleMode( KbdHandle, &mode ) ;
  1596.     mode &= ~ENABLE_MOUSE_INPUT ;
  1597.     rc = SetConsoleMode( KbdHandle, mode ) ;
  1598.     debug(F101,"Mouse Off","",rc) ;
  1599.  
  1600. #else /* NT */
  1601.     if ( hMouse ) {
  1602.     rc = MouClose( hMouse ) ;
  1603.     debug(F101,"Mouse Off","",rc) ;
  1604.     hMouse = 0 ;
  1605.     DosWaitThread( &tidMouse, DCWW_WAIT ) ;
  1606.     debug(F100,"os2_mouevt() thread dead","",0) ;
  1607.     tidMouse = 0 ;
  1608.     }
  1609. #endif /* NT */
  1610. return rc ;
  1611. }
  1612.  
  1613. #endif /* OS2MOUSE */
  1614.  
  1615.  
  1616.