diff --git a/mac.c b/mac.c index 94ef5d2..ff37f01 100644 --- a/mac.c +++ b/mac.c @@ -266,6 +266,8 @@ PtrAddEvent(buttonMask, x, y, cl) (buttonMask & (1 << 7)) ? TRUE : FALSE); } +Bool viewOnly = FALSE, sharedMode = FALSE; + void ScreenInit(int argc, char**argv) { @@ -278,8 +280,15 @@ ScreenInit(int argc, char**argv) rfbScreen->paddedWidthInBytes = CGDisplayBytesPerRow(kCGDirectMainDisplay); rfbScreen->frameBuffer = (char *)CGDisplayBaseAddress(kCGDirectMainDisplay); - rfbScreen->ptrAddEvent = PtrAddEvent; - rfbScreen->kbdAddEvent = KbdAddEvent; + + if(!viewOnly) { + rfbScreen->ptrAddEvent = PtrAddEvent; + rfbScreen->kbdAddEvent = KbdAddEvent; + } + if(sharedMode) { + rfbScreen->rfbAlwaysShared = TRUE; + } + rfbInitServer(rfbScreen); } @@ -321,6 +330,10 @@ int main(int argc,char *argv[]) startTime = time(0); } else if(strcmp(argv[i],"-runforever")==0) { disconnectAfterFirstClient = FALSE; + } else if(strcmp(argv[i],"-viewonly")==0) { + viewOnly=TRUE; + } else if(strcmp(argv[i],"-shared")==0) { + sharedMode=TRUE; } ScreenInit(argc,argv); diff --git a/x11vnc.c b/x11vnc.c index 70b4ca8..3c067f1 100644 --- a/x11vnc.c +++ b/x11vnc.c @@ -16,8 +16,10 @@ Display *dpy = 0; int window; int c=0,blockLength = 32; -int tileX=0,tileY=0,tileWidth=32,tileHeight=32*2,dontTile=True; +int tileX=0,tileY=0,tileWidth=32,tileHeight=32*2,dontTile=TRUE; Bool gotInput = FALSE; +Bool viewOnly = FALSE; +Bool sharedMode = FALSE; Bool disconnectAfterFirstClient = TRUE; @@ -129,7 +131,7 @@ int oldButtonMask = 0; void mouse(int buttonMask,int x,int y,rfbClientPtr cl) { int i=0; - //fprintf(stderr,"/"); + XTestFakeMotionEvent(dpy,0,x,y,CurrentTime ); while(i<5) { if ((oldButtonMask&(1<frameBuffer = backupImage; screen->cursor = 0; screen->newClientHook = newClient; - screen->kbdAddEvent = keyboard; - screen->ptrAddEvent = mouse; + + if(!viewOnly) { + screen->kbdAddEvent = keyboard; + screen->ptrAddEvent = mouse; + } + if(sharedMode) { + screen->rfbAlwaysShared = TRUE; + } screen->rfbDeferUpdateTime = 1; updateCounter /= screen->rfbDeferUpdateTime;