VirtualBox

Changeset 21888 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Jul 30, 2009 1:51:20 PM (15 years ago)
Author:
vboxsync
Message:

Additions/WINNT: fix problems of the mouse cursor not being shown when mouse integration is enabled or disabled

Location:
trunk/src/VBox/Additions/WINNT
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest.cpp

    r21703 r21888  
    7777#endif
    7878
     79#ifdef DEBUG
     80static VOID testVBoxGuest(VOID);
     81#endif
     82
    7983/*******************************************************************************
    8084*   Exported Functions                                                         *
     
    123127    PsGetVersion(&majorVersion, &minorVersion, &buildNumber, NULL);
    124128    dprintf(("VBoxGuest::DriverEntry: running on Windows NT version %d.%d, build %d\n", majorVersion, minorVersion, buildNumber));
     129#ifdef DEBUG
     130    testVBoxGuest();
     131#endif
    125132    switch (majorVersion)
    126133    {
     
    783790}
    784791
     792/** A quick implementation of AtomicTestAndClear for uint32_t and multiple
     793 *  bits.
     794 */
     795static uint32_t guestAtomicBitsTestAndClear(void *pu32Bits, uint32_t u32Mask)
     796{
     797    AssertPtrReturn(pu32Bits, 0);
     798    LogFlowFunc(("*pu32Bits=0x%x, u32Mask=0x%x\n", *(long *)pu32Bits,
     799                 u32Mask));
     800    uint32_t u32Result = 0;
     801    uint32_t u32WorkingMask = u32Mask;
     802    int iBitOffset = ASMBitFirstSetU32 (u32WorkingMask);
     803
     804    while (iBitOffset > 0)
     805    {
     806        bool fSet = ASMAtomicBitTestAndClear(pu32Bits, iBitOffset - 1);
     807        if (fSet)
     808            u32Result |= 1 << (iBitOffset - 1);
     809        u32WorkingMask &= ~(1 << (iBitOffset - 1));
     810        iBitOffset = ASMBitFirstSetU32 (u32WorkingMask);
     811    }
     812    LogFlowFunc(("Returning 0x%x\n", u32Result));
     813    return u32Result;
     814}
     815
    785816/**
    786817 * Device I/O Control entry point.
     
    850881            VBoxGuestWaitEventInfo *eventInfo = (VBoxGuestWaitEventInfo *)pBuf;
    851882
    852             if (!eventInfo->u32EventMaskIn || !IsPowerOfTwo (eventInfo->u32EventMaskIn)) {
     883            if (!eventInfo->u32EventMaskIn) {
    853884                dprintf (("VBoxGuest::VBoxGuestDeviceControl: Invalid input mask %#x\n",
    854885                          eventInfo->u32EventMaskIn));
     
    858889
    859890            eventInfo->u32EventFlagsOut = 0;
    860             int iBitOffset = ASMBitFirstSetU32 (eventInfo->u32EventMaskIn) - 1;
    861891            bool fTimeout = (eventInfo->u32TimeoutIn != ~0L);
    862 
    863             dprintf (("mask = %d, iBitOffset = %d\n", iBitOffset, eventInfo->u32EventMaskIn));
    864892
    865893            /* Possible problem with request completion right between the pending event check and KeWaitForSingleObject
     
    874902            for (;;)
    875903            {
    876                 bool fEventPending = ASMAtomicBitTestAndClear(&pDevExt->u32Events, iBitOffset);
    877                 if (fEventPending)
     904                uint32_t u32EventsPending =
     905                    guestAtomicBitsTestAndClear(&pDevExt->u32Events,
     906                                                eventInfo->u32EventMaskIn);
     907                dprintf (("mask = 0x%x, pending = 0x%x\n",
     908                          eventInfo->u32EventMaskIn, u32EventsPending));
     909
     910                if (u32EventsPending)
    878911                {
    879                     eventInfo->u32EventFlagsOut = 1 << iBitOffset;
     912                    eventInfo->u32EventFlagsOut = u32EventsPending;
    880913                    break;
    881914                }
     
    18821915    dprintf(("VBoxGuest::vboxIdleThread leaving\n"));
    18831916}
     1917
     1918#ifdef DEBUG
     1919static VOID testAtomicTestAndClearBitsU32(uint32_t u32Mask, uint32_t u32Bits,
     1920                                          uint32_t u32Exp)
     1921{
     1922    ULONG u32Bits2 = u32Bits;
     1923    uint32_t u32Result = guestAtomicBitsTestAndClear(&u32Bits2, u32Mask);
     1924    if (   u32Result != u32Exp
     1925        || (u32Bits2 & u32Mask)
     1926        || (u32Bits2 & u32Result)
     1927        || ((u32Bits2 | u32Result) != u32Bits)
     1928       )
     1929        AssertLogRelMsgFailed(("%s: TEST FAILED: u32Mask=0x%x, u32Bits (before)=0x%x, u32Bits (after)=0x%x, u32Result=0x%x, u32Exp=ox%x\n",
     1930                               __PRETTY_FUNCTION__, u32Mask, u32Bits, u32Bits2,
     1931                               u32Result));
     1932}
     1933
     1934static VOID testVBoxGuest(VOID)
     1935{
     1936    testAtomicTestAndClearBitsU32(0x00, 0x23, 0);
     1937    testAtomicTestAndClearBitsU32(0x11, 0, 0);
     1938    testAtomicTestAndClearBitsU32(0x11, 0x22, 0);
     1939    testAtomicTestAndClearBitsU32(0x11, 0x23, 0x1);
     1940    testAtomicTestAndClearBitsU32(0x11, 0x32, 0x10);
     1941    testAtomicTestAndClearBitsU32(0x22, 0x23, 0x22);
     1942}
     1943#endif
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDisplay.cpp

    r21219 r21888  
    386386    DWORD cbReturned;
    387387
    388     maskInfo.u32OrMask = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
     388    maskInfo.u32OrMask = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED;
    389389    maskInfo.u32NotMask = 0;
    390390    if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
     
    403403        VBoxGuestWaitEventInfo waitEvent;
    404404        waitEvent.u32TimeoutIn = 1000;
    405         waitEvent.u32EventMaskIn = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
     405        waitEvent.u32EventMaskIn = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED;
    406406        if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent), &waitEvent, sizeof(waitEvent), &cbReturned, NULL))
    407407        {
     
    591591                }
    592592            }
     593            if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED)
     594                VBoxServiceReloadCursor();
    593595        } else
    594596        {
     
    604606
    605607    maskInfo.u32OrMask = 0;
    606     maskInfo.u32NotMask = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
     608    maskInfo.u32NotMask = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED;
    607609    if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
    608610    {
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp

    r18265 r21888  
    215215
    216216
     217/** Attempt to force Windows to reload the cursor image by attaching to the
     218 * thread of the window currently under the mouse, hiding the cursor and
     219 * showing it again.  This could fail to work in any number of ways (no
     220 * window under the cursor, the cursor has moved to a different window while
     221 * we are processing), but we just accept this, as the cursor will be reloaded
     222 * at some point anyway. */
     223void VBoxServiceReloadCursor(void)
     224{
     225    LogFlowFunc(("\n"));
     226    POINT mousePos;
     227    HWND hWin;
     228    DWORD hThread, hCurrentThread;
     229   
     230    GetCursorPos(&mousePos);
     231    hWin = WindowFromPoint(mousePos);
     232    if (hWin)
     233    {
     234        hThread = GetWindowThreadProcessId(hWin, NULL);
     235        hCurrentThread = GetCurrentThreadId();
     236        if (hCurrentThread != hThread)
     237            AttachThreadInput(hCurrentThread, hThread, TRUE);
     238    }
     239    ShowCursor(false);
     240    ShowCursor(true);
     241    if (hWin && (hCurrentThread != hThread))
     242        AttachThreadInput(hCurrentThread, hThread, FALSE);
     243    LogFlowFunc(("exiting\n"));
     244}
     245
     246
    217247void WINAPI VBoxServiceStart(void)
    218248{
     
    264294            status = GetLastError();
    265295        else
    266         {
    267             /* move the window beneach the mouse pointer so that we get access to it */
    268             POINT mousePos;
    269             GetCursorPos(&mousePos);
    270             SetWindowPos(gToolWindow, HWND_TOPMOST, mousePos.x - 10, mousePos.y - 10, 0, 0,
    271                          SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOSIZE);
    272             /* change the mouse pointer so that we can go for a hardware shape */
    273             SetCursor(LoadCursor(NULL, IDC_APPSTARTING));
    274             SetCursor(LoadCursor(NULL, IDC_ARROW));
    275             /* move back our tool window */
    276             SetWindowPos(gToolWindow, HWND_TOPMOST, -200, -200, 0, 0,
    277                          SWP_NOACTIVATE | SWP_HIDEWINDOW | SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_NOSIZE);
    278         }
     296            VBoxServiceReloadCursor();
    279297    }
    280298
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.h

    r21229 r21888  
    6767extern HWND  gToolWindow;
    6868
     69extern void VBoxServiceReloadCursor(void);
     70
    6971#endif /* !___VBOXTRAY_H */
    7072
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette