VirtualBox

Changeset 886 in vbox


Ignore:
Timestamp:
Feb 13, 2007 5:51:42 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18598
Message:

Main: Implemented sending essential notifications (such as the current mouse shape and state) to a callback registered during the VM runtime (defect #1817).

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r833 r886  
    306306    AssertReturn (mAudioSniffer, E_FAIL);
    307307
     308    memset (&mCallbackData, 0, sizeof (mCallbackData));   
     309   
    308310    /* Confirm a successful initialization when it's the case */
    309311    autoInitSpan.setSucceeded();
     
    419421    unconst (mMachine).setNull();
    420422
    421     // Release all callbacks. Do this after uninitializing the components,
    422     // as some of them are well-behaved and unregister their callbacks.
    423     // These would trigger error messages complaining about trying to
    424     // unregister a non-registered callback.
     423    /* Release all callbacks. Do this after uninitializing the components,
     424     * as some of them are well-behaved and unregister their callbacks.
     425     * These would trigger error messages complaining about trying to
     426     * unregister a non-registered callback. */
    425427    mCallbacks.clear();
     428
     429    /* dynamically allocated members of mCallbackData are uninitialized
     430     * at the end of powerDown() */
     431    Assert (!mCallbackData.mpsc.valid && mCallbackData.mpsc.shape == NULL);
     432    Assert (!mCallbackData.mcc.valid);
     433    Assert (!mCallbackData.klc.valid);
    426434
    427435    LogFlowThisFuncLeave();
     
    23552363    mCallbacks.push_back (CallbackList::value_type (aCallback));
    23562364
    2357 #if 0
    2358     /* @todo dmik please implement this.
    2359      * Inform the callback about the current status, because the new callback
    2360      * must know at least the current mouse capabilities and the pointer shape.
    2361      */
    2362     aCallback->OnMousePointerShapeChange (mCallbacksStatus.pointerShape.fVisible,
    2363                                           mCallbackStatus.pointerShape.fAlpha,
    2364                                           mCallbackStatus.pointerShape.xHot,
    2365                                           mCallbackStatus.pointerShape.yHot,
    2366                                           mCallbackStatus.pointerShape.width,
    2367                                           mCallbackStatus.pointerShape.height,
    2368                                           mCallbackStatus.pointerShape.pShape);
    2369     aCallback->OnMouseCapabilityChange (mCallbackStatus.mouseCapability.supportsAbsolute,
    2370                                         mCallbackStatus.mouseCapability.needsHostCursor);
    2371     aCallback->OnStateChange (mCallbackStatus.machineState);
     2365    /* Inform the callback about the current status (for example, the new
     2366     * callback must know the current mouse capabilities and the pointer
     2367     * shape in order to properly integrate the mouse pointer). */
     2368
     2369    if (mCallbackData.mpsc.valid)
     2370        aCallback->OnMousePointerShapeChange (mCallbackData.mpsc.visible,
     2371                                              mCallbackData.mpsc.alpha,
     2372                                              mCallbackData.mpsc.xHot,
     2373                                              mCallbackData.mpsc.yHot,
     2374                                              mCallbackData.mpsc.width,
     2375                                              mCallbackData.mpsc.height,
     2376                                              mCallbackData.mpsc.shape);
     2377    if (mCallbackData.mcc.valid)
     2378        aCallback->OnMouseCapabilityChange (mCallbackData.mcc.supportsAbsolute,
     2379                                            mCallbackData.mcc.needsHostCursor);
     2380
     2381    aCallback->OnStateChange (mMachineState);
    23722382    aCallback->OnAdditionsStateChange();
    2373     aCallback->OnKeyboardLedsChange(mCallbackStatus.keyboardLeds.fNumLock,
    2374                                     mCallbackStatus.keyboardLeds.fCapsLock,
    2375                                     mCallbackStatus.keyboardLeds.fScrollLock);
    2376 #endif
     2383
     2384    if (mCallbackData.klc.valid)
     2385        aCallback->OnKeyboardLedsChange (mCallbackData.klc.numLock,
     2386                                         mCallbackData.klc.capsLock,
     2387                                         mCallbackData.klc.scrollLock);
    23772388
    23782389    return S_OK;
     
    32643275
    32653276/**
    3266  *  @note Locks this object for reading.
     3277 *  @note Locks this object for writing.
    32673278 */
    32683279void Console::onMousePointerShapeChange(bool fVisible, bool fAlpha,
     
    32753286                      fVisible, fAlpha, xHot, yHot, width, height, pShape));
    32763287
    3277     AutoReaderLock alock (this);
     3288    AutoCaller autoCaller (this);
     3289    AssertComRCReturnVoid (autoCaller.rc());
     3290
     3291    /* We need a write lock because we alter the cached callback data */
     3292    AutoLock alock (this);
     3293
     3294    /* save the callback arguments */
     3295    mCallbackData.mpsc.visible = fVisible;
     3296    mCallbackData.mpsc.alpha = fAlpha;
     3297    mCallbackData.mpsc.xHot = xHot;
     3298    mCallbackData.mpsc.yHot = yHot;
     3299    mCallbackData.mpsc.width = width;
     3300    mCallbackData.mpsc.height = height;
     3301   
     3302    if (pShape != NULL)
     3303    {
     3304        size_t cb = (width + 7) / 8 * height; /* size of the AND mask */
     3305        cb += (cb + 3) & ~3 + width * 4 * height; /* + gap + size of the XOR mask */
     3306        mCallbackData.mpsc.shape = (BYTE *) RTMemAllocZ (cb);
     3307        AssertReturnVoid (mCallbackData.mpsc.shape);
     3308        memcpy (mCallbackData.mpsc.shape, pShape, cb);
     3309    }
     3310    else
     3311        mCallbackData.mpsc.shape = NULL;
     3312
     3313    mCallbackData.mpsc.valid = true;
    32783314
    32793315    CallbackList::iterator it = mCallbacks.begin();
     
    32843320
    32853321/**
    3286  *  @note Locks this object for reading.
     3322 *  @note Locks this object for writing.
    32873323 */
    32883324void Console::onMouseCapabilityChange (BOOL supportsAbsolute, BOOL needsHostCursor)
     
    32943330    AssertComRCReturnVoid (autoCaller.rc());
    32953331
    3296     AutoReaderLock alock (this);
    3297 
     3332    /* We need a write lock because we alter the cached callback data */
     3333    AutoLock alock (this);
     3334
     3335    /* save the callback arguments */
     3336    mCallbackData.mcc.supportsAbsolute = supportsAbsolute;
     3337    mCallbackData.mcc.needsHostCursor = needsHostCursor;
     3338    mCallbackData.mcc.valid = true;
     3339   
    32983340    CallbackList::iterator it = mCallbacks.begin();
    32993341    while (it != mCallbacks.end())
     
    33523394
    33533395/**
    3354  *  @note Locks this object for reading.
     3396 *  @note Locks this object for writing.
    33553397 */
    33563398void Console::onKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock)
     
    33593401    AssertComRCReturnVoid (autoCaller.rc());
    33603402
    3361     AutoReaderLock alock (this);
     3403    /* We need a write lock because we alter the cached callback data */
     3404    AutoLock alock (this);
     3405
     3406    /* save the callback arguments */
     3407    mCallbackData.klc.numLock = fNumLock;
     3408    mCallbackData.klc.capsLock = fCapsLock;
     3409    mCallbackData.klc.scrollLock = fScrollLock;
     3410    mCallbackData.klc.valid = true;
    33623411
    33633412    CallbackList::iterator it = mCallbacks.begin();
     
    36573706        mVMDestroying = false;
    36583707
     3708    if (SUCCEEDED (rc))
     3709    {
     3710        /* uninit dynamically allocated members of mCallbackData */
     3711        if (mCallbackData.mpsc.valid)
     3712        {
     3713            if (mCallbackData.mpsc.shape != NULL)
     3714                RTMemFree (mCallbackData.mpsc.shape);
     3715        }
     3716        memset (&mCallbackData, 0, sizeof (mCallbackData));   
     3717    }
     3718   
    36593719    LogFlowThisFuncLeave();
    36603720    return rc;
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r606 r886  
    478478    bool mVMStateChangeCallbackDisabled;
    479479
    480     // local state value
     480    /* Local machine state value */
    481481    MachineState_T mMachineState;
    482482
     
    484484    CallbackList mCallbacks;
    485485
     486    struct
     487    {
     488        /** OnMousePointerShapeChange() cache */
     489        struct
     490        {
     491            bool valid;
     492            bool visible;
     493            bool alpha;
     494            uint32_t xHot;
     495            uint32_t yHot;
     496            uint32_t width;
     497            uint32_t height;
     498            BYTE *shape;
     499        }
     500        mpsc;
     501
     502        /** OnMouseCapabilityChange() cache */
     503        struct
     504        {
     505            bool valid;
     506            BOOL supportsAbsolute;
     507            BOOL needsHostCursor;
     508        }
     509        mcc;
     510
     511        /** OnKeyboardLedsChange() cache */
     512        struct
     513        {
     514            bool valid;
     515            bool numLock;
     516            bool capsLock;
     517            bool scrollLock;
     518        }
     519        klc;
     520    }
     521    mCallbackData;
     522   
    486523    friend struct VMTask;
    487524};
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