VirtualBox

Changeset 37434 in vbox


Ignore:
Timestamp:
Jun 14, 2011 1:14:57 PM (13 years ago)
Author:
vboxsync
Message:

GuestHost/SharedClipboard: moved the RTEnvGet("DISPLAY") hack out into the host-specific code

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/SharedClipboard.h

    r36536 r37434  
    5454
    5555/* APIs exported by the X11 backend */
    56 extern CLIPBACKEND *ClipConstructX11(VBOXCLIPBOARDCONTEXT *pFrontend);
     56extern CLIPBACKEND *ClipConstructX11(VBOXCLIPBOARDCONTEXT *pFrontend, bool fHeadless);
    5757extern void ClipDestructX11(CLIPBACKEND *pBackend);
    5858#ifdef __cplusplus
  • trunk/include/VBox/HostServices/VBoxClipboardSvc.h

    r28800 r37434  
    5151 * The service functions which are callable by host.
    5252 */
    53 #define VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE   1
     53#define VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE      1
     54/** Run headless on the host, i.e. do not touch the host clipboard. */
     55#define VBOX_SHARED_CLIPBOARD_HOST_FN_SET_HEADLESS  2
    5456
    5557/*
  • trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp

    r33595 r37434  
    186186    /* Sanity */
    187187    AssertReturn(g_ctx.client == 0, VERR_WRONG_ORDER);
    188     g_ctx.pBackend = ClipConstructX11(&g_ctx);
     188    g_ctx.pBackend = ClipConstructX11(&g_ctx, false);
    189189    if (!g_ctx.pBackend)
    190190        rc = VERR_NO_MEMORY;
  • trunk/src/VBox/GuestHost/SharedClipboard/x11-clipboard.cpp

    r33995 r37434  
    4444
    4545#include <iprt/types.h>
    46 #include <iprt/env.h>
    4746#include <iprt/mem.h>
    4847#include <iprt/semaphore.h>
     
    698697 * @note  X11 backend code
    699698 */
    700 CLIPBACKEND *ClipConstructX11(VBOXCLIPBOARDCONTEXT *pFrontend)
     699CLIPBACKEND *ClipConstructX11(VBOXCLIPBOARDCONTEXT *pFrontend, bool fHeadless)
    701700{
    702701    int rc;
     
    704703    CLIPBACKEND *pCtx = (CLIPBACKEND *)
    705704                    RTMemAllocZ(sizeof(CLIPBACKEND));
    706     if (pCtx && !RTEnvExist("DISPLAY"))
     705    if (pCtx && fHeadless)
    707706    {
    708707        /*
     
    22412240}
    22422241
     2242static void testNoX11(CLIPBACKEND *pCtx, const char *pcszTestCtx)
     2243{
     2244    CLIPREADCBREQ *pReq = (CLIPREADCBREQ *)&pReq, *pReqRet = NULL;
     2245    int rc = ClipRequestDataFromX11(pCtx,
     2246                                    VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT,
     2247                                    pReq);
     2248    RTTESTI_CHECK_MSG(rc == VERR_NO_DATA, ("context: %s\n", pcszTestCtx));
     2249}
     2250
    22432251static void testStringFromVBoxFailed(RTTEST hTest, CLIPBACKEND *pCtx,
    22442252                                     const char *pcszTarget)
     
    22572265}
    22582266
     2267static void testNoSelectionOwnership(CLIPBACKEND *pCtx,
     2268                                     const char *pcszTestCtx)
     2269{
     2270    RTTESTI_CHECK_MSG(!g_ownsSel, ("context: %s\n", pcszTestCtx));
     2271}
     2272
    22592273int main()
    22602274{
     
    22712285     * Run the test.
    22722286     */
    2273     CLIPBACKEND *pCtx = ClipConstructX11(NULL);
     2287    CLIPBACKEND *pCtx = ClipConstructX11(NULL, false);
    22742288    char *pc;
    22752289    uint32_t cbActual;
     
    25242538    ClipDestructX11(pCtx);
    25252539
     2540    /*** Headless clipboard tests ***/
     2541
     2542    pCtx = ClipConstructX11(NULL, true);
     2543    rc = ClipStartX11(pCtx);
     2544    AssertRCReturn(rc, 1);
     2545
     2546    /*** Read from X11 ***/
     2547    RTTestSub(hTest, "reading from X11, headless clipboard");
     2548    /* Simple test */
     2549    clipSetVBoxUtf16(pCtx, VINF_SUCCESS, "",
     2550                     sizeof("") * 2);
     2551    clipSetSelectionValues("UTF8_STRING", XA_STRING, "hello world",
     2552                           sizeof("hello world"), 8);
     2553    testNoX11(pCtx, "reading from X11, headless clipboard");
     2554
     2555    /*** Read from VBox ***/
     2556    RTTestSub(hTest, "reading from VBox, headless clipboard");
     2557    /* Simple test */
     2558    clipEmptyVBox(pCtx, VERR_WRONG_ORDER);
     2559    clipSetSelectionValues("TEXT", XA_STRING, "", sizeof(""), 8);
     2560    clipSetVBoxUtf16(pCtx, VINF_SUCCESS, "hello world",
     2561                     sizeof("hello world") * 2);
     2562    testNoSelectionOwnership(pCtx, "reading from VBox, headless clipboard");
     2563
     2564    rc = ClipStopX11(pCtx);
     2565    AssertRCReturn(rc, 1);
     2566    ClipDestructX11(pCtx);
     2567
    25262568    return RTTestSummaryAndDestroy(hTest);
    25272569}
     
    25362578 * the command line. */
    25372579
     2580#include <iprt/env.h>
    25382581#include <iprt/test.h>
    25392582
     
    25772620        return RTTestSummaryAndDestroy(hTest);
    25782621    }
    2579     CLIPBACKEND *pCtx = ClipConstructX11(NULL);
     2622    CLIPBACKEND *pCtx = ClipConstructX11(NULL, false);
    25802623    AssertReturn(pCtx, 1);
    25812624    rc = ClipStartX11(pCtx);
  • trunk/src/VBox/HostServices/SharedClipboard/Makefile.kmk

    r35380 r37434  
    1818SUB_DEPTH = ../../../..
    1919include $(KBUILD_PATH)/subheader.kmk
     20
     21# Include sub-makefile(s).
     22include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
    2023
    2124#
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxClipboard.h

    r28800 r37434  
    2020
    2121#define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
     22#include <VBox/hgcmsvc.h>
    2223#include <VBox/log.h>
    2324
  • trunk/src/VBox/HostServices/SharedClipboard/x11-clipboard.cpp

    r33540 r37434  
    2323#include <iprt/assert.h>
    2424#include <iprt/critsect.h>
     25#include <iprt/env.h>
    2526#include <iprt/mem.h>
    2627#include <iprt/semaphore.h>
     
    111112    {
    112113        RTCritSectInit(&pCtx->clipboardMutex);
    113         pBackend = ClipConstructX11(pCtx);
     114        pBackend = ClipConstructX11(pCtx, !RTEnvGet("DISPLAY"));
    114115        if (pBackend == NULL)
    115116            rc = VERR_NO_MEMORY;
     
    470471}
    471472
    472 CLIPBACKEND *ClipConstructX11(VBOXCLIPBOARDCONTEXT *pFrontend)
     473CLIPBACKEND *ClipConstructX11(VBOXCLIPBOARDCONTEXT *pFrontend, bool)
    473474{
    474475    return (CLIPBACKEND *)RTMemAllocZ(sizeof(CLIPBACKEND));
Note: See TracChangeset for help on using the changeset viewer.

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