VirtualBox

Ignore:
Timestamp:
Jun 15, 2010 2:18:05 PM (14 years ago)
Author:
vboxsync
Message:

FE/headless: VNC coding style and minor fixes

Location:
trunk/src/VBox/Frontends/VBoxHeadless
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxHeadless/FramebufferVNC.cpp

    r28800 r30200  
    5959}
    6060
    61 
    62 VNCFB::~VNCFB() {
     61VNCFB::~VNCFB()
     62{
    6363    LogFlow(("Destroying VNCFB object %p\n", this));
    6464    RTCritSectDelete(&mCritSect);
    65     if (vncServer) {
    66     if (vncServer->authPasswdData) {
    67         char **papszPassword = (char **)vncServer->authPasswdData;
    68         vncServer->authPasswdData = NULL;
    69         RTMemFree(papszPassword[0]);
    70         RTMemFree(papszPassword);
    71     }
     65    if (vncServer)
     66    {
     67        RTStrFree((char*)vncServer->desktopName);
     68        if (vncServer->authPasswdData)
     69        {
     70            char **papszPassword = (char **)vncServer->authPasswdData;
     71            vncServer->authPasswdData = NULL;
     72            RTMemFree(papszPassword[0]);
     73            RTMemFree(papszPassword);
     74        }
    7275        rfbScreenCleanup(vncServer);
    7376    }
     
    7881}
    7982
    80 HRESULT VNCFB::init() {
     83HRESULT VNCFB::init(const char *pszName)
     84{
    8185    LogFlow(("Initialising VNCFB object %p\n", this));
    8286    int rc = RTCritSectInit(&mCritSect);
     
    8589    vncServer = rfbGetScreen(0, NULL, mWidth, mHeight, 8, 3, 1);
    8690    vncServer->screenData = (void*)this;
    87     if (mVncPort) vncServer->port = mVncPort;
    88     vncServer->desktopName = "VirtualBox";
    89 
    90     if (mVncPassword) {
    91     char **papszPasswords = (char **)RTMemAlloc(2 * sizeof(char **));
     91    if (mVncPort)
     92        vncServer->port = mVncPort;
     93    char *pszDesktopName;
     94    rc = RTStrAPrintf(&pszDesktopName, "%s - VirtualBox", pszName);
     95    if (RT_SUCCESS(rc))
     96        vncServer->desktopName = (const char*)pszDesktopName;
     97    else
     98        vncServer->desktopName = "VirtualBox";
     99    if (mVncPassword)
     100    {
     101        char **papszPasswords = (char **)RTMemAlloc(2 * sizeof(char **));
    92102        papszPasswords[0] = RTStrDup(mVncPassword);
    93103        papszPasswords[1] = NULL;
    94     vncServer->authPasswdData = papszPasswords;
     104        vncServer->authPasswdData = papszPasswords;
    95105        vncServer->passwordCheck = rfbCheckPasswordByList; //Password list based authentication function
    96     } else {
    97     vncServer->authPasswdData = NULL;
    98     }
     106    }
     107    else
     108        vncServer->authPasswdData = NULL;
    99109
    100110    rfbInitServer(vncServer);
     
    114124}
    115125
     126void VNCFB::enableAbsMouse(bool fEnable)
     127{
     128    fAbsMouseEnabled = fEnable;
     129}
     130
    116131DECLCALLBACK(int) VNCFB::vncThreadFn(RTTHREAD hThreadSelf, void *pvUser)
    117132{
     
    120135}
    121136
    122 void VNCFB::vncMouseEvent(int buttonMask, int x, int y, rfbClientPtr cl) {
     137void VNCFB::vncMouseEvent(int buttonMask, int x, int y, rfbClientPtr cl)
     138{
    123139    ((VNCFB*)(cl->screen->screenData))->handleVncMouseEvent(buttonMask, x, y);
    124140    rfbDefaultPtrAddEvent(buttonMask, x, y, cl);
    125141}
    126142
    127 void VNCFB::handleVncMouseEvent(int buttonMask, int x, int y) {
     143void VNCFB::handleVncMouseEvent(int buttonMask, int x, int y)
     144{
    128145    //RTPrintf("VNC mouse: button=%d x=%d y=%d\n", buttonMask, x, y);
    129     if (!mMouse) {
     146    if (!mMouse)
     147    {
    130148        this->mConsole->COMGETTER(Mouse)(mMouse.asOutParam());
    131         if (!mMouse) {
     149        if (!mMouse)
     150        {
    132151            RTPrintf("Warning: could not get mouse object!\n");
    133152            return;
     
    135154    }
    136155    int dz = 0, buttons = 0;
    137     if (buttonMask & 16) dz = 1; else if (buttonMask & 8) dz = -1;
    138     if (buttonMask & 1) buttons |= 1;
    139     if (buttonMask & 2) buttons |= 4;
    140     if (buttonMask & 4) buttons |= 2;
    141     mMouse->PutMouseEvent(x - mouseX, y - mouseY, dz, 0, buttons);
    142     //mMouse->PutMouseEventAbsolute(x + 1, y + 1, dz, 0, buttonMask);
     156    if (buttonMask & 16)
     157        dz = 1;
     158    else if (buttonMask & 8)
     159        dz = -1;
     160    if (buttonMask & 1)
     161        buttons |= 1;
     162    if (buttonMask & 2)
     163        buttons |= 4;
     164    if (buttonMask & 4)
     165        buttons |= 2;
     166    if (fAbsMouseEnabled)
     167        mMouse->PutMouseEventAbsolute(x, y, dz, 0, buttons);
     168    else
     169        mMouse->PutMouseEvent(x - mouseX, y - mouseY, dz, 0, buttons);
    143170    mouseX = x;
    144171    mouseY = y;
    145172}
    146173
    147 void VNCFB::kbdPutCode(int code) {
     174void VNCFB::kbdPutCode(int code)
     175{
    148176    mKeyboard->PutScancode(code);
    149177}
    150 void VNCFB::kbdSetShift(int state) {
    151     if (state && !kbdShiftState) {
     178
     179void VNCFB::kbdSetShift(int state)
     180{
     181    if (state && !kbdShiftState)
     182    {
    152183        kbdPutCode(0x2a, 1);
    153184        kbdShiftState = 1;
    154     } else if (!state && kbdShiftState) {
     185    }
     186    else if (!state && kbdShiftState)
     187    {
    155188        kbdPutCode(0x2a, 0);
    156189        kbdShiftState = 0;
    157190    }
    158191}
    159 void VNCFB::kbdPutCode(int code, int down) {
    160     if (code & 0xff00) kbdPutCode((code >> 8) & 0xff);
     192void VNCFB::kbdPutCode(int code, int down)
     193{
     194    if (code & 0xff00)
     195        kbdPutCode((code >> 8) & 0xff);
    161196    kbdPutCode((code & 0xff) | (down ? 0 : 0x80));
    162197}
    163 void VNCFB::kbdPutCodeShift(int shift, int code, int down) {
    164     if (shift != kbdShiftState) kbdPutCode(0x2a, shift);
     198
     199void VNCFB::kbdPutCodeShift(int shift, int code, int down)
     200{
     201    if (shift != kbdShiftState)
     202        kbdPutCode(0x2a, shift);
    165203    kbdPutCode(code, down);
    166     if (shift != kbdShiftState) kbdPutCode(0x2a, kbdShiftState);
     204    if (shift != kbdShiftState)
     205        kbdPutCode(0x2a, kbdShiftState);
    167206}
    168207
     
    171210 * Now we're using one lookup table for the lower X11 key codes (ASCII characters)
    172211 * and a switch() block to handle some special keys. */
    173 void VNCFB::handleVncKeyboardEvent(int down, int keycode) {
     212void VNCFB::handleVncKeyboardEvent(int down, int keycode)
     213{
    174214    //RTPrintf("VNC keyboard: down=%d code=%d -> ", down, keycode);
    175     if (mKeyboard == NULL) {
     215    if (mKeyboard == NULL)
     216    {
    176217        this->mConsole->COMGETTER(Keyboard)(mKeyboard.asOutParam());
    177         if (!mKeyboard) {
     218        if (!mKeyboard)
     219        {
    178220            RTPrintf("Warning: could not get keyboard object!\n");
    179221            return;
     
    188230     * This is necessary because the VNC protocol sends a shift key sequence, but also
    189231     * sends the 'shifted' version of the characters. */
    190     static int codes_low[] = { //Conversion table for VNC key code range 32-127
     232    static int codes_low[] =
     233    {
     234        //Conversion table for VNC key code range 32-127
    191235        0x0239, 0x0102, 0x0128, 0x0104, 0x0105, 0x0106, 0x0108, 0x0028, 0x010a, 0x010b, 0x0109, 0x010d, 0x0029, 0x000c, 0x0034, 0x0035, //space, !"#$%&'()*+`-./
    192236        0x0b, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, //0123456789
     
    198242    };
    199243    int shift = -1, code = -1;
    200     if (keycode < 32) { //ASCII control codes.. unused..
    201     } else if (keycode < 127) { //DEL is in high area
     244    if (keycode < 32)
     245    {
     246        //ASCII control codes.. unused..
     247    }
     248    else if (keycode < 127)
     249    {
     250        //DEL is in high area
    202251        code = codes_low[keycode - 32];
    203         shift = (code >> 8) & 0x03; if (shift == 0x02 || code & 0xe000) shift = -1;
     252        shift = (code >> 8) & 0x03;
     253        if (shift == 0x02 || code & 0xe000)
     254            shift = -1;
    204255        code = code & 0xe0ff;
    205     } else if ((keycode & 0xFF00) != 0xFF00) {
    206     } else {
    207         switch(keycode) {
     256    }
     257    else if ((keycode & 0xFF00) != 0xFF00)
     258    {
     259    }
     260    else
     261    {
     262        switch(keycode)
     263        {
    208264/*Numpad keys - these have to be implemented yet
    209265Todo: numpad arrows, home, pageup, pagedown, end, insert, delete
     
    273329    }
    274330    //RTPrintf("down=%d shift=%d code=%d\n", down, shift, code);
    275     if (shift != -1 && code != -1) {
     331    if (shift != -1 && code != -1)
     332    {
    276333        kbdPutCodeShift(shift, code, down);
    277     } else if (shift != -1) {
     334    }
     335    else if (shift != -1)
     336    {
    278337        kbdSetShift(shift);
    279     } else if (code != -1) {
     338    }
     339    else if (code != -1)
     340    {
    280341        kbdPutCode(code, down);
    281342    }
    282343}
    283 void VNCFB::handleVncKeyboardReleaseEvent() {
     344void VNCFB::handleVncKeyboardReleaseEvent()
     345{
    284346    kbdSetShift(0);
    285347    kbdPutCode(0x1d, 0); //Left ctrl
     
    289351}
    290352
    291 void VNCFB::vncKeyboardEvent(rfbBool down, rfbKeySym keySym, rfbClientPtr cl) {
     353void VNCFB::vncKeyboardEvent(rfbBool down, rfbKeySym keySym, rfbClientPtr cl)
     354{
    292355    ((VNCFB*)(cl->screen->screenData))->handleVncKeyboardEvent(down, keySym);
    293356}
    294 void VNCFB::vncReleaseKeysEvent(rfbClientPtr cl) { //Release modifier keys
     357
     358void VNCFB::vncReleaseKeysEvent(rfbClientPtr cl)
     359{
     360    //Release modifier keys
    295361    ((VNCFB*)(cl->screen->screenData))->handleVncKeyboardReleaseEvent();
    296362}
     
    327393                                  BYTE *vram, ULONG bitsPerPixel,
    328394                                  ULONG bytesPerLine,
    329                                   ULONG w, ULONG h, BOOL *finished) {
     395                                  ULONG w, ULONG h, BOOL *finished)
     396{
    330397    NOREF(aScreenId);
    331     if (!finished) return E_POINTER;
     398    if (!finished)
     399        return E_POINTER;
    332400
    333401    /* For now, we are doing things synchronously */
    334402    *finished = true;
    335403
    336     if (mRGBBuffer) RTMemFree(mRGBBuffer);
     404    if (mRGBBuffer)
     405        RTMemFree(mRGBBuffer);
    337406
    338407    mWidth = w;
    339408    mHeight = h;
    340409
    341     if (pixelFormat == FramebufferPixelFormat_FOURCC_RGB && bitsPerPixel == 32) {
     410    if (pixelFormat == FramebufferPixelFormat_FOURCC_RGB && bitsPerPixel == 32)
     411    {
    342412        mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
    343413            mBufferAddress = reinterpret_cast<uint8_t *>(vram);
     
    345415            mBitsPerPixel = bitsPerPixel;
    346416            mRGBBuffer = NULL;
    347     } else {
     417    }
     418    else
     419    {
    348420            mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
    349421            mBytesPerLine = w * 4;
     
    358430        AssertReturn(mScreenBuffer != 0, E_OUTOFMEMORY);
    359431
    360     for (ULONG i = 0; i < mBytesPerLine * h; i += 4) {
     432    for (ULONG i = 0; i < mBytesPerLine * h; i += 4)
     433    {
    361434        mScreenBuffer[i]   = mBufferAddress[i+2];
    362435        mScreenBuffer[i+1] = mBufferAddress[i+1];
     
    364437    }
    365438
    366     RTPrintf("Set framebuffer: buffer=%d w=%lu h=%lu bpp=%d\n", mBufferAddress, mWidth, mHeight, (int)mBitsPerPixel);
     439    RTPrintf("Set framebuffer: buffer=%llx w=%lu h=%lu bpp=%d\n",
     440            (uint64_t)mBufferAddress, mWidth, mHeight, (int)mBitsPerPixel);
    367441    rfbNewFramebuffer(vncServer, (char*)mScreenBuffer, mWidth, mHeight, 8, 3, mBitsPerPixel / 8);
    368     if (oldBuffer) RTMemFree(oldBuffer);
     442    if (oldBuffer)
     443        RTMemFree(oldBuffer);
    369444    return S_OK;
    370445}
    371446
    372447//Guest framebuffer update notification
    373 STDMETHODIMP VNCFB::NotifyUpdate(ULONG x, ULONG y, ULONG w, ULONG h) {
    374     if (!mBufferAddress || !mScreenBuffer) return S_OK;
     448STDMETHODIMP VNCFB::NotifyUpdate(ULONG x, ULONG y, ULONG w, ULONG h)
     449{
     450    if (!mBufferAddress || !mScreenBuffer)
     451        return S_OK;
    375452    ULONG joff = y * mBytesPerLine + x * 4;
    376453    for (ULONG j = joff; j < joff + h * mBytesPerLine; j += mBytesPerLine)
    377     for (ULONG i = j; i < j + w * 4; i += 4) {
    378         mScreenBuffer[i]   = mBufferAddress[i+2];
    379         mScreenBuffer[i+1] = mBufferAddress[i+1];
    380         mScreenBuffer[i+2] = mBufferAddress[i];
    381     }
     454        for (ULONG i = j; i < j + w * 4; i += 4)
     455        {
     456            mScreenBuffer[i]   = mBufferAddress[i+2];
     457            mScreenBuffer[i+1] = mBufferAddress[i+1];
     458            mScreenBuffer[i+2] = mBufferAddress[i];
     459        }
    382460    rfbMarkRectAsModified(vncServer, x, y, x+w, y+h);
    383461    return S_OK;
    384462}
    385 
    386 
    387463
    388464
     
    396472 * @retval  address The address of the buffer
    397473 */
    398 STDMETHODIMP VNCFB::COMGETTER(Address) (BYTE **address) {
    399     if (!address) return E_POINTER;
     474STDMETHODIMP VNCFB::COMGETTER(Address) (BYTE **address)
     475{
     476    if (!address)
     477        return E_POINTER;
    400478    LogFlow(("FFmpeg::COMGETTER(Address): returning address %p\n", mBufferAddress));
    401479    *address = mBufferAddress;
     
    409487 * @retval  width The width of the frame buffer
    410488 */
    411 STDMETHODIMP VNCFB::COMGETTER(Width) (ULONG *width) {
    412     if (!width) return E_POINTER;
     489STDMETHODIMP VNCFB::COMGETTER(Width) (ULONG *width)
     490{
     491    if (!width)
     492        return E_POINTER;
    413493    LogFlow(("FFmpeg::COMGETTER(Width): returning width %lu\n", (unsigned long) mWidth));
    414494    *width = mWidth;
     
    422502 * @retval  height The height of the frame buffer
    423503 */
    424 STDMETHODIMP VNCFB::COMGETTER(Height) (ULONG *height) {
    425     if (!height) return E_POINTER;
     504STDMETHODIMP VNCFB::COMGETTER(Height) (ULONG *height)
     505{
     506    if (!height)
     507        return E_POINTER;
    426508    LogFlow(("FFmpeg::COMGETTER(Height): returning height %lu\n", (unsigned long) mHeight));
    427509    *height = mHeight;
     
    439521 * @retval  bitsPerPixel The colour depth of the frame buffer
    440522 */
    441 STDMETHODIMP VNCFB::COMGETTER(BitsPerPixel) (ULONG *bitsPerPixel) {
    442     if (!bitsPerPixel) return E_POINTER;
     523STDMETHODIMP VNCFB::COMGETTER(BitsPerPixel) (ULONG *bitsPerPixel)
     524{
     525    if (!bitsPerPixel)
     526        return E_POINTER;
    443527    *bitsPerPixel = mBitsPerPixel;
    444528    LogFlow(("FFmpeg::COMGETTER(BitsPerPixel): returning depth %lu\n",
     
    453537 * @retval  bytesPerLine The number of bytes per line
    454538 */
    455 STDMETHODIMP VNCFB::COMGETTER(BytesPerLine) (ULONG *bytesPerLine) {
    456     if (!bytesPerLine) return E_POINTER;
     539STDMETHODIMP VNCFB::COMGETTER(BytesPerLine) (ULONG *bytesPerLine)
     540{
     541    if (!bytesPerLine)
     542        return E_POINTER;
    457543    LogFlow(("FFmpeg::COMGETTER(BytesPerLine): returning line size %lu\n", (unsigned long) mBytesPerLine));
    458544    *bytesPerLine = mBytesPerLine;
     
    466552 * @retval  pixelFormat The pixel layout
    467553 */
    468 STDMETHODIMP VNCFB::COMGETTER(PixelFormat) (ULONG *pixelFormat) {
    469     if (!pixelFormat) return E_POINTER;
     554STDMETHODIMP VNCFB::COMGETTER(PixelFormat) (ULONG *pixelFormat)
     555{
     556    if (!pixelFormat)
     557        return E_POINTER;
    470558    LogFlow(("FFmpeg::COMGETTER(PixelFormat): returning pixel format: %lu\n", (unsigned long) mPixelFormat));
    471559    *pixelFormat = mPixelFormat;
     
    479567 * @retval  pixelFormat The pixel layout
    480568 */
    481 STDMETHODIMP VNCFB::COMGETTER(UsesGuestVRAM) (BOOL *usesGuestVRAM) {
    482     if (!usesGuestVRAM) return E_POINTER;
     569STDMETHODIMP VNCFB::COMGETTER(UsesGuestVRAM) (BOOL *usesGuestVRAM)
     570{
     571    if (!usesGuestVRAM)
     572        return E_POINTER;
    483573    LogFlow(("FFmpeg::COMGETTER(UsesGuestVRAM): uses guest VRAM? %d\n", mRGBBuffer == NULL));
    484574    *usesGuestVRAM = (mRGBBuffer == NULL);
     
    493583 * @retval  heightReduction The number of unused lines
    494584 */
    495 STDMETHODIMP VNCFB::COMGETTER(HeightReduction) (ULONG *heightReduction) {
    496     if (!heightReduction) return E_POINTER;
     585STDMETHODIMP VNCFB::COMGETTER(HeightReduction) (ULONG *heightReduction)
     586{
     587    if (!heightReduction)
     588        return E_POINTER;
    497589    /* no reduction */
    498590    *heightReduction = 0;
     
    508600 * @retval  aOverlay The overlay framebuffer
    509601 */
    510 STDMETHODIMP VNCFB::COMGETTER(Overlay) (IFramebufferOverlay **aOverlay) {
    511     if (!aOverlay) return E_POINTER;
     602STDMETHODIMP VNCFB::COMGETTER(Overlay) (IFramebufferOverlay **aOverlay)
     603{
     604    if (!aOverlay)
     605        return E_POINTER;
    512606    /* not yet implemented */
    513607    *aOverlay = 0;
     
    522616 * @retval  winId Associated window id
    523617 */
    524 STDMETHODIMP VNCFB::COMGETTER(WinId) (ULONG64 *winId) {
    525     if (!winId) return E_POINTER;
     618STDMETHODIMP VNCFB::COMGETTER(WinId) (ULONG64 *winId)
     619{
     620    if (!winId)
     621        return E_POINTER;
    526622    *winId = 0;
    527623    return S_OK;
     
    531627/////////////////////////////////////////////////////////////////////////////
    532628
    533 STDMETHODIMP VNCFB::Lock() {
     629STDMETHODIMP VNCFB::Lock()
     630{
    534631    LogFlow(("VNCFB::Lock: called\n"));
    535632    int rc = RTCritSectEnter(&mCritSect);
    536633    AssertRC(rc);
    537     if (rc == VINF_SUCCESS) return S_OK;
     634    if (rc == VINF_SUCCESS)
     635        return S_OK;
    538636    return E_UNEXPECTED;
    539637}
    540638
    541 STDMETHODIMP VNCFB::Unlock() {
     639STDMETHODIMP VNCFB::Unlock()
     640{
    542641    LogFlow(("VNCFB::Unlock: called\n"));
    543642    RTCritSectLeave(&mCritSect);
     
    545644}
    546645
    547 
    548646/**
    549647 * Returns whether we like the given video mode.
     
    551649 * @returns COM status code
    552650 */
    553 STDMETHODIMP VNCFB::VideoModeSupported(ULONG width, ULONG height, ULONG bpp, BOOL *supported) {
    554     if (!supported) return E_POINTER;
     651STDMETHODIMP VNCFB::VideoModeSupported(ULONG width, ULONG height, ULONG bpp, BOOL *supported)
     652{
     653    if (!supported)
     654        return E_POINTER;
    555655    *supported = true;
    556656    return S_OK;
     
    558658
    559659/** Stubbed */
    560 STDMETHODIMP VNCFB::GetVisibleRegion(BYTE *rectangles, ULONG /* count */, ULONG * /* countCopied */) {
    561     if (!rectangles) return E_POINTER;
     660STDMETHODIMP VNCFB::GetVisibleRegion(BYTE *rectangles, ULONG /* count */, ULONG * /* countCopied */)
     661{
     662    if (!rectangles)
     663        return E_POINTER;
    562664    *rectangles = 0;
    563665    return S_OK;
     
    565667
    566668/** Stubbed */
    567 STDMETHODIMP VNCFB::SetVisibleRegion(BYTE *rectangles, ULONG /* count */) {
    568     if (!rectangles) return E_POINTER;
    569     return S_OK;
    570 }
    571 
    572 STDMETHODIMP VNCFB::ProcessVHWACommand(BYTE *pCommand) {
     669STDMETHODIMP VNCFB::SetVisibleRegion(BYTE *rectangles, ULONG /* count */)
     670{
     671    if (!rectangles)
     672        return E_POINTER;
     673    return S_OK;
     674}
     675
     676STDMETHODIMP VNCFB::ProcessVHWACommand(BYTE *pCommand)
     677{
    573678    return E_NOTIMPL;
    574679}
  • trunk/src/VBox/Frontends/VBoxHeadless/FramebufferVNC.h

    r28800 r30200  
    4343    STDMETHOD_(ULONG, Release)() {
    4444        long cnt = ::InterlockedDecrement (&refcnt);
    45         if (cnt == 0) delete this;
     45        if (cnt == 0)
     46            delete this;
    4647        return cnt;
    4748    }
     
    5253
    5354    // public methods only for internal purposes
    54     HRESULT init ();
     55    HRESULT init (const char *pszName);
     56    void enableAbsMouse(bool fEnable);
    5557
    5658    STDMETHOD(COMGETTER(Width))(ULONG *width);
     
    104106    void kbdPutCodeShift(int shift, int code, int down);
    105107
     108    bool fAbsMouseEnabled;
     109
    106110    ULONG mWidth, mHeight;
    107111
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r30109 r30200  
    8181static IConsole *gConsole = NULL;
    8282static EventQueue *gEventQ = NULL;
     83
     84#ifdef VBOX_WITH_VNC
     85static VNCFB *g_pFramebufferVNC;
     86#endif
     87
    8388
    8489////////////////////////////////////////////////////////////////////////////////
     
    322327            }
    323328        }
     329#ifdef VBOX_WITH_VNC
     330        if (g_pFramebufferVNC)
     331            g_pFramebufferVNC->enableAbsMouse(supportsAbsolute);
     332#endif
    324333        return S_OK;
    325334    }
     
    963972        if (fVNCEnable)
    964973        {
    965             VNCFB *pFramebufferVNC = new VNCFB(console, uVNCPort, pszVNCPassword);
    966             rc = pFramebufferVNC->init();
     974            Bstr name;
     975            machine->COMGETTER(Name)(name.asOutParam());
     976            g_pFramebufferVNC = new VNCFB(console, uVNCPort, pszVNCPassword);
     977            rc = g_pFramebufferVNC->init(name ? Utf8Str(name).raw() : "");
    967978            if (rc != S_OK)
    968979            {
    969980                LogError("Failed to load the vnc server extension, possibly due to a damaged file\n", rc);
    970                 delete pFramebufferVNC;
     981                delete g_pFramebufferVNC;
    971982                break;
    972983            }
    973984
    974985            Log2(("VBoxHeadless: Registering VNC framebuffer\n"));
    975             pFramebufferVNC->AddRef();
    976             display->SetFramebuffer(VBOX_VIDEO_PRIMARY_SCREEN, pFramebufferVNC);
     986            g_pFramebufferVNC->AddRef();
     987            display->SetFramebuffer(VBOX_VIDEO_PRIMARY_SCREEN, g_pFramebufferVNC);
    977988        }
    978989        if (rc != S_OK)
     
    986997        for (uScreenId = 0; uScreenId < cMonitors; uScreenId++)
    987998        {
    988 #ifdef VBOX_FFMPEG
     999# ifdef VBOX_FFMPEG
    9891000            if (fFFMPEG && uScreenId == 0)
    9901001            {
     
    9921003                continue;
    9931004            }
    994 #endif /* defined(VBOX_FFMPEG) */
     1005# endif
     1006# ifdef VBOX_WITH_VNC
     1007            if (fVNCEnable && uScreenId == 0)
     1008            {
     1009                /* Already registered. */
     1010                continue;
     1011            }
     1012# endif
    9951013            VRDPFramebuffer *pVRDPFramebuffer = new VRDPFramebuffer();
    9961014            if (!pVRDPFramebuffer)
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