VirtualBox

Ignore:
Timestamp:
Mar 31, 2009 4:39:34 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
45479
Message:

HostServices/SharedClipboard: fixed remaining host/X11 separation todos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/x11-clipboard.cpp

    r18578 r18582  
    118118struct _VBOXCLIPBOARDCONTEXTX11
    119119{
     120    /** Opaque data structure describing the front-end. */
     121    VBOXCLIPBOARDCONTEXT *pFrontend;
    120122    /** The X Toolkit application context structure */
    121123    XtAppContext appContext;
     
    200202static bool g_fHaveX11;
    201203
     204/** @todo this is a temporary declaration. */
     205static void vboxClipboardFormatAnnounceBackend (uint32_t u32Formats);
    202206
    203207/**
     
    222226         * data from X11. */
    223227        LogFunc(("host requested guest clipboard data after guest had disconnected.\n"));
    224         vboxClipboardFormatAnnounce(NULL, 0);
     228        vboxClipboardFormatAnnounceBackend(0);
    225229        pCtx->waiter = NONE;
    226230        return VERR_TIMEOUT;
     
    584588
    585589/**
     590 * Report formats available in the X11 clipboard to VBox.
     591 * @param  pCtx        Opaque context pointer for the glue code
     592 * @param  u32Formats  The formats available
     593 * @note  Host glue code
     594 */
     595void VBoxX11ClipboardReportX11Formats(VBOXCLIPBOARDCONTEXT *pCtx,
     596                                      uint32_t u32Formats)
     597{
     598    vboxSvcClipboardReportMsg(pCtx->pClient,
     599                              VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS,
     600                              u32Formats);
     601}
     602
     603
     604/**
    586605 * Notify the host clipboard about the data formats we support, based on the
    587606 * "targets" (available data formats) information obtained from the X11
     
    589608 * @note  X11 backend code, callback for XtGetSelectionValue, called when we
    590609 *        poll for available targets.
    591  * @todo  This function still references host-specific data and calls host
    592  *        frontend APIs.  Fix.
    593610 */
    594611static void vboxClipboardGetTargetsFromX11(Widget,
     
    664681        if (eBestTarget != INVALID)
    665682            u32Formats |= VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT;
    666         vboxSvcClipboardReportMsg (g_ctxHost.pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS,
    667                                    u32Formats);
     683        VBoxX11ClipboardReportX11Formats(g_ctxX11.pFrontend, u32Formats);
    668684        g_ctxX11.notifyVBox = false;
    669685    }
     
    676692 * @note  X11 backend code, callback for XtAppAddTimeOut, recursively
    677693 *        re-armed.
    678  * @todo  This function still references host-specific data.  Fix.
    679694 * @todo  Use the XFIXES extension to check for new clipboard data when
    680695 *        available.
     
    684699    Log3 (("%s: called\n", __PRETTY_FUNCTION__));
    685700    /* Get the current clipboard contents */
    686     if (g_ctxX11.eOwner == X11 && g_ctxHost.pClient != 0)
     701    if (g_ctxX11.eOwner == X11)
    687702    {
    688703        Log3 (("%s: requesting the targets that the host clipboard offers\n",
    689704               __PRETTY_FUNCTION__));
    690         XtGetSelectionValue(g_ctxX11.widget, g_ctxX11.atomClipboard, g_ctxX11.atomTargets,
    691                             vboxClipboardGetTargetsFromX11, reinterpret_cast<XtPointer>(g_ctxHost.pClient),
     705        XtGetSelectionValue(g_ctxX11.widget, g_ctxX11.atomClipboard,
     706                            g_ctxX11.atomTargets,
     707                            vboxClipboardGetTargetsFromX11, NULL,
    692708                            CurrentTime);
    693709    }
    694710    /* Re-arm our timer */
    695     XtAppAddTimeOut(g_ctxX11.appContext, 200 /* ms */, vboxClipboardPollX11ForTargets, 0);
     711    XtAppAddTimeOut(g_ctxX11.appContext, 200 /* ms */,
     712                    vboxClipboardPollX11ForTargets, 0);
    696713}
    697714
     
    812829 * @note  X11 backend code
    813830 */
    814 int vboxClipboardInitBackend (void)
     831int vboxClipboardInitBackend (VBOXCLIPBOARDCONTEXT *pFrontend)
    815832{
    816833    int rc;
     
    852869
    853870    LogRel(("Initializing X11 clipboard backend\n"));
     871    g_ctxX11.pFrontend = pFrontend;
    854872    RTSemEventCreate(&g_ctxX11.waitForData);
    855873    rc = vboxClipboardInitX11();
     
    876894    RTSemEventCreate(&g_ctxHost.waitForData);
    877895    RTSemMutexCreate(&g_ctxHost.clipboardMutex);
    878     rc = vboxClipboardInitBackend();
     896    rc = vboxClipboardInitBackend(&g_ctxHost);
    879897    if (RT_FAILURE(rc))
    880898    {
     
    962980         * successfully and no other calls from the host code should be
    963981         * forthcoming. */
    964         /** @todo  move these two into a frontend proxy object that the
    965          * backend can call. */
    966982        /** @todo  can the backend fail to exit successfully?  What then? */
    967983        RTSemEventDestroy(g_ctxHost.waitForData);
     
    9881004    else
    9891005    {
    990         /** @todo take ownership of the X11 clipboard. */
     1006        /** @todo Check whether the guest gets a format announcement at
     1007          *       startup. */
     1008        vboxClipboardFormatAnnounceBackend(0);
    9911009    }
    9921010    return VINF_SUCCESS;
     
    10501068
    10511069/**
    1052  * Shut down the shared clipboard service and "disconnect" the guest.
    1053  * @todo  This mixes host glue and X11 backend code, separate into two
    1054  *        functions.
     1070 * Shut down the shared clipboard X11 backend.
     1071 * @note  X11 backend code
    10551072 */
    10561073void vboxClipboardDisconnectBackend (void)
     
    10691086/**
    10701087 * Shut down the shared clipboard service and "disconnect" the guest.
    1071  * @todo  This mixes host glue and X11 backend code, separate into two
    1072  *        functions.
     1088 * @note  Host glue code
    10731089 */
    10741090void vboxClipboardDisconnect (VBOXCLIPBOARDCLIENTDATA *)
     
    11641180 *                         data we are returning
    11651181 * @note  X11 backend code, called by the callback for XtOwnSelection.
    1166  * @todo  this function uses host-specific data and APIs.  Fix.
    11671182 */
    11681183static Boolean vboxClipboardConvertUtf16(Atom *atomTypeReturn,
     
    11781193
    11791194    LogFlowFunc (("called\n"));
    1180     rc = vboxClipboardReadDataFromVBox(&g_ctxHost, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, &pvVBox, &cbVBox);
     1195    rc = vboxClipboardReadDataFromVBox(g_ctxX11.pFrontend, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, &pvVBox, &cbVBox);
    11811196    if ((RT_FAILURE(rc)) || (cbVBox == 0))
    11821197    {
     
    12481263 *                         data we are returning
    12491264 * @note  X11 backend code, called by the callback for XtOwnSelection.
    1250  * @todo  this function uses host-specific data and APIs.  Fix.
    12511265 */
    12521266static Boolean vboxClipboardConvertToUtf8ForX11(Atom *atomTypeReturn,
     
    12641278    LogFlowFunc (("called\n"));
    12651279    /* Read the clipboard data from the guest. */
    1266     rc = vboxClipboardReadDataFromVBox(&g_ctxHost, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, &pvVBox, &cbVBox);
     1280    rc = vboxClipboardReadDataFromVBox(g_ctxX11.pFrontend, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, &pvVBox, &cbVBox);
    12671281    if ((rc != VINF_SUCCESS) || (cbVBox == 0))
    12681282    {
     
    13551369 *                         data we are returning
    13561370 * @note  X11 backend code, called by the callback for XtOwnSelection.
    1357  * @todo  this function uses host-specific data and APIs.  Fix.
    13581371 */
    13591372static Boolean vboxClipboardConvertToCTextForX11(Atom *atomTypeReturn,
     
    13721385    LogFlowFunc (("called\n"));
    13731386    /* Read the clipboard data from the guest. */
    1374     rc = vboxClipboardReadDataFromVBox(&g_ctxHost, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, &pvVBox, &cbVBox);
     1387    rc = vboxClipboardReadDataFromVBox(g_ctxX11.pFrontend, VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, &pvVBox, &cbVBox);
    13751388    if ((rc != VINF_SUCCESS) || (cbVBox == 0))
    13761389    {
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