VirtualBox

Ignore:
Timestamp:
Dec 12, 2013 8:09:20 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
91269
Message:

Merged private draganddrop branch into trunk.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/VBox

  • trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp

    r49455 r49891  
    44
    55/*
    6  * Copyright (C) 2011-2012 Oracle Corporation
     6 * Copyright (C) 2011-2013 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5555 * G->H:
    5656 * This is a lot more trickery than H->G. When a pending event from HGCM
    57  * arrives, we asks if there is currently an owner of the XdndSelection
     57 * arrives, we ask if there currently is an owner of the XdndSelection
    5858 * property. If so, our proxy window is shown (1x1, but without backing store)
    5959 * and some mouse event is triggered. This should be followed by an XdndEnter
     
    6565 * Todo:
    6666 * - this isn't finished, yet. Currently the mouse isn't correctly released
    67  * in the guest (both, when the drop was successfully or canceled).
     67 *   in the guest (both, when the drop was successfully or canceled).
    6868 * - cancel (e.g. with the ESC key) doesn't work
    6969 *
     
    7474 * - really check for the Xdnd version and the supported features
    7575 */
    76 
    77 #define VERBOSE 1
    78 
    79 #if defined(VERBOSE) && defined(DEBUG_poetzsch)
    80 # include <iprt/stream.h>
    81 # define DO(s) RTPrintf s
    82 #else
    83 # define DO(s) do {} while (0)
    84 //# define DO(s) Log s
    85 #endif
    8676
    8777#define VBOX_XDND_VERSION    (4)
     
    154144public:
    155145
    156     static xHelpers *instance(Display *pDisplay = 0)
     146    static xHelpers *getInstance(Display *pDisplay = 0)
    157147    {
    158148        if (!m_pInstance)
    159149        {
    160             AssertPtrReturn(pDisplay, 0);
     150            AssertPtrReturn(pDisplay, NULL);
    161151            m_pInstance = new xHelpers(pDisplay);
    162152        }
     153
    163154        return m_pInstance;
    164155    }
     
    211202
    212203/* Some xHelpers convenience defines. */
    213 #define gX11 xHelpers::instance()
     204#define gX11 xHelpers::getInstance()
    214205#define xAtom(xa) gX11->xAtom((xa))
    215206#define xAtomToString(xa) gX11->xAtomToString((xa))
     
    285276
    286277/* Todo: make this iterative */
    287 Window xHelpers::applicationWindowBelowCursor(Window parentWin) const
     278Window xHelpers::applicationWindowBelowCursor(Window wndParent) const
    288279{
    289280    /* No parent, nothing to do. */
    290     if(parentWin == 0)
     281    if(wndParent == 0)
    291282        return 0;
    292283
    293     Window appWin = 0;
     284    Window wndApp = 0;
    294285    int cProps = -1;
    295286    /* Fetch all x11 window properties of the parent window. */
    296     Atom *pProps = XListProperties(m_pDisplay, parentWin, &cProps);
     287    Atom *pProps = XListProperties(m_pDisplay, wndParent, &cProps);
    297288    if (cProps > 0)
    298289    {
    299290        /* We check the window for the WM_STATE property. */
    300         for(int i = 0; i < cProps; ++i)
    301             if(pProps[i] == xAtom(XA_WM_STATE))
     291        for (int i = 0; i < cProps; ++i)
     292            if (pProps[i] == xAtom(XA_WM_STATE))
    302293            {
    303294                /* Found it. */
    304                 appWin = parentWin;
     295                wndApp = wndParent;
    305296                break;
    306297            }
     
    309300    }
    310301
    311     if (!appWin)
    312     {
    313         Window childWin, wtmp;
     302    if (!wndApp)
     303    {
     304        Window wndChild, wndTemp;
    314305        int tmp;
    315306        unsigned int utmp;
    316307        /* Query the next child window of the parent window at the current
    317308         * mouse position. */
    318         XQueryPointer(m_pDisplay, parentWin, &wtmp, &childWin, &tmp, &tmp, &tmp, &tmp, &utmp);
     309        XQueryPointer(m_pDisplay, wndParent, &wndTemp, &wndChild, &tmp, &tmp, &tmp, &tmp, &utmp);
    319310        /* Recursive call our self to dive into the child tree. */
    320         appWin = applicationWindowBelowCursor(childWin);
    321     }
    322 
    323     return appWin;
     311        wndApp = applicationWindowBelowCursor(wndChild);
     312    }
     313
     314    return wndApp;
    324315}
    325316
     
    390381
    391382    /* Member vars */
     383    uint32_t            m_uClientID;
    392384    DragAndDropService *m_pParent;
    393385    Display            *m_pDisplay;
    394386    int                 m_screenId;
    395387    Screen             *m_pScreen;
    396     Window              m_rootWin;
    397     Window              m_proxyWin;
    398     Window              m_curWin;
     388    Window              m_wndRoot;
     389    Window              m_wndProxy;
     390    Window              m_wndCur;
    399391    long                m_curVer;
    400392    RTCList<Atom>       m_formats;
     
    418410{
    419411public:
    420     DragAndDropService()
     412    DragAndDropService(void)
    421413      : m_pDisplay(0)
    422414      , m_hHGCMThread(NIL_RTTHREAD)
     
    433425    virtual int run(bool fDaemonised = false);
    434426
    435     virtual void cleanup()
     427    virtual void cleanup(void)
    436428    {
    437429        /* Cleanup */
    438430        x11DragAndDropTerm();
    439         VbglR3DnDTerm();
    440431    };
    441432
    442433private:
    443     int x11DragAndDropInit();
    444     int x11DragAndDropTerm();
     434    int x11DragAndDropInit(void);
     435    int x11DragAndDropTerm(void);
    445436    static int hgcmEventThread(RTTHREAD hThread, void *pvUser);
    446437    static int x11EventThread(RTTHREAD hThread, void *pvUser);
     
    451442     * Unfortunately this doesn't work exactly with the events we need. So we
    452443     * use this predicate method below and XCheckIfEvent. */
    453     static Bool isDnDRespondEvent(Display * /* pDisplay */, XEvent *pEvent, char *pUser)
     444    static bool isDnDRespondEvent(Display * /* pDisplay */, XEvent *pEvent, char *pUser)
    454445    {
    455446        if (!pEvent)
    456             return False;
     447            return false;
    457448        if (   pEvent->type == SelectionClear
    458449            || pEvent->type == ClientMessage
     
    463454//            || (   pEvent->type == SelectionRequest
    464455//                && reinterpret_cast<XSelectionRequestEvent*>(pEvent)->requestor == reinterpret_cast<Window>(pUser)))
    465             return True;
    466         return False;
     456            return true;
     457        return false;
    467458    }
    468459
     
    487478
    488479DragInstance::DragInstance(Display *pDisplay, DragAndDropService *pParent)
    489   : m_pParent(pParent)
     480  : m_uClientID(0)
     481  , m_pParent(pParent)
    490482  , m_pDisplay(pDisplay)
    491483  , m_pScreen(0)
    492   , m_rootWin(0)
    493   , m_proxyWin(0)
    494   , m_curWin(0)
     484  , m_wndRoot(0)
     485  , m_wndProxy(0)
     486  , m_wndCur(0)
    495487  , m_curVer(-1)
    496488  , m_mode(Unknown)
     
    500492}
    501493
    502 void DragInstance::uninit()
     494void DragInstance::uninit(void)
    503495{
    504496    reset();
    505     if (m_proxyWin != 0)
    506         XDestroyWindow(m_pDisplay, m_proxyWin);
     497    if (m_wndProxy != 0)
     498        XDestroyWindow(m_pDisplay, m_wndProxy);
     499
     500    if (m_uClientID)
     501    {
     502        VbglR3DnDDisconnect(m_uClientID);
     503        m_uClientID = 0;
     504    }
     505
    507506    m_state    = Uninitialized;
    508507    m_screenId = -1;
    509508    m_pScreen  = 0;
    510     m_rootWin  = 0;
    511     m_proxyWin = 0;
    512 }
    513 
    514 void DragInstance::reset()
     509    m_wndRoot  = 0;
     510    m_wndProxy = 0;
     511}
     512
     513void DragInstance::reset(void)
    515514{
    516515    /* Hide the proxy win. */
     
    518517    /* If we are currently the Xdnd selection owner, clear that. */
    519518    Window w = XGetSelectionOwner(m_pDisplay, xAtom(XA_XdndSelection));
    520     if (w == m_proxyWin)
     519    if (w == m_wndProxy)
    521520        XSetSelectionOwner(m_pDisplay, xAtom(XA_XdndSelection), None, CurrentTime);
    522521    /* Clear any other DnD specific data on the proxy win. */
    523     clearFormatsWindowProperty(m_proxyWin);
    524     clearActionsWindowProperty(m_proxyWin);
     522    clearFormatsWindowProperty(m_wndProxy);
     523    clearActionsWindowProperty(m_wndProxy);
    525524    /* Reset the internal state. */
    526525    m_formats.clear();
    527     m_curWin = 0;
     526    m_wndCur = 0;
    528527    m_curVer = -1;
    529528    m_state  = Initialized;
     
    546545int DragInstance::init(uint32_t u32ScreenId)
    547546{
    548     int rc = VINF_SUCCESS;
     547    int rc;
     548
    549549    do
    550550    {
    551551        uninit();
    552         /* Enough screens configured in the x11 server? */
     552
     553        rc = VbglR3DnDConnect(&m_uClientID);
     554        if (RT_FAILURE(rc))
     555            break;
     556
     557        /*
     558         * Enough screens configured in the x11 server?
     559         */
    553560        if ((int)u32ScreenId > ScreenCount(m_pDisplay))
    554561        {
    555             rc = VERR_GENERAL_FAILURE;
     562            rc = VERR_INVALID_PARAMETER;
    556563            break;
    557564        }
     
    565572        m_screenId = u32ScreenId;
    566573        /* Now query the corresponding root window of this screen. */
    567         m_rootWin = RootWindow(m_pDisplay, m_screenId);
    568         if (!m_rootWin)
     574        m_wndRoot = RootWindow(m_pDisplay, m_screenId);
     575        if (!m_wndRoot)
    569576        {
    570577            rc = VERR_GENERAL_FAILURE;
    571578            break;
    572579        }
    573         /* Create an invisible window which will act as proxy for the DnD
     580
     581        /*
     582         * Create an invisible window which will act as proxy for the DnD
    574583         * operation. This window will be used for both the GH and HG
    575          * direction. */
     584         * direction.
     585         */
    576586        XSetWindowAttributes attr;
    577587        RT_ZERO(attr);
    578588        attr.do_not_propagate_mask = 0;
    579589        attr.override_redirect     = True;
    580 //        attr.background_pixel      = WhitePixel(m_pDisplay, m_screenId);
    581         m_proxyWin = XCreateWindow(m_pDisplay, m_rootWin, 0, 0, 1, 1, 0,
     590#if 0
     591        attr.background_pixel      = WhitePixel(m_pDisplay, m_screenId);
     592#endif
     593        m_wndProxy = XCreateWindow(m_pDisplay, m_wndRoot, 0, 0, 1, 1, 0,
    582594                                   CopyFromParent, InputOnly, CopyFromParent,
    583595                                   CWOverrideRedirect | CWDontPropagate,
    584596                                   &attr);
    585 
    586 //        m_proxyWin = XCreateSimpleWindow(m_pDisplay, m_rootWin, 0, 0, 50, 50, 0, WhitePixel(m_pDisplay, m_screenId), WhitePixel(m_pDisplay, m_screenId));
    587 
    588         if (!m_proxyWin)
     597#ifdef DEBUG_andy
     598        m_wndProxy = XCreateSimpleWindow(m_pDisplay, m_wndRoot, 0, 0, 50, 50, 0,
     599                                         WhitePixel(m_pDisplay, m_screenId),
     600                                         WhitePixel(m_pDisplay, m_screenId));
     601#endif
     602        if (!m_wndProxy)
    589603        {
    590604            rc = VERR_GENERAL_FAILURE;
    591605            break;
    592606        }
     607
    593608        /* Make the new window Xdnd aware. */
    594609        Atom ver = VBOX_XDND_VERSION;
    595         XChangeProperty(m_pDisplay, m_proxyWin, xAtom(XA_XdndAware), XA_ATOM, 32, PropModeReplace,
     610        XChangeProperty(m_pDisplay, m_wndProxy, xAtom(XA_XdndAware), XA_ATOM, 32, PropModeReplace,
    596611                        reinterpret_cast<unsigned char*>(&ver), 1);
    597612    } while (0);
    598613
    599     m_state = Initialized;
    600 
     614    if (RT_SUCCESS(rc))
     615        m_state = Initialized;
     616
     617    LogFlowFuncLeaveRC(rc);
    601618    return rc;
    602619}
     
    606623 */
    607624
    608 int DragInstance::hgEnter(const RTCList<RTCString> &formats, uint32_t actions)
    609 {
    610     int rc = VINF_SUCCESS;
    611 
     625int DragInstance::hgEnter(const RTCList<RTCString> &formats, uint32_t uActions)
     626{
    612627    reset();
    613     DO(("DnD_ENTR: formats=%u: ", formats.size()));
    614 #if defined(VERBOSE) && defined(DEBUG_poetzsch)
     628
     629#ifdef DEBUG
     630    LogFlowThisFunc(("uActions=0x%x, lstFormats=%zu: ", uActions, formats.size()));
    615631    for (size_t i = 0; i < formats.size(); ++i)
    616         DO(("'%s' ", formats.at(i).c_str()));
    617 #endif /* DEBUG */
    618     DO(("\n"));
     632        LogFlow(("'%s' ", formats.at(i).c_str()));
     633    LogFlow(("\n"));
     634#endif
    619635
    620636    m_formats = toAtomList(formats);
     
    622638    /* If we have more than 3 formats we have to use the type list extension. */
    623639    if (m_formats.size() > 3)
    624         setFormatsWindowProperty(m_proxyWin, xAtom(XA_XdndTypeList));
     640        setFormatsWindowProperty(m_wndProxy, xAtom(XA_XdndTypeList));
    625641
    626642    /* Announce the possible actions */
    627     setActionsWindowProperty(m_proxyWin, toX11Actions(actions));
     643    setActionsWindowProperty(m_wndProxy, toX11Actions(uActions));
    628644
    629645    /* Set the DnD selection owner to our window. */
    630     XSetSelectionOwner(m_pDisplay, xAtom(XA_XdndSelection), m_proxyWin, CurrentTime);
     646    XSetSelectionOwner(m_pDisplay, xAtom(XA_XdndSelection), m_wndProxy, CurrentTime);
    631647
    632648    m_mode  = HG;
    633649    m_state = Dragging;
    634650
    635     return rc;
    636 }
    637 
    638 int DragInstance::hgMove(uint32_t u32xPos, uint32_t u32yPos, uint32_t action)
    639 {
    640     DO(("DnD_MOVE: "));
     651    return VINF_SUCCESS;
     652}
     653
     654int DragInstance::hgMove(uint32_t u32xPos, uint32_t u32yPos, uint32_t uAction)
     655{
     656    LogFlowThisFunc(("u32xPos=%RU32, u32yPos=%RU32, uAction=%RU32\n",
     657                     u32xPos, u32yPos, uAction));
    641658
    642659    if (   m_mode  != HG
     
    650667    moveCursor(u32xPos, u32yPos);
    651668
    652     Window newWin = None; /* Default to _no_ window below the cursor. */
    653     long   newVer = -1;   /* This means the current window is _not_ XdndAware. */
     669    long newVer = -1; /* This means the current window is _not_ XdndAware. */
    654670
    655671    /* Search for the application window below the cursor. */
    656     newWin = gX11->applicationWindowBelowCursor(m_rootWin);
    657     if (newWin != None)
     672    Window wndCursor = gX11->applicationWindowBelowCursor(m_wndRoot);
     673    if (wndCursor != None)
    658674    {
    659675        /* Temp stuff for the XGetWindowProperty call. */
     
    662678        unsigned long cItems, cbRemaining;
    663679        unsigned char *pcData = NULL;
     680
    664681        /* Query the XdndAware property from the window. We are interested in
    665682         * the version and if it is XdndAware at all. */
    666         xrc = XGetWindowProperty(m_pDisplay, newWin, xAtom(XA_XdndAware), 0, 2, False, AnyPropertyType, &atmp, &fmt, &cItems, &cbRemaining, &pcData);
     683        xrc = XGetWindowProperty(m_pDisplay, wndCursor, xAtom(XA_XdndAware),
     684                                 0, 2, False, AnyPropertyType,
     685                                 &atmp, &fmt, &cItems, &cbRemaining, &pcData);
    667686        if (RT_UNLIKELY(xrc != Success))
    668             DO(("DnD_MOVE: error in getting the window property (%s)\n", gX11->xErrorToString(xrc).c_str()));
     687            LogFlowThisFunc(("Error in getting the window property: %s\n", gX11->xErrorToString(xrc).c_str()));
    669688        else
    670689        {
    671690            if (RT_UNLIKELY(pcData == NULL || fmt != 32 || cItems != 1))
    672                 DO(("Prop=error[data=%#x,fmt=%u,items=%u] ", pcData, fmt, cItems));
     691                LogFlowThisFunc(("Wrong properties pcData=%#x, iFmt=%u, cItems=%u\n", pcData, fmt, cItems));
    673692            else
    674693            {
    675694                newVer = reinterpret_cast<long*>(pcData)[0];
    676                 DO(("XdndAware=%u ", newVer));
     695                LogFlowThisFunc(("wndCursor=%#x, XdndAware=%u\n", newVer));
    677696            }
    678697            XFree(pcData);
     
    680699    }
    681700
    682     if (newWin != m_curWin && m_curVer != -1)
    683     {
    684         DO(("leave=%#x ", m_curWin));
     701    /*
     702     * Is the window under the cursor another one than our current one?
     703     */
     704    if (wndCursor != m_wndCur && m_curVer != -1)
     705    {
     706        LogFlowThisFunc(("Leaving window=%#x\n", m_wndCur));
    685707
    686708        /* We left the current XdndAware window. Announce this to the window. */
    687 
    688709        XClientMessageEvent m;
    689710        RT_ZERO(m);
    690711        m.type         = ClientMessage;
    691712        m.display      = m_pDisplay;
    692         m.window       = m_curWin;
     713        m.window       = m_wndCur;
    693714        m.message_type = xAtom(XA_XdndLeave);
    694715        m.format       = 32;
    695         m.data.l[0]    = m_proxyWin;
    696 
    697         xrc = XSendEvent(m_pDisplay, m_curWin, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
     716        m.data.l[0]    = m_wndProxy;
     717
     718        xrc = XSendEvent(m_pDisplay, m_wndCur, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    698719        if (RT_UNLIKELY(xrc == 0))
    699             DO(("DnD_MOVE: error sending xevent\n"));
    700     }
    701 
    702     if (newWin != m_curWin && newVer != -1)
    703     {
    704         DO(("enter=%#x ", newWin));
    705 
    706         /* We enter a new window. Announce the XdndEnter event to the new
     720            LogFlowThisFunc(("Error sending XA_XdndLeave to old window=%#x\n", m_wndCur));
     721    }
     722
     723    /*
     724     * Do we have a new window which now is under the cursor?
     725     */
     726    if (wndCursor != m_wndCur && newVer != -1)
     727    {
     728        LogFlowThisFunc(("Entering window=%#x\n", wndCursor));
     729
     730        /*
     731         * We enter a new window. Announce the XdndEnter event to the new
    707732         * window. The first three mime types are attached to the event (the
    708733         * others could be requested by the XdndTypeList property from the
    709          * window itself). */
    710 
     734         * window itself).
     735         */
    711736        XClientMessageEvent m;
    712737        RT_ZERO(m);
    713738        m.type         = ClientMessage;
    714739        m.display      = m_pDisplay;
    715         m.window       = newWin;
     740        m.window       = wndCursor;
    716741        m.message_type = xAtom(XA_XdndEnter);
    717742        m.format       = 32;
    718         m.data.l[0]    = m_proxyWin;
     743        m.data.l[0]    = m_wndProxy;
    719744        m.data.l[1]    = RT_MAKE_U32_FROM_U8(m_formats.size() > 3 ? 1 : 0, 0, 0, RT_MIN(VBOX_XDND_VERSION, newVer));
    720745        m.data.l[2]    = m_formats.value(0, None);
     
    722747        m.data.l[4]    = m_formats.value(2, None);
    723748
    724         xrc = XSendEvent(m_pDisplay, newWin, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
     749        xrc = XSendEvent(m_pDisplay, wndCursor, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    725750        if (RT_UNLIKELY(xrc == 0))
    726             DO(("DnD_MOVE: error sending xevent\n"));
     751            LogFlowThisFunc(("Error sending XA_XdndEnter to new window=%#x\n", wndCursor));
    727752    }
    728753
    729754    if (newVer != -1)
    730755    {
    731         DO(("move=%#x pos=%ux%u ", newWin, u32xPos, u32yPos));
    732 
    733         /* Send a XdndPosition event with the proposed action to the guest. */
    734 
    735         Atom pa = toX11Action(action);
    736         DO(("action='%s' ", xAtomToString(pa).c_str()));
     756        LogFlowThisFunc(("Moving window=%#x, xPos=%RU32, yPos=%RU32\n",
     757                         wndCursor, u32xPos, u32yPos));
     758
     759        /*
     760         * Send a XdndPosition event with the proposed action to the guest.
     761         */
     762        Atom pa = toX11Action(uAction);
     763        LogFlowThisFunc(("strAction='%s' ", xAtomToString(pa).c_str()));
    737764
    738765        XClientMessageEvent m;
     
    740767        m.type         = ClientMessage;
    741768        m.display      = m_pDisplay;
    742         m.window       = newWin;
     769        m.window       = wndCursor;
    743770        m.message_type = xAtom(XA_XdndPosition);
    744771        m.format       = 32;
    745         m.data.l[0]    = m_proxyWin;
     772        m.data.l[0]    = m_wndProxy;
    746773        m.data.l[2]    = RT_MAKE_U32(u32yPos, u32xPos);
    747774        m.data.l[3]    = CurrentTime;
    748775        m.data.l[4]    = pa;
    749776
    750         xrc = XSendEvent(m_pDisplay, newWin, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
     777        xrc = XSendEvent(m_pDisplay, wndCursor, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    751778        if (RT_UNLIKELY(xrc == 0))
    752             DO(("DnD_MOVE: error sending xevent\n"));
    753     }
    754     if (newWin == None && newVer == -1)
     779            LogFlowThisFunc(("Error sending XA_XdndPosition to window=%#x\n", wndCursor));
     780    }
     781
     782    if (wndCursor == None && newVer == -1)
     783    {
    755784        /* No window to process, so send a ignore ack event to the host. */
    756         rc = VbglR3DnDHGAcknowledgeOperation(DND_IGNORE_ACTION);
    757 
    758     m_curWin = newWin;
     785        rc = VbglR3DnDHGAcknowledgeOperation(m_uClientID, DND_IGNORE_ACTION);
     786    }
     787
     788    m_wndCur = wndCursor;
    759789    m_curVer = RT_MIN(VBOX_XDND_VERSION, newVer);
    760790
    761     DO(("\n"));
    762 
     791    LogFlowFuncLeaveRC(rc);
    763792    return rc;
    764793}
     
    774803    int rc = VINF_SUCCESS;
    775804    if (   e.xclient.message_type == xAtom(XA_XdndStatus)
    776         && m_curWin               == static_cast<Window>(e.xclient.data.l[0]))
     805        && m_wndCur               == static_cast<Window>(e.xclient.data.l[0]))
    777806    {
    778807        /* The XdndStatus message tell us if the window will accept the DnD
    779808         * event and with which action. We immediately send this info down to
    780809         * the host as a response of a previous DnD message. */
    781         DO(("DnD_STAT: win=%#x,accept=%RTbool,action='%s'\n",
    782             e.xclient.data.l[0],
    783             ASMBitTest(&e.xclient.data.l[1], 0),
    784             xAtomToString(e.xclient.data.l[4]).c_str()));
     810        LogFlowThisFunc(("XA_XdndStatus wnd=%#x, accept=%RTbool, action='%s'\n",
     811                         e.xclient.data.l[0],
     812                         ASMBitTest(&e.xclient.data.l[1], 0),
     813                         xAtomToString(e.xclient.data.l[4]).c_str()));
     814
    785815        uint32_t uAction = DND_IGNORE_ACTION;
    786         /* Todo: compare this with the allowed actions. */
     816        /** @todo Compare this with the allowed actions. */
    787817        if (ASMBitTest(&e.xclient.data.l[1], 0))
    788818            uAction = toHGCMAction(static_cast<Atom>(e.xclient.data.l[4]));
    789         rc = VbglR3DnDHGAcknowledgeOperation(uAction);
     819
     820        rc = VbglR3DnDHGAcknowledgeOperation(m_uClientID, uAction);
    790821    }
    791822    else if (e.xclient.message_type == xAtom(XA_XdndFinished))
    792823    {
    793824        /* This message is send on a un/successful DnD drop request. */
    794         DO(("DnD_FINI: win=%#x,success=%RTbool,action='%s'\n",
     825        LogFlowThisFunc(("XA_XdndFinished: wnd=%#x, success=%RTbool, action='%s'\n",
    795826            e.xclient.data.l[0],
    796827            ASMBitTest(&e.xclient.data.l[1], 0),
    797828            xAtomToString(e.xclient.data.l[2]).c_str()));
     829
    798830        reset();
    799831    }
    800832    else
    801         DO(("DnD_CLI: win=%#x,msg='%s'\n", e.xclient.data.l[0], xAtomToString(e.xclient.message_type).c_str()));
     833        LogFlowThisFunc(("Unhandled: wnd=%#x, msg='%s'\n",
     834                         e.xclient.data.l[0], xAtomToString(e.xclient.message_type).c_str()));
     835
     836    LogFlowFuncLeaveRC(rc);
    802837    return rc;
    803838}
    804839
    805 int DragInstance::hgDrop()
    806 {
    807     DO(("DnD_DROP: win=%#x\n", m_curWin));
     840int DragInstance::hgDrop(void)
     841{
     842    LogFlowThisFunc(("wndCur=%#x, mMode=%RU32, mState=%RU32\n",
     843                     m_wndCur, m_mode, m_state));
    808844
    809845    if (   m_mode  != HG
     
    818854    m.type         = ClientMessage;
    819855    m.display      = m_pDisplay;
    820     m.window       = m_curWin;
     856    m.window       = m_wndCur;
    821857    m.message_type = xAtom(XA_XdndDrop);
    822858    m.format       = 32;
    823     m.data.l[0]    = m_proxyWin;
     859    m.data.l[0]    = m_wndProxy;
    824860    m.data.l[2]    = CurrentTime;
    825861
    826     int xrc = XSendEvent(m_pDisplay, m_curWin, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
     862    int xrc = XSendEvent(m_pDisplay, m_wndCur, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    827863    if (RT_UNLIKELY(xrc == 0))
    828         DO(("DnD_DROP: error sending xevent\n"));
    829 
    830     m_curWin = None;
     864        LogFlowThisFunc(("Error sending XA_XdndDrop to window=%#x\n", m_wndCur));
     865
     866    m_wndCur = None;
    831867    m_curVer = -1;
    832868
    833869    m_state = Dropped;
    834870
     871    LogFlowFuncLeaveRC(rc);
    835872    return rc;
    836873}
     
    844881        return VERR_INVALID_STATE;
    845882
    846     DO(("DnD_SELR: owner=%#x,requestor=%#x,sel_atom='%s',tar_atom='%s',prop_atom='%s',time=%u\n",
    847         e.xselectionrequest.owner,
    848         e.xselectionrequest.requestor,
    849         xAtomToString(e.xselectionrequest.selection).c_str(),
    850         xAtomToString(e.xselectionrequest.target).c_str(),
    851         xAtomToString(e.xselectionrequest.property).c_str(),
    852         e.xselectionrequest.time));
     883    LogFlowThisFunc(("owner=%#x, requestor=%#x, sel_atom='%s', tar_atom='%s', prop_atom='%s', time=%u\n",
     884                     e.xselectionrequest.owner,
     885                     e.xselectionrequest.requestor,
     886                     xAtomToString(e.xselectionrequest.selection).c_str(),
     887                     xAtomToString(e.xselectionrequest.target).c_str(),
     888                     xAtomToString(e.xselectionrequest.property).c_str(),
     889                     e.xselectionrequest.time));
    853890
    854891    int rc = VINF_SUCCESS;
    855892
    856     /* A window is asking for some data. Normally here the data would be copied
     893    /*
     894     * A window is asking for some data. Normally here the data would be copied
    857895     * into the selection buffer and send to the requestor. Obviously we can't
    858896     * do that, cause we first need to ask the host for the data of the
    859897     * requested mime type. This is done and later answered with the correct
    860      * data (s. dataReceived). */
     898     * data (s. dataReceived).
     899     */
    861900
    862901    /* Is the requestor asking for the possible mime types? */
    863902    if(e.xselectionrequest.target == xAtom(XA_TARGETS))
    864903    {
    865         DO(("DnD_SELR: ask for target list\n"));
     904        LogFlowThisFunc(("wnd=%#x asking for target list\n", e.xselectionrequest.requestor));
     905
    866906        /* If so, set the window property with the formats on the requestor
    867907         * window. */
    868908        setFormatsWindowProperty(e.xselectionrequest.requestor, e.xselectionrequest.property);
     909
    869910        XEvent s;
    870911        RT_ZERO(s);
     
    876917        s.xselection.target    = e.xselectionrequest.target;
    877918        s.xselection.property  = e.xselectionrequest.property;
     919
    878920        int xrc = XSendEvent(e.xselection.display, e.xselectionrequest.requestor, False, 0, &s);
    879921        if (RT_UNLIKELY(xrc == 0))
    880             DO(("DnD_SELR: error sending xevent\n"));
     922            LogFlowThisFunc(("Error sending SelectionNotify event to wnd=%#x\n", e.xselectionrequest.requestor));
    881923    }
    882924    /* Is the requestor asking for a specific mime type (we support)? */
    883925    else if(m_formats.contains(e.xselectionrequest.target))
    884926    {
    885         DO(("DnD_SELR: ask for data (format='%s')\n", xAtomToString(e.xselectionrequest.target).c_str()));
     927        LogFlowThisFunc(("wnd=%#x asking for data (format='%s')\n",
     928                         e.xselectionrequest.requestor, xAtomToString(e.xselectionrequest.target).c_str()));
     929
    886930        /* If so, we need to inform the host about this request. Save the
    887931         * selection request event for later use. */
     
    889933            //        || m_curWin != e.xselectionrequest.requestor)
    890934        {
    891             DO(("DnD_SELR: refuse\n"));
     935            LogFlowThisFunc(("Refusing ...\n"));
     936
    892937            XEvent s;
    893938            RT_ZERO(s);
     
    899944            s.xselection.target    = None;
    900945            s.xselection.property  = e.xselectionrequest.property;
     946
    901947            int xrc = XSendEvent(e.xselection.display, e.xselectionrequest.requestor, False, 0, &s);
    902948            if (RT_UNLIKELY(xrc == 0))
    903                 DO(("DnD_SELR: error sending xevent\n"));
     949                LogFlowThisFunc(("Error sending SelectionNotify event to wnd=%#x\n", e.xselectionrequest.requestor));
    904950        }
    905951        else
    906952        {
     953            LogFlowThisFunc(("Copying data from host ...\n"));
     954
    907955            memcpy(&m_selEvent, &e, sizeof(XEvent));
    908             rc = VbglR3DnDHGRequestData(xAtomToString(e.xselectionrequest.target).c_str());
     956            rc = VbglR3DnDHGRequestData(m_uClientID, xAtomToString(e.xselectionrequest.target).c_str());
    909957        }
    910958    }
     
    912960    else
    913961    {
    914         DO(("DnD_SELR: refuse\n"));
     962        LogFlowThisFunc(("Refusing unknown command\n"));
     963
    915964        /* We don't understand this request message and therefore answer with an
    916965         * refusal messages. */
     
    926975        int xrc = XSendEvent(e.xselection.display, e.xselectionrequest.requestor, False, 0, &s);
    927976        if (RT_UNLIKELY(xrc == 0))
    928             DO(("DnD_SELR: error sending xevent\n"));
    929     }
    930 
     977            LogFlowThisFunc(("Error sending SelectionNotify event to wnd=%#x\n", e.xselectionrequest.requestor));
     978    }
     979
     980    LogFlowFuncLeaveRC(rc);
    931981    return rc;
    932982}
     
    9511001    memcpy(pvNewData, pvData, cData);
    9521002
    953     /* The host send us the DnD data in the requested mime type. This allows us
     1003    /*
     1004     * The host send us the DnD data in the requested mime type. This allows us
    9541005     * to fill the XdndSelection property of the requestor window with the data
    955      * and afterwards inform him about the new status. */
     1006     * and afterwards inform him about the new status.
     1007     */
    9561008    XEvent s;
    9571009    RT_ZERO(s);
     
    9651017    s.xselection.property  = m_selEvent.xselectionrequest.property;
    9661018
    967     DO(("DnD_SEND: owner=%#x,requestor=%#x,sel_atom='%s',tar_atom='%s',prop_atom='%s',time=%u\n",
    968         m_selEvent.xselectionrequest.owner,
    969         s.xselection.requestor,
    970         xAtomToString(s.xselection.selection).c_str(),
    971         xAtomToString(s.xselection.target).c_str(),
    972         xAtomToString(s.xselection.property).c_str(),
    973         s.xselection.time));
     1019    LogFlowThisFunc(("owner=%#x,requestor=%#x,sel_atom='%s',tar_atom='%s',prop_atom='%s',time=%u\n",
     1020                     m_selEvent.xselectionrequest.owner,
     1021                     s.xselection.requestor,
     1022                     xAtomToString(s.xselection.selection).c_str(),
     1023                     xAtomToString(s.xselection.target).c_str(),
     1024                     xAtomToString(s.xselection.property).c_str(),
     1025                     s.xselection.time));
    9741026
    9751027    /* Fill up the property with the data. */
     
    9781030    int xrc = XSendEvent(s.xselection.display, s.xselection.requestor, True, 0, &s);
    9791031    if (RT_UNLIKELY(xrc == 0))
    980         DO(("DnD_SEND: error sending xevent\n"));
     1032        LogFlowThisFunc(("Error sending SelectionNotify event to wnd=%#x\n", s.xselection.requestor));
    9811033
    9821034    return VINF_SUCCESS;
     
    9891041 */
    9901042
    991 int DragInstance::ghIsDnDPending()
     1043int DragInstance::ghIsDnDPending(void)
    9921044{
    9931045    int rc = VINF_SUCCESS;
    994     Window w = XGetSelectionOwner(m_pDisplay, xAtom(XA_XdndSelection));
    995     DO(("Checking pending %X %X\n", w, m_proxyWin));
     1046    Window wndOwner = XGetSelectionOwner(m_pDisplay, xAtom(XA_XdndSelection));
     1047    LogFlowThisFunc(("Checking pending wndOwner=%#x wndProxy=%#x\n", wndOwner, m_wndProxy));
     1048
    9961049    /* Is there someone own the Xdnd selection which aren't we. */
    997     if (   w
    998         && w != m_proxyWin)
     1050    if (   wndOwner
     1051        && wndOwner != m_wndProxy)
    9991052    {
    10001053        /* Map the window on the current cursor position, which should provoke
     
    10071060            int xrc = Success;
    10081061            XClientMessageEvent *clme = reinterpret_cast<XClientMessageEvent*>(&e);
    1009             DO(("next X event %s\n", gX11->xAtomToString(clme->message_type).c_str()));
     1062            LogFlowThisFunc(("Next X event %s\n", gX11->xAtomToString(clme->message_type).c_str()));
    10101063            if (clme->message_type == xAtom(XA_XdndEnter))
    10111064            {
     
    10181071                m_formats.clear();
    10191072                m_actions.clear();
    1020                 m_curWin = w;
    1021                 DO(("XA_XdndEnter\n"));
     1073                m_wndCur = wndOwner;
     1074                LogFlowThisFunc(("XA_XdndEnter\n"));
    10221075                /* Check if the mime types are in the msg itself or if we need
    10231076                 * to fetch the XdndTypeList property from the window. */
     
    10261079                    for (int i = 2; i < 5; ++i)
    10271080                    {
    1028                         DO(("receive list msg: %s\n", gX11->xAtomToString(clme->data.l[i]).c_str()));
     1081                        LogFlowThisFunc(("Receive list msg: %s\n", gX11->xAtomToString(clme->data.l[i]).c_str()));
    10291082                        m_formats.append(clme->data.l[i]);
    10301083                    }
     
    10321085                else
    10331086                {
    1034                     xrc = XGetWindowProperty(m_pDisplay, w, xAtom(XA_XdndTypeList), 0, VBOX_MAX_XPROPERTIES, False, XA_ATOM, &type, &f, &n, &a, &ret);
     1087                    xrc = XGetWindowProperty(m_pDisplay, wndOwner, xAtom(XA_XdndTypeList), 0, VBOX_MAX_XPROPERTIES, False, XA_ATOM, &type, &f, &n, &a, &ret);
    10351088                    if (   xrc == Success
    10361089                        && n > 0
     
    10401093                        for (int i = 0; i < RT_MIN(VBOX_MAX_XPROPERTIES, n); ++i)
    10411094                        {
    1042                             DO(("receive list: %s\n", gX11->xAtomToString(data[i]).c_str()));
     1095                            LogFlowThisFunc(("Receive list: %s\n", gX11->xAtomToString(data[i]).c_str()));
    10431096                            m_formats.append(data[i]);
    10441097                        }
     
    10471100                }
    10481101                /* Fetch the possible list of actions, if this property is set. */
    1049                 xrc = XGetWindowProperty(m_pDisplay, w, xAtom(XA_XdndActionList), 0, VBOX_MAX_XPROPERTIES, False, XA_ATOM, &type, &f, &n, &a, &ret);
     1102                xrc = XGetWindowProperty(m_pDisplay, wndOwner, xAtom(XA_XdndActionList), 0, VBOX_MAX_XPROPERTIES, False, XA_ATOM, &type, &f, &n, &a, &ret);
    10501103                if (   xrc == Success
    10511104                    && n > 0
     
    10551108                    for (int i = 0; i < RT_MIN(VBOX_MAX_XPROPERTIES, n); ++i)
    10561109                    {
    1057                         DO(("receive actions: %s\n", gX11->xAtomToString(data[i]).c_str()));
     1110                        LogFlowThisFunc(("Receive actions: %s\n", gX11->xAtomToString(data[i]).c_str()));
    10581111                        m_actions.append(data[i]);
    10591112                    }
     
    10721125                m.message_type = xAtom(XA_XdndStatus);
    10731126                m.format       = 32;
    1074                 m.data.l[0]    = m_proxyWin;
     1127                m.data.l[0]    = m_wndProxy;
    10751128                m.data.l[1]    = 1;
    10761129                m.data.l[4]    = xAtom(XA_XdndActionCopy);
    10771130                xrc = XSendEvent(m_pDisplay, clme->data.l[0], False, 0, reinterpret_cast<XEvent*>(&m));
    10781131                if (RT_UNLIKELY(xrc == 0))
    1079                     DO(("DnD_PNDG: error sending xevent\n"));
     1132                    LogFlowThisFunc(("Error sending xevent\n"));
    10801133            }
    10811134            else if (clme->message_type == xAtom(XA_XdndPosition))
    10821135            {
    1083                 DO(("XA_XdndPosition\n"));
     1136                LogFlowThisFunc(("XA_XdndPosition\n"));
    10841137                XClientMessageEvent m;
    10851138                RT_ZERO(m);
     
    10891142                m.message_type = xAtom(XA_XdndStatus);
    10901143                m.format       = 32;
    1091                 m.data.l[0]    = m_proxyWin;
     1144                m.data.l[0]    = m_wndProxy;
    10921145                m.data.l[1]    = 1;
    10931146                m.data.l[4]    = clme->data.l[4];
    10941147                xrc = XSendEvent(m_pDisplay, clme->data.l[0], False, 0, reinterpret_cast<XEvent*>(&m));
    10951148                if (RT_UNLIKELY(xrc == 0))
    1096                     DO(("DnD_PNDG: error sending xevent\n"));
     1149                    LogFlowThisFunc(("Error sending xevent\n"));
    10971150            }
    10981151            else if (clme->message_type == xAtom(XA_XdndLeave))
     
    11021155        hideProxyWin();
    11031156
    1104         rc = VbglR3DnDGHAcknowledgePending(DND_COPY_ACTION, toHGCMActions(m_actions), gX11->xAtomListToString(m_formats).c_str());
    1105     }
     1157        rc = VbglR3DnDGHAcknowledgePending(DND_COPY_ACTION, toHGCMActions(m_actions),
     1158                                           gX11->xAtomListToString(m_formats).c_str());
     1159    }
     1160
     1161    LogFlowFuncLeaveRC(rc);
    11061162    return rc;
    11071163}
     
    11091165int DragInstance::ghDropped(const RTCString &strFormat, uint32_t action)
    11101166{
    1111     DO(("DND_DRO: format='%s' action=%d\n", strFormat.c_str(), action));
     1167    LogFlowThisFunc(("format='%s' action=%d\n", strFormat.c_str(), action));
    11121168    int rc = VINF_SUCCESS;
    11131169
     
    11181174    /* We send a fake release event to the current window, cause
    11191175     * this should have the grab. */
    1120     sendButtonEvent(m_curWin, rx, ry, 1, false);
     1176    sendButtonEvent(m_wndCur, rx, ry, 1, false);
    11211177    /* The fake button release event, should lead to an XdndDrop event from the
    11221178     * source. Because of the showing of the proxy window, sometimes other Xdnd
     
    11451201            /* Request to convert the selection in the specific format and
    11461202             * place it to our proxy window as property. */
    1147             Window srcWin = m_curWin;//clme->data.l[0];
     1203            Window srcWin = m_wndCur;//clme->data.l[0];
    11481204            Atom aFormat  = gX11->stringToxAtom(strFormat.c_str());
    1149             XConvertSelection(m_pDisplay, xAtom(XA_XdndSelection), aFormat, xAtom(XA_XdndSelection), m_proxyWin, clme->data.l[2]);
     1205            XConvertSelection(m_pDisplay, xAtom(XA_XdndSelection), aFormat, xAtom(XA_XdndSelection), m_wndProxy, clme->data.l[2]);
    11501206            /* Wait for the selection notify event. */
    11511207            RT_ZERO(e);
     
    11561212                    && e.xselection.display   == m_pDisplay
    11571213                    && e.xselection.selection == xAtom(XA_XdndSelection)
    1158                     && e.xselection.requestor == m_proxyWin
     1214                    && e.xselection.requestor == m_wndProxy
    11591215                    && e.xselection.target    == aFormat)
    11601216                {
    1161                     DO(("DND_DRO: selection notfiy (from: %x)\n", m_curWin));
     1217                    LogFlowThisFunc(("Selection notfiy (from: %x)\n", m_wndCur));
    11621218                    Atom type;
    11631219                    int format;
    11641220                    unsigned long cItems, cbRemaining;
    11651221                    unsigned char *ucData = 0;
    1166                     XGetWindowProperty(m_pDisplay, m_proxyWin, xAtom(XA_XdndSelection),
     1222                    XGetWindowProperty(m_pDisplay, m_wndProxy, xAtom(XA_XdndSelection),
    11671223                                       0, VBOX_MAX_XPROPERTIES, True, AnyPropertyType,
    11681224                                       &type, &format, &cItems, &cbRemaining, &ucData);
    1169                     DO(("DND_DRO: %s %d %d %s\n", gX11->xAtomToString(type).c_str(), cItems, format, ucData));
     1225                    LogFlowThisFunc(("%s %d %d %s\n", gX11->xAtomToString(type).c_str(), cItems, format, ucData));
    11701226                    if (   type        != None
    11711227                        && ucData      != NULL
     
    11811237                            && ucData[cbData - 1] != '\0')
    11821238                        {
    1183                             DO(("rebuild %u\n", cbData));
     1239                            LogFlowThisFunc(("Rebuild %u\n", cbData));
    11841240                            unsigned char *ucData1 = static_cast<unsigned char*>(RTMemAlloc(cbData + 1));
    11851241                            if (ucData1)
     
    11981254                            rc = VbglR3DnDGHSendData(ucData, cbData);
    11991255
    1200                         DO(("send responce\n"));
     1256                        LogFlowThisFunc(("send responce\n"));
    12011257                        /* Confirm the result of the transfer to the source window. */
    12021258                        XClientMessageEvent m;
     
    12071263                        m.message_type = xAtom(XA_XdndFinished);
    12081264                        m.format       = 32;
    1209                         m.data.l[0]    = m_proxyWin;
     1265                        m.data.l[0]    = m_wndProxy;
    12101266                        m.data.l[1]    = RT_SUCCESS(rc) ?                   1 : 0;    /* Confirm or deny success */
    12111267                        m.data.l[2]    = RT_SUCCESS(rc) ? toX11Action(action) : None; /* Action used on success */
     
    12131269                        int xrc = XSendEvent(m_pDisplay, srcWin, True, NoEventMask, reinterpret_cast<XEvent*>(&m));
    12141270                        if (RT_UNLIKELY(xrc == 0))
    1215                             DO(("DnD_DRO: error sending xevent\n"));
     1271                            LogFlowThisFunc(("Error sending xevent\n"));
    12161272                    }
    12171273                    else
     
    12361292                        m.message_type = xAtom(XA_XdndFinished);
    12371293                        m.format       = 32;
    1238                         m.data.l[0]    = m_proxyWin;
     1294                        m.data.l[0]    = m_wndProxy;
    12391295                        m.data.l[1]    = 0;
    12401296                        m.data.l[2]    = None;
    12411297                        int xrc = XSendEvent(m_pDisplay, srcWin, False, NoEventMask, reinterpret_cast<XEvent*>(&m));
    12421298                        if (RT_UNLIKELY(xrc == 0))
    1243                             DO(("DnD_DRO: error sending xevent\n"));
    1244                         m_curWin = 0;
     1299                            LogFlowThisFunc(("Error sending xevent\n"));
     1300                        m_wndCur = 0;
    12451301                    }
    12461302                    /* Cleanup */
     
    12681324    reset();
    12691325
     1326    LogFlowFuncLeaveRC(rc);
    12701327    return rc;
    12711328}
     
    12811338    /* Move the guest pointer to the DnD position, so we can find the window
    12821339     * below that position. */
    1283     XWarpPointer(m_pDisplay, None, m_rootWin, 0, 0, 0, 0, u32xPos, u32yPos);
     1340    XWarpPointer(m_pDisplay, None, m_wndRoot, 0, 0, 0, 0, u32xPos, u32yPos);
    12841341    return VINF_SUCCESS;
    12851342}
     
    12951352        RT_ZERO(be);
    12961353        be.display      = m_pDisplay;
    1297         be.root         = m_rootWin;
     1354        be.root         = m_wndRoot;
    12981355        be.window       = w;
    12991356        be.subwindow    = None;
     
    13121369        int xrc = XSendEvent(m_pDisplay, be.window, True, ButtonPressMask, reinterpret_cast<XEvent*>(&be));
    13131370        if (RT_UNLIKELY(xrc == 0))
    1314             DO(("DnD_BTN: error sending xevent\n"));
    1315     }
    1316 
     1371            LogFlowThisFunc(("Error sending xevent\n"));
     1372    }
    13171373}
    13181374
     
    13231379    Window r, c;
    13241380//    XTestGrabControl(m_pDisplay, False);
    1325     XQueryPointer(m_pDisplay, m_rootWin, &r, &c, &rx, &ry, &cx, &cy, &m);
     1381    XQueryPointer(m_pDisplay, m_wndRoot, &r, &c, &rx, &ry, &cx, &cy, &m);
    13261382    XSynchronize(m_pDisplay, True);
    1327     XMapWindow(m_pDisplay, m_proxyWin);
    1328     XRaiseWindow(m_pDisplay, m_proxyWin);
    1329     XMoveResizeWindow(m_pDisplay, m_proxyWin, rx, ry, 1, 1);
    1330     XWarpPointer(m_pDisplay, None, m_rootWin, 0, 0, 0, 0, rx , ry);
     1383    XMapWindow(m_pDisplay, m_wndProxy);
     1384    XRaiseWindow(m_pDisplay, m_wndProxy);
     1385    XMoveResizeWindow(m_pDisplay, m_wndProxy, rx, ry, 1, 1);
     1386    XWarpPointer(m_pDisplay, None, m_wndRoot, 0, 0, 0, 0, rx , ry);
    13311387    XSynchronize(m_pDisplay, False);
    13321388//    XTestGrabControl(m_pDisplay, True);
    13331389}
    13341390
    1335 void DragInstance::hideProxyWin() const
    1336 {
    1337     XUnmapWindow(m_pDisplay, m_proxyWin);
     1391void DragInstance::hideProxyWin(void) const
     1392{
     1393    XUnmapWindow(m_pDisplay, m_wndProxy);
    13381394}
    13391395
    13401396/* Currently, not used */
    1341 void DragInstance::registerForEvents(Window w) const
     1397void DragInstance::registerForEvents(Window wndThis) const
    13421398{
    13431399//    if (w == m_proxyWin)
    13441400//        return;
    13451401
    1346     DO(("%x\n", w));
     1402    LogFlowThisFunc(("%x\n", wndThis));
    13471403//    XSelectInput(m_pDisplay, w, Button1MotionMask | Button2MotionMask | Button3MotionMask | Button4MotionMask | Button5MotionMask);//| SubstructureNotifyMask);
    13481404//    XSelectInput(m_pDisplay, w, ButtonMotionMask); //PointerMotionMask);
    1349     XSelectInput(m_pDisplay, w, PointerMotionMask); //PointerMotionMask);
     1405    XSelectInput(m_pDisplay, wndThis, PointerMotionMask); //PointerMotionMask);
    13501406    Window hRealRoot, hParent;
    13511407    Window *phChildrenRaw = NULL;
    13521408    unsigned cChildren;
    1353     if (XQueryTree(m_pDisplay, w, &hRealRoot, &hParent, &phChildrenRaw, &cChildren))
     1409    if (XQueryTree(m_pDisplay, wndThis, &hRealRoot, &hParent, &phChildrenRaw, &cChildren))
    13541410    {
    13551411        for (unsigned i = 0; i < cChildren; ++i)
     
    13591415}
    13601416
    1361 void DragInstance::setActionsWindowProperty(Window win, const RTCList<Atom> &actionList) const
     1417void DragInstance::setActionsWindowProperty(Window wndThis, const RTCList<Atom> &actionList) const
    13621418{
    13631419    if (actionList.isEmpty())
    13641420        return;
    13651421
    1366     XChangeProperty(m_pDisplay, win, xAtom(XA_XdndActionList), XA_ATOM, 32, PropModeReplace,
     1422    XChangeProperty(m_pDisplay, wndThis, xAtom(XA_XdndActionList), XA_ATOM, 32, PropModeReplace,
    13671423                    reinterpret_cast<const unsigned char*>(actionList.raw()), actionList.size());
    13681424}
    13691425
    1370 void DragInstance::clearActionsWindowProperty(Window win) const
    1371 {
    1372     XDeleteProperty(m_pDisplay, win, xAtom(XA_XdndActionList));
    1373 }
    1374 
    1375 void DragInstance::setFormatsWindowProperty(Window win, Atom property) const
     1426void DragInstance::clearActionsWindowProperty(Window wndThis) const
     1427{
     1428    XDeleteProperty(m_pDisplay, wndThis, xAtom(XA_XdndActionList));
     1429}
     1430
     1431void DragInstance::setFormatsWindowProperty(Window wndThis, Atom property) const
    13761432{
    13771433    if (m_formats.isEmpty())
     
    13841440
    13851441    /* Add the property with the property data to the window. */
    1386     XChangeProperty(m_pDisplay, win, property, XA_ATOM, 32, PropModeReplace,
     1442    XChangeProperty(m_pDisplay, wndThis, property, XA_ATOM, 32, PropModeReplace,
    13871443                    reinterpret_cast<const unsigned char*>(targets.raw()), targets.size());
    13881444}
    13891445
    1390 void DragInstance::clearFormatsWindowProperty(Window win) const
    1391 {
    1392     XDeleteProperty(m_pDisplay, win, xAtom(XA_XdndTypeList));
     1446void DragInstance::clearFormatsWindowProperty(Window wndThis) const
     1447{
     1448    XDeleteProperty(m_pDisplay, wndThis, xAtom(XA_XdndTypeList));
    13931449}
    13941450
     
    14171473         * even if the data isn't zero terminated. */
    14181474        char *pszTmp = RTStrDupN(pszStr, cSize);
    1419         DO(("f: %s\n", pszTmp));
     1475        LogFlowThisFunc(("f: %s\n", pszTmp));
    14201476        atomList.append(XInternAtom(m_pDisplay, pszTmp, False));
    14211477        RTStrFree(pszTmp);
     
    15121568        if (!m_eventQueue.isEmpty())
    15131569        {
    1514             DO(("new msg size %d\n", m_eventQueue.size()));
     1570            LogFlowThisFunc(("new msg size %d\n", m_eventQueue.size()));
    15151571            /* Check if there is a client message in the queue. */
    15161572            for (size_t i = 0; i < m_eventQueue.size(); ++i)
     
    15181574                DnDEvent e = m_eventQueue.at(i);
    15191575                if(   e.type     == DnDEvent::X11_Type)
    1520                     DO(("new msg\n"));
     1576                    LogFlowThisFunc(("new msg\n"));
    15211577                if(   e.type     == DnDEvent::X11_Type
    15221578                   && e.x11.type == type)
     
    15511607    do
    15521608    {
    1553         /* Initialize our service */
    1554         rc = VbglR3DnDInit();
    1555         if (RT_FAILURE(rc))
    1556             break;
    1557 
    15581609        /* Initialize X11 DND */
    15591610        rc = x11DragAndDropInit();
     
    15621613
    15631614        m_pCurDnD = new DragInstance(m_pDisplay, this);
     1615        if (!m_pCurDnD)
     1616        {
     1617            rc = VERR_NO_MEMORY;
     1618            break;
     1619        }
    15641620        /* Note: For multiple screen support in VBox it is not necessary to use
    15651621         * another screen number than zero. Maybe in the future it will become
    15661622         * necessary if VBox supports multiple X11 screens. */
    1567         m_pCurDnD->init(0);
     1623        rc = m_pCurDnD->init(0);
     1624        if (RT_FAILURE(rc))
     1625            break;
     1626
    15681627        /* Loop over new events */
    15691628        do
     
    15771636                e = m_eventQueue.first();
    15781637                m_eventQueue.removeFirst();
    1579                 DO(("new msg %d\n", e.type));
     1638                LogFlowThisFunc(("new msg %d\n", e.type));
    15801639                if (e.type == DnDEvent::HGCM_Type)
    15811640                {
     
    16241683                        }
    16251684#endif
     1685                        default:
     1686                            LogFlowThisFunc(("Unknown message: %RU32\n", e.hgcm.uType));
     1687                            break;
    16261688                    }
     1689
    16271690                    /* Some messages require cleanup. */
    16281691                    switch (e.hgcm.uType)
     
    16471710                            break;
    16481711                        }
     1712                        default:
     1713                            break;
    16491714                    }
    1650 
    16511715                }
    16521716                else if(e.type == DnDEvent::X11_Type)
    16531717                {
    1654                     DO(("X11 type: %u\n", e.x11.type));
     1718                    LogFlowThisFunc(("X11 type: %u\n", e.x11.type));
    16551719                    /* Now the X11 event stuff */
    16561720                    switch (e.x11.type)
     
    16581722                        case SelectionRequest: m_pCurDnD->hgX11SelectionRequest(e.x11); break;
    16591723                        case ClientMessage:    m_pCurDnD->hgX11ClientMessage(e.x11); break;
    1660                         case SelectionClear:   DO(("DnD_CLER\n")); break;
     1724                        case SelectionClear:   LogFlowThisFunc(("DnD_CLER\n")); break;
    16611725//                      case MotionNotify: m_pCurDnD->hide(); break;
    16621726                    }
     
    16661730    } while (0);
    16671731
    1668     LogRelFlowFunc(("returning %Rrc\n", rc));
     1732    LogFlowFuncLeaveRC(rc);
    16691733    return rc;
    16701734}
    16711735
    1672 int DragAndDropService::x11DragAndDropInit()
     1736int DragAndDropService::x11DragAndDropInit(void)
    16731737{
    16741738    /* Connect to the x11 server. */
     
    16781742        return VERR_NOT_FOUND;
    16791743
    1680     xHelpers::instance(m_pDisplay);
     1744    xHelpers *pHelpers = xHelpers::getInstance(m_pDisplay);
     1745    if (!pHelpers)
     1746        return VERR_NO_MEMORY;
    16811747
    16821748    int rc = VINF_SUCCESS;
     
    17061772}
    17071773
    1708 int DragAndDropService::x11DragAndDropTerm()
     1774int DragAndDropService::x11DragAndDropTerm(void)
    17091775{
    17101776    /* Mark that we are stopping. */
     
    17241790        int xrc = XSendEvent(m_pDisplay, None, True, NoEventMask, reinterpret_cast<XEvent*>(&m));
    17251791        if (RT_UNLIKELY(xrc == 0))
    1726                 DO(("DnD_TERM: error sending xevent\n"));
     1792            LogFlowThisFunc(("Error sending xevent\n"));
    17271793    }
    17281794
     
    17551821    DragAndDropService *pThis = static_cast<DragAndDropService*>(pvUser);
    17561822    DnDEvent e;
     1823
     1824    uint32_t uClientID;
     1825    int rc = VbglR3DnDConnect(&uClientID);
     1826    if (RT_FAILURE(rc)) {
     1827        LogFlowFunc(("Unable to connect to HGCM service, rc=%Rrc\n", rc));
     1828        return rc;
     1829    }
     1830
    17571831    do
    17581832    {
     
    17601834        e.type = DnDEvent::HGCM_Type;
    17611835        /* Wait for new events */
    1762         int rc = VbglR3DnDProcessNextMessage(&e.hgcm);
     1836        rc = VbglR3DnDProcessNextMessage(uClientID, &e.hgcm);
    17631837        if (RT_SUCCESS(rc))
    17641838        {
     
    17691843        }
    17701844    } while (!ASMAtomicReadBool(&pThis->m_fSrvStopping));
     1845
     1846    VbglR3DnDDisconnect(uClientID);
    17711847
    17721848    return VINF_SUCCESS;
     
    18151891
    18161892/* Static factory */
    1817 VBoxClient::Service *VBoxClient::GetDragAndDropService()
    1818 {
    1819     return new(DragAndDropService);
    1820 }
     1893VBoxClient::Service *VBoxClient::GetDragAndDropService(void)
     1894{
     1895    DragAndDropService *pService = new DragAndDropService();
     1896    return pService;
     1897}
     1898
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