home *** CD-ROM | disk | FTP | other *** search
/ Kyūkyoku!! X68000 Emulator / X68000Book.dat / mac / OLS / X68000 / Ko-Window / kow142s.lzh / wsrv / manager.c < prev    next >
C/C++ Source or Header  |  1995-11-24  |  16KB  |  721 lines

  1. /*
  2.  *        âEâCâôâhâEâ}âlü[âWââÅêù¥è╓Éö
  3.  *
  4.  *            Copyright    T.Kobayashi
  5.  *            1990.1.1
  6.  */
  7.  
  8. /*
  9.     1995 11/5    ö≈ÅCÉ│ COR.
  10.     1995 11/22  MAXPROCESSâVâôâ{âïé≡èOòöé╓
  11. */
  12.  
  13. #define        COR    1
  14.  
  15. #include    <stdio.h>
  16. #include    <mm_alloc.h>
  17. #include    <sys_doslib.h>
  18. #include    <iocslib.h>
  19. #include    <microstr.h>
  20.  
  21. #define    MANAGER
  22. #include    "clip.h"
  23. #include    "window.h"
  24. #include    "manager.h"
  25. #include    "mouselib.h"
  26. #include    "error.h"
  27.  
  28. #include    "vram.h"
  29. #include    "kanji.h"
  30. #include    "screen.h"
  31. #include    "sheet.h"
  32. #include    "process.h"
  33.  
  34. extern    Sheet    *BackPattern;
  35.  
  36. WindowClass    RootWindow;
  37. /*int        CommonSize= 100;*/        /* Number of Entory */
  38. int            (*RootEventExec[MAXPROCESS])();
  39. int            Palet1= ( 20 << 11 ) + ( 20 << 6 ) + ( 20 << 1 );
  40. int            Palet3= ( 31 << 11 ) + ( 31 << 6 ) + ( 31 << 1 );
  41.  
  42. typedef    struct    _KeyBuf {
  43.         char    function[20][32];
  44.         char    spcial[12][6];
  45.     }
  46.         KeyBuf;
  47.  
  48. static    KeyBuf    KeySet = {
  49.         {
  50.             "\x1B[A", "\x1B[B", "\x1B[C", "\x1B[D", "\x1B[E",
  51.             "\x1B[F", "\x1B[G", "\x1B[H", "\x1B[I", "\x1B[J",
  52.             "\x1B[K", "\x1B[L", "\x1B[M", "\x1B[N", "\x1B[O",
  53.             "\x1B[P", "\x1B[Q", "\x1B[R", "\x1B[S", "\x1B[T"
  54.         },
  55.         {
  56.             "\x1B[U", "\x1B[V", "\x1B[W", "\x1B[X", "\x1B[Y",
  57.             "\x1B[Z", "\x1B[[", "\x1B[\\", "\x1B[]", "\x1B[^",
  58.             "\x1B[_", "\x1B[`"
  59.         }
  60.     };
  61.  
  62. static    KeyBuf    DefaultKeySet ;
  63.  
  64. #if COR
  65. extern int    ScreenH, ScreenV;    /* 1991-94 COR. */
  66. extern int    MouseX, MouseY ;
  67. extern int    MouseCursor ;
  68. extern int    GraphicLock;
  69. #else
  70. static int    ScreenH= 768, ScreenV= 512;
  71. static int    MouseX, MouseY ;
  72. static int    MouseCursor ;
  73. #endif
  74.  
  75. static    Sheet    *BackSetPattern ;
  76.  
  77. static Common        *CommonBuf= NULL;
  78. static EventInfo    Info;
  79. static WindowClass    *FocusWP;
  80.  
  81. /*
  82.     proto -s manager.c > temp
  83. */
  84. static    int        RootEvent( WindowClass*, EventInfo* );
  85. /*static    int        ChengeKeyCode( int );*/
  86.  
  87. /*  Åëè·ë╗  */
  88. WindowClass    *ManagerInit( line, col )
  89. int        line ;
  90. int        col ;
  91. {
  92.     int        i ;
  93.     EventInfo    info ;
  94.  
  95.     if( line > 64 )
  96.         line= 64;    /* 62 -> 64  COR. */
  97.     if( col > 128 )
  98.         col= 128;
  99.  
  100.     FNCKEYGT( 0, (unsigned char*) &DefaultKeySet );
  101.  
  102. #if 0
  103.     if( !(CommonBuf= WindowMemoryAlloc( CommonSize*sizeof(Common*) )) ){
  104.         errput( "ïñùLù╠êµé¬é╞éΩé▄é╣é±\n" );    /* 1991 COR. */
  105.         EXIT2( 1 );
  106.     }
  107.     s_memclr_short( CommonSize*sizeof(Common), CommonBuf );    /* 24x100 */
  108. #endif
  109.  
  110.     for( i = 0 ; i < MAXPROCESS ; ++i )
  111.         RootEventExec[i] = NULL ;
  112.  
  113.     MouseX = -1 ;
  114.     MouseY = -1 ;
  115.     MouseCursor = ON ;
  116.     Info.LeftStat = FALSE ;
  117.     Info.RightStat = FALSE ;
  118.     Info.Counter = 0 ;
  119.     info.option = EventOpen ;
  120.     info.x = 0 ;
  121.     info.y = 0 ;
  122.     info.h = col*8 ;
  123.     info.v = line*16 ;
  124.  
  125.     WindowSet( &RootWindow, 0, 0, col*8, line*16, NULL, -1, RootEvent );
  126.     WindowSetEventAttr( &RootWindow, EventAttrDefault|EventMouseMoveON|EventNonON );
  127.     WindowSendEvent( &RootWindow, &info );
  128.  
  129. /*    C_CLS_AL();        COR. */
  130.     ScreenInit();
  131.  
  132.     return    &RootWindow;
  133. }
  134.  
  135. /*    ëµû╩é╠Åëè·ë╗  */
  136. void    ScreenInit()
  137. {
  138.     int        h, v ;
  139. /*    int        line ;*/
  140.     WindowClass    *wp ;
  141.  
  142.  
  143.     WindowSetScreenMode( -1 );
  144. #if 0
  145.     for( wp = RootWindow.window.childtop ; wp != NULL ; wp = wp->window.next )
  146.     {
  147.         if ( wp->window.attr & WindowAttrGraphicUse )
  148.             break ;
  149.     }
  150.     if ( wp == NULL )
  151.     {
  152.         SetGraphicMode( 0 );
  153.     }
  154.     else
  155.     {
  156.         SetGraphicMode( -1 );
  157.         /*G_CLR_ON();*/
  158.     }
  159. #endif
  160.  
  161.     KanjiInit();
  162.     C_FNKMOD( 3 );
  163.  
  164.     WindowGetViewSize( &RootWindow, &h, &v );
  165.  
  166. #if 0
  167.     line = v / 16 ;
  168.     if ( line < 32 )
  169.         C_WINDOW( line, 32-line );
  170.     else
  171. #endif
  172.         C_CUROFF();
  173.  
  174.     FNCKEYST( 0, (unsigned char*)&KeySet );
  175.  
  176.     TPALET( 0, 1 );
  177.     TPALET( 2, 0 );
  178.     TPALET( 1, Palet1 );
  179.     TPALET( 3, Palet3 );
  180.  
  181.     WindowRootScroll( 0, 0 );
  182.     MouseInitialize();
  183.     MouseRegion( 0, 0, h-1, v-1 );
  184.     VramRegion( 0, 0, h-1, v-1 );
  185.  
  186.     PutCVtInit();
  187.  
  188.     WindowRedraw( & RootWindow );
  189.     for( wp= RootWindow.window.childtop ; wp ; wp= wp->window.next ){
  190.         WindowRedraw( wp );
  191.     }
  192.     if( GraphicLock ){
  193.         TGUSEMD( 0, 2 );    /* Lock */
  194.     }
  195. }
  196.  
  197. /*  ÅIù╣Åêù¥  */
  198. void    ManagerQuit()
  199. {
  200.     WindowClass    *p ;
  201.  
  202.     Info.option = EventClose ;
  203.     for( p = RootWindow.window.childtop ; p != NULL ; p = p->window.next )
  204.         WindowSendEvent( p, &Info );
  205.  
  206.     WindowClose( & RootWindow );
  207.  
  208. /* ManagerQuit() é╠îπé╔é═òKé╕ ServerQuit() é¬î─é╬éΩéΘéτé╡éóüB
  209.    ServerQuit() ôαé┼éα ScreenQuit() é≡Ä└ìsé╡é─é¿éΦéQôxô«ì∞é╖éΘé▒é╞é╔é╚éΘ
  210.    é╠é┼âRâüâôâgâAâEâg 1992 10/6 H.Ogasawara (COR.)    */
  211. /*    ScreenQuit();*/
  212. }
  213.  
  214. /*  ëµû╩é╠ÅIù╣Åêù¥  */
  215. void    ScreenQuit()
  216. {
  217.     PutCVtQuit();
  218.  
  219.     KanjiQuit();
  220.  
  221.     WindowRootScroll( 0, 0 );
  222.  
  223.     C_WINDOW( 0, 31 );
  224.     C_FNKMOD( 0 );
  225.     C_CURON();
  226.  
  227.     FNCKEYST( 0, (unsigned char*)&DefaultKeySet );
  228.  
  229.     TPALET( 0, -2 );    /* âVâXâeâÇÆlé╔û▀é╖éµéñÅCÉ│ 1991 COR.*/
  230.     TPALET( 1, -2 );
  231.     TPALET( 2, -2 );
  232.     TPALET( 3, -2 );
  233.  
  234. /*    if( GraphicMode & WindowAttrGraphicUse )
  235.             TGUSEMD( 0, 0 );*/
  236.  
  237.     if( GraphicLock ){
  238.         TGUSEMD( 0, 0 );    /* UnLock */
  239.     }
  240.  
  241.     C_WIDTH( 0 );    /* 1991 COR. */
  242.  
  243.     MouseQuit();
  244. }
  245.  
  246.  
  247. /*  âpâîâbâgé╠É▌ÆΦ  */
  248. void    SetPalet( p1, p3 )
  249. int        p1, p3 ;
  250. {
  251.     Palet1 = p1 ;
  252.     Palet3 = p3 ;
  253.     TPALET( 1, Palet1 );
  254.     TPALET( 3, Palet3 );
  255. }
  256.  
  257. /*  âïü[âgé╠âCâxâôâgÅêù¥É▌ÆΦ  */
  258. void    SetRootEvent( id, exec )
  259. int        id ;
  260. int        (*exec)();
  261. {
  262.     ErrorCheck( 0 <= id && id < MAXPROCESS, "SetRootEvent" );
  263.  
  264.     RootEventExec[id] = exec ;
  265. }
  266.  
  267. static    int        RootEvent( wp, info )
  268. WindowClass    *wp ;
  269. EventInfo    *info ;
  270. {
  271.     int            i ;
  272.     WindowClass    *cwp ;
  273.     EventInfo    info2 ;
  274.     static    WindowClass    *lastwp ;
  275.     static    DrawBuf        buf[1] ;
  276.  
  277.     if ( info->option != EventNon )
  278.     {
  279.         for( i = 0 ; i < MAXPROCESS ; ++i )
  280.         {
  281.             if ( RootEventExec[i] != NULL )
  282.             {
  283.                 if ( SendEvent( i, RootEventExec[i], wp, info ) )
  284.                     return( TRUE );
  285.             }
  286.         }
  287.     }
  288. /* 1991 COR. */
  289.     {
  290.         /* [XF5]+[CTRL]+[XF2]+[BS] */
  291.         if( (BITSNS(11) & 2) && (BITSNS(1) & 128) && (BITSNS(10) & 64) && (BITSNS(14) & 2 ) ){
  292.             WindowSendSignal( 0, 1, 0 );    /* SignalKill */
  293.             /*return    TRUE;    û▀é┴é─ùêé╚éó*/
  294.         }
  295.     }
  296. /*************/
  297.     switch( info->option )
  298.     {
  299.         case EventOpen:
  300.             lastwp= NULL;
  301.             return    TRUE;
  302.         case EventRedraw :
  303.             DrawSetPattern( buf, GetBackPattern() );
  304.             WindowDraw( wp, buf, 1 );
  305.             return    TRUE;
  306.         case EventKey :
  307.             if ( FocusWP != NULL )
  308.                 return    WindowSendEvent( FocusWP, info );
  309.         case EventMouseSwitch :
  310.         case EventMouseMove :
  311.         case EventNon :
  312.             cwp = WindowGetChild( wp, info );
  313.             if( lastwp != cwp ){
  314. /*                info2= *info;*/
  315.                 s_memcpy_simple( sizeof(EventInfo), &info2, info );
  316.                 if( lastwp != NULL && lastwp->window.check != 0 &&
  317.                             !( lastwp->window.attr & WindowAttrInvisible ) ){
  318.                     info2.option = EventMouseOut ;
  319.                     WindowSendEvent( lastwp, &info2 );
  320.                 }
  321.                 if( cwp != NULL ){
  322.                     info2.option = EventMouseEnter ;
  323.                     WindowSendEvent( cwp, &info2 );
  324.                 }
  325.                 lastwp = cwp ;
  326.             }
  327.             if( cwp != NULL && info->option != EventNon )
  328.                 return    WindowSendEvent( cwp, info );
  329.             else
  330.                 return    FALSE;
  331.         default :
  332.             ErrorCheck( FALSE, "RootEvent" );
  333.     }
  334.     return    TRUE;
  335. }
  336.  
  337. void    RootZoomOperation( info )
  338. EventInfo    *info ;
  339. {
  340.     int        h, v ;
  341.  
  342.     info->x = HomeX ;
  343.     info->y = HomeY ;
  344.     WindowGetViewSize( &RootWindow, &h, &v );
  345.     info->h = ScreenH < h ? ScreenH : h ;
  346.     info->v = ScreenV < v ? ScreenV : v ;
  347. }
  348.  
  349. /*  âtâHü[âJâXâEâCâôâhâEé╠É▌ÆΦ  */
  350. void    SetFocus( wp )
  351. WindowClass    *wp ;
  352. {
  353.     FocusWP = wp ;
  354. }
  355.  
  356. /*    âoâbâNé╠âpâ^ü[âôé╠âZâbâg  */
  357. void    SetBackPattern( sp )
  358. void    *sp ;
  359. {
  360.     BackSetPattern = sp ;
  361.     WindowRedraw( & RootWindow );
  362. }
  363.  
  364. /*    âoâbâNé╠âpâ^ü[âôé≡ô╛éΘ  */
  365. void    *GetBackPattern()
  366. {
  367.     if ( BackSetPattern == NULL )
  368.         return( BackPattern );
  369.     else
  370.         return( BackSetPattern );
  371. }
  372.  
  373. /*  â}âEâXâJü[â\âïé╠É▌ÆΦ  */
  374. void    WindowMouseCursor( sw )
  375. int        sw ;
  376. {
  377.     if ( sw )
  378.     {
  379.         MouseCursor = ON ;
  380.         MouseMove( MouseX, MouseY );
  381.         MouseCursorOn();
  382.     }
  383.     else
  384.     {
  385.         MouseCursor = OFF ;
  386.         MouseCursorOff();
  387.     }
  388. }
  389.  
  390. /*  ïñùLù╠êµé╠É▌ÆΦ  */
  391. /* 1992 H.Ogasawara */
  392. /* 1995 11/22 mm_realloc é≡Ägùpé╖éΘéµéñëⁿù╟(Äßè▒é╠ìéæ¼ë╗é╠é═é╕) */
  393. /* 1995 11/24 ïñùLù╠êµéαÄ⌐ô«ègÆúé╖éΘéµéñé╔é╡é╜ */
  394. #define    NameCmp(str1,str2)    ( *(str1) == *(str2) && !n_strcmp( str1, str2 ) )
  395.  
  396. static Common *
  397. SearchCommon( name )
  398. char    *name;
  399. {
  400.     Common    *cp= CommonBuf;
  401.     for(; cp ; cp= cp->next ){
  402.         if( cp->pointer && NameCmp( cp->name, name ) )
  403.             return    cp;
  404.     }
  405.     return    NULL;
  406. }
  407.  
  408. void *
  409. WindowGetCommon( name, len )
  410. char    *name;
  411. int        len;
  412. {
  413.     Common    *cp= SearchCommon( name );
  414. {
  415. /*v_format_put( "GetCommon '%s' %d\r\n", name, len );*/
  416. }
  417.     if( !len )
  418.         return    cp ? cp->pointer+sizeof(int) : NULL;
  419.     if( cp ){
  420.         if( cp->pointer= realloc( cp->pointer, len+ sizeof(int)*2 ) )
  421.             return    cp->pointer+ sizeof(int);
  422.     }else{
  423.         for( cp= CommonBuf ; cp ; cp= cp->next ){
  424.             if( !cp->pointer )
  425.                 goto    _CommonSet;
  426.         }
  427.         if( cp= WindowMemoryAlloc( sizeof(Common) ) ){
  428.             cp->next= CommonBuf;
  429.             CommonBuf= cp;
  430.         _CommonSet:
  431.             s_strcpy( cp->name, name );
  432.             if( cp->pointer= WindowMemoryAlloc( len+ sizeof(int)*2 ) ){
  433.                 *((int*)cp->pointer)= -1;
  434.                 return    cp->pointer+ sizeof(int);
  435.             }
  436.         }
  437.     }
  438.     ErrorCheck( FALSE, "ïñùLù╠êµé¬èmò█é┼é½é▄é╣é±" );
  439.     return    NULL;
  440. }
  441.  
  442. /*  ïñùLù╠êµé╠èJò·  */
  443. int
  444. WindowResetCommon( name )
  445. char    *name;
  446. {
  447.     Common    *cp= SearchCommon( name );
  448. {
  449. /*v_format_put( "ResetCommon '%s' %x\r\n", name, cp );*/
  450. }
  451.     if( cp ){
  452.         WindowMemoryFree( cp->pointer );
  453.         cp->pointer= NULL;
  454.         return    TRUE;
  455.     }
  456.     return    FALSE;
  457. }
  458.  
  459. /*    âCâxâôâgæ╥é┐  */
  460. /*void    EventWait( sw )
  461. int        sw ;*/
  462. void    EventWait()
  463. {
  464.     WindowClass    *cwp ;
  465.  
  466.     if ( GetEventInfo( &Info ) )
  467.     {
  468.         Info.Counter ++ ;
  469.         WindowSendEvent( &RootWindow, &Info );
  470.     }
  471.     else
  472.     {
  473.     /*    âüâé    1991 COR.
  474.     (1) EventInterval é≡ Send é╡é╚éóÅΩìçé═üAÆPé╔âèâXâgé≡ÆHéΘé╛é»é┼âïü[âvôαé╠
  475.         Ä₧è╘æ╥é┐é═é┘é┌0é┼é╖üBé┬é▄éΦï≤âïü[âvé╔ôÖé╡éóé╠é┼üAé╗é╠ÅΩìçéαûêë± Event
  476.         é≡ Check é╖éΘé╠é═û│æ╩é╔é╚éΦé▄é╖üBé╗é▒é┼ Check é═ EventInterval é≡ Send
  477.         é╡é╜ÅΩìçé╔î└éΦüAé╗éñé┼é╚éóÅΩìçé═ 32 âEâBâôâhâEé╔éPë±é╠é╛é»â`âFâbâNé≡
  478.         ìsé╚éóé▄é╖üB( EventCheck é═îïì\ÅdéóÅêù¥é┼é╖üBô┴é╔ ASK é¬ægé▌ì₧é▄éΩé─
  479.         éóéΘé╞üEüE)
  480.     (2) é▄é╜ EventInterval é≡ Send é╡é╜ÅΩìçé┼éαüAâAâvâèâPü[âVâçâôé┼ë±Éöé≡âJâE
  481.         âôâgé╡ë╜éαé╣é╕é╔ return é╖éΘÅΩìçé¬é┘é╞é±é╟é┼é╖üBé╗éΩé≡ìlù╢é╡é─üAéαé╡
  482.         FALSE é¬ò╘é┴é─é½é╜éτ Check é≡Å╚ù¬é╖éΘéµéñé╔é╡é─é▌é▄é╡é╜üBé╜é╛é╡üAé▒é╠
  483.         ÅΩìçì┼Æßé┼éα 8 âEâBâôâhâEé╔éPë±é═ Check é≡ìsé╚éóé▄é╖üB
  484.  
  485.         (1) é╔é┬éóé─é═ë╜é╠ûΓæΦéαé╚éóé═é╕é┼é╖üB(2) é╔é┬éóé─é═éáéΘÆ÷ôxâTü[âoü[
  486.         é╠Ädùlé╔è╓é╖éΘòöò¬é╚é╠é┼üAéáé▄éΦŃÄΦé╔Åæé½è╖éªéΘé▒é╞é═é┼é½é▄é╣é±üB
  487.         EventInterval é╔è╓é╖éΘâvâëâCâIâèâeâBé═âTü[âoü[é┼âJâEâôâgé╡é─éαéóéóé┼
  488.         é╡éσéñé¬üAâAâvâèæñé┼Ä₧è╘é≡ÄQÅ╞é╖éΘòKùvé¬Åoé─é½é╜ÅΩìçéΓìíé▄é┼é╠î▌è╖ɽ
  489.         éαìçé╣éΘé╞üA(2) é╠Ädùlé┼Å\ò¬é⌐éαé╡éΩé▄é╣é±üB
  490.     */
  491. #define    EVENTMAX    32
  492.         int        i= 0;
  493.         Info.option = EventInterval ;
  494.         cwp = RootWindow.window.childtop ;
  495.         while( cwp != NULL )
  496.         {
  497. #define    INTERVAL    1
  498.             if ( cwp->window.eventattr & EventIntervalON ){
  499. #if !INTERVAL
  500.                 WindowSendEvent( cwp, &Info );
  501.                 if( CheckEventInfo( &Info ) )    /* 1991 COR. */
  502.                     break;
  503.                 i= 0;
  504. #else
  505.                 if( WindowSendEvent( cwp, &Info ) ){
  506.                     if ( CheckEventInfo( &Info ) )    /* 1991 COR. */
  507.                         break;
  508.                     i= 0;
  509.                 }else{
  510.                     if( i< 16 )
  511.                         i= 16;
  512.                 }
  513. #endif
  514.             }else if( ++i >= EVENTMAX ){    /* no count */
  515.                 if ( CheckEventInfo( &Info ) )    /* 1991 COR. */
  516.                     break;
  517.                 i= 0;
  518.             }
  519.             cwp = cwp->window.next ;
  520.         }
  521.         if ( cwp == NULL )
  522.         {
  523.             unsigned int    i;
  524.             extern int    BGmode;
  525.             if( BGmode )
  526.                 CHANGE_PR();        /* wsrv+7 */
  527.             Info.option = EventNon ;
  528.             Info.x= ( (i= MS_CURGT()) >>16 );
  529.             Info.y= ( i & 0xffff );
  530. /*            MouseGetPosition( &(Info.x), &(Info.y) );*/
  531.             WindowSendEvent( &RootWindow, &Info );
  532.         }
  533. #if 0    /* 1991 12/16 NEWëµû╩É▌ÆΦâïü[â`âôé╠ì╠ùpé╔éµéΦòsùpé╔é╚éΘ */
  534.         if ( GraphicMode & WindowAttrGraphicUse )
  535.         {
  536.             /* 964.w        9dc.b    */
  537.             if ( APAGE( -1 ) < 0 || TGUSEMD( 0, -1 ) != 2 )
  538.             {
  539.                 WindowClass    *wp ;
  540. /*                G_CLR_ON();*/
  541.                 TGUSEMD( 0, 2 );
  542.                 for( wp = RootWindow.window.childtop ; wp != NULL ; wp = wp->window.next )
  543.                 {
  544.                     if ( wp->window.attr & WindowAttrGraphicUse )
  545.                         WindowRedraw( wp );
  546.                 }
  547.             }
  548.         }
  549. #endif
  550.     }
  551. }
  552.  
  553. /*    âCâxâôâgÅεò±é╠èmò█  */
  554. /* 1991 COR. âCâxâôâgè╓ÿAé═ getevent.s é╔ê┌ìsé╡é▄é╡é╜ */
  555. /*#if !COR*/
  556. #if 0
  557. int
  558. GetEventInfo( info )
  559. EventInfo    *info;
  560. {
  561.     int        flag= FALSE;
  562.     int        left,
  563.             right;
  564.  
  565.     info->LeftON= info->LeftOFF= info->RightON= info->RightOFF= FALSE;
  566.     info->MoveFlag= FALSE;
  567.     info->KeyCode= 0;
  568.     info->option= EventNon;
  569.  
  570.     if( MouseCursor ){
  571.         unsigned int    i= MS_GETDT();
  572.         left= (i & 0x100) == 0x100;
  573.         right= i & 1;
  574.         info->x= ( (i= MS_CURGT()) >>16 );
  575.         info->y= ( i & 0xffff );
  576.  
  577.         if( info->LeftStat != left ){
  578.             flag= TRUE;
  579.             info->option= EventMouseSwitch;
  580.             if( left )
  581.                 info->LeftON= TRUE;
  582.             else
  583.                 info->LeftOFF= TRUE;
  584.             info->LeftStat= left;
  585.         }
  586.         if( info->RightStat != right ){
  587.             flag= TRUE;
  588.             info->option= EventMouseSwitch;
  589.             if( right )
  590.                 info->RightON= TRUE;
  591.             else
  592.                 info->RightOFF= TRUE;
  593.             info->RightStat= right;
  594.         }
  595.         if( info->x != MouseX || info->y != MouseY ){
  596.             if( flag || right || left )
  597.                 info->option= EventMouseSwitch;
  598.             else
  599.                 info->option= EventMouseMove;
  600.             flag= TRUE;
  601.             info->MoveFlag= TRUE;
  602.             MouseX= info->x;
  603.             MouseY= info->y;
  604.             if( MouseX < HomeX )
  605.                 HomeX= MouseX;
  606.             if( MouseX >= HomeX +ScreenH )
  607.                 HomeX= MouseX - ScreenH +1;
  608.             if( MouseY < HomeY )
  609.                 HomeY= MouseY;
  610.             if( MouseY >= HomeY +ScreenV )
  611.                 HomeY= MouseY - ScreenV +1;
  612.             WindowRootScroll( HomeX, HomeY );
  613.         }
  614.     }else{
  615.         info->x= MouseX;
  616.         info->y= MouseY;
  617.     }
  618.     if( ! flag ){
  619.         if( K_KEYSNS() ){
  620.             info->KeyCode= K_KEYINP() & 0xff;
  621.             flag= TRUE;
  622.             info->option= EventKey;
  623.             info->KeyCode= ChengeKeyCode( info->KeyCode );
  624.         }
  625.     }
  626.     if( flag )
  627.         info->ShiftStat= B_SFTSNS();
  628.     return    flag;
  629. }
  630. /*    if( info->KeyCode= KeyGet() )    */
  631. /*    MouseGetSwitch( &left, &right );*/
  632. /*    MouseGetPosition( &(info->x), &(info->y) );    */
  633.  
  634. /*  âLü[âRü[âhé╠ò╧è╖  */
  635. static    int        ChengeKeyCode( code )
  636. int        code ;
  637. {
  638.     if ( code == 0x1B && KeySense() == '[' )
  639.     {
  640.         KeyGet();
  641.         code = KeyGet();
  642.         if ( 'A' <= code && code <= '`' )
  643.         {
  644.             return( 0x8000 + code - '@' );
  645.         }
  646.     }
  647.     return( code );
  648. }
  649.  
  650. /*  âCâxâôâgâ`âFâbâN  */        /* 1991 COR. */
  651. int        CheckEventInfo( info )
  652. EventInfo    *info;
  653. {
  654.     int                left;
  655.     unsigned int    i= MS_GETDT();
  656.     left= (i & 0x100) == 0x100;
  657.     if( info->LeftStat != left || info->RightStat != (i&1) )
  658.         return    TRUE;
  659.     info->x= ( (i= MS_CURGT()) >>16 );
  660.     info->y= ( i & 0xffff );
  661.     if( info->x != MouseX || info->y != MouseY )
  662.         return    TRUE;
  663.     if( K_KEYSNS() & 0xff )
  664.         return    TRUE;
  665.     return    FALSE;
  666.  
  667. /*    MouseGetSwitch( &left, &right );*/
  668. /*    MouseGetPosition( &(info->x), &(info->y) );*/
  669. /*    if ( KeySense() )*/
  670. }
  671. #endif
  672.  
  673.  
  674. /*  âüâéâèè╟ù¥ù╠êµ  */
  675. typedef    struct {
  676.         short    id;
  677.         short    size;        /* é▒éΩé┴é─ 64K(or32K) é▄é┼é⌐!? */
  678.     }
  679.         MMA ;
  680.  
  681. /*  âüâéâèé╠èmò█  */
  682. void    *WindowMemoryAlloc( size )
  683. int        size ;
  684. {                    /* éαé╡é⌐é╡é─ëⁿê½üIüHé▓é▀é±é╚é│éó 1995 11/22 COR. */
  685.     void    *p= malloc( size );
  686. /*v_format_put( "malloc %d %x\r\n", size, p );*/
  687.     ErrorCheck( p, "âqü[âvù╠êµé¬æ½éΦé▄é╣é±" );
  688.     return    p;
  689. #if 0
  690.     MMA        *h ;
  691.  
  692.     h = (MMA*)malloc( size + sizeof( MMA ) );
  693.  
  694.     ErrorCheck( h != NULL, "âqü[âvù╠êµé¬æ½éΦé▄é╣é±" );
  695.  
  696.     h->id = 4321 ;
  697.     h->size = size ;
  698. /*    memset( (char*)( h + 1 ), 0, size );*/
  699. /*  1992,8 â[âìâNâèâAìφÅ£ H.Ogasawara(COR.) */
  700.  
  701.     return( (void*)( h + 1 ) );
  702. #endif
  703. }
  704.  
  705. /*  âüâéâèé╠èJò·  */
  706. void    WindowMemoryFree( p )
  707. void    *p ;
  708. {
  709.     free( p );
  710. /*v_format_put( "free %x\r\n", p );*/
  711. #if 0
  712.     MMA        *h ;
  713.  
  714.     h = (MMA*)p - 1 ;
  715.     ErrorCheck( h->id == 4321, "âüâéâèè╟ù¥ù╠êµé¬öjë≤é│éΩé▄é╡é╜üIüI" );
  716.     h->id = 0 ;
  717.     free( (char*)h );
  718. #endif
  719. }
  720. /* :vi:se ts=4 sw=4: */
  721.