VirtualBox

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


Ignore:
Timestamp:
Dec 2, 2022 8:39:26 PM (2 years ago)
Author:
vboxsync
Message:

DnD/VBoxClient: Use RT_BIT macros for the Xdnd flags, renamed DnDEvent -> DNDEVENT to emphasize that it's a POD type + some more renaming.

File:
1 edited

Legend:

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

    r97734 r97735  
    117117#define VBOX_XDND_VERSION                       (5)
    118118
     119/** No flags specified. */
     120#define VBOX_XDND_STATUS_FLAG_NONE              0
    119121/** Whether the target window accepts the data being dragged over or not. */
    120 #define VBOX_XDND_STATUS_FLAG_ACCEPT            0x1
     122#define VBOX_XDND_STATUS_FLAG_ACCEPT            RT_BIT(0)
    121123/** Whether the target window wants XdndPosition messages while dragging stuff over it. */
    122 #define VBOX_XDND_STATUS_FLAG_WANTS_POS         0x2
     124#define VBOX_XDND_STATUS_FLAG_WANTS_POS         RT_BIT(1)
    123125
    124126/** Whether the target window accepted the drop data or not. */
    125 #define VBOX_XDND_FINISHED_FLAG_SUCCEEDED       0x1
     127#define VBOX_XDND_FINISHED_FLAG_SUCCEEDED       RT_BIT(0)
    126128
    127129/** How many X properties our proxy window can hold. */
     
    135137 * into a single event queue.
    136138 */
    137 struct DnDEvent
     139typedef struct DNDEVENT
    138140{
    139141    enum DnDEventType
     
    158160    RTMEM_IMPLEMENT_NEW_AND_DELETE();
    159161#endif
    160 };
     162} DNDEVENT;
     163/** Pointer to a DnD event. */
     164typedef DNDEVENT *PDNDEVENT;
    161165
    162166enum XA_Type
     
    627631    /** Current source/target window handle. */
    628632    Window                      m_wndCur;
    629     /** The XDnD protocol version the current source/target window is using. */
    630     long                        m_curVer;
     633    /** The XDnD protocol version the current source/target window is using.
     634     *  Set to 0 if not available / not set yet. */
     635    uint8_t                     m_uXdndVer;
    631636    /** List of (Atom) formats the current source/target window supports. */
    632637    VBoxDnDAtomList             m_lstAtomFormats;
     
    686691    Display             *m_pDisplay;
    687692    /** Our (thread-safe) event queue with mixed events (DnD HGCM / X11). */
    688     RTCMTList<DnDEvent>  m_eventQueue;
     693    RTCMTList<DNDEVENT>  m_eventQueue;
    689694    /** Critical section for providing serialized access to list
    690695     *  event queue's contents. */
     
    717722    , m_wndRoot(0)
    718723    , m_wndCur(0)
    719     , m_curVer(-1)
     724    , m_uXdndVer(0)
    720725    , m_pvSelReqData(NULL)
    721726    , m_cbSelReqData(0)
     
    801806        /** @todo Support INC (incremental transfers). */
    802807
    803         m_wndCur    = 0;
    804         m_curVer    = -1;
    805         m_enmState  = Initialized;
    806         m_enmMode   = Unknown;
     808        m_wndCur   = 0;
     809        m_uXdndVer = 0;
     810        m_enmState = Initialized;
     811        m_enmMode  = Unknown;
    807812        m_eventQueueList.clear();
    808813        m_cFailedPendingAttempts = 0;
     
    10051010
    10061011                /* Does the target accept the drop? */
    1007                 const bool fAcceptDrop    = e.xclient.data.l[XdndStatusFlags] & VBOX_XDND_STATUS_FLAG_ACCEPT;
     1012                bool const fAcceptDrop    = RT_BOOL(e.xclient.data.l[XdndStatusFlags] & VBOX_XDND_STATUS_FLAG_ACCEPT);
    10081013                /* Does the target want XdndPosition messages? */
    1009                 const bool fWantsPosition = e.xclient.data.l[XdndStatusFlags] & VBOX_XDND_STATUS_FLAG_WANTS_POS;
    1010                 RT_NOREF(fWantsPosition);
     1014                bool const fWantsPosition = RT_BOOL(e.xclient.data.l[XdndStatusFlags] & VBOX_XDND_STATUS_FLAG_WANTS_POS);
    10111015
    10121016                /*
     
    10551059                AssertPtrBreakStmt(pszWndTgtName, VERR_NO_MEMORY);
    10561060
    1057                 if (m_curVer >= 5)
     1061                if (m_uXdndVer >= 5)
    10581062                {
    10591063                    const bool  fSucceeded = e.xclient.data.l[XdndFinishedFlags] & VBOX_XDND_FINISHED_FLAG_SUCCEEDED;
     
    11061110                if (RT_SUCCESS(rc))
    11071111                {
    1108                     long const xdndVer = e.xclient.data.l[XdndEnterFlags] >> XdndEnterVersionRShift;
    1109 
    1110                     VBClLogInfo("Entered new source window %#x ('%s'), supports Xdnd version %ld\n", wndSel, pszWndSelName, xdndVer);
     1112                    uint8_t const uXdndVer = (uint8_t)e.xclient.data.l[XdndEnterFlags] >> XdndEnterVersionRShift;
     1113
     1114                    VBClLogInfo("Entered new source window %#x ('%s'), supports Xdnd version %u\n", wndSel, pszWndSelName, uXdndVer);
    11111115#ifdef DEBUG
    11121116                    XWindowAttributes xwa;
     
    11461150                     * Retrieve supported actions.
    11471151                     */
    1148                     if (xdndVer >= 2) /* More than one action allowed since protocol version 2. */
     1152                    if (uXdndVer >= 2) /* More than one action allowed since protocol version 2. */
    11491153                    {
    11501154                        rc = wndXDnDGetActionList(wndSel, m_lstAtomActions);
     
    11811185
    11821186                    m_wndCur   = wndSel;
    1183                     m_curVer   = xdndVer;
     1187                    m_uXdndVer = uXdndVer;
    11841188                    m_enmMode  = GH;
    11851189                    m_enmState = Dragging;
     
    12001204#ifdef LOG_ENABLED
    12011205                int32_t iPos      = e.xclient.data.l[XdndPositionXY];
    1202                 Atom    atmAction = m_curVer >= 2 /* Actions other than "copy" or only supported since protocol version 2. */
     1206                Atom    atmAction = m_uXdndVer >= 2 /* Actions other than "copy" or only supported since protocol version 2. */
    12031207                                  ? e.xclient.data.l[XdndPositionAction] : xAtom(XA_XdndActionCopy);
    12041208                LogFlowThisFunc(("XA_XdndPosition: wndProxy=%#x, wndCur=%#x, x=%RI32, y=%RI32, strAction=%s\n",
     
    12181222                m.format       = 32;
    12191223                m.data.l[XdndStatusWindow]  = m_wndProxy.hWnd;
    1220                 m.data.l[XdndStatusFlags]   = fAcceptDrop ? RT_BIT(0) : 0; /* Whether to accept the drop or not. */
     1224                m.data.l[XdndStatusFlags]   = fAcceptDrop ? VBOX_XDND_STATUS_FLAG_ACCEPT : VBOX_XDND_STATUS_FLAG_NONE; /* Whether to accept the drop or not. */
    12211225
    12221226                /* We don't want any new XA_XdndPosition messages while being
     
    16171621
    16181622    bool fFound = false;
    1619     const uint64_t uiStart = RTTimeMilliTS();
     1623    uint64_t const tsStartMs = RTTimeMilliTS();
    16201624
    16211625    do
     
    16551659        }
    16561660    }
    1657     while (RTTimeMilliTS() - uiStart < uTimeoutMS);
    1658 
    1659     LogFlowThisFunc(("Returning fFound=%RTbool, msRuntime=%RU64\n", fFound, RTTimeMilliTS() - uiStart));
     1661    while (RTTimeMilliTS() - tsStartMs < uTimeoutMS);
     1662
     1663    LogFlowThisFunc(("Returning fFound=%RTbool, msRuntime=%RU64\n", fFound, RTTimeMilliTS() - tsStartMs));
    16601664    return fFound;
    16611665}
     
    18561860    AssertPtrReturn(pszWndBelowCursorName, VERR_NO_MEMORY);
    18571861
    1858     long newVer = -1; /* This means the current window is _not_ XdndAware. */
     1862    uint8_t uBelowCursorXdndVer = 0; /* 0 means the current window is _not_ XdndAware. */
    18591863
    18601864    if (wndBelowCursor != None)
     
    18861890            {
    18871891                /* Get the current window's Xdnd version. */
    1888                 newVer = reinterpret_cast<long *>(pcData)[0];
     1892                uBelowCursorXdndVer = (uint8_t)reinterpret_cast<long *>(pcData)[0];
    18891893            }
    18901894
     
    18961900    AssertPtrReturn(pszWndCurName, VERR_NO_MEMORY);
    18971901
    1898     LogFlowThisFunc(("wndCursor=%x ('%s', Xdnd version %ld), wndCur=%x ('%s', Xdnd version %ld)\n",
    1899                      wndBelowCursor, pszWndBelowCursorName, newVer, m_wndCur, pszWndCurName, m_curVer));
     1902    LogFlowThisFunc(("wndCursor=%x ('%s', Xdnd version %u), wndCur=%x ('%s', Xdnd version %u)\n",
     1903                     wndBelowCursor, pszWndBelowCursorName, uBelowCursorXdndVer, m_wndCur, pszWndCurName, m_uXdndVer));
    19001904
    19011905    if (   wndBelowCursor != m_wndCur
    1902         && m_curVer       != -1)
    1903     {
    1904         VBClLogInfo("Left old window %#x ('%s'), supported Xdnd version %ld\n", m_wndCur, pszWndCurName, m_curVer);
     1906        && m_uXdndVer)
     1907    {
     1908        VBClLogInfo("Left old window %#x ('%s'), supported Xdnd version %u\n", m_wndCur, pszWndCurName, m_uXdndVer);
    19051909
    19061910        /* We left the current XdndAware window. Announce this to the current indow. */
     
    19191923
    19201924        /* Reset our current window. */
    1921         m_wndCur = 0;
    1922         m_curVer = -1;
     1925        m_wndCur   = 0;
     1926        m_uXdndVer = 0;
    19231927    }
    19241928
     
    19271931     */
    19281932    if (   wndBelowCursor != m_wndCur
    1929         && newVer         != -1)
    1930     {
    1931         VBClLogInfo("Entered new window %#x ('%s'), supports Xdnd version=%ld\n", wndBelowCursor, pszWndBelowCursorName, newVer);
     1933        && uBelowCursorXdndVer)
     1934    {
     1935        VBClLogInfo("Entered new window %#x ('%s'), supports Xdnd version=%u\n",
     1936                    wndBelowCursor, pszWndBelowCursorName, uBelowCursorXdndVer);
    19321937
    19331938        /*
     
    19511956                                    0, 0,
    19521957                                    /* Protocol version to use. */
    1953                                     RT_MIN(VBOX_XDND_VERSION, newVer));
     1958                                    RT_MIN(VBOX_XDND_VERSION, uBelowCursorXdndVer));
    19541959        m.data.l[XdndEnterType1]  = m_lstAtomFormats.value(0, None); /* First data type to use. */
    19551960        m.data.l[XdndEnterType2]  = m_lstAtomFormats.value(1, None); /* Second data type to use. */
     
    19611966    }
    19621967
    1963     if (newVer != -1)
     1968    if (uBelowCursorXdndVer)
    19641969    {
    19651970        Assert(wndBelowCursor != None);
     
    19921997    }
    19931998
    1994     if (newVer == -1)
     1999    if (uBelowCursorXdndVer == 0)
    19952000    {
    19962001        /* No window to process, so send a ignore ack event to the host. */
     
    20012006        Assert(wndBelowCursor != None);
    20022007
    2003         m_wndCur = wndBelowCursor;
    2004         m_curVer = newVer;
     2008        m_wndCur   = wndBelowCursor;
     2009        m_uXdndVer = uBelowCursorXdndVer;
    20052010    }
    20062011
     
    24172422
    24182423        Time tsDrop;
    2419         if (m_curVer >= 1)
     2424        if (m_uXdndVer >= 1)
    24202425            tsDrop = evDnDDrop.data.l[XdndDropTimeStamp];
    24212426        else
     
    32843289        do
    32853290        {
    3286             DnDEvent e;
     3291            DNDEVENT e;
    32873292            RT_ZERO(e);
    32883293
     
    32973302            m_eventQueue.removeFirst();
    32983303
    3299             if (e.enmType == DnDEvent::DnDEventType_HGCM)
     3304            if (e.enmType == DNDEVENT::DnDEventType_HGCM)
    33003305            {
    33013306                PVBGLR3DNDEVENT pVbglR3Event = e.hgcm;
     
    34203425                    break;
    34213426            }
    3422             else if (e.enmType == DnDEvent::DnDEventType_X11)
     3427            else if (e.enmType == DNDEVENT::DnDEventType_X11)
    34233428            {
    34243429                m_pCurDnD->onX11Event(e.x11);
     
    35513556    /* Number of invalid messages skipped in a row. */
    35523557    int cMsgSkippedInvalid = 0;
    3553     DnDEvent e;
     3558    DNDEVENT e;
    35543559
    35553560    do
    35563561    {
    35573562        RT_ZERO(e);
    3558         e.enmType = DnDEvent::DnDEventType_HGCM;
     3563        e.enmType = DNDEVENT::DnDEventType_HGCM;
    35593564
    35603565        /* Wait for new events. */
     
    36173622    VBClLogVerbose(2, "X11 thread started\n");
    36183623
    3619     DnDEvent e;
     3624    DNDEVENT e;
    36203625    do
    36213626    {
     
    36303635        {
    36313636            RT_ZERO(e);
    3632             e.enmType = DnDEvent::DnDEventType_X11;
     3637            e.enmType = DNDEVENT::DnDEventType_X11;
    36333638
    36343639            /* XNextEvent will block until a new X event becomes available. */
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