Changeset 21502 for trunk/src


Ignore:
Timestamp:
Dec 3, 2010, 1:58:55 PM (15 years ago)
Author:
dmik
Message:

Added support for mouse wheel messages to mouse_event() and SendInput() (untested).

Location:
trunk/src/user32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/oslibmsg.cpp

    r21340 r21502  
    129129   WM_BUTTON3UP,     WINWM_MBUTTONUP,
    130130   WM_BUTTON3DBLCLK, WINWM_MBUTTONDBLCLK,
    131    WM_BUTTON3DBLCLK, WINWM_MOUSEWHEEL,    //WM_MOUSELAST
     131   WM_VSCROLL,      WINWM_MOUSEWHEEL,    //WM_MOUSELAST
    132132   999999999,        999999999,
    133133};
     
    762762//******************************************************************************
    763763//******************************************************************************
    764 BOOL OSLibSendWinMessage(HWND hwnd, ULONG winmsg)
    765 {
     764BOOL OSLibSendWinMessage(HWND hwnd, ULONG winmsg, ULONG extra /*= 0*/)
     765{
     766    if (winmsg == WINWM_MOUSEWHEEL)
     767    {
     768        return (BOOL)WinSendMsg(Win32ToOS2Handle(hwnd), TranslateWinMsg(winmsg, TRUE),
     769                                0, MPFROM2SHORT(0, extra < 0 ? SB_LINEDOWN : SB_LINEUP));
     770    }
    766771    return (BOOL)WinSendMsg(Win32ToOS2Handle(hwnd), TranslateWinMsg(winmsg, TRUE), 0, 0);
    767772}
  • trunk/src/user32/oslibmsg.h

    r10430 r21502  
    5555ULONG OSLibSendMessage(HWND hwndWin32, HWND hwndOS2, ULONG msg, ULONG wParam, ULONG lParam, BOOL fUnicode);
    5656ULONG OSLibWinBroadcastMsg(ULONG msg, ULONG wParam, ULONG lParam, BOOL fSend);
    57 BOOL  OSLibSendWinMessage(HWND hwnd, ULONG winmsg);
     57BOOL  OSLibSendWinMessage(HWND hwnd, ULONG winmsg, ULONG extra = 0);
    5858
    5959//Direct posting of messages that must remain invisible to the win32 app
  • trunk/src/user32/winmouse.cpp

    r10185 r21502  
    88 *
    99 * Copyright 1993 Bob Amstadt
    10  * Copyright 1996 Albrecht Kleine 
     10 * Copyright 1996 Albrecht Kleine
    1111 * Copyright 1997 David Faure
    1212 * Copyright 1998 Morten Welinder
    1313 * Copyright 1998 Ulrich Weigand
    1414 *
    15  * TODO: SwapMouseButton: 
     15 * TODO: SwapMouseButton:
    1616 *       We shouldn't let win32 apps change this for the whole system
    1717 *       better to change mouse button message translation instead
     
    130130  if (0 == hwndWin32Capture)
    131131    hwndWin32Capture = OS2ToWin32Handle(OSLibWinQueryCapture());
    132  
     132
    133133  return hwndWin32Capture;
    134134}
     
    139139  HWND hwndPrev = GetCapture();
    140140  BOOL rc;
    141  
     141
    142142  // invalidate capture "cache"
    143143  hwndWin32Capture = 0;
    144  
    145   if(hwnd == 0) 
     144
     145  if(hwnd == 0)
    146146  {
    147147    ReleaseCapture();
    148148    return hwndPrev;
    149149  }
    150  
    151   if(hwnd == hwndPrev) 
     150
     151  if(hwnd == hwndPrev)
    152152  {
    153153    dprintf(("USER32: SetCapture %x; already set to that window; ignore", hwnd));
     
    156156    return hwndPrev;
    157157  }
    158  
    159   if(hwndPrev != NULL) 
     158
     159  if(hwndPrev != NULL)
    160160  {
    161161    //SvL: WinSetCapture returns an error if mouse is already captured
    162162    OSLibWinSetCapture(0);
    163163  }
    164  
     164
    165165  rc = OSLibWinSetCapture(Win32ToOS2Handle(hwnd));
    166166  dprintf(("USER32: SetCapture %x (prev %x) returned %d", hwnd, hwndPrev, rc));
    167   if(hwndPrev) 
     167  if(hwndPrev)
    168168  {
    169169    SendMessageA(hwndPrev, WM_CAPTURECHANGED, 0L, hwnd);
     
    179179
    180180  hwndPrev = GetCapture();
    181  
     181
    182182  // invalidate capture "cache"
    183183  hwndWin32Capture = 0;
    184  
     184
    185185  ret = OSLibWinSetCapture(0);
    186   if(hwndPrev) 
     186  if(hwndPrev)
    187187  {
    188188    SendMessageA(hwndPrev, WM_CAPTURECHANGED, 0L, 0L);
     
    255255{
    256256  INPUT i;
    257  
     257
    258258  i.type           = INPUT_MOUSE;
    259259  i.mi.dx          = dx;
     
    262262  i.mi.dwFlags     = dwFlags;
    263263  i.mi.dwExtraInfo = dwExtraInfo;
    264  
     264
    265265  // forward to more modern API
    266266  SendInput(1, &i, sizeof(i) );
     
    270270/*****************************************************************************
    271271 * Name      : UINT SendInput
    272  * Purpose   : The SendInput function synthesizes keystrokes, mouse motions, 
     272 * Purpose   : The SendInput function synthesizes keystrokes, mouse motions,
    273273 *             and button clicks
    274274 * Parameters: UINT    nInputs // count if input events
     
    288288{
    289289  dprintf(("not correctly implemented"));
    290  
     290
    291291  // The simulated input is sent to the
    292292  // foreground thread's message queue.
     
    297297
    298298  HWND hwnd = GetForegroundWindow();
    299    
     299
    300300  LPINPUT piBase = pInputs;
    301301  for (int i = 0;
     
    309309      {
    310310        PMOUSEINPUT p = (PMOUSEINPUT)&piBase->mi;
    311         MSG msg; 
     311        MSG msg;
    312312        HWND hwndCapture;
    313313
    314314        hwndCapture = GetCapture();
    315315        if(hwndCapture) hwnd = hwndCapture;
    316        
    317         if(p->dwFlags & MOUSEEVENTF_MOVE) 
     316
     317        if(p->dwFlags & MOUSEEVENTF_MOVE)
    318318        {
    319319            if(!(p->dwFlags & MOUSEEVENTF_ABSOLUTE)) {
     
    332332                }
    333333            }
    334             SetCursorPos(p->dx, p->dy);   
     334            SetCursorPos(p->dx, p->dy);
    335335            OSLibSendWinMessage(hwnd, WM_MOUSEMOVE);
    336336        }
    337337
    338         if(p->dwFlags & MOUSEEVENTF_LEFTDOWN) 
     338        if(p->dwFlags & MOUSEEVENTF_LEFTDOWN)
    339339        {
    340340            KeySetOverlayKeyState(VK_LBUTTON, KEYOVERLAYSTATE_DOWN);
    341341            OSLibSendWinMessage(hwnd, WM_LBUTTONDOWN);
    342342        }
    343         if(p->dwFlags & MOUSEEVENTF_LEFTUP) 
     343        if(p->dwFlags & MOUSEEVENTF_LEFTUP)
    344344        {
    345345            KeySetOverlayKeyState(VK_LBUTTON, KEYOVERLAYSTATE_DONTCARE);
    346346            OSLibSendWinMessage(hwnd, WM_LBUTTONUP);
    347347        }
    348         if(p->dwFlags & MOUSEEVENTF_RIGHTDOWN) 
     348        if(p->dwFlags & MOUSEEVENTF_RIGHTDOWN)
    349349        {
    350350            KeySetOverlayKeyState(VK_RBUTTON, KEYOVERLAYSTATE_DOWN);
    351351            OSLibSendWinMessage(hwnd, WM_RBUTTONDOWN);
    352352        }
    353         if(p->dwFlags & MOUSEEVENTF_RIGHTUP) 
     353        if(p->dwFlags & MOUSEEVENTF_RIGHTUP)
    354354        {
    355355            KeySetOverlayKeyState(VK_RBUTTON, KEYOVERLAYSTATE_DONTCARE);
    356356            OSLibSendWinMessage(hwnd, WM_RBUTTONUP);
    357357        }
    358         if(p->dwFlags & MOUSEEVENTF_MIDDLEDOWN) 
     358        if(p->dwFlags & MOUSEEVENTF_MIDDLEDOWN)
    359359        {
    360360            KeySetOverlayKeyState(VK_MBUTTON, KEYOVERLAYSTATE_DOWN);
    361361            OSLibSendWinMessage(hwnd, WM_MBUTTONDOWN);
    362362        }
    363         if(p->dwFlags & MOUSEEVENTF_MIDDLEUP) 
     363        if(p->dwFlags & MOUSEEVENTF_MIDDLEUP)
    364364        {
    365365            KeySetOverlayKeyState(VK_MBUTTON, KEYOVERLAYSTATE_DONTCARE);
    366366            OSLibSendWinMessage(hwnd, WM_MBUTTONUP);
    367367        }
    368       } 
     368        if(p->dwFlags & MOUSEEVENTF_WHEEL)
     369        {
     370            OSLibSendWinMessage(hwnd, WM_MOUSEWHEEL, p->mouseData);
     371        }
     372      }
    369373      break;
    370      
     374
    371375      // compose a keyboard input message
    372376      case INPUT_KEYBOARD:
     
    380384        //      our existing code handle everything (WM_CHAR generation)
    381385        //      This is a quick and dirty implementation. Not entirely correct.
    382        
     386
    383387        // build keyboard message
    384388        msg.message = (p->dwFlags & KEYEVENTF_KEYUP) ? WM_KEYUP : WM_KEYDOWN;
    385        
     389
    386390        if (p->dwFlags & KEYEVENTF_SCANCODE)
    387391        {
     
    394398        else
    395399          msg.wParam = p->wVk;
    396        
     400
    397401        msg.lParam = 0x0000001 |                    // repeat count
    398402                      ( (p->wScan & 0xff) << 16);   // scan code
    399        
     403
    400404        if (p->dwFlags & KEYEVENTF_EXTENDEDKEY)
    401405          msg.lParam |= (1 << 24);
    402        
     406
    403407        // set additional message flags
    404408        if (msg.message == WM_KEYDOWN)
     
    414418          msg.lParam |= (1 << 31);
    415419        }
    416        
     420
    417421        msg.time   = p->time;
    418        
     422
    419423        // @@@PH
    420424        // unknown: do we have to post or to send the message?
     
    423427
    424428        KeySetOverlayKeyState(msg.wParam, (msg.message == WM_KEYDOWN) ? KEYOVERLAYSTATE_DOWN : KEYOVERLAYSTATE_DONTCARE);
    425        
     429
    426430        if (fUnicode)
    427431          SendMessageW(hwnd, msg.message, msg.wParam, msg.lParam);
     
    442446        SetMessageExtraInfo(extrainfo);
    443447        break;
    444       } 
    445      
     448      }
     449
    446450      case INPUT_HARDWARE:
    447451      {
    448452        PHARDWAREINPUT p = (PHARDWAREINPUT)&piBase->hi;
    449        
     453
    450454        // @@@PH
    451455        // not supported for the time being
    452       } 
     456      }
    453457      break;
    454      
     458
    455459      default:
    456460        dprintf(("unsupported input packet type %d",
     
    459463    }
    460464  }
    461  
     465
    462466  return 0;
    463467}
     
    490494    POINT pos; /* center of hover rectangle */
    491495    INT iHoverTime; /* elapsed time the cursor has been inside of the hover rect */
    492 } _TRACKINGLIST; 
    493 
    494 #define UINT_PTR        UINT 
     496} _TRACKINGLIST;
     497
     498#define UINT_PTR        UINT
    495499static _TRACKINGLIST TrackingList[10];
    496500static int iTrackMax = 0;
     
    529533        if(TrackingList[i].tme.dwFlags & TME_HOVER) {
    530534            /* add the timer interval to the hovering time */
    531             TrackingList[i].iHoverTime+=iTimerInterval; 
    532      
     535            TrackingList[i].iHoverTime+=iTimerInterval;
     536
    533537            /* has the cursor moved outside the rectangle centered around pos? */
    534538            if((abs(pos.x - TrackingList[i].pos.x) > (hoverwidth / 2.0))
     
    559563        }
    560564    }
    561        
     565
    562566    /* stop the timer if the tracking list is empty */
    563567    if(iTrackMax == 0) {
     
    611615
    612616    flags = ptme->dwFlags;
    613    
     617
    614618    /* if HOVER_DEFAULT was specified replace this with the systems current value */
    615619    if(ptme->dwHoverTime == HOVER_DEFAULT)
     
    617621
    618622    GetCursorPos(&pos);
    619     hwnd = WindowFromPoint(pos);   
     623    hwnd = WindowFromPoint(pos);
    620624
    621625    if ( flags & TME_CANCEL ) {
     
    623627        cancel = 1;
    624628    }
    625    
     629
    626630    if ( flags & TME_HOVER  ) {
    627631        flags &= ~ TME_HOVER;
    628632        hover = 1;
    629633    }
    630    
     634
    631635    if ( flags & TME_LEAVE ) {
    632636        flags &= ~ TME_LEAVE;
     
    650654        else
    651655            ptme->dwFlags = 0;
    652    
     656
    653657        return TRUE; /* return here, TME_QUERY is retrieving information */
    654658    }
     
    673677            {
    674678                TrackingList[i] = TrackingList[--iTrackMax];
    675        
     679
    676680                if(iTrackMax == 0) {
    677681                    KillTimer(0, timer);
     
    694698                        TrackingList[i].tme.dwHoverTime = ptme->dwHoverTime;
    695699                    }
    696  
     700
    697701                    if(leave)
    698702                        TrackingList[i].tme.dwFlags |= TME_LEAVE;
    699703
    700704                    /* reset iHoverTime as per winapi specs */
    701                     TrackingList[i].iHoverTime = 0;                 
    702  
     705                    TrackingList[i].iHoverTime = 0;
     706
    703707                    return TRUE;
    704708                }
    705             }           
     709            }
    706710
    707711            /* if the tracking list is full return FALSE */
Note: See TracChangeset for help on using the changeset viewer.