- Timestamp:
- Oct 2, 2014 6:36:54 AM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 96356
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r52830 r52921 15038 15038 15039 15039 <interface 15040 name="IMousePointerShape" extends="$unknown" 15041 uuid="4609f3e1-839a-4edd-b57f-cc4584b39173" 15042 wsmap="managed" 15043 > 15044 <desc> 15045 The guest mouse pointer description. 15046 </desc> 15047 15048 <attribute name="visible" type="boolean" readonly="yes"> 15049 <desc> 15050 Flag whether the pointer is visible. 15051 </desc> 15052 </attribute> 15053 <attribute name="alpha" type="boolean" readonly="yes"> 15054 <desc> 15055 Flag whether the pointer has an alpha channel. 15056 </desc> 15057 </attribute> 15058 <attribute name="hotX" type="unsigned long" readonly="yes"> 15059 <desc> 15060 The pointer hot spot X coordinate. 15061 </desc> 15062 </attribute> 15063 <attribute name="hotY" type="unsigned long" readonly="yes"> 15064 <desc> 15065 The pointer hot spot Y coordinate. 15066 </desc> 15067 </attribute> 15068 <attribute name="width" type="unsigned long" readonly="yes"> 15069 <desc> 15070 Width of the pointer shape in pixels. 15071 </desc> 15072 </attribute> 15073 <attribute name="height" type="unsigned long" readonly="yes"> 15074 <desc> 15075 Height of the pointer shape in pixels. 15076 </desc> 15077 </attribute> 15078 <attribute name="shape" type="octet" safearray="yes" readonly="yes"> 15079 <desc> 15080 Shape bitmaps. 15081 15082 The @a shape buffer contains a 1bpp (bits per pixel) AND mask 15083 followed by a 32bpp XOR (color) mask. 15084 15085 For pointers without alpha channel the XOR mask pixels are 15086 32 bit values: (lsb)BGR0(msb). For pointers with alpha channel 15087 the XOR mask consists of (lsb)BGRA(msb) 32 bit values. 15088 15089 An AND mask is provided for pointers with alpha channel, so if the 15090 client does not support alpha, the pointer could be 15091 displayed as a normal color pointer. 15092 15093 The AND mask is a 1bpp bitmap with byte aligned scanlines. The 15094 size of the AND mask therefore is <tt>cbAnd = (width + 7) / 8 * 15095 height</tt>. The padding bits at the end of each scanline are 15096 undefined. 15097 15098 The XOR mask follows the AND mask on the next 4-byte aligned 15099 offset: <tt>uint8_t *pu8Xor = pu8And + (cbAnd + 3) & ~3</tt>. 15100 Bytes in the gap between the AND and the XOR mask are undefined. 15101 The XOR mask scanlines have no gap between them and the size of 15102 the XOR mask is: <tt>cbXor = width * 4 * height</tt>. 15103 15104 <note> 15105 If @a shape size is 0, then the shape is not known or did not change. 15106 This can happen if only the pointer visibility is changed. 15107 </note> 15108 </desc> 15109 </attribute> 15110 </interface> 15111 15112 <interface 15040 15113 name="IMouse" extends="$unknown" 15041 uuid=" ee770393-415f-4421-b2d5-28b73cacf86a"15114 uuid="4c3fa51c-7b9a-4ecf-97f0-d75a945bd26c" 15042 15115 wsmap="managed" 15043 15116 > … … 15098 15171 </note> 15099 15172 <see><link to="#putMouseEvent"/></see> 15173 </desc> 15174 </attribute> 15175 15176 <attribute name="pointerShape" type="IMousePointerShape" readonly="yes"> 15177 <desc> 15178 The current mouse pointer used by the guest. 15100 15179 </desc> 15101 15180 </attribute> -
trunk/src/VBox/Main/include/MouseImpl.h
r52858 r52921 57 57 } 58 58 59 void updateMousePointerShape(bool fVisible, bool fAlpha, 60 uint32_t hotX, uint32_t hotY, 61 uint32_t width, uint32_t height, 62 const uint8_t *pu8Shape, uint32_t cbShape); 59 63 private: 60 64 … … 64 68 HRESULT getMultiTouchSupported(BOOL *aMultiTouchSupported); 65 69 HRESULT getNeedsHostCursor(BOOL *aNeedsHostCursor); 70 HRESULT getPointerShape(ComPtr<IMousePointerShape> &aPointerShape); 66 71 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource); 67 72 … … 123 128 uint32_t mfLastButtons; 124 129 130 ComPtr<IMousePointerShape> mPointerShape; 131 struct 132 { 133 bool fVisible; 134 bool fAlpha; 135 uint32_t hotX; 136 uint32_t hotY; 137 uint32_t width; 138 uint32_t height; 139 uint8_t *pu8Shape; 140 uint32_t cbShape; 141 } mPointerData; 142 125 143 const ComObjPtr<EventSource> mEventSource; 126 144 VBoxEventDesc mMouseEvent; -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r52901 r52921 6382 6382 } 6383 6383 #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()); 6384 6388 6385 6389 fireMousePointerShapeChangedEvent(mEventSource, fVisible, fAlpha, xHot, yHot, width, height, ComSafeArrayInArg(pShape)); -
trunk/src/VBox/Main/src-client/MouseImpl.cpp
r52821 r52921 21 21 #include "DisplayImpl.h" 22 22 #include "VMMDev.h" 23 #include "MousePointerShapeWrap.h" 23 24 24 25 #include "AutoCaller.h" … … 29 30 30 31 #include <iprt/asm.h> 32 33 class ATL_NO_VTABLE MousePointerShape: 34 public MousePointerShapeWrap 35 { 36 public: 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 51 private: 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 */ 79 DEFINE_EMPTY_CTOR_DTOR(MousePointerShape) 80 81 HRESULT MousePointerShape::FinalConstruct() 82 { 83 return BaseFinalConstruct(); 84 } 85 86 void MousePointerShape::FinalRelease() 87 { 88 uninit(); 89 90 BaseFinalRelease(); 91 } 92 93 HRESULT 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 125 void 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 137 HRESULT MousePointerShape::getVisible(BOOL *aVisible) 138 { 139 *aVisible = m.fVisible; 140 return S_OK; 141 } 142 143 HRESULT MousePointerShape::getAlpha(BOOL *aAlpha) 144 { 145 *aAlpha = m.fAlpha; 146 return S_OK; 147 } 148 149 HRESULT MousePointerShape::getHotX(ULONG *aHotX) 150 { 151 *aHotX = m.hotX; 152 return S_OK; 153 } 154 155 HRESULT MousePointerShape::getHotY(ULONG *aHotY) 156 { 157 *aHotY = m.hotY; 158 return S_OK; 159 } 160 161 HRESULT MousePointerShape::getWidth(ULONG *aWidth) 162 { 163 *aWidth = m.width; 164 return S_OK; 165 } 166 167 HRESULT MousePointerShape::getHeight(ULONG *aHeight) 168 { 169 *aHeight = m.height; 170 return S_OK; 171 } 172 173 HRESULT 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 31 180 32 181 /** @name Mouse device capabilities bitfield … … 78 227 { 79 228 RT_ZERO(mpDrv); 229 RT_ZERO(mPointerData); 80 230 mcLastX = 0x8000; 81 231 mcLastY = 0x8000; … … 144 294 } 145 295 296 mPointerShape.setNull(); 297 298 RTMemFree(mPointerData.pu8Shape); 299 mPointerData.pu8Shape = NULL; 300 mPointerData.cbShape = 0; 301 146 302 mMouseEvent.uninit(); 147 303 unconst(mEventSource).setNull(); … … 149 305 } 150 306 307 void 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 } 151 335 152 336 // IMouse properties … … 222 406 *aNeedsHostCursor = i_guestNeedsHostCursor(); 223 407 return S_OK; 408 } 409 410 HRESULT 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; 224 440 } 225 441
Note:
See TracChangeset
for help on using the changeset viewer.