Changeset 97735 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Dec 2, 2022 8:39:26 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp
r97734 r97735 117 117 #define VBOX_XDND_VERSION (5) 118 118 119 /** No flags specified. */ 120 #define VBOX_XDND_STATUS_FLAG_NONE 0 119 121 /** Whether the target window accepts the data being dragged over or not. */ 120 #define VBOX_XDND_STATUS_FLAG_ACCEPT 0x1122 #define VBOX_XDND_STATUS_FLAG_ACCEPT RT_BIT(0) 121 123 /** Whether the target window wants XdndPosition messages while dragging stuff over it. */ 122 #define VBOX_XDND_STATUS_FLAG_WANTS_POS 0x2124 #define VBOX_XDND_STATUS_FLAG_WANTS_POS RT_BIT(1) 123 125 124 126 /** Whether the target window accepted the drop data or not. */ 125 #define VBOX_XDND_FINISHED_FLAG_SUCCEEDED 0x1127 #define VBOX_XDND_FINISHED_FLAG_SUCCEEDED RT_BIT(0) 126 128 127 129 /** How many X properties our proxy window can hold. */ … … 135 137 * into a single event queue. 136 138 */ 137 struct DnDEvent 139 typedef struct DNDEVENT 138 140 { 139 141 enum DnDEventType … … 158 160 RTMEM_IMPLEMENT_NEW_AND_DELETE(); 159 161 #endif 160 }; 162 } DNDEVENT; 163 /** Pointer to a DnD event. */ 164 typedef DNDEVENT *PDNDEVENT; 161 165 162 166 enum XA_Type … … 627 631 /** Current source/target window handle. */ 628 632 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; 631 636 /** List of (Atom) formats the current source/target window supports. */ 632 637 VBoxDnDAtomList m_lstAtomFormats; … … 686 691 Display *m_pDisplay; 687 692 /** Our (thread-safe) event queue with mixed events (DnD HGCM / X11). */ 688 RTCMTList<D nDEvent> m_eventQueue;693 RTCMTList<DNDEVENT> m_eventQueue; 689 694 /** Critical section for providing serialized access to list 690 695 * event queue's contents. */ … … 717 722 , m_wndRoot(0) 718 723 , m_wndCur(0) 719 , m_ curVer(-1)724 , m_uXdndVer(0) 720 725 , m_pvSelReqData(NULL) 721 726 , m_cbSelReqData(0) … … 801 806 /** @todo Support INC (incremental transfers). */ 802 807 803 m_wndCur 804 m_ curVer = -1;805 m_enmState 806 m_enmMode 808 m_wndCur = 0; 809 m_uXdndVer = 0; 810 m_enmState = Initialized; 811 m_enmMode = Unknown; 807 812 m_eventQueueList.clear(); 808 813 m_cFailedPendingAttempts = 0; … … 1005 1010 1006 1011 /* 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); 1008 1013 /* 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); 1011 1015 1012 1016 /* … … 1055 1059 AssertPtrBreakStmt(pszWndTgtName, VERR_NO_MEMORY); 1056 1060 1057 if (m_ curVer >= 5)1061 if (m_uXdndVer >= 5) 1058 1062 { 1059 1063 const bool fSucceeded = e.xclient.data.l[XdndFinishedFlags] & VBOX_XDND_FINISHED_FLAG_SUCCEEDED; … … 1106 1110 if (RT_SUCCESS(rc)) 1107 1111 { 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); 1111 1115 #ifdef DEBUG 1112 1116 XWindowAttributes xwa; … … 1146 1150 * Retrieve supported actions. 1147 1151 */ 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. */ 1149 1153 { 1150 1154 rc = wndXDnDGetActionList(wndSel, m_lstAtomActions); … … 1181 1185 1182 1186 m_wndCur = wndSel; 1183 m_ curVer = xdndVer;1187 m_uXdndVer = uXdndVer; 1184 1188 m_enmMode = GH; 1185 1189 m_enmState = Dragging; … … 1200 1204 #ifdef LOG_ENABLED 1201 1205 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. */ 1203 1207 ? e.xclient.data.l[XdndPositionAction] : xAtom(XA_XdndActionCopy); 1204 1208 LogFlowThisFunc(("XA_XdndPosition: wndProxy=%#x, wndCur=%#x, x=%RI32, y=%RI32, strAction=%s\n", … … 1218 1222 m.format = 32; 1219 1223 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. */ 1221 1225 1222 1226 /* We don't want any new XA_XdndPosition messages while being … … 1617 1621 1618 1622 bool fFound = false; 1619 const uint64_t uiStart= RTTimeMilliTS();1623 uint64_t const tsStartMs = RTTimeMilliTS(); 1620 1624 1621 1625 do … … 1655 1659 } 1656 1660 } 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)); 1660 1664 return fFound; 1661 1665 } … … 1856 1860 AssertPtrReturn(pszWndBelowCursorName, VERR_NO_MEMORY); 1857 1861 1858 long newVer = -1; /* Thismeans the current window is _not_ XdndAware. */1862 uint8_t uBelowCursorXdndVer = 0; /* 0 means the current window is _not_ XdndAware. */ 1859 1863 1860 1864 if (wndBelowCursor != None) … … 1886 1890 { 1887 1891 /* Get the current window's Xdnd version. */ 1888 newVer =reinterpret_cast<long *>(pcData)[0];1892 uBelowCursorXdndVer = (uint8_t)reinterpret_cast<long *>(pcData)[0]; 1889 1893 } 1890 1894 … … 1896 1900 AssertPtrReturn(pszWndCurName, VERR_NO_MEMORY); 1897 1901 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)); 1900 1904 1901 1905 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); 1905 1909 1906 1910 /* We left the current XdndAware window. Announce this to the current indow. */ … … 1919 1923 1920 1924 /* Reset our current window. */ 1921 m_wndCur = 0;1922 m_ curVer = -1;1925 m_wndCur = 0; 1926 m_uXdndVer = 0; 1923 1927 } 1924 1928 … … 1927 1931 */ 1928 1932 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); 1932 1937 1933 1938 /* … … 1951 1956 0, 0, 1952 1957 /* Protocol version to use. */ 1953 RT_MIN(VBOX_XDND_VERSION, newVer));1958 RT_MIN(VBOX_XDND_VERSION, uBelowCursorXdndVer)); 1954 1959 m.data.l[XdndEnterType1] = m_lstAtomFormats.value(0, None); /* First data type to use. */ 1955 1960 m.data.l[XdndEnterType2] = m_lstAtomFormats.value(1, None); /* Second data type to use. */ … … 1961 1966 } 1962 1967 1963 if ( newVer != -1)1968 if (uBelowCursorXdndVer) 1964 1969 { 1965 1970 Assert(wndBelowCursor != None); … … 1992 1997 } 1993 1998 1994 if ( newVer == -1)1999 if (uBelowCursorXdndVer == 0) 1995 2000 { 1996 2001 /* No window to process, so send a ignore ack event to the host. */ … … 2001 2006 Assert(wndBelowCursor != None); 2002 2007 2003 m_wndCur = wndBelowCursor;2004 m_ curVer = newVer;2008 m_wndCur = wndBelowCursor; 2009 m_uXdndVer = uBelowCursorXdndVer; 2005 2010 } 2006 2011 … … 2417 2422 2418 2423 Time tsDrop; 2419 if (m_ curVer >= 1)2424 if (m_uXdndVer >= 1) 2420 2425 tsDrop = evDnDDrop.data.l[XdndDropTimeStamp]; 2421 2426 else … … 3284 3289 do 3285 3290 { 3286 D nDEvente;3291 DNDEVENT e; 3287 3292 RT_ZERO(e); 3288 3293 … … 3297 3302 m_eventQueue.removeFirst(); 3298 3303 3299 if (e.enmType == D nDEvent::DnDEventType_HGCM)3304 if (e.enmType == DNDEVENT::DnDEventType_HGCM) 3300 3305 { 3301 3306 PVBGLR3DNDEVENT pVbglR3Event = e.hgcm; … … 3420 3425 break; 3421 3426 } 3422 else if (e.enmType == D nDEvent::DnDEventType_X11)3427 else if (e.enmType == DNDEVENT::DnDEventType_X11) 3423 3428 { 3424 3429 m_pCurDnD->onX11Event(e.x11); … … 3551 3556 /* Number of invalid messages skipped in a row. */ 3552 3557 int cMsgSkippedInvalid = 0; 3553 D nDEvente;3558 DNDEVENT e; 3554 3559 3555 3560 do 3556 3561 { 3557 3562 RT_ZERO(e); 3558 e.enmType = D nDEvent::DnDEventType_HGCM;3563 e.enmType = DNDEVENT::DnDEventType_HGCM; 3559 3564 3560 3565 /* Wait for new events. */ … … 3617 3622 VBClLogVerbose(2, "X11 thread started\n"); 3618 3623 3619 D nDEvente;3624 DNDEVENT e; 3620 3625 do 3621 3626 { … … 3630 3635 { 3631 3636 RT_ZERO(e); 3632 e.enmType = D nDEvent::DnDEventType_X11;3637 e.enmType = DNDEVENT::DnDEventType_X11; 3633 3638 3634 3639 /* XNextEvent will block until a new X event becomes available. */
Note:
See TracChangeset
for help on using the changeset viewer.