VirtualBox

Changeset 51476 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 30, 2014 2:58:02 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
94064
Message:

DnD: API overhaul; now using IDnDTarget + IDnDSource. Renamed DragAndDrop* enumerations to DnD*. Also rewrote some internal code.

Location:
trunk/src/VBox
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox

  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp

    r48538 r51476  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    198198            }
    199199
    200             DragAndDropMode_T mode;
     200            DnDMode_T mode;
    201201            if (!strcmp(a->argv[2], "disabled"))
    202                 mode = DragAndDropMode_Disabled;
     202                mode = DnDMode_Disabled;
    203203            else if (!strcmp(a->argv[2], "hosttoguest"))
    204                 mode = DragAndDropMode_HostToGuest;
     204                mode = DnDMode_HostToGuest;
    205205            else if (!strcmp(a->argv[2], "guesttohost"))
    206                 mode = DragAndDropMode_GuestToHost;
     206                mode = DnDMode_GuestToHost;
    207207            else if (!strcmp(a->argv[2], "bidirectional"))
    208                 mode = DragAndDropMode_Bidirectional;
     208                mode = DnDMode_Bidirectional;
    209209            else
    210210            {
     
    214214            if (SUCCEEDED(rc))
    215215            {
    216                 CHECK_ERROR_BREAK(sessionMachine, COMSETTER(DragAndDropMode)(mode));
     216                CHECK_ERROR_BREAK(sessionMachine, COMSETTER(DnDMode)(mode));
    217217            }
    218218        }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r51384 r51476  
    16101610    {
    16111611        const char *psz = "Unknown";
    1612         DragAndDropMode_T enmMode;
    1613         rc = machine->COMGETTER(DragAndDropMode)(&enmMode);
     1612        DnDMode_T enmMode;
     1613        rc = machine->COMGETTER(DnDMode)(&enmMode);
    16141614        switch (enmMode)
    16151615        {
    1616             case DragAndDropMode_Disabled:
     1616            case DnDMode_Disabled:
    16171617                if (details == VMINFO_MACHINEREADABLE)
    16181618                    psz = "disabled";
     
    16201620                    psz = "disabled";
    16211621                break;
    1622             case DragAndDropMode_HostToGuest:
     1622            case DnDMode_HostToGuest:
    16231623                if (details == VMINFO_MACHINEREADABLE)
    16241624                    psz = "hosttoguest";
     
    16261626                    psz = "HostToGuest";
    16271627                break;
    1628             case DragAndDropMode_GuestToHost:
     1628            case DnDMode_GuestToHost:
    16291629                if (details == VMINFO_MACHINEREADABLE)
    16301630                    psz = "guesttohost";
     
    16321632                    psz = "GuestToHost";
    16331633                break;
    1634             case DragAndDropMode_Bidirectional:
     1634            case DnDMode_Bidirectional:
    16351635                if (details == VMINFO_MACHINEREADABLE)
    16361636                    psz = "bidirectional";
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r51259 r51476  
    21682168            case MODIFYVM_DRAGANDDROP:
    21692169            {
    2170                 DragAndDropMode_T mode;
     2170                DnDMode_T mode;
    21712171                if (!RTStrICmp(ValueUnion.psz, "disabled"))
    2172                     mode = DragAndDropMode_Disabled;
     2172                    mode = DnDMode_Disabled;
    21732173                else if (!RTStrICmp(ValueUnion.psz, "hosttoguest"))
    2174                     mode = DragAndDropMode_HostToGuest;
     2174                    mode = DnDMode_HostToGuest;
    21752175                else if (!RTStrICmp(ValueUnion.psz, "guesttohost"))
    2176                     mode = DragAndDropMode_GuestToHost;
     2176                    mode = DnDMode_GuestToHost;
    21772177                else if (!RTStrICmp(ValueUnion.psz, "bidirectional"))
    2178                     mode = DragAndDropMode_Bidirectional;
     2178                    mode = DnDMode_Bidirectional;
    21792179                else
    21802180                {
     
    21842184                if (SUCCEEDED(rc))
    21852185                {
    2186                     CHECK_ERROR(machine, COMSETTER(DragAndDropMode)(mode));
     2186                    CHECK_ERROR(machine, COMSETTER(DnDMode)(mode));
    21872187                }
    21882188                break;
  • trunk/src/VBox/Frontends/VirtualBox/src/UIVMInfoDialog.cpp

    r51410 r51476  
    606606        QString strClipboardMode = gpConverter->toString(m.GetClipboardMode());
    607607        /* Determine Drag&Drop mode: */
    608         QString strDragAndDropMode = gpConverter->toString(m.GetDragAndDropMode());
     608        QString strDnDMode = gpConverter->toString(m.GetDnDMode());
    609609
    610610        /* Deterine virtualization attributes: */
     
    658658        strResult += formatValue(tr("VM Uptime"), strUptime, iMaxLength);
    659659        strResult += formatValue(tr("Clipboard Mode"), strClipboardMode, iMaxLength);
    660         strResult += formatValue(tr("Drag'n'Drop Mode"), strDragAndDropMode, iMaxLength);
     660        strResult += formatValue(tr("Drag'n'Drop Mode"), strDnDMode, iMaxLength);
    661661        strResult += formatValue(VBoxGlobal::tr("VT-x/AMD-V", "details report"), strVirtualization, iMaxLength);
    662662        strResult += formatValue(VBoxGlobal::tr("Nested Paging", "details report"), strNestedPaging, iMaxLength);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h

    r51401 r51476  
    66
    77/*
    8  * Copyright (C) 2012 Oracle Corporation
     8 * Copyright (C) 2012-2014 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    8888template<> bool canConvert<KDeviceType>();
    8989template<> bool canConvert<KClipboardMode>();
    90 template<> bool canConvert<KDragAndDropMode>();
     90template<> bool canConvert<KDnDMode>();
    9191template<> bool canConvert<KPointingHIDType>();
    9292template<> bool canConvert<KMediumType>();
     
    161161template<> QString toString(const KDeviceType &type);
    162162template<> QString toString(const KClipboardMode &mode);
    163 template<> QString toString(const KDragAndDropMode &mode);
     163template<> QString toString(const KDnDMode &mode);
    164164template<> QString toString(const KPointingHIDType &type);
    165165template<> QString toString(const KMediumType &type);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp

    r50041 r51476  
    77
    88/*
    9  * Copyright (C) 2012-2013 Oracle Corporation
     9 * Copyright (C) 2012-2014 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3434template<> bool canConvert<KDeviceType>() { return true; }
    3535template<> bool canConvert<KClipboardMode>() { return true; }
    36 template<> bool canConvert<KDragAndDropMode>() { return true; }
     36template<> bool canConvert<KDnDMode>() { return true; }
    3737template<> bool canConvert<KPointingHIDType>() { return true; }
    3838template<> bool canConvert<KMediumType>() { return true; }
     
    202202}
    203203
    204 /* QString <= KDragAndDropMode: */
    205 template<> QString toString(const KDragAndDropMode &mode)
     204/* QString <= KDnDMode: */
     205template<> QString toString(const KDnDMode &mode)
    206206{
    207207    switch (mode)
    208208    {
    209         case KDragAndDropMode_Disabled:      return QApplication::translate("VBoxGlobal", "Disabled", "DragAndDropType");
    210         case KDragAndDropMode_HostToGuest:   return QApplication::translate("VBoxGlobal", "Host To Guest", "DragAndDropType");
    211         case KDragAndDropMode_GuestToHost:   return QApplication::translate("VBoxGlobal", "Guest To Host", "DragAndDropType");
    212         case KDragAndDropMode_Bidirectional: return QApplication::translate("VBoxGlobal", "Bidirectional", "DragAndDropType");
     209        case KDnDMode_Disabled:      return QApplication::translate("VBoxGlobal", "Disabled", "DragAndDropType");
     210        case KDnDMode_HostToGuest:   return QApplication::translate("VBoxGlobal", "Host To Guest", "DragAndDropType");
     211        case KDnDMode_GuestToHost:   return QApplication::translate("VBoxGlobal", "Guest To Host", "DragAndDropType");
     212        case KDnDMode_Bidirectional: return QApplication::translate("VBoxGlobal", "Bidirectional", "DragAndDropType");
    213213        default: AssertMsgFailed(("No text for %d", mode)); break;
    214214    }
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.cpp

    r50604 r51476  
    4141
    4242UIDnDDataObject::UIDnDDataObject(CSession &session,
     43                                 CDnDSource &dndSource,
    4344                                 const QStringList &lstFormats,
    4445                                 QWidget *pParent)
    4546    : mSession(session),
     47      mDnDSource(dndSource),
    4648      mpParent(pParent),
    4749      mStatus(Uninitialized),
     
    6567        RT_BZERO(mpStgMedium, sizeof(STGMEDIUM) * cMaxFormats);
    6668
    67         for (int i = 0; i < lstFormats.size(); i++)
     69        for (int i = 0;
     70             (   i < lstFormats.size()
     71              && i < cMaxFormats); i++)
    6872        {
    6973            const QString &strFormat = lstFormats.at(i);
     
    9599        }
    96100
    97         LogFlowFunc(("Total registered formats: %RU32 (of %d total)\n",
     101        LogFlowFunc(("Total registered native formats: %RU32 (for %d formats from guest)\n",
    98102                     cRegisteredFormats, lstFormats.size()));
    99103        hr = S_OK;
     
    290294        {
    291295            rc = UIDnDDrag::RetrieveData(mSession,
     296                                         mDnDSource,
     297                                         /** @todo Support other actions. */
    292298                                         Qt::CopyAction,
    293299                                         strMIMEType, vaType, mVaData,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.h

    r50604 r51476  
    2929/* COM includes: */
    3030#include "COMEnums.h"
     31#include "CDndSource.h"
    3132#include "CSession.h"
    3233
     
    4950public:
    5051
    51     UIDnDDataObject(CSession &session, const QStringList &lstFormats, QWidget *pParent);
     52    UIDnDDataObject(CSession &session, CDnDSource &dndSource, const QStringList &lstFormats, QWidget *pParent);
    5253    virtual ~UIDnDDataObject(void);
    5354
     
    8788    QWidget    *mpParent;
    8889    CSession    mSession;
     90    CDnDSource  mDnDSource;
    8991    Status      mStatus;
    9092    LONG        mRefCount;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDrag.cpp

    r51033 r51476  
    4444#endif
    4545
    46 UIDnDDrag::UIDnDDrag(CSession &session,
     46UIDnDDrag::UIDnDDrag(CSession &session,
     47                     CDnDSource &dndSource,
    4748                     const QStringList &lstFormats,
    4849                     Qt::DropAction defAction, Qt::DropActions actions,
    4950                     QWidget *pParent /* = NULL */)
    5051    : m_session(session)
     52    , m_dndSource(dndSource)
    5153    , m_lstFormats(lstFormats)
    5254    , m_defAction(defAction)
     
    7274#ifdef RT_OS_WINDOWS
    7375    UIDnDDropSource *pDropSource = new UIDnDDropSource(m_pParent);
    74     UIDnDDataObject *pDataObject = new UIDnDDataObject(m_session, m_lstFormats, m_pParent);
     76    UIDnDDataObject *pDataObject = new UIDnDDataObject(m_session, m_dndSource, m_lstFormats, m_pParent);
    7577
    7678    DWORD dwOKEffects = DROPEFFECT_NONE;
     
    8688
    8789    DWORD dwEffect;
     90    LogFlowFunc(("dwOKEffects=0x%x\n", dwOKEffects));
    8891    HRESULT hr = ::DoDragDrop(pDataObject, pDropSource,
    8992                              dwOKEffects, &dwEffect);
    90     LogFlowThisFunc(("DoDragDrop ended with hr=%Rhrc, dwEffect=%RI32\n",
    91                      hr, dwEffect));
     93    LogFlowFunc(("DoDragDrop ended with hr=%Rhrc, dwEffect=%RI32\n",
     94                 hr, dwEffect));
    9295
    9396    if (pDropSource)
     
    99102
    100103    /* pMData is transfered to the QDrag object, so no need for deletion. */
    101     pMData = new UIDnDMimeData(m_session,
     104    pMData = new UIDnDMimeData(m_session, m_dndSource,
    102105                               m_lstFormats, m_defAction, m_actions,
    103106                               m_pParent);
     
    129132/* static */
    130133int UIDnDDrag::RetrieveData(const CSession &session,
     134                            CDnDSource &dndSource,
    131135                            Qt::DropAction dropAction,
    132136                            const QString &strMimeType,
     
    140144    CGuest guest = session.GetConsole().GetGuest();
    141145
    142     /* Start getting the data from the guest. First inform the guest we
     146    /* Start getting the data from the source. First inform the source we
    143147     * want the data in the specified MIME type. */
    144     CProgress progress = guest.DragGHDropped(strMimeType,
    145                                              UIDnDHandler::toVBoxDnDAction(dropAction));
     148    CProgress progress = dndSource.Drop(strMimeType,
     149                                        UIDnDHandler::toVBoxDnDAction(dropAction));
    146150    if (guest.isOk())
    147151    {
     
    157161            if (RT_SUCCESS(rc))
    158162            {
    159                 /* After the data successfully arrived from the guest, we query it from Main. */
    160                 QVector<uint8_t> vecData = guest.DragGHGetData();
     163                /* After we successfully retrieved data from
     164                * the source, we query it from Main. */
     165                QVector<uint8_t> vecData = dndSource.ReceiveData();
    161166                if (!vecData.isEmpty())
    162167                {
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDrag.h

    r50602 r51476  
    2828#include "CSession.h"
    2929#include "CConsole.h"
     30#include "CDnDSource.h"
    3031#include "CGuest.h"
    3132
     
    4546public:
    4647
    47     UIDnDDrag(CSession &session,
     48    UIDnDDrag(CSession &session, CDnDSource &dndSource,
    4849              const QStringList &lstFormats, Qt::DropAction defAction, Qt::DropActions actions,
    4950              QWidget *pParent = NULL);
     
    5455public:
    5556
    56     static int RetrieveData(const CSession &session, Qt::DropAction dropAction, const QString &strMimeType, QVariant::Type vaType, QVariant &vaData, QWidget *pParent);
     57    static int RetrieveData(const CSession &session, CDnDSource &dndSource, Qt::DropAction dropAction, const QString &strMimeType, QVariant::Type vaType, QVariant &vaData, QWidget *pParent);
    5758
    5859private:
    5960
    6061    CSession          m_session;
     62    CDnDSource        m_dndSource;
    6163    QStringList       m_lstFormats;
    6264    Qt::DropAction    m_defAction;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.cpp

    r51033 r51476  
    3434#include "UIDnDHandler.h"
    3535#ifdef VBOX_WITH_DRAG_AND_DROP_GH
     36# include "CDnDSource.h"
    3637# include "UIDnDDrag.h"
    3738#endif
     
    3940
    4041/* COM includes: */
     42#include "CConsole.h"
     43#include "CDnDTarget.h"
     44#include "CGuest.h"
    4145#include "CSession.h"
    42 #include "CConsole.h"
    43 #include "CGuest.h"
     46
     47
    4448
    4549UIDnDHandler *UIDnDHandler::m_pInstance = NULL;
    4650
    4751UIDnDHandler::UIDnDHandler(void)
    48     : mMode(Unknown)
    4952{
    5053}
    5154
    5255/*
    53  * Host -> Guest
    54  */
    55 
    56 Qt::DropAction UIDnDHandler::dragHGEnter(CGuest &guest, ulong screenId, int x, int y,
    57                                          Qt::DropAction proposedAction, Qt::DropActions possibleActions,
    58                                          const QMimeData *pMimeData, QWidget * /* pParent = NULL */)
    59 {
    60     if (mMode == GH) /* Wrong mode? Bail out. */
    61         return Qt::IgnoreAction;
    62 
     56 * Frontend -> Target.
     57 */
     58
     59Qt::DropAction UIDnDHandler::dragEnter(CDnDTarget &dndTarget, ulong screenId, int x, int y,
     60                                       Qt::DropAction proposedAction, Qt::DropActions possibleActions,
     61                                       const QMimeData *pMimeData, QWidget * /* pParent = NULL */)
     62{
    6363    LogFlowFunc(("screenId=%RU32, x=%d, y=%d, action=%ld\n",
    6464                 screenId, x, y, toVBoxDnDAction(proposedAction)));
    6565
    6666    /* Ask the guest for starting a DnD event. */
    67     KDragAndDropAction result = guest.DragHGEnter(screenId,
    68                                                   x,
    69                                                   y,
    70                                                   toVBoxDnDAction(proposedAction),
    71                                                   toVBoxDnDActions(possibleActions),
    72                                                   pMimeData->formats().toVector());
     67    KDnDAction result = dndTarget.Enter(screenId,
     68                                        x,
     69                                        y,
     70                                        toVBoxDnDAction(proposedAction),
     71                                        toVBoxDnDActions(possibleActions),
     72                                        pMimeData->formats().toVector());
     73
    7374    /* Set the DnD action returned by the guest. */
    7475    return toQtDnDAction(result);
    7576}
    7677
    77 Qt::DropAction UIDnDHandler::dragHGMove(CGuest &guest, ulong screenId, int x, int y,
    78                                         Qt::DropAction proposedAction, Qt::DropActions possibleActions,
    79                                         const QMimeData *pMimeData, QWidget * /* pParent = NULL */)
    80 {
    81     if (mMode == GH) /* Wrong mode? Bail out. */
    82         return Qt::IgnoreAction;
    83 
     78Qt::DropAction UIDnDHandler::dragMove(CDnDTarget &dndTarget, ulong screenId, int x, int y,
     79                                      Qt::DropAction proposedAction, Qt::DropActions possibleActions,
     80                                      const QMimeData *pMimeData, QWidget * /* pParent = NULL */)
     81{
    8482#ifdef DEBUG_andy
    8583    LogFlowFunc(("screenId=%RU32, x=%d, y=%d, action=%ld\n",
     
    8987    /* Notify the guest that the mouse has been moved while doing
    9088     * a drag'n drop operation. */
    91     KDragAndDropAction result = guest.DragHGMove(screenId,
    92                                                  x,
    93                                                  y,
    94                                                  toVBoxDnDAction(proposedAction),
    95                                                  toVBoxDnDActions(possibleActions),
    96                                                  pMimeData->formats().toVector());
     89    KDnDAction result = dndTarget.Move(screenId,
     90                                       x,
     91                                       y,
     92                                       toVBoxDnDAction(proposedAction),
     93                                       toVBoxDnDActions(possibleActions),
     94                                       pMimeData->formats().toVector());
    9795    /* Set the DnD action returned by the guest. */
    9896    return toQtDnDAction(result);
    9997}
    10098
    101 Qt::DropAction UIDnDHandler::dragHGDrop(CGuest &guest, ulong screenId, int x, int y,
    102                                         Qt::DropAction proposedAction, Qt::DropActions possibleActions,
    103                                         const QMimeData *pMimeData, QWidget *pParent /* = NULL */)
    104 {
    105     if (mMode == GH) /* Wrong mode? Bail out. */
    106         return Qt::IgnoreAction;
     99Qt::DropAction UIDnDHandler::dragDrop(CSession &session, CDnDTarget &dndTarget,
     100                                      ulong screenId, int x, int y,
     101                                      Qt::DropAction proposedAction, Qt::DropActions possibleActions,
     102                                      const QMimeData *pMimeData, QWidget *pParent /* = NULL */)
     103{
     104    CGuest guest = session.GetConsole().GetGuest();
    107105
    108106    LogFlowFunc(("screenId=%RU32, x=%d, y=%d, action=%ld\n",
     
    112110    QString format;
    113111    /* Ask the guest for dropping data. */
    114     KDragAndDropAction result = guest.DragHGDrop(screenId,
    115                                                  x,
    116                                                  y,
    117                                                  toVBoxDnDAction(proposedAction),
    118                                                  toVBoxDnDActions(possibleActions),
    119                                                  pMimeData->formats().toVector(), format);
     112    KDnDAction result = dndTarget.Drop(screenId,
     113                                       x,
     114                                       y,
     115                                       toVBoxDnDAction(proposedAction),
     116                                       toVBoxDnDActions(possibleActions),
     117                                       pMimeData->formats().toVector(), format);
    120118    /* Has the guest accepted the drop event? */
    121     if (result != KDragAndDropAction_Ignore)
     119    if (result != KDnDAction_Ignore)
    122120    {
    123121        /* Get the actual MIME data in the requested format. */
     122        AssertPtr(pMimeData);
    124123        const QByteArray &d = pMimeData->data(format);
    125124        if (   !d.isEmpty()
     
    131130            memcpy(dv.data(), d.constData(), d.size());
    132131
    133             CProgress progress = guest.DragHGPutData(screenId, format, dv);
     132            CProgress progress = dndTarget.SendData(screenId, format, dv);
    134133            if (guest.isOk())
    135134            {
     
    142141                {
    143142                    msgCenter().cannotDropData(progress, pParent);
    144                     result = KDragAndDropAction_Ignore;
     143                    result = KDnDAction_Ignore;
    145144                }
    146145            }
     
    148147            {
    149148                msgCenter().cannotDropData(guest, pParent);
    150                 result = KDragAndDropAction_Ignore;
     149                result = KDnDAction_Ignore;
    151150            }
    152151        }
     
    156155}
    157156
    158 void UIDnDHandler::dragHGLeave(CGuest &guest, ulong screenId, QWidget * /* pParent = NULL */)
    159 {
    160     if (mMode == GH) /* Wrong mode? Bail out. */
    161         return;
    162 
     157void UIDnDHandler::dragLeave(CDnDTarget &dndTarget,
     158                             ulong screenId, QWidget * /* pParent = NULL */)
     159{
    163160    LogFlowFunc(("screenId=%RU32\n", screenId));
    164     guest.DragHGLeave(screenId);
    165 }
    166 
    167 int UIDnDHandler::dragGHPending(CSession &session, ulong screenId, QWidget *pParent /* = NULL */)
     161    dndTarget.Leave(screenId);
     162}
     163
     164/*
     165 * Source -> Frontend.
     166 */
     167
     168int UIDnDHandler::dragIsPending(CSession &session, CDnDSource &dndSource,
     169                                ulong screenId, QWidget *pParent /* = NULL */)
    168170{
    169171    int rc;
    170172#ifdef VBOX_WITH_DRAG_AND_DROP_GH
    171     if (mMode == HG) /* Wrong mode? Bail out. */
    172         return VERR_WRONG_ORDER;
    173 
    174173    /*
    175      * How this works: Host is asking the guest if there is any DnD
    176      * operation pending, when the mouse leaves the guest window
    177      * (DragGHPending). On return there is some info about a running DnD
    178      * operation (or defaultAction is KDragAndDropAction_Ignore if not). With
     174     * How this works: Source is asking the target if there is any DnD
     175     * operation pending, when the mouse leaves the guest window. On
     176     * return there is some info about a running DnD operation
     177     * (or defaultAction is KDnDAction_Ignore if not). With
    179178     * this information we create a Qt QDrag object with our own QMimeType
    180179     * implementation and call exec. Please note, this *blocks* until the DnD
     
    183182    CGuest guest = session.GetConsole().GetGuest();
    184183    QVector<QString> vecFmtGuest;
    185     QVector<KDragAndDropAction> vecActions;
    186     KDragAndDropAction defaultAction = guest.DragGHPending(screenId, vecFmtGuest, vecActions);
     184    QVector<KDnDAction> vecActions;
     185    KDnDAction defaultAction = dndSource.DragIsPending(screenId, vecFmtGuest, vecActions);
    187186    LogFlowFunc(("defaultAction=%d, numFormats=%d\n", defaultAction, vecFmtGuest.size()));
    188187
    189188    QStringList lstFmtNative;
    190     if (defaultAction != KDragAndDropAction_Ignore)
     189    if (defaultAction != KDnDAction_Ignore)
    191190    {
    192191        /*
     
    234233    if (!lstFmtNative.isEmpty())
    235234    {
    236         UIDnDDrag *pDrag = new UIDnDDrag(session, lstFmtNative,
    237                                          toQtDnDAction(defaultAction),
    238                                          toQtDnDActions(vecActions), pParent);
    239         rc = pDrag->DoDragDrop();
    240 
    241         delete pDrag;
     235        try
     236        {
     237            UIDnDDrag *pDrag = new UIDnDDrag(session, dndSource, lstFmtNative,
     238                                             toQtDnDAction(defaultAction),
     239                                             toQtDnDActions(vecActions), pParent);
     240            rc = pDrag->DoDragDrop();
     241
     242            delete pDrag;
     243        }
     244        catch (std::bad_alloc &)
     245        {
     246            rc = VERR_NO_MEMORY;
     247        }
    242248    }
    243     else
    244         rc = VINF_SUCCESS;
     249    else /* No format data from the guest arrived yet. */
     250        rc = VERR_NO_DATA;
    245251#else /* !VBOX_WITH_DRAG_AND_DROP_GH */
    246252    NOREF(session);
     
    260266
    261267/* static */
    262 KDragAndDropAction UIDnDHandler::toVBoxDnDAction(Qt::DropAction action)
     268KDnDAction UIDnDHandler::toVBoxDnDAction(Qt::DropAction action)
    263269{
    264270    if (action == Qt::CopyAction)
    265         return KDragAndDropAction_Copy;
     271        return KDnDAction_Copy;
    266272    if (action == Qt::MoveAction)
    267         return KDragAndDropAction_Move;
     273        return KDnDAction_Move;
    268274    if (action == Qt::LinkAction)
    269         return KDragAndDropAction_Link;
    270 
    271     return KDragAndDropAction_Ignore;
     275        return KDnDAction_Link;
     276
     277    return KDnDAction_Ignore;
    272278}
    273279
    274280/* static */
    275 QVector<KDragAndDropAction> UIDnDHandler::toVBoxDnDActions(Qt::DropActions actions)
    276 {
    277     QVector<KDragAndDropAction> vbActions;
     281QVector<KDnDAction> UIDnDHandler::toVBoxDnDActions(Qt::DropActions actions)
     282{
     283    QVector<KDnDAction> vbActions;
    278284    if (actions.testFlag(Qt::IgnoreAction))
    279         vbActions << KDragAndDropAction_Ignore;
     285        vbActions << KDnDAction_Ignore;
    280286    if (actions.testFlag(Qt::CopyAction))
    281         vbActions << KDragAndDropAction_Copy;
     287        vbActions << KDnDAction_Copy;
    282288    if (actions.testFlag(Qt::MoveAction))
    283         vbActions << KDragAndDropAction_Move;
     289        vbActions << KDnDAction_Move;
    284290    if (actions.testFlag(Qt::LinkAction))
    285         vbActions << KDragAndDropAction_Link;
     291        vbActions << KDnDAction_Link;
    286292
    287293    return vbActions;
     
    289295
    290296/* static */
    291 Qt::DropAction UIDnDHandler::toQtDnDAction(KDragAndDropAction action)
     297Qt::DropAction UIDnDHandler::toQtDnDAction(KDnDAction action)
    292298{
    293299    Qt::DropAction dropAct = Qt::IgnoreAction;
    294     if (action == KDragAndDropAction_Copy)
     300    if (action == KDnDAction_Copy)
    295301        dropAct = Qt::CopyAction;
    296     if (action == KDragAndDropAction_Move)
     302    if (action == KDnDAction_Move)
    297303        dropAct = Qt::MoveAction;
    298     if (action == KDragAndDropAction_Link)
     304    if (action == KDnDAction_Link)
    299305        dropAct = Qt::LinkAction;
    300306
     
    304310
    305311/* static */
    306 Qt::DropActions UIDnDHandler::toQtDnDActions(const QVector<KDragAndDropAction> &vecActions)
     312Qt::DropActions UIDnDHandler::toQtDnDActions(const QVector<KDnDAction> &vecActions)
    307313{
    308314    Qt::DropActions dropActs = Qt::IgnoreAction;
     
    311317        switch (vecActions.at(i))
    312318        {
    313             case KDragAndDropAction_Ignore:
     319            case KDnDAction_Ignore:
    314320                dropActs |= Qt::IgnoreAction;
    315321                break;
    316             case KDragAndDropAction_Copy:
     322            case KDnDAction_Copy:
    317323                dropActs |= Qt::CopyAction;
    318324                break;
    319             case KDragAndDropAction_Move:
     325            case KDnDAction_Move:
    320326                dropActs |= Qt::MoveAction;
    321327                break;
    322             case KDragAndDropAction_Link:
     328            case KDnDAction_Link:
    323329                dropActs |= Qt::LinkAction;
    324330                break;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.h

    r50460 r51476  
    33 *
    44 * VBox frontends: Qt GUI ("VirtualBox"):
    5  * UIDnDHandler class declaration
     5 * UIDnDHandler class declaration.
    66 */
    77
     
    2626/* Forward declarations: */
    2727class QMimeData;
     28class CDnDSource;
     29class CDnDTarget;
     30class CGuest;
    2831class CSession;
    29 class CGuest;
    3032class UIDnDMimeData;
    3133
     
    3739
    3840    /* Singleton factory. */
    39     static UIDnDHandler* instance(void)
     41    static UIDnDHandler *instance(void)
    4042    {
    4143        if (!m_pInstance)
     
    5658     * Current operation mode.
    5759     */
    58     enum Mode
     60    enum Direction
    5961    {
    6062        /** Unknown mode. */
    6163        Unknown = 0,
    6264        /** Host to guest. */
    63         HG,
     65        HostToGuest,
    6466        /** Guest to host. */
    65         GH
     67        GuestToHost
     68        /** @todo Implement guest to guest. */
    6669    };
    6770
    68     /* Host -> Guest. */
    69     Qt::DropAction dragHGEnter(CGuest &guest, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent = NULL);
    70     Qt::DropAction dragHGMove (CGuest &guest, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent = NULL);
    71     Qt::DropAction dragHGDrop (CGuest &guest, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent = NULL);
    72     void           dragHGLeave(CGuest &guest, ulong screenId, QWidget *pParent = NULL);
     71    /* Frontend -> Target. */
     72    Qt::DropAction             dragEnter(CDnDTarget &dndTarget, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent = NULL);
     73    Qt::DropAction             dragMove (CDnDTarget &dndTarget, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent = NULL);
     74    Qt::DropAction             dragDrop (CSession &session, CDnDTarget &dndTarget, ulong screenId, int x, int y, Qt::DropAction proposedAction, Qt::DropActions possibleActions, const QMimeData *pMimeData, QWidget *pParent = NULL);
     75    void                       dragLeave(CDnDTarget &dndTarget, ulong screenId, QWidget *pParent = NULL);
    7376
    74     /* Guest -> Host. */
    75     int            dragGHPending(CSession &session, ulong screenId, QWidget *pParent = NULL);
     77    /* Source -> Frontend. */
     78    int                        dragIsPending(CSession &session, CDnDSource &dndSource, ulong screenId, QWidget *pParent = NULL);
    7679
    7780public:
    7881
    79     static KDragAndDropAction          toVBoxDnDAction(Qt::DropAction action);
    80     static QVector<KDragAndDropAction> toVBoxDnDActions(Qt::DropActions actions);
    81     static Qt::DropAction              toQtDnDAction(KDragAndDropAction action);
    82     static Qt::DropActions             toQtDnDActions(const QVector<KDragAndDropAction> &vecActions);
     82    static KDnDAction          toVBoxDnDAction(Qt::DropAction action);
     83    static QVector<KDnDAction> toVBoxDnDActions(Qt::DropActions actions);
     84    static Qt::DropAction      toQtDnDAction(KDnDAction action);
     85    static Qt::DropActions     toQtDnDActions(const QVector<KDnDAction> &vecActions);
    8386
    8487private:
    85     static UIDnDHandler *m_pInstance;
    8688
    8789    UIDnDHandler(void);
    8890    virtual ~UIDnDHandler(void) {}
    8991
    90     /** The current operation mode. */
    91     Mode mMode;
     92private:
     93
     94    /** Static pointer to singleton instance. */
     95    static UIDnDHandler *m_pInstance;
    9296};
    9397
    94 #define gDnD UIDnDHandler::instance()
     98/** Gets the singleton instance of the drag'n drop UI helper class. */
     99#define DnDHandler() UIDnDHandler::instance()
    95100
    96101#endif /* ___UIDnDHandler_h___ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.cpp

    r51033 r51476  
    3838#include "UIMessageCenter.h"
    3939
    40 UIDnDMimeData::UIDnDMimeData(CSession &session,
     40UIDnDMimeData::UIDnDMimeData(CSession &session,
     41                             CDnDSource &dndSource,
    4142                             QStringList formats,
    4243                             Qt::DropAction defAction, Qt::DropActions actions,
    4344                             QWidget *pParent)
    4445    : m_Session(session)
     46    , m_DnDSource(dndSource)
    4547    , m_lstFormats(formats)
    4648    , m_defAction(defAction)
     
    109111
    110112QVariant UIDnDMimeData::retrieveData(const QString &strMIMEType,
    111                                      QVariant::Type vaType) const
     113                                     QVariant::Type vaType)
    112114{
    113115    LogFlowFunc(("m_enmState=%d, mimeType=%s, type=%d (%s)\n",
     
    165167    {
    166168        rc = UIDnDDrag::RetrieveData(m_Session,
     169                                     m_DnDSource,
    167170                                     m_defAction,
    168171                                     strMIMEType, vaType, m_vaData,
     
    198201                LogFlowFunc(("MouseMove: x=%d, y=%d\n",
    199202                             pMouseEvent->globalX(), pMouseEvent->globalY()));
    200                
     203
    201204                return true;
    202205                /* Never reached. */
     
    207210                LogFlowFunc(("MouseButtonRelease\n"));
    208211                m_enmState = Dropped;
    209                
     212
    210213                return true;
    211214                /* Never reached. */
     
    220223                    m_enmState = Canceled;
    221224                }
    222                
     225
    223226                return true;
    224227                /* Never reached. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDMIMEData.h

    r50734 r51476  
    2626/* COM includes: */
    2727#include "COMEnums.h"
     28#include "CConsole.h"
     29#include "CDnDSource.h"
     30#include "CGuest.h"
    2831#include "CSession.h"
    29 #include "CConsole.h"
    30 #include "CGuest.h"
    3132
    3233#include "UIDnDHandler.h"
     
    6162public:
    6263
    63     UIDnDMimeData(CSession &session, QStringList formats, Qt::DropAction defAction, Qt::DropActions actions, QWidget *pParent);
     64    UIDnDMimeData(CSession &session, CDnDSource &dndSource, QStringList formats, Qt::DropAction defAction, Qt::DropActions actions, QWidget *pParent);
    6465
    6566public:
     
    7879    virtual bool hasFormat(const QString &mimeType) const;
    7980
    80     virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
     81    virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type);
    8182
    8283#ifndef RT_OS_WINDOWS
     
    9899
    99100    CSession          m_Session;
     101    CDnDSource        m_DnDSource;
    100102    QStringList       m_lstFormats;
    101103    Qt::DropAction    m_defAction;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r51398 r51476  
    55
    66/*
    7  * Copyright (C) 2010-2013 Oracle Corporation
     7 * Copyright (C) 2010-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    729729    {
    730730        foreach (QAction *pAction, m_pDragAndDropActions->actions())
    731             pAction->setText(gpConverter->toString(pAction->data().value<KDragAndDropMode>()));
     731            pAction->setText(gpConverter->toString(pAction->data().value<KDnDMode>()));
    732732    }
    733733}
     
    18641864    {
    18651865        m_pDragAndDropActions = new QActionGroup(this);
    1866         for (int i = KDragAndDropMode_Disabled; i < KDragAndDropMode_Max; ++i)
     1866        for (int i = KDnDMode_Disabled; i < KDnDMode_Max; ++i)
    18671867        {
    1868             KDragAndDropMode mode = (KDragAndDropMode)i;
     1868            KDnDMode mode = (KDnDMode)i;
    18691869            QAction *pAction = new QAction(gpConverter->toString(mode), m_pDragAndDropActions);
    18701870            pMenu->addAction(pAction);
    18711871            pAction->setData(QVariant::fromValue(mode));
    18721872            pAction->setCheckable(true);
    1873             pAction->setChecked(session().GetMachine().GetDragAndDropMode() == mode);
     1873            pAction->setChecked(session().GetMachine().GetDnDMode() == mode);
    18741874        }
    18751875        connect(m_pDragAndDropActions, SIGNAL(triggered(QAction*)),
     
    18791879    else
    18801880        foreach (QAction *pAction, m_pDragAndDropActions->actions())
    1881             if (pAction->data().value<KDragAndDropMode>() == session().GetMachine().GetDragAndDropMode())
     1881            if (pAction->data().value<KDnDMode>() == session().GetMachine().GetDnDMode())
    18821882                pAction->setChecked(true);
    18831883}
     
    19611961{
    19621962    /* Assign new mode (without save): */
    1963     KDragAndDropMode mode = pAction->data().value<KDragAndDropMode>();
    1964     session().GetMachine().SetDragAndDropMode(mode);
     1963    KDnDMode mode = pAction->data().value<KDnDMode>();
     1964    session().GetMachine().SetDnDMode(mode);
    19651965}
    19661966
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r51467 r51476  
    6161#include "CFramebuffer.h"
    6262#ifdef VBOX_WITH_DRAG_AND_DROP
     63# include "CDnDSource.h"
     64# include "CDnDTarget.h"
    6365# include "CGuest.h"
     66# include "CGuestDnDTarget.h"
     67# include "CGuestDnDSource.h"
    6468#endif /* VBOX_WITH_DRAG_AND_DROP */
    6569
     
    11601164void UIMachineView::dragEnterEvent(QDragEnterEvent *pEvent)
    11611165{
    1162     /* The guest object to talk to. */
     1166    AssertPtrReturnVoid(pEvent);
     1167
     1168    /* Get mouse-pointer location. */
     1169    const QPoint &cpnt = viewportToContents(pEvent->pos());
     1170
    11631171    CGuest guest = session().GetConsole().GetGuest();
    1164 
    1165     /* Get mouse-pointer location */
    1166     const QPoint &cpnt = viewportToContents(pEvent->pos());
    1167 
    1168     /* Ask the guest for starting a DnD event. */
    1169     Qt::DropAction result = gDnD->dragHGEnter(guest,
    1170                                               screenId(),
    1171                                               frameBuffer()->convertHostXTo(cpnt.x()),
    1172                                               frameBuffer()->convertHostYTo(cpnt.y()),
    1173                                               pEvent->proposedAction(),
    1174                                               pEvent->possibleActions(),
    1175                                               pEvent->mimeData(), this);
     1172    CGuestDnDTarget dndTarget = guest.GetDnDTarget();
     1173
     1174    /* Ask the target for starting a DnD event. */
     1175    Qt::DropAction result = DnDHandler()->dragEnter(static_cast<CDnDTarget>(dndTarget),
     1176                                                    screenId(),
     1177                                                    frameBuffer()->convertHostXTo(cpnt.x()),
     1178                                                    frameBuffer()->convertHostYTo(cpnt.y()),
     1179                                                    pEvent->proposedAction(),
     1180                                                    pEvent->possibleActions(),
     1181                                                    pEvent->mimeData(), this /* pParent */);
    11761182
    11771183    /* Set the DnD action returned by the guest. */
     
    11821188void UIMachineView::dragMoveEvent(QDragMoveEvent *pEvent)
    11831189{
    1184     /* The guest object to talk to. */
     1190    AssertPtrReturnVoid(pEvent);
     1191
     1192    /* Get mouse-pointer location. */
     1193    const QPoint &cpnt = viewportToContents(pEvent->pos());
     1194
    11851195    CGuest guest = session().GetConsole().GetGuest();
    1186 
    1187     /* Get mouse-pointer location */
    1188     const QPoint &cpnt = viewportToContents(pEvent->pos());
     1196    CGuestDnDTarget dndTarget = guest.GetDnDTarget();
    11891197
    11901198    /* Ask the guest for moving the drop cursor. */
    1191     Qt::DropAction result = gDnD->dragHGMove(guest,
    1192                                              screenId(),
    1193                                              frameBuffer()->convertHostXTo(cpnt.x()),
    1194                                              frameBuffer()->convertHostYTo(cpnt.y()),
    1195                                              pEvent->proposedAction(),
    1196                                              pEvent->possibleActions(),
    1197                                              pEvent->mimeData(), this);
     1199    Qt::DropAction result = DnDHandler()->dragMove(static_cast<CDnDTarget>(dndTarget),
     1200                                                   screenId(),
     1201                                                   frameBuffer()->convertHostXTo(cpnt.x()),
     1202                                                   frameBuffer()->convertHostYTo(cpnt.y()),
     1203                                                   pEvent->proposedAction(),
     1204                                                   pEvent->possibleActions(),
     1205                                                   pEvent->mimeData(), this /* pParent */);
    11981206
    11991207    /* Set the DnD action returned by the guest. */
     
    12041212void UIMachineView::dragLeaveEvent(QDragLeaveEvent *pEvent)
    12051213{
    1206     /* The guest object to talk to. */
     1214    AssertPtrReturnVoid(pEvent);
     1215
    12071216    CGuest guest = session().GetConsole().GetGuest();
     1217    CGuestDnDTarget dndTarget = guest.GetDnDTarget();
    12081218
    12091219    /* Ask the guest for stopping this DnD event. */
    1210     gDnD->dragHGLeave(guest, screenId(), this);
     1220    DnDHandler()->dragLeave(static_cast<CDnDTarget>(dndTarget),
     1221                            screenId(), this /* pParent */);
    12111222    pEvent->accept();
    12121223}
    12131224
     1225void UIMachineView::dragIsPending(void)
     1226{
     1227    /* At the moment we only support guest->host DnD. */
     1228    /** @todo Add guest->guest DnD functionality here by getting
     1229     *        the source of guest B (when copying from B to A). */
     1230    CGuest guest = session().GetConsole().GetGuest();
     1231    CDnDSource &dndSource = static_cast<CDnDSource>(guest.GetDnDSource());
     1232
     1233    /* Check for a pending DnD event within the guest and if so, handle all the
     1234     * magic. */
     1235    DnDHandler()->dragIsPending(session(), dndSource, screenId(), this /* pParent */);
     1236}
     1237
    12141238void UIMachineView::dropEvent(QDropEvent *pEvent)
    12151239{
    1216     /* The guest object to talk to. */
     1240    AssertPtrReturnVoid(pEvent);
     1241
     1242    /* Get mouse-pointer location. */
     1243    const QPoint &cpnt = viewportToContents(pEvent->pos());
     1244
    12171245    CGuest guest = session().GetConsole().GetGuest();
    1218 
    1219     /* Get mouse-pointer location */
    1220     const QPoint &cpnt = viewportToContents(pEvent->pos());
     1246    CGuestDnDTarget dndTarget = guest.GetDnDTarget();
    12211247
    12221248    /* Ask the guest for dropping data. */
    1223     Qt::DropAction result = gDnD->dragHGDrop(guest,
    1224                                              screenId(),
    1225                                              frameBuffer()->convertHostXTo(cpnt.x()),
    1226                                              frameBuffer()->convertHostYTo(cpnt.y()),
    1227                                              pEvent->proposedAction(),
    1228                                              pEvent->possibleActions(),
    1229                                              pEvent->mimeData(), this);
     1249    Qt::DropAction result = DnDHandler()->dragDrop(session(),
     1250                                                   static_cast<CDnDTarget>(dndTarget),
     1251                                                   screenId(),
     1252                                                   frameBuffer()->convertHostXTo(cpnt.x()),
     1253                                                   frameBuffer()->convertHostYTo(cpnt.y()),
     1254                                                   pEvent->proposedAction(),
     1255                                                   pEvent->possibleActions(),
     1256                                                   pEvent->mimeData(), this /* pParent */);
    12301257
    12311258    /* Set the DnD action returned by the guest. */
     
    12331260    pEvent->accept();
    12341261}
    1235 
    1236 void UIMachineView::handleGHDnd(void)
    1237 {
    1238     /* The guest object to talk to. */
    1239     CGuest guest = session().GetConsole().GetGuest();
    1240 
    1241     /* Check for a pending DnD event within the guest and if so, handle all the
    1242      * magic. */
    1243     gDnD->dragGHPending(session(), screenId(), this);
    1244 }
    12451262#endif /* VBOX_WITH_DRAG_AND_DROP */
    12461263
     
    12491266bool UIMachineView::winEvent(MSG *pMsg, long* /* piResult */)
    12501267{
    1251     /* Check if some system event should be filtered-out.
    1252      * Returning 'true' means filtering-out,
    1253      * Returning 'false' means passing event to Qt. */
    1254     bool fResult = false; /* Pass to Qt by default: */
     1268    AssertPtrReturn(pMsg, false);
     1269
     1270    /* Check if some system event should be filtered out.
     1271     * Returning @c true means filtering-out,
     1272     * Returning @c false means passing event to Qt. */
     1273    bool fResult = false; /* Pass to Qt by default. */
    12551274    switch (pMsg->message)
    12561275    {
     
    12601279        case WM_SYSKEYUP:
    12611280        {
    1262             /* Filter using keyboard-filter: */
    1263             bool fKeyboardFilteringResult = machineLogic()->keyboardHandler()->winEventFilter(pMsg, screenId());
    1264             /* Keyboard filter rules the result: */
     1281            /* Filter using keyboard filter? */
     1282            bool fKeyboardFilteringResult =
     1283                machineLogic()->keyboardHandler()->winEventFilter(pMsg, screenId());
     1284            /* Keyboard filter rules the result? */
    12651285            fResult = fKeyboardFilteringResult;
    12661286            break;
     
    12691289            break;
    12701290    }
    1271     /* Return result: */
     1291
    12721292    return fResult;
    12731293}
     
    12771297bool UIMachineView::x11Event(XEvent *pEvent)
    12781298{
    1279     /* Check if some system event should be filtered-out.
    1280      * Returning 'true' means filtering-out,
    1281      * Returning 'false' means passing event to Qt. */
    1282     bool fResult = false; /* Pass to Qt by default: */
     1299    AssertPtrReturn(pEvent, false);
     1300
     1301    /* Check if some system event should be filtered out.
     1302     * Returning @c true means filtering-out,
     1303     * Returning @c false means passing event to Qt. */
     1304    bool fResult = false; /* Pass to Qt by default. */
    12831305    switch (pEvent->type)
    12841306    {
     
    12881310        case XKeyRelease:
    12891311        {
    1290             /* Filter using keyboard-filter: */
    1291             bool fKeyboardFilteringResult = machineLogic()->keyboardHandler()->x11EventFilter(pEvent, screenId());
    1292             /* Filter using mouse-filter: */
    1293             bool fMouseFilteringResult = machineLogic()->mouseHandler()->x11EventFilter(pEvent, screenId());
    1294             /* If at least one of filters wants to filter event out then the result is 'true': */
     1312            /* Filter using keyboard-filter? */
     1313            bool fKeyboardFilteringResult =
     1314                machineLogic()->keyboardHandler()->x11EventFilter(pEvent, screenId());
     1315            /* Filter using mouse-filter? */
     1316            bool fMouseFilteringResult =
     1317                machineLogic()->mouseHandler()->x11EventFilter(pEvent, screenId());
     1318            /* If at least one of filters wants to filter event out then the result is true. */
    12951319            fResult = fKeyboardFilteringResult || fMouseFilteringResult;
    12961320            break;
     
    12991323            break;
    13001324    }
    1301     /* Return result: */
     1325
    13021326    return fResult;
    13031327}
    13041328
    1305 #endif
    1306 
     1329#endif /* Q_WS_X11 */
     1330
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r51436 r51476  
    3939class UIMachineWindow;
    4040class UIFrameBuffer;
     41#ifdef VBOX_WITH_DRAG_AND_DROP
     42 class CDnDTarget;
     43#endif
    4144class CSession;
    4245
     
    217220    void dragLeaveEvent(QDragLeaveEvent *pEvent);
    218221    void dragMoveEvent(QDragMoveEvent *pEvent);
     222    void dragIsPending(void);
    219223    void dropEvent(QDropEvent *pEvent);
    220 
    221     void handleGHDnd();
    222224#endif /* VBOX_WITH_DRAG_AND_DROP */
    223225
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r51339 r51476  
    77
    88/*
    9  * Copyright (C) 2010-2012 Oracle Corporation
     9 * Copyright (C) 2010-2014 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    936936                || cpnt.y() > iCh - 1)
    937937            {
    938                 bool fHandledGHDnD
     938                bool fHandleDnDPending
    939939                    = RT_BOOL(mouseButtons.testFlag(Qt::LeftButton));
    940                 if (fHandledGHDnD)
    941                 {
    942                     m_views[uScreenId]->handleGHDnd();
     940                if (fHandleDnDPending)
     941                {
     942                    m_views[uScreenId]->dragIsPending();
    943943                    return true;
    944944                }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp

    r48576 r51476  
    77
    88/*
    9  * Copyright (C) 2006-2012 Oracle Corporation
     9 * Copyright (C) 2006-2014 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4444
    4545    /* Drag'n'drop mode */
    46     mCbDragAndDrop->addItem (""); /* KDragAndDropMode_Disabled */
    47     mCbDragAndDrop->addItem (""); /* KDragAndDropMode_HostToGuest */
    48     mCbDragAndDrop->addItem (""); /* KDragAndDropMode_GuestToHost */
    49     mCbDragAndDrop->addItem (""); /* KDragAndDropMode_Bidirectional */
     46    mCbDragAndDrop->addItem (""); /* KDnDMode_Disabled */
     47    mCbDragAndDrop->addItem (""); /* KDnDMode_HostToGuest */
     48    mCbDragAndDrop->addItem (""); /* KDnDMode_GuestToHost */
     49    mCbDragAndDrop->addItem (""); /* KDnDMode_Bidirectional */
    5050
    5151#ifdef Q_WS_MAC
     
    115115    generalData.m_strSnapshotsHomeDir = QFileInfo(m_machine.GetSettingsFilePath()).absolutePath();
    116116    generalData.m_clipboardMode = m_machine.GetClipboardMode();
    117     generalData.m_dragAndDropMode = m_machine.GetDragAndDropMode();
     117    generalData.m_dndMode = m_machine.GetDnDMode();
    118118    generalData.m_strDescription = m_machine.GetDescription();
    119119
     
    141141    mPsSnapshot->setHomeDir(generalData.m_strSnapshotsHomeDir);
    142142    mCbClipboard->setCurrentIndex(generalData.m_clipboardMode);
    143     mCbDragAndDrop->setCurrentIndex(generalData.m_dragAndDropMode);
     143    mCbDragAndDrop->setCurrentIndex(generalData.m_dndMode);
    144144    mTeDescription->setPlainText(generalData.m_strDescription);
    145145
     
    166166    generalData.m_strSnapshotsFolder = mPsSnapshot->path();
    167167    generalData.m_clipboardMode = (KClipboardMode)mCbClipboard->currentIndex();
    168     generalData.m_dragAndDropMode = (KDragAndDropMode)mCbDragAndDrop->currentIndex();
     168    generalData.m_dndMode = (KDnDMode)mCbDragAndDrop->currentIndex();
    169169    generalData.m_strDescription = mTeDescription->toPlainText().isEmpty() ?
    170170                                   QString::null : mTeDescription->toPlainText();
     
    192192            /* Advanced tab: */
    193193            m_machine.SetClipboardMode(generalData.m_clipboardMode);
    194             m_machine.SetDragAndDropMode(generalData.m_dragAndDropMode);
     194            m_machine.SetDnDMode(generalData.m_dndMode);
    195195            m_machine.SetExtraData(GUI_SaveMountedAtRuntime, generalData.m_fSaveMountedAtRuntime ? "yes" : "no");
    196196            m_machine.SetExtraData(GUI_ShowMiniToolBar, generalData.m_fShowMiniToolBar ? "yes" : "no");
     
    292292
    293293    /* Drag'n'drop mode */
    294     mCbDragAndDrop->setItemText (0, gpConverter->toString (KDragAndDropMode_Disabled));
    295     mCbDragAndDrop->setItemText (1, gpConverter->toString (KDragAndDropMode_HostToGuest));
    296     mCbDragAndDrop->setItemText (2, gpConverter->toString (KDragAndDropMode_GuestToHost));
    297     mCbDragAndDrop->setItemText (3, gpConverter->toString (KDragAndDropMode_Bidirectional));
     294    mCbDragAndDrop->setItemText (0, gpConverter->toString (KDnDMode_Disabled));
     295    mCbDragAndDrop->setItemText (1, gpConverter->toString (KDnDMode_HostToGuest));
     296    mCbDragAndDrop->setItemText (2, gpConverter->toString (KDnDMode_GuestToHost));
     297    mCbDragAndDrop->setItemText (3, gpConverter->toString (KDnDMode_Bidirectional));
    298298}
    299299
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h

    r47944 r51476  
    66
    77/*
    8  * Copyright (C) 2006-2012 Oracle Corporation
     8 * Copyright (C) 2006-2014 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3737        , m_strSnapshotsHomeDir(QString())
    3838        , m_clipboardMode(KClipboardMode_Disabled)
    39         , m_dragAndDropMode(KDragAndDropMode_Disabled)
     39        , m_dndMode(KDnDMode_Disabled)
    4040        , m_strDescription(QString()) {}
    4141    /* Functions: */
     
    5050               (m_strSnapshotsHomeDir == other.m_strSnapshotsHomeDir) &&
    5151               (m_clipboardMode == other.m_clipboardMode) &&
    52                (m_dragAndDropMode == other.m_dragAndDropMode) &&
     52               (m_dndMode == other.m_dndMode) &&
    5353               (m_strDescription == other.m_strDescription);
    5454    }
     
    6565    QString m_strSnapshotsHomeDir;
    6666    KClipboardMode m_clipboardMode;
    67     KDragAndDropMode m_dragAndDropMode;
     67    KDnDMode m_dndMode;
    6868    QString m_strDescription;
    6969};
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