VirtualBox

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


Ignore:
Timestamp:
Jul 31, 2009 8:01:47 PM (15 years ago)
Author:
vboxsync
Message:

Additions/x11: made VBoxClient responsible for switching between software and hardware cursors and removed a hack from vboxvideo

Location:
trunk/src/VBox/Additions/x11
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/display.cpp

    r21922 r21923  
    2828
    2929#include <X11/Xlib.h>
     30#include <X11/cursorfont.h>
    3031
    3132#include <iprt/assert.h>
     
    4243    int rc = VINF_SUCCESS;
    4344    int rcSystem, rcErrno;
     45    uint32_t fMouseFeatures = 0;
    4446
    4547    LogFlowFunc(("\n"));
     
    5658    }
    5759    if (RT_SUCCESS(rc))
    58         rc = VbglR3CtlFilterMask(  VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST
    59                                  | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED, 0);
     60        rc = VbglR3CtlFilterMask(VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, 0);
     61    /* Enable support for switching between hardware and software cursors */
     62    rc = VbglR3CtlFilterMask(VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED, 0);
     63    if (RT_SUCCESS(rc))
     64    {
     65        rc = VbglR3GetMouseStatus(&fMouseFeatures, NULL, NULL);
     66        if (RT_SUCCESS(rc))
     67            VbglR3SetMouseStatus(  fMouseFeatures
     68                                 & ~VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR);
     69    }
    6070    LogFlowFunc(("returning %Rrc\n", rc));
    6171    return rc;
     
    6474void cleanupDisplay(void)
    6575{
     76    uint32_t fMouseFeatures = 0;
    6677    LogFlowFunc(("\n"));
    6778    VbglR3CtlFilterMask(0,   VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST
    6879                           | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED);
     80    int rc = VbglR3GetMouseStatus(&fMouseFeatures, NULL, NULL);
     81    if (RT_SUCCESS(rc))
     82        VbglR3SetMouseStatus(  fMouseFeatures
     83                             | VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR);
    6984    LogFlowFunc(("returning\n"));
    7085}
     
    91106    LogFlowFunc(("\n"));
    92107    uint32_t cx0 = 0, cy0 = 0, cBits0 = 0, iDisplay0 = 0;
     108    Display *pDisplay = XOpenDisplay(NULL);
     109    if (pDisplay == NULL)
     110        return VERR_NOT_FOUND;
     111    Cursor hClockCursor = XCreateFontCursor(pDisplay, XC_watch);
     112    Cursor hArrowCursor = XCreateFontCursor(pDisplay, XC_left_ptr);
    93113    int rc = RTThreadCreate(NULL, x11ConnectionMonitor, NULL, 0,
    94114                   RTTHREADTYPE_INFREQUENT_POLLER, 0, "X11 monitor");
     
    99119    {
    100120        uint32_t fEvents = 0, cx = 0, cy = 0, cBits = 0, iDisplay = 0;
    101         rc = VbglR3WaitEvent(VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST,
     121        rc = VbglR3WaitEvent(  VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST
     122                             | VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED,
    102123                             RT_INDEFINITE_WAIT, &fEvents);
    103124        if (RT_SUCCESS(rc) && (fEvents & VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST))
    104125        {
    105             rc = VbglR3GetDisplayChangeRequest(&cx, &cy, &cBits, &iDisplay,
    106                                                true);
     126            int rc2 = VbglR3GetDisplayChangeRequest(&cx, &cy, &cBits,
     127                                                    &iDisplay, true);
    107128            /* Ignore the request if it is stale */
    108             if ((cx != cx0) || (cy != cy0) || RT_FAILURE(rc))
     129            if ((cx != cx0) || (cy != cy0) || RT_FAILURE(rc2))
    109130            {
    110131                    /* If we are not stopping, sleep for a bit to avoid using up
    111132                        too much CPU while retrying. */
    112                     if (RT_FAILURE(rc))
     133                    if (RT_FAILURE(rc2))
    113134                        RTThreadYield();
    114135                    else
     
    119140                    }
    120141            }
     142        }
     143        if (   RT_SUCCESS(rc)
     144            && (fEvents & VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED))
     145        {
     146            XGrabPointer(pDisplay,
     147                         DefaultRootWindow(pDisplay), true, 0, GrabModeAsync,
     148                         GrabModeAsync, None, hClockCursor, CurrentTime);
     149            XFlush(pDisplay);
     150            XGrabPointer(pDisplay,
     151                         DefaultRootWindow(pDisplay), true, 0, GrabModeAsync,
     152                         GrabModeAsync, None, hArrowCursor, CurrentTime);
     153            XFlush(pDisplay);
     154            XUngrabPointer(pDisplay, CurrentTime);
     155            XFlush(pDisplay);
    121156        }
    122157    }
  • trunk/src/VBox/Additions/x11/vboxvideo/vboxutils.c

    r21912 r21923  
    399399    Bool rc = TRUE;
    400400    int vrc;
     401    uint32_t fMouseFeatures = 0;
    401402
    402403    TRACE_ENTRY();
     
    411412    }
    412413    pVBox->useDevice = rc;
     414    /* We can't switch to a software cursor at will without help from
     415     * VBoxClient.  So tell that to the host and wait for VBoxClient to
     416     * change this. */
     417    vrc = VbglR3GetMouseStatus(&fMouseFeatures, NULL, NULL);
     418    if (RT_SUCCESS(vrc))
     419        VbglR3SetMouseStatus(  fMouseFeatures
     420                             | VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR);
    413421    return rc;
    414422}
     
    531539}
    532540
    533 /**
    534  * This function is called to set the position of the hardware cursor.
    535  * Since we already know the position (exactly where the host pointer is),
    536  * we only use this function to poll for whether we need to switch from a
    537  * hardware to a software cursor (that is, whether the user has disabled
    538  * pointer integration).  Sadly this doesn't work the other way round,
    539  * as the server updates the software cursor itself without notifying us.
    540  */
     541
    541542static void
    542543vbox_set_cursor_position(ScrnInfoPtr pScrn, int x, int y)
    543544{
    544     VBOXPtr pVBox = pScrn->driverPrivate;
    545 
    546     if (pVBox->accessEnabled && !vbox_host_uses_hwcursor(pScrn))
    547     {
    548         /* This triggers a cursor image reload, and before reloading, the X
    549          * server will check whether we can "handle" the new cursor "in
    550          * hardware".  We can use this check to force a switch to a software
    551          * cursor if we need to do so. */
    552         pScrn->EnableDisableFBAccess(pScrn->scrnIndex, FALSE);
    553         pScrn->EnableDisableFBAccess(pScrn->scrnIndex, TRUE);
    554     }
     545    /* Nothing to do here, as we are telling the guest where the mouse is,
     546     * not vice versa. */
     547    NOREF(pScrn);
     548    NOREF(x);
     549    NOREF(y);
    555550}
    556551
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