From f6e8bc8927253e315665e68033ca2f7df09ba1bf Mon Sep 17 00:00:00 2001 From: dscho Date: Tue, 2 Oct 2001 16:40:45 +0000 Subject: [PATCH] implemented rfbSetCursor --- CHANGES | 1 + cursor.c | 26 ++++++++++++++++++++++++++ rfb.h | 20 +++----------------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/CHANGES b/CHANGES index 1c7ddf5..d9ed9c8 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ pthreads now work cleaned up mac.c (from original OSXvnc); now compiles (untested!) compiles cleanly on Linux, IRIX, BSD, Apple + fixed prototypes 0.1 rewrote API to use pseudo-methods instead of required functions. lots of clean up. diff --git a/cursor.c b/cursor.c index 19897bb..90d6ad9 100644 --- a/cursor.c +++ b/cursor.c @@ -472,3 +472,29 @@ void rfbPrintXCursor(rfbCursorPtr cursor) putchar('\n'); } } + +extern void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c,Bool freeOld) +{ + rfbClientPtr cl; +#ifdef HAVE_PTHREADS + pthread_mutex_lock(rfbScreen->cursor->mutex); +#endif + for(cl=rfbScreen->rfbClientHead;cl;cl=cl->next) + if(cl->sock>=0) { +#ifdef HAVE_PTHREADS + pthread_mutex_lock(cl->updateMutex); +#endif + rfbUndrawCursor(cl); +#ifdef HAVE_PTHREADS + pthread_mutex_unlock(cl->updateMutex); +#endif + } +#ifdef HAVE_PTHREADS + pthread_mutex_unlock(rfbScreen->cursor->mutex); +#endif + + if(freeOld && rfbScreen->cursor) + rfbFreeCursor(rfbScreen->cursor); + + rfbScreen->cursor = c; +} diff --git a/rfb.h b/rfb.h index facfe50..81a165c 100644 --- a/rfb.h +++ b/rfb.h @@ -143,14 +143,14 @@ typedef struct routines can invoke the cursor routines, but also the cursor routines themselves end up invoking drawing routines. - Removing the cursor (rfbSpriteRemoveCursor) is eventually achieved by + Removing the cursor (rfbUndrawCursor) is eventually achieved by doing a CopyArea from a pixmap to the screen, where the pixmap contains the saved contents of the screen under the cursor. Before doing this, however, we set cursorIsDrawn to FALSE. Then, when CopyArea is called, it sees that cursorIsDrawn is FALSE and so doesn't feel the need to (recursively!) remove the cursor before doing it. - Putting up the cursor (rfbSpriteRestoreCursor) involves a call to + Putting up the cursor (rfbDrawCursor) involves a call to PushPixels. While this is happening, cursorIsDrawn must be FALSE so that PushPixels doesn't think it has to remove the cursor first. Obviously cursorIsDrawn is set to TRUE afterwards. @@ -175,23 +175,8 @@ typedef struct int cursorX, cursorY,underCursorBufferLen; char* underCursorBuffer; - /* wrapped screen functions */ - - /* - CloseScreenProcPtr CloseScreen; - CreateGCProcPtr CreateGC; - PaintWindowBackgroundProcPtr PaintWindowBackground; - PaintWindowBorderProcPtr PaintWindowBorder; - CopyWindowProcPtr CopyWindow; - ClearToBackgroundProcPtr ClearToBackground; - RestoreAreasProcPtr RestoreAreas; - */ - /* additions by libvncserver */ - /* - ScreenRec screen; - */ rfbPixelFormat rfbServerFormat; rfbColourMap colourMap; /* set this if rfbServerFormat.trueColour==FALSE */ char* desktopName; @@ -628,6 +613,7 @@ extern void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cu extern void rfbFreeCursor(rfbCursorPtr cursor); extern void rfbDrawCursor(rfbClientPtr cl); extern void rfbUndrawCursor(rfbClientPtr cl); +extern void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c,Bool freeOld); /* cursor handling for the pointer */ extern void defaultPtrAddEvent(int buttonMask,int x,int y,rfbClientPtr cl);