VirtualBox

Changeset 50593 in vbox for trunk/src/VBox/Additions/x11


Ignore:
Timestamp:
Feb 26, 2014 8:44:58 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
92464
Message:

DnD: Bugfixes for Linux hosts.

File:
1 edited

Legend:

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

    r50561 r50593  
    10341034}
    10351035
    1036 
    10371036#ifdef VBOX_WITH_DRAG_AND_DROP_GH
    1038 /*
    1039  * Guest -> Host
    1040  */
    1041 
    10421037int DragInstance::ghIsDnDPending(void)
    10431038{
     
    10841079                else
    10851080                {
    1086                     xrc = XGetWindowProperty(m_pDisplay, wndOwner, xAtom(XA_XdndTypeList), 0, VBOX_MAX_XPROPERTIES, False, XA_ATOM, &type, &f, &n, &a, &ret);
     1081                    xrc = XGetWindowProperty(m_pDisplay, wndOwner,
     1082                                             xAtom(XA_XdndTypeList),
     1083                                             0, VBOX_MAX_XPROPERTIES,
     1084                                             False, XA_ATOM, &type, &f, &n, &a, &ret);
    10871085                    if (   xrc == Success
    10881086                        && n > 0
     
    10981096                    }
    10991097                }
     1098
    11001099                /* Fetch the possible list of actions, if this property is set. */
    1101                 xrc = XGetWindowProperty(m_pDisplay, wndOwner, xAtom(XA_XdndActionList), 0, VBOX_MAX_XPROPERTIES, False, XA_ATOM, &type, &f, &n, &a, &ret);
     1100                xrc = XGetWindowProperty(m_pDisplay, wndOwner,
     1101                                         xAtom(XA_XdndActionList),
     1102                                         0, VBOX_MAX_XPROPERTIES,
     1103                                         False, XA_ATOM, &type, &f, &n, &a, &ret);
    11021104                if (   xrc == Success
    11031105                    && n > 0
     
    11101112                        m_actions.append(data[i]);
    11111113                    }
     1114
    11121115                    XFree(ret);
    11131116                }
     
    11151118                m_state = Dragging;
    11161119                m_mode  = GH;
     1120
    11171121                /* Acknowledge the event by sending a Status msg back to the
    11181122                 * window. */
     
    11521156            }
    11531157        }
     1158
    11541159        hideProxyWin();
    11551160
    1156         rc = VbglR3DnDGHAcknowledgePending(DND_COPY_ACTION, toHGCMActions(m_actions),
     1161        rc = VbglR3DnDGHAcknowledgePending(m_uClientID, DND_COPY_ACTION, toHGCMActions(m_actions),
    11571162                                           gX11->xAtomListToString(m_formats).c_str());
    11581163    }
     
    11621167}
    11631168
    1164 int DragInstance::ghDropped(const RTCString &strFormat, uint32_t action)
    1165 {
    1166     LogFlowThisFunc(("format='%s' action=%d\n", strFormat.c_str(), action));
     1169int DragInstance::ghDropped(const RTCString &strFormat, uint32_t uAction)
     1170{
     1171    LogFlowThisFunc(("strFormat=%s, uAction=%RU32\n",
     1172                     strFormat.c_str(), uAction));
     1173
    11671174    int rc = VINF_SUCCESS;
    11681175
     
    11711178    showProxyWin(rx, ry);
    11721179    XFlush(m_pDisplay);
     1180
    11731181    /* We send a fake release event to the current window, cause
    11741182     * this should have the grab. */
    11751183    sendButtonEvent(m_wndCur, rx, ry, 1, false);
     1184
    11761185    /* The fake button release event, should lead to an XdndDrop event from the
    11771186     * source. Because of the showing of the proxy window, sometimes other Xdnd
     
    11811190    XClientMessageEvent *clme = 0;
    11821191    RT_ZERO(e);
    1183     int tries = 3;
    1184     do
     1192
     1193    int cRetries = 3;
     1194    for (int i = 0; i < cRetries; i++)
    11851195    {
    11861196        if (m_pParent->waitForXMsg(e, ClientMessage))
     
    11921202            }
    11931203        }
    1194     } while (tries--);
     1204    }
     1205
    11951206    if (clme)
    11961207    {
     
    12021213            Window srcWin = m_wndCur;//clme->data.l[0];
    12031214            Atom aFormat  = gX11->stringToxAtom(strFormat.c_str());
    1204             XConvertSelection(m_pDisplay, xAtom(XA_XdndSelection), aFormat, xAtom(XA_XdndSelection), m_wndProxy, clme->data.l[2]);
     1215
     1216            XConvertSelection(m_pDisplay, xAtom(XA_XdndSelection),
     1217                              aFormat, xAtom(XA_XdndSelection),
     1218                              m_wndProxy, clme->data.l[2]);
     1219
    12051220            /* Wait for the selection notify event. */
    12061221            RT_ZERO(e);
     
    12151230                {
    12161231                    LogFlowThisFunc(("Selection notfiy (from: %x)\n", m_wndCur));
     1232
    12171233                    Atom type;
    12181234                    int format;
     
    12421258                                memcpy(ucData1, ucData, cbData);
    12431259                                ucData1[cbData++] = '\0';
     1260
    12441261                                /* Got the data and its fully transfered. */
    1245                                 rc = VbglR3DnDGHSendData(ucData1, cbData);
     1262                                rc = VbglR3DnDGHSendData(m_uClientID, strFormat.c_str(),
     1263                                                         ucData1, cbData);
    12461264                                RTMemFree(ucData1);
    12471265                            }
     
    12501268                        }
    12511269                        else
     1270                        {
    12521271                            /* Just send the data to the host. */
    1253                             rc = VbglR3DnDGHSendData(ucData, cbData);
     1272                            rc = VbglR3DnDGHSendData(m_uClientID, strFormat.c_str(),
     1273                                                     ucData, cbData);
     1274                        }
    12541275
    12551276                        LogFlowThisFunc(("send responce\n"));
     
    12641285                        m.data.l[0]    = m_wndProxy;
    12651286                        m.data.l[1]    = RT_SUCCESS(rc) ?                   1 : 0;    /* Confirm or deny success */
    1266                         m.data.l[2]    = RT_SUCCESS(rc) ? toX11Action(action) : None; /* Action used on success */
     1287                        m.data.l[2]    = RT_SUCCESS(rc) ? toX11Action(uAction) : None; /* Action used on success */
    12671288
    12681289                        int xrc = XSendEvent(m_pDisplay, srcWin, True, NoEventMask, reinterpret_cast<XEvent*>(&m));
     
    12741295                        if (type == xAtom(XA_INCR))
    12751296                        {
    1276                             /* Todo: */
     1297                            /** @todo Support incremental transfers. */
    12771298                            AssertMsgFailed(("Incrementally transfers are not supported, yet\n"));
    12781299                            rc = VERR_NOT_IMPLEMENTED;
     
    12831304                            rc = VERR_INVALID_PARAMETER;
    12841305                        }
     1306
    12851307                        /* Cancel this. */
    12861308                        XClientMessageEvent m;
     
    12941316                        m.data.l[1]    = 0;
    12951317                        m.data.l[2]    = None;
     1318
    12961319                        int xrc = XSendEvent(m_pDisplay, srcWin, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    12971320                        if (RT_UNLIKELY(xrc == 0))
     
    12991322                        m_wndCur = 0;
    13001323                    }
     1324
    13011325                    /* Cleanup */
    13021326                    if (ucData)
     
    13151339        rc = VERR_TIMEOUT;
    13161340
    1317     /* Inform the host on error */
     1341    /* Inform the host on error. */
    13181342    if (RT_FAILURE(rc))
    1319         VbglR3DnDGHSendError(rc);
     1343        VbglR3DnDGHSendError(m_uClientID, rc);
    13201344
    13211345    /* At this point, we have either successfully transfered any data or not.
     
    13261350    return rc;
    13271351}
    1328 
    13291352#endif /* VBOX_WITH_DRAG_AND_DROP_GH */
    13301353
Note: See TracChangeset for help on using the changeset viewer.

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