VirtualBox

Changeset 52921 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Oct 2, 2014 6:36:54 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
96356
Message:

IMouse::PointerShape

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

Legend:

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

    r52901 r52921  
    63826382    }
    63836383#endif
     6384    com::SafeArray<BYTE> aShape(ComSafeArrayInArg(pShape));
     6385    if (!mMouse.isNull())
     6386       mMouse->updateMousePointerShape(fVisible, fAlpha, xHot, yHot, width, height,
     6387                                       aShape.raw(), aShape.size());
    63846388
    63856389    fireMousePointerShapeChangedEvent(mEventSource, fVisible, fAlpha, xHot, yHot, width, height, ComSafeArrayInArg(pShape));
  • trunk/src/VBox/Main/src-client/MouseImpl.cpp

    r52821 r52921  
    2121#include "DisplayImpl.h"
    2222#include "VMMDev.h"
     23#include "MousePointerShapeWrap.h"
    2324
    2425#include "AutoCaller.h"
     
    2930
    3031#include <iprt/asm.h>
     32
     33class ATL_NO_VTABLE MousePointerShape:
     34    public MousePointerShapeWrap
     35{
     36public:
     37
     38    DECLARE_EMPTY_CTOR_DTOR(MousePointerShape)
     39
     40    HRESULT FinalConstruct();
     41    void FinalRelease();
     42
     43    /* Public initializer/uninitializer for internal purposes only. */
     44    HRESULT init(ComObjPtr<Mouse> pMouse,
     45                 bool fVisible, bool fAlpha,
     46                 uint32_t hotX, uint32_t hotY,
     47                 uint32_t width, uint32_t height,
     48                 const uint8_t *pu8Shape, uint32_t cbShape);
     49    void uninit();
     50
     51private:
     52    // wrapped IMousePointerShape properties
     53    virtual HRESULT getVisible(BOOL *aVisible);
     54    virtual HRESULT getAlpha(BOOL *aAlpha);
     55    virtual HRESULT getHotX(ULONG *aHotX);
     56    virtual HRESULT getHotY(ULONG *aHotY);
     57    virtual HRESULT getWidth(ULONG *aWidth);
     58    virtual HRESULT getHeight(ULONG *aHeight);
     59    virtual HRESULT getShape(std::vector<BYTE> &aShape);
     60
     61    struct Data
     62    {
     63        ComObjPtr<Mouse> pMouse;
     64        bool fVisible;
     65        bool fAlpha;
     66        uint32_t hotX;
     67        uint32_t hotY;
     68        uint32_t width;
     69        uint32_t height;
     70        std::vector<BYTE> shape;
     71    };
     72
     73    Data m;
     74};
     75
     76/*
     77 * MousePointerShape implementation.
     78 */
     79DEFINE_EMPTY_CTOR_DTOR(MousePointerShape)
     80
     81HRESULT MousePointerShape::FinalConstruct()
     82{
     83    return BaseFinalConstruct();
     84}
     85
     86void MousePointerShape::FinalRelease()
     87{
     88    uninit();
     89
     90    BaseFinalRelease();
     91}
     92
     93HRESULT MousePointerShape::init(ComObjPtr<Mouse> pMouse,
     94                                bool fVisible, bool fAlpha,
     95                                uint32_t hotX, uint32_t hotY,
     96                                uint32_t width, uint32_t height,
     97                                const uint8_t *pu8Shape, uint32_t cbShape)
     98{
     99    LogFlowThisFunc(("v %d, a %d, h %d,%d, %dx%d, cb %d\n",
     100                     fVisible, fAlpha, hotX, hotY, width, height, cbShape));
     101
     102    /* Enclose the state transition NotReady->InInit->Ready */
     103    AutoInitSpan autoInitSpan(this);
     104    AssertReturn(autoInitSpan.isOk(), E_FAIL);
     105
     106    m.pMouse = pMouse;
     107    m.fVisible = fVisible;
     108    m.fAlpha   = fAlpha;
     109    m.hotX     = hotX;
     110    m.hotY     = hotY;
     111    m.width    = width;
     112    m.height   = height;
     113    m.shape.resize(cbShape);
     114    if (cbShape)
     115    {
     116        memcpy(&m.shape.front(), pu8Shape, cbShape);
     117    }
     118
     119    /* Confirm a successful initialization */
     120    autoInitSpan.setSucceeded();
     121
     122    return S_OK;
     123}
     124
     125void MousePointerShape::uninit()
     126{
     127    LogFlowThisFunc(("\n"));
     128
     129    /* Enclose the state transition Ready->InUninit->NotReady */
     130    AutoUninitSpan autoUninitSpan(this);
     131    if (autoUninitSpan.uninitDone())
     132        return;
     133
     134    m.pMouse.setNull();
     135}
     136
     137HRESULT MousePointerShape::getVisible(BOOL *aVisible)
     138{
     139    *aVisible = m.fVisible;
     140    return S_OK;
     141}
     142
     143HRESULT MousePointerShape::getAlpha(BOOL *aAlpha)
     144{
     145    *aAlpha = m.fAlpha;
     146    return S_OK;
     147}
     148
     149HRESULT MousePointerShape::getHotX(ULONG *aHotX)
     150{
     151    *aHotX = m.hotX;
     152    return S_OK;
     153}
     154
     155HRESULT MousePointerShape::getHotY(ULONG *aHotY)
     156{
     157    *aHotY = m.hotY;
     158    return S_OK;
     159}
     160
     161HRESULT MousePointerShape::getWidth(ULONG *aWidth)
     162{
     163    *aWidth = m.width;
     164    return S_OK;
     165}
     166
     167HRESULT MousePointerShape::getHeight(ULONG *aHeight)
     168{
     169    *aHeight = m.height;
     170    return S_OK;
     171}
     172
     173HRESULT MousePointerShape::getShape(std::vector<BYTE> &aShape)
     174{
     175    aShape.resize(m.shape.size());
     176    memcpy(&aShape.front(), &m.shape.front(), aShape.size());
     177    return S_OK;
     178}
     179
    31180
    32181/** @name Mouse device capabilities bitfield
     
    78227{
    79228    RT_ZERO(mpDrv);
     229    RT_ZERO(mPointerData);
    80230    mcLastX = 0x8000;
    81231    mcLastY = 0x8000;
     
    144294    }
    145295
     296    mPointerShape.setNull();
     297
     298    RTMemFree(mPointerData.pu8Shape);
     299    mPointerData.pu8Shape = NULL;
     300    mPointerData.cbShape = 0;
     301
    146302    mMouseEvent.uninit();
    147303    unconst(mEventSource).setNull();
     
    149305}
    150306
     307void Mouse::updateMousePointerShape(bool fVisible, bool fAlpha,
     308                                    uint32_t hotX, uint32_t hotY,
     309                                    uint32_t width, uint32_t height,
     310                                    const uint8_t *pu8Shape, uint32_t cbShape)
     311{
     312    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     313
     314    RTMemFree(mPointerData.pu8Shape);
     315    mPointerData.pu8Shape = NULL;
     316    mPointerData.cbShape = 0;
     317
     318    mPointerData.fVisible = fVisible;
     319    mPointerData.fAlpha   = fAlpha;
     320    mPointerData.hotX     = hotX;
     321    mPointerData.hotY     = hotY;
     322    mPointerData.width    = width;
     323    mPointerData.height   = height;
     324    if (cbShape)
     325    {
     326        mPointerData.pu8Shape = (uint8_t *)RTMemDup(pu8Shape, cbShape);
     327        if (mPointerData.pu8Shape)
     328        {
     329            mPointerData.cbShape = cbShape;
     330        }
     331    }
     332
     333    mPointerShape.setNull();
     334}
    151335
    152336// IMouse properties
     
    222406    *aNeedsHostCursor = i_guestNeedsHostCursor();
    223407    return S_OK;
     408}
     409
     410HRESULT Mouse::getPointerShape(ComPtr<IMousePointerShape> &aPointerShape)
     411{
     412    HRESULT hr = S_OK;
     413
     414    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     415
     416    if (mPointerShape.isNull())
     417    {
     418        ComObjPtr<MousePointerShape> obj;
     419        hr = obj.createObject();
     420        if (SUCCEEDED(hr))
     421        {
     422            hr = obj->init(this, mPointerData.fVisible, mPointerData.fAlpha,
     423                           mPointerData.hotX, mPointerData.hotY,
     424                           mPointerData.width, mPointerData.height,
     425                           mPointerData.pu8Shape, mPointerData.cbShape);
     426        }
     427
     428        if (SUCCEEDED(hr))
     429        {
     430            mPointerShape = obj;
     431        }
     432    }
     433
     434    if (SUCCEEDED(hr))
     435    {
     436        aPointerShape = mPointerShape;
     437    }
     438
     439    return hr;
    224440}
    225441
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