changed cursor functions to use screen info, not cursor

fixed copy rect.
pull/1/head
dscho 23 years ago
parent 8f407f8a1a
commit 018e90db59

@ -1,5 +1,11 @@
0.2 0.2
flag backgroundLoop in rfbScreenInfo fixed CopyRect (was using the wrong order of rectangles...)
should also work with pthreads, because copyrects are
always sent immediately (so that two consecutive copy rects
cannot conflict).
changed rfbUndrawCursor(rfbClientPtr) to (rfbScreenInfoPtr), because
this makes more sense!
flag backgroundLoop in rfbScreenInfo (if having pthreads)
rfbCopyRect & rfbCopyRegion (really copies rectangle in frameBuffer) rfbCopyRect & rfbCopyRegion (really copies rectangle in frameBuffer)
added flag to optionally not send XCursor updates. added flag to optionally not send XCursor updates.
fixed java viewer on server side: fixed java viewer on server side:

@ -1,7 +1,7 @@
immediate: immediate:
---------- ----------
copyRect and pthreads possible problem. test copyRect and pthreads.
authentification schemes (secure vnc) authentification schemes (secure vnc)
udp udp
documentation documentation

@ -331,9 +331,8 @@ void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
/* functions to draw/hide cursor directly in the frame buffer */ /* functions to draw/hide cursor directly in the frame buffer */
void rfbUndrawCursor(rfbClientPtr cl) void rfbUndrawCursor(rfbScreenInfoPtr s)
{ {
rfbScreenInfoPtr s=cl->screen;
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;
@ -372,9 +371,8 @@ void rfbUndrawCursor(rfbClientPtr cl)
UNLOCK(s->cursorMutex); UNLOCK(s->cursorMutex);
} }
void rfbDrawCursor(rfbClientPtr cl) void rfbDrawCursor(rfbScreenInfoPtr s)
{ {
rfbScreenInfoPtr s=cl->screen;
rfbCursorPtr c=s->cursor; rfbCursorPtr c=s->cursor;
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,
@ -453,16 +451,8 @@ void rfbPrintXCursor(rfbCursorPtr cursor)
extern void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c,Bool freeOld) extern void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c,Bool freeOld)
{ {
rfbClientIteratorPtr i = rfbGetClientIterator(rfbScreen);
rfbClientPtr cl;
LOCK(rfbScreen->cursorMutex); LOCK(rfbScreen->cursorMutex);
rfbUndrawCursor(rfbScreen);
while((cl=rfbClientIteratorNext(i))) {
LOCK(cl->updateMutex);
rfbUndrawCursor(cl);
UNLOCK(cl->updateMutex);
}
if(freeOld && rfbScreen->cursor) if(freeOld && rfbScreen->cursor)
rfbFreeCursor(rfbScreen->cursor); rfbFreeCursor(rfbScreen->cursor);

@ -102,7 +102,7 @@ void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
ClientData* cd=cl->clientData; ClientData* cd=cl->clientData;
if(cl->screen->cursorIsDrawn) if(cl->screen->cursorIsDrawn)
rfbUndrawCursor(cl); rfbUndrawCursor(cl->screen);
if(x>=0 && y>=0 && x<maxx && y<maxy) { if(x>=0 && y>=0 && x<maxx && y<maxy) {
if(buttonMask) { if(buttonMask) {
@ -149,14 +149,14 @@ void dokey(Bool down,KeySym key,rfbClientPtr cl)
rfbCloseClient(cl); rfbCloseClient(cl);
else if(key==XK_Page_Up) { else if(key==XK_Page_Up) {
if(cl->screen->cursorIsDrawn) if(cl->screen->cursorIsDrawn)
rfbUndrawCursor(cl); rfbUndrawCursor(cl->screen);
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) if(cl->screen->cursorIsDrawn)
rfbUndrawCursor(cl); rfbUndrawCursor(cl->screen);
cd->oldx+=rfbDrawChar(cl->screen,&radonFont,cd->oldx,cd->oldy,key,0xffffff); cd->oldx+=rfbDrawChar(cl->screen,&radonFont,cd->oldx,cd->oldy,key,0xffffff);
rfbFontBBox(&radonFont,key,&x1,&y1,&x2,&y2); rfbFontBBox(&radonFont,key,&x1,&y1,&x2,&y2);
rfbMarkRectAsModified(cl->screen,x1,y1,x2-1,y2-1); rfbMarkRectAsModified(cl->screen,x1,y1,x2-1,y2-1);

@ -67,23 +67,29 @@ void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,in
rfbClientIteratorPtr iterator; rfbClientIteratorPtr iterator;
rfbClientPtr cl; rfbClientPtr cl;
iterator=rfbGetClientIterator(rfbScreen); rfbUndrawCursor(rfbScreen);
iterator=rfbGetClientIterator(rfbScreen);
while((cl=rfbClientIteratorNext(iterator))) { while((cl=rfbClientIteratorNext(iterator))) {
LOCK(cl->updateMutex); LOCK(cl->updateMutex);
if(cl->useCopyRect) { if(cl->useCopyRect) {
while(!sraRgnEmpty(cl->copyRegion) && (cl->copyDX!=dx || cl->copyDY!=dy)) {
#ifdef HAVE_PTHREADS
if(cl->screen->backgroundLoop) {
SIGNAL(cl->updateCond);
UNLOCK(cl->updateMutex);
LOCK(cl->updateMutex);
} else
#endif
rfbSendFramebufferUpdate(cl,cl->copyRegion);
}
sraRgnOr(cl->copyRegion,copyRegion); sraRgnOr(cl->copyRegion,copyRegion);
cl->copyDX = dx; cl->copyDX = dx;
cl->copyDY = dy; cl->copyDY = dy;
#ifdef HAVE_PTHREADS
if(cl->screen->backgroundLoop) {
SIGNAL(cl->updateCond);
UNLOCK(cl->updateMutex);
LOCK(cl->updateMutex);
} else
#endif
{
sraRegionPtr updateRegion = sraRgnCreateRgn(cl->modifiedRegion);
sraRgnOr(updateRegion,cl->copyRegion);
rfbSendFramebufferUpdate(cl,updateRegion);
sraRgnDestroy(updateRegion);
}
} else { } else {
sraRgnOr(cl->modifiedRegion,copyRegion); sraRgnOr(cl->modifiedRegion,copyRegion);
} }
@ -332,7 +338,7 @@ defaultPtrAddEvent(int buttonMask, int x, int y, rfbClientPtr cl)
{ {
if(x!=cl->screen->cursorX || y!=cl->screen->cursorY) { if(x!=cl->screen->cursorX || y!=cl->screen->cursorY) {
if(cl->screen->cursorIsDrawn) if(cl->screen->cursorIsDrawn)
rfbUndrawCursor(cl); rfbUndrawCursor(cl->screen);
LOCK(cl->screen->cursorMutex); LOCK(cl->screen->cursorMutex);
if(!cl->screen->cursorIsDrawn) { if(!cl->screen->cursorIsDrawn) {
cl->screen->cursorX = x; cl->screen->cursorX = x;

@ -667,8 +667,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 rfbDrawCursor(rfbScreenInfoPtr rfbScreen);
extern void rfbUndrawCursor(rfbClientPtr cl); extern void rfbUndrawCursor(rfbScreenInfoPtr rfbScreen);
extern void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c,Bool freeOld); extern void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c,Bool freeOld);
/* cursor handling for the pointer */ /* cursor handling for the pointer */

@ -857,14 +857,14 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
if (cl->enableCursorShapeUpdates) { if (cl->enableCursorShapeUpdates) {
if (cl->screen->cursorIsDrawn) { if (cl->screen->cursorIsDrawn) {
rfbUndrawCursor(cl); rfbUndrawCursor(cl->screen);
} }
if (!cl->screen->cursorIsDrawn && cl->cursorWasChanged && if (!cl->screen->cursorIsDrawn && cl->cursorWasChanged &&
cl->readyForSetColourMapEntries) cl->readyForSetColourMapEntries)
sendCursorShape = TRUE; sendCursorShape = TRUE;
} else { } else {
if (!cl->screen->cursorIsDrawn) { if (!cl->screen->cursorIsDrawn) {
rfbDrawCursor(cl); rfbDrawCursor(cl->screen);
} }
} }
@ -1093,7 +1093,7 @@ rfbSendCopyRegion(cl, reg, dx, dy)
sraRectangleIterator* i; sraRectangleIterator* i;
sraRect rect1; sraRect rect1;
i = sraRgnGetReverseIterator(reg,dx<0,dy<0); i = sraRgnGetReverseIterator(reg,dx>0,dy>0);
while(sraRgnIteratorNext(i,&rect1)) { while(sraRgnIteratorNext(i,&rect1)) {
x = rect1.x1; x = rect1.x1;
@ -1113,7 +1113,7 @@ rfbSendCopyRegion(cl, reg, dx, dy)
cr.srcX = Swap16IfLE(x - dx); cr.srcX = Swap16IfLE(x - dx);
cr.srcY = Swap16IfLE(y - dy); cr.srcY = Swap16IfLE(y - dy);
fprintf(stderr,"sent copyrect (%d,%d) (%d,%d) (%d,%d)\n",x,y,w,h,x-dx,y-dy);
memcpy(&cl->updateBuf[cl->ublen], (char *)&cr, sz_rfbCopyRect); memcpy(&cl->updateBuf[cl->ublen], (char *)&cr, sz_rfbCopyRect);
cl->ublen += sz_rfbCopyRect; cl->ublen += sz_rfbCopyRect;

Loading…
Cancel
Save