: majorVersion(0), minorVersion(0),
width(0), height(0), useCopyRect(false),
supportsLocalCursor(false), supportsLocalXCursor(false),
+ supportsLocalCursorWithAlpha(false),
supportsDesktopResize(false), supportsExtendedDesktopSize(false),
supportsDesktopRename(false), supportsLastRect(false),
supportsSetDesktopSize(false), supportsFence(false),
{
useCopyRect = false;
supportsLocalCursor = false;
+ supportsLocalCursorWithAlpha = false;
supportsDesktopResize = false;
supportsExtendedDesktopSize = false;
supportsLocalXCursor = false;
case pseudoEncodingXCursor:
supportsLocalXCursor = true;
break;
+ case pseudoEncodingCursorWithAlpha:
+ supportsLocalCursorWithAlpha = true;
+ break;
case pseudoEncodingDesktopSize:
supportsDesktopResize = true;
break;
: cp(cp_), os(os_),
nRectsInUpdate(0), nRectsInHeader(0),
needSetDesktopSize(false), needExtendedDesktopSize(false),
- needSetDesktopName(false), needSetCursor(false), needSetXCursor(false)
+ needSetDesktopName(false), needSetCursor(false),
+ needSetXCursor(false), needSetCursorWithAlpha(false)
{
}
return true;
}
+bool SMsgWriter::writeSetCursorWithAlpha()
+{
+ if (!cp->supportsLocalCursorWithAlpha)
+ return false;
+
+ needSetCursorWithAlpha = true;
+
+ return true;
+}
+
bool SMsgWriter::needFakeUpdate()
{
if (needSetDesktopName)
return true;
- if (needSetCursor || needSetXCursor)
+ if (needSetCursor || needSetXCursor || needSetCursorWithAlpha)
return true;
if (needNoDataUpdate())
return true;
nRects++;
if (needSetXCursor)
nRects++;
+ if (needSetCursorWithAlpha)
+ nRects++;
}
os->writeU16(nRects);
needSetXCursor = false;
}
+ if (needSetCursorWithAlpha) {
+ const Cursor& cursor = cp->cursor();
+
+ writeSetCursorWithAlphaRect(cursor.width(), cursor.height(),
+ cursor.hotspot().x, cursor.hotspot().y,
+ cursor.getBuffer());
+ needSetCursorWithAlpha = false;
+ }
+
if (needSetDesktopName) {
writeSetDesktopNameRect(cp->name());
needSetDesktopName = false;
os->writeBytes(mask, (width+7)/8 * height);
}
}
+
+void SMsgWriter::writeSetCursorWithAlphaRect(int width, int height,
+ int hotspotX, int hotspotY,
+ const rdr::U8* data)
+{
+ if (!cp->supportsLocalCursorWithAlpha)
+ throw Exception("Client does not support local cursors");
+ if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
+ throw Exception("SMsgWriter::writeSetCursorWithAlphaRect: nRects out of sync");
+
+ os->writeS16(hotspotX);
+ os->writeS16(hotspotY);
+ os->writeU16(width);
+ os->writeU16(height);
+ os->writeU32(pseudoEncodingCursorWithAlpha);
+
+ // FIXME: Use an encoder with compression?
+ os->writeU32(encodingRaw);
+
+ // Alpha needs to be pre-multiplied
+ for (int i = 0;i < width*height;i++) {
+ os->writeU8((unsigned)data[0] * data[3] / 255);
+ os->writeU8((unsigned)data[1] * data[3] / 255);
+ os->writeU8((unsigned)data[2] * data[3] / 255);
+ os->writeU8(data[3]);
+ data += 4;
+ }
+}
// immediately.
bool writeSetCursor();
bool writeSetXCursor();
+ bool writeSetCursorWithAlpha();
// needFakeUpdate() returns true when an immediate update is needed in
// order to flush out pseudo-rectangles to the client.
void writeSetXCursorRect(int width, int height,
int hotspotX, int hotspotY,
const void* data, const void* mask);
+ void writeSetCursorWithAlphaRect(int width, int height,
+ int hotspotX, int hotspotY,
+ const rdr::U8* data);
ConnParams* cp;
rdr::OutStream* os;
bool needLastRect;
bool needSetCursor;
bool needSetXCursor;
+ bool needSetCursorWithAlpha;
typedef struct {
rdr::U16 reason, result;