mirror of
https://github.com/KDE/krfb
synced 2026-07-01 07:41:17 -07:00
Fix: softcursor looked like trash when serverFormat != clientFormat (this fixes the BGR233 cursor issue as well)
svn path=/trunk/kdenetwork/krfb/; revision=163173
This commit is contained in:
@@ -177,8 +177,7 @@ rfbSendCursorShape(cl)
|
||||
*/
|
||||
|
||||
Bool
|
||||
rfbSendSoftCursor(cl)
|
||||
rfbClientPtr cl;
|
||||
rfbSendSoftCursor(rfbClientPtr cl, Bool cursorWasChanged)
|
||||
{
|
||||
rfbCursorPtr pCursor;
|
||||
rfbSoftCursorSetImage setImage;
|
||||
@@ -187,7 +186,14 @@ rfbSendSoftCursor(cl)
|
||||
int saved_ublen, i, scOindex, scNindex, nlen, imgLen;
|
||||
|
||||
pCursor = cl->screen->getCursorPtr(cl);
|
||||
MakeSoftCursor(cl->screen,pCursor);
|
||||
if (cursorWasChanged && cl->softSource) {
|
||||
free(cl->softSource);
|
||||
cl->softSource = 0;
|
||||
}
|
||||
if (!cl->softSource)
|
||||
MakeSoftCursor(cl, pCursor);
|
||||
|
||||
imgLen = cl->softSourceLen;
|
||||
|
||||
/* If there is no cursor, send update with empty cursor data. */
|
||||
|
||||
@@ -197,11 +203,6 @@ rfbSendSoftCursor(cl)
|
||||
pCursor = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (pCursor == NULL)
|
||||
imgLen = 0;
|
||||
else
|
||||
imgLen = pCursor->softCursorLength;
|
||||
setImage.imageLength = Swap16IfLE(imgLen);
|
||||
|
||||
scOindex = -1;
|
||||
@@ -216,7 +217,7 @@ rfbSendSoftCursor(cl)
|
||||
setImage.imageIndex = scsi->imageIndex;
|
||||
if (!memcmp((char*)scsi, (char*)&setImage, sizeof(setImage))) {
|
||||
if (imgLen && !memcmp(((char*)scsi)+sizeof(rfbSoftCursorSetImage),
|
||||
(char*)pCursor->softSource,
|
||||
cl->softSource,
|
||||
imgLen)) {
|
||||
scOindex = i;
|
||||
break;
|
||||
@@ -241,7 +242,7 @@ rfbSendSoftCursor(cl)
|
||||
sizeof(setImage));
|
||||
if (imgLen)
|
||||
memcpy(((char*)cl->softCursorImages[scNindex])+sizeof(setImage),
|
||||
(char*)pCursor->softSource, imgLen);
|
||||
(char*)cl->softSource, imgLen);
|
||||
}
|
||||
|
||||
/* Send buffer contents if needed. */
|
||||
@@ -460,70 +461,82 @@ void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
|
||||
else memcpy(cp,back,bpp);
|
||||
}
|
||||
|
||||
void MakeSoftCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
|
||||
void MakeSoftCursor(rfbClientPtr cl, rfbCursorPtr cursor)
|
||||
{
|
||||
int w = (cursor->width+7)/8;
|
||||
int bpp = rfbScreen->rfbServerFormat.bitsPerPixel/8;
|
||||
unsigned char *cp, *sp;
|
||||
int state; /* 0 = transparent, 1 otherwise */
|
||||
CARD8 *counter;
|
||||
unsigned char bit;
|
||||
int i,j;
|
||||
int w = (cursor->width+7)/8;
|
||||
int bpp = cl->format.bitsPerPixel/8;
|
||||
int sbpp= cl->screen->rfbServerFormat.bitsPerPixel/8;
|
||||
unsigned char *cp, *sp, *translatedCursor;
|
||||
int state; /* 0 = transparent, 1 otherwise */
|
||||
CARD8 *counter;
|
||||
unsigned char bit;
|
||||
int i,j;
|
||||
|
||||
if ((!cursor) || (cl->softSource)) {
|
||||
cl->softSourceLen = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cursor->richSource)
|
||||
MakeRichCursorFromXCursor(cl->screen, cursor);
|
||||
|
||||
if ((!cursor) || cursor->softSource)
|
||||
return;
|
||||
sp = malloc(cursor->width*bpp*cursor->height);
|
||||
|
||||
if (!cursor->richSource)
|
||||
MakeRichCursorFromXCursor(rfbScreen, cursor);
|
||||
(*cl->translateFn)(cl->translateLookupTable,
|
||||
&(cl->screen->rfbServerFormat),
|
||||
&cl->format, cursor->richSource,
|
||||
sp, cursor->width*sbpp,
|
||||
cursor->width, cursor->height);
|
||||
|
||||
cp=cursor->softSource=(unsigned char*)calloc(cursor->width*(bpp+2),cursor->height);
|
||||
sp=cursor->richSource;
|
||||
translatedCursor = sp;
|
||||
cp=cl->softSource=(unsigned char*)calloc(cursor->width*(bpp+2),cursor->height);
|
||||
|
||||
state = 0;
|
||||
counter = cp++;
|
||||
*counter = 0;
|
||||
|
||||
for(j=0;j<cursor->height;j++)
|
||||
for(i=0,bit=0x80;i<cursor->width;i++,bit=(bit&1)?0x80:bit>>1)
|
||||
if(cursor->mask[j*w+i/8]&bit) {
|
||||
if (state) {
|
||||
memcpy(cp,sp,bpp);
|
||||
cp += bpp;
|
||||
sp += bpp;
|
||||
(*counter)++;
|
||||
if (*counter == 255) {
|
||||
state = 0;
|
||||
counter = cp++;
|
||||
*counter = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
state = 1;
|
||||
counter = cp++;
|
||||
*counter = 1;
|
||||
memcpy(cp,sp,bpp);
|
||||
cp += bpp;
|
||||
sp += bpp;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!state) {
|
||||
(*counter)++;
|
||||
if (*counter == 255) {
|
||||
state = 1;
|
||||
counter = cp++;
|
||||
*counter = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
state = 0;
|
||||
counter = cp++;
|
||||
*counter = 1;
|
||||
}
|
||||
sp += bpp;
|
||||
}
|
||||
|
||||
state = 0;
|
||||
counter = cp++;
|
||||
*counter = 0;
|
||||
|
||||
for(j=0;j<cursor->height;j++)
|
||||
for(i=0,bit=0x80;i<cursor->width;i++,bit=(bit&1)?0x80:bit>>1)
|
||||
if(cursor->mask[j*w+i/8]&bit) {
|
||||
if (state) {
|
||||
memcpy(cp,sp,bpp);
|
||||
cp += bpp;
|
||||
sp += bpp;
|
||||
(*counter)++;
|
||||
if (*counter == 255) {
|
||||
state = 0;
|
||||
counter = cp++;
|
||||
*counter = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
state = 1;
|
||||
counter = cp++;
|
||||
*counter = 1;
|
||||
memcpy(cp,sp,bpp);
|
||||
cp += bpp;
|
||||
sp += bpp;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!state) {
|
||||
(*counter)++;
|
||||
if (*counter == 255) {
|
||||
state = 1;
|
||||
counter = cp++;
|
||||
*counter = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
state = 0;
|
||||
counter = cp++;
|
||||
*counter = 1;
|
||||
}
|
||||
sp += bpp;
|
||||
}
|
||||
|
||||
cursor->softCursorLength = cp - cursor->softSource;
|
||||
free(translatedCursor);
|
||||
cl->softSourceLen = cp - cl->softSource;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -504,6 +504,8 @@ typedef struct _rfbClientRec {
|
||||
int tightQualityLevel;
|
||||
|
||||
/* soft cursor images */
|
||||
unsigned char *softSource;
|
||||
int softSourceLen;
|
||||
rfbSoftCursorSetImage *softCursorImages[rfbSoftCursorMaxImages];
|
||||
int nextUnusedSoftCursorImage;
|
||||
|
||||
@@ -703,20 +705,18 @@ typedef struct rfbCursor {
|
||||
unsigned short width, height, xhot, yhot; /* metrics */
|
||||
unsigned short foreRed, foreGreen, foreBlue; /* device-independent colour */
|
||||
unsigned short backRed, backGreen, backBlue; /* device-independent colour */
|
||||
unsigned short softCursorLength;
|
||||
unsigned char *richSource; /* source bytes for a rich cursor */
|
||||
unsigned char *softSource; /* image for a soft cursor */
|
||||
} rfbCursor, *rfbCursorPtr;
|
||||
|
||||
extern Bool rfbSendCursorShape(rfbClientPtr cl/*, rfbScreenInfoPtr pScreen*/);
|
||||
extern Bool rfbSendSoftCursor(rfbClientPtr cl);
|
||||
extern Bool rfbSendSoftCursor(rfbClientPtr cl, Bool cursorWasChanged);
|
||||
extern unsigned char rfbReverseByte[0x100];
|
||||
extern void rfbConvertLSBCursorBitmapOrMask(int width,int height,unsigned char* bitmap);
|
||||
extern rfbCursorPtr rfbMakeXCursor(int width,int height,char* cursorString,char* maskString);
|
||||
extern char* rfbMakeMaskForXCursor(int width,int height,char* cursorString);
|
||||
extern void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
|
||||
extern void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
|
||||
extern void MakeSoftCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
|
||||
extern void MakeSoftCursor(rfbClientPtr cl,rfbCursorPtr cursor);
|
||||
extern void rfbFreeCursor(rfbCursorPtr cursor);
|
||||
extern void rfbDrawCursor(rfbScreenInfoPtr rfbScreen);
|
||||
extern void rfbUndrawCursor(rfbScreenInfoPtr rfbScreen);
|
||||
|
||||
@@ -1093,12 +1093,12 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
|
||||
}
|
||||
|
||||
if (sendSoftCursorRects) {
|
||||
cl->cursorWasChanged = FALSE;
|
||||
cl->cursorWasMoved = FALSE;
|
||||
if (!rfbSendSoftCursor(cl)) {
|
||||
if (!rfbSendSoftCursor(cl, cl->cursorWasChanged)) {
|
||||
sraRgnDestroy(updateRegion);
|
||||
return FALSE;
|
||||
}
|
||||
cl->cursorWasChanged = FALSE;
|
||||
cl->cursorWasMoved = FALSE;
|
||||
}
|
||||
|
||||
if (!sraRgnEmpty(updateCopyRegion)) {
|
||||
|
||||
Reference in New Issue
Block a user