cursor changes

pull/1/head
dscho 24 years ago
parent 1e83d9a599
commit fa85c12aa9

@ -495,6 +495,7 @@ void rfbUndrawCursor(rfbClientPtr cl)
rfbCursorPtr c=s->cursor; rfbCursorPtr c=s->cursor;
int j,x1,x2,y1,y2,bpp=s->rfbServerFormat.bitsPerPixel/8, int j,x1,x2,y1,y2,bpp=s->rfbServerFormat.bitsPerPixel/8,
rowstride=s->paddedWidthInBytes; rowstride=s->paddedWidthInBytes;
return;
if(!s->cursorIsDrawn) if(!s->cursorIsDrawn)
return; return;
/* restore what is under the cursor */ /* restore what is under the cursor */
@ -512,6 +513,9 @@ void rfbUndrawCursor(rfbClientPtr cl)
memcpy(s->frameBuffer+(y1+j)*rowstride+x1*bpp, memcpy(s->frameBuffer+(y1+j)*rowstride+x1*bpp,
s->underCursorBuffer+j*x2*bpp, s->underCursorBuffer+j*x2*bpp,
x2*bpp); x2*bpp);
rfbMarkRectAsModified(s,x1,y1,x1+x2,y1+y2);
s->cursorIsDrawn = FALSE;
} }
void rfbDrawCursor(rfbClientPtr cl) void rfbDrawCursor(rfbClientPtr cl)
@ -521,6 +525,7 @@ void rfbDrawCursor(rfbClientPtr cl)
int i,j,x1,x2,y1,y2,i1,j1,bpp=s->rfbServerFormat.bitsPerPixel/8, int i,j,x1,x2,y1,y2,i1,j1,bpp=s->rfbServerFormat.bitsPerPixel/8,
rowstride=s->paddedWidthInBytes, rowstride=s->paddedWidthInBytes,
bufSize=c->width*c->height*bpp,w=(c->width+7)/8; bufSize=c->width*c->height*bpp,w=(c->width+7)/8;
return;
if(s->cursorIsDrawn) if(s->cursorIsDrawn)
rfbUndrawCursor(cl); rfbUndrawCursor(cl);
if(s->underCursorBufferLen<bufSize) { if(s->underCursorBufferLen<bufSize) {
@ -555,6 +560,9 @@ void rfbDrawCursor(rfbClientPtr cl)
if((c->mask[(j+j1)*w+(i+i1)/8]<<((i+i1)&7))&0x80) if((c->mask[(j+j1)*w+(i+i1)/8]<<((i+i1)&7))&0x80)
memcpy(s->frameBuffer+(j+y1)*rowstride+(i+x1)*bpp, memcpy(s->frameBuffer+(j+y1)*rowstride+(i+x1)*bpp,
c->richSource+(j+j1)*c->width*bpp+(i+i1)*bpp,bpp); c->richSource+(j+j1)*c->width*bpp+(i+i1)*bpp,bpp);
rfbMarkRectAsModified(s,x1,y1,x1+x2,y1+y2);
s->cursorIsDrawn = TRUE;
} }
void rfbPrintXCursor(rfbCursorPtr cursor) void rfbPrintXCursor(rfbCursorPtr cursor)

@ -94,6 +94,10 @@ void drawline(unsigned char* buffer,int rowstride,int bpp,int x1,int y1,int x2,i
void doptr(int buttonMask,int x,int y,rfbClientPtr cl) void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
{ {
ClientData* cd=cl->clientData; ClientData* cd=cl->clientData;
//if(cl->screen->cursorIsDrawn)
//rfbUndrawCursor(cl);
//cl->screen->cursorX=x;
//cl->screen->cursorY=y;
if(x>=0 && y>=0 && x<maxx && y<maxy) { if(x>=0 && y>=0 && x<maxx && y<maxy) {
if(buttonMask) { if(buttonMask) {
int i,j,x1,x2,y1,y2; int i,j,x1,x2,y1,y2;
@ -189,11 +193,15 @@ void dokey(Bool down,KeySym key,rfbClientPtr cl)
if(key==XK_Escape) if(key==XK_Escape)
rfbCloseClient(cl); rfbCloseClient(cl);
else if(key==XK_Page_Up) { else if(key==XK_Page_Up) {
//if(cl->screen->cursorIsDrawn)
//rfbUndrawCursor(cl);
initBuffer(cl->screen->frameBuffer); initBuffer(cl->screen->frameBuffer);
rfbMarkRectAsModified(cl->screen,0,0,maxx,maxy); rfbMarkRectAsModified(cl->screen,0,0,maxx,maxy);
} else if(key>=' ' && key<0x100) { } else if(key>=' ' && key<0x100) {
ClientData* cd=cl->clientData; ClientData* cd=cl->clientData;
int x1=cd->oldx,y1=cd->oldy,x2,y2; int x1=cd->oldx,y1=cd->oldy,x2,y2;
//if(cl->screen->cursorIsDrawn)
//rfbUndrawCursor(cl);
cd->oldx+=drawchar(cl->screen->frameBuffer, cd->oldx+=drawchar(cl->screen->frameBuffer,
cl->screen->paddedWidthInBytes,bpp,cd->oldx,cd->oldy, cl->screen->paddedWidthInBytes,bpp,cd->oldx,cd->oldy,
key); key);

@ -90,8 +90,8 @@ void rfbMarkRegionAsModified(rfbScreenInfoPtr rfbScreen,RegionPtr modRegion)
void rfbMarkRectAsModified(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2) void rfbMarkRectAsModified(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y2)
{ {
BoxRec box; BoxRec box; //=(BoxRec*)malloc(sizeof(BoxRec));
RegionRec region; RegionRec* region=(RegionRec*)malloc(sizeof(RegionRec));
int i; int i;
if(x1>x2) { i=x1; x1=x2; x2=i; } if(x1>x2) { i=x1; x1=x2; x2=i; }
x2++; x2++;
@ -104,8 +104,8 @@ void rfbMarkRectAsModified(rfbScreenInfoPtr rfbScreen,int x1,int y1,int x2,int y
if(y2>=rfbScreen->height) { y2=rfbScreen->height-1; if(y1==y2) y1--; } if(y2>=rfbScreen->height) { y2=rfbScreen->height-1; if(y1==y2) y1--; }
box.x1=x1; box.y1=y1; box.x2=x2; box.y2=y2; box.x1=x1; box.y1=y1; box.x2=x2; box.y2=y2;
REGION_INIT(cl->screen,&region,&box,0); REGION_INIT(cl->screen,region,&box,0);
rfbMarkRegionAsModified(rfbScreen,&region); rfbMarkRegionAsModified(rfbScreen,region);
} }
int rfbDeferUpdateTime = 40; /* ms */ int rfbDeferUpdateTime = 40; /* ms */
@ -298,6 +298,15 @@ defaultKbdAddEvent(Bool down, KeySym keySym, rfbClientPtr cl)
void void
defaultPtrAddEvent(int buttonMask, int x, int y, rfbClientPtr cl) defaultPtrAddEvent(int buttonMask, int x, int y, rfbClientPtr cl)
{ {
if(x!=cl->screen->cursorX || y!=cl->screen->cursorY) {
Bool cursorWasDrawn=cl->screen->cursorIsDrawn;
if(cursorWasDrawn)
rfbUndrawCursor(cl);
cl->screen->cursorX = x;
cl->screen->cursorY = y;
if(cursorWasDrawn)
rfbDrawCursor(cl);
}
} }
void defaultSetXCutText(char* text, int len, rfbClientPtr cl) void defaultSetXCutText(char* text, int len, rfbClientPtr cl)

@ -539,6 +539,8 @@ extern char* rfbMakeMaskForXCursor(int width,int height,char* cursorString);
extern void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor); extern void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
extern void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor); extern void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor);
extern void rfbFreeCursor(rfbCursorPtr cursor); extern void rfbFreeCursor(rfbCursorPtr cursor);
extern void rfbDrawCursor(rfbClientPtr cl);
extern void rfbUndrawCursor(rfbClientPtr cl);
/* stats.c */ /* stats.c */

@ -834,17 +834,20 @@ rfbSendFramebufferUpdate(cl, updateRegion)
* removed from the framebuffer. Otherwise, make sure it's put up. * removed from the framebuffer. Otherwise, make sure it's put up.
*/ */
if (cl->enableCursorShapeUpdates) { cursorWasDrawn = cl->screen->cursorIsDrawn;
cursorWasDrawn = cl->screen->cursorIsDrawn;
if (cl->screen->cursorIsDrawn) { if (cl->enableCursorShapeUpdates) {
fprintf(stderr,"rfbSpriteRemoveCursor(pScreen); not yet!\n"); if (cl->screen->cursorIsDrawn) {
} rfbUndrawCursor(cl);
if (!cl->screen->cursorIsDrawn && cl->cursorWasChanged) //fprintf(stderr,"rfbSpriteRemoveCursor(pScreen); not yet!\n");
sendCursorShape = TRUE; }
} else { if (!cl->screen->cursorIsDrawn && cl->cursorWasChanged)
if (!cl->screen->cursorIsDrawn) sendCursorShape = TRUE;
fprintf(stderr,"rfbSpriteRestoreCursor(pScreen); not yet!\n"); } else {
} if (!cl->screen->cursorIsDrawn)
//rfbDrawCursor(cl);
fprintf(stderr,"rfbSpriteRestoreCursor(pScreen); not yet!\n");
}
/* /*
* The modifiedRegion may overlap the destination copyRegion. We remove * The modifiedRegion may overlap the destination copyRegion. We remove
@ -1046,9 +1049,11 @@ rfbSendFramebufferUpdate(cl, updateRegion)
if(cursorWasDrawn != cl->screen->cursorIsDrawn) { if(cursorWasDrawn != cl->screen->cursorIsDrawn) {
if(cursorWasDrawn) if(cursorWasDrawn)
fprintf(stderr,"rfbSpriteRestoreCursor(pScreen); not yet!!\n"); rfbDrawCursor(cl);
//fprintf(stderr,"rfbSpriteRestoreCursor(pScreen); not yet!!\n");
else else
fprintf(stderr,"rfbSpriteRemoveCursor(pScreen); not yet!!\n"); rfbUndrawCursor(cl);
//fprintf(stderr,"rfbSpriteRemoveCursor(pScreen); not yet!!\n");
} }
return TRUE; return TRUE;

Loading…
Cancel
Save