diff options
author | dscho <dscho> | 2002-01-14 11:09:50 +0000 |
---|---|---|
committer | dscho <dscho> | 2002-01-14 11:09:50 +0000 |
commit | b9e4a63f128b24c1548cabd983e8269042d63732 (patch) | |
tree | e743cbfb214a15cd6b5ebf392e223ee384a9e40a /mac.c | |
parent | ca932ee1024979204e57c8b2b70c3da95f78457e (diff) | |
download | libtdevnc-b9e4a63f128b24c1548cabd983e8269042d63732.tar.gz libtdevnc-b9e4a63f128b24c1548cabd983e8269042d63732.zip |
toggle view only with OSX
Diffstat (limited to 'mac.c')
-rw-r--r-- | mac.c | 59 |
1 files changed, 55 insertions, 4 deletions
@@ -27,6 +27,12 @@ * */ +#define LOCAL_CONTROL + +#ifdef LOCAL_CONTROL +#include "1instance.c" +#endif + #include <unistd.h> #include <ApplicationServices/ApplicationServices.h> #include <Carbon/Carbon.h> @@ -225,6 +231,8 @@ KbdAddEvent(Bool down, KeySym keySym, struct rfbClientRec* cl) CGKeyCode keyCode = -1; int found = 0; + if(((int)cl->clientData)==-1) return; /* viewOnly */ + for (i = 0; i < (sizeof(keyTable) / sizeof(int)); i += 2) { if (keyTable[i] == keySym) { keyCode = keyTable[i+1]; @@ -252,6 +260,8 @@ PtrAddEvent(buttonMask, x, y, cl) { CGPoint position; + if(((int)cl->clientData)==-1) return; /* viewOnly */ + position.x = x; position.y = y; @@ -281,10 +291,9 @@ ScreenInit(int argc, char**argv) rfbScreen->frameBuffer = (char *)CGDisplayBaseAddress(kCGDirectMainDisplay); - if(!viewOnly) { - rfbScreen->ptrAddEvent = PtrAddEvent; - rfbScreen->kbdAddEvent = KbdAddEvent; - } + rfbScreen->ptrAddEvent = PtrAddEvent; + rfbScreen->kbdAddEvent = KbdAddEvent; + if(sharedMode) { rfbScreen->rfbAlwaysShared = TRUE; } @@ -292,11 +301,33 @@ ScreenInit(int argc, char**argv) rfbInitServer(rfbScreen); } +#ifdef LOCAL_CONTROL +single_instance_struct single_instance = { "/tmp/OSXvnc_control" }; +#endif + static void refreshCallback(CGRectCount count, const CGRect *rectArray, void *ignore) { int i; +#ifdef LOCAL_CONTROL + if(get_next_message(message,1024,&single_instance,50)) { + if(message[0]=='l' && message[1]==0) { + rfbClientPtr cl; + int i; + for(i=0,cl=rfbScreen->rfbClientHead;cl;cl=cl->next,i++) + fprintf(stderr,"%02d: %s\n",i,cl->host); + } else if(message[0]=='t') { + rfbClientPtr cl; + for(cl=rfbScreen->rfbClientHead;cl;cl=cl->next) + if(!strcmp(message+1,cl->host)) { + cl->clientData=(cl->clientData==0)?-1:0; + break; + } + } + } +#endif + if(startTime>0 && time(0)>startTime+maxSecsToConnect) exit(0); @@ -319,12 +350,32 @@ void newClient(rfbClientPtr cl) if(disconnectAfterFirstClient) cl->clientGoneHook = clientGone; + + cl->clientData=(void*)((viewOnly)?-1:0); } int main(int argc,char *argv[]) { int i; + +#ifdef LOCAL_CONTROL + char message[1024]; + + open_control_file(&single_instance); +#endif + for(i=argc-1;i>0;i--) +#ifdef LOCAL_CONTROL + if(i<argc-1 && !strcmp(argv[i],"-toggleviewonly")) { + sprintf(message,"t%s",argv[i+1]); + send_message(&single_instance,message); + exit(0); + } else if(!strcmp(argv[i],"-listclients")) { + fprintf(stderr,"list clients\n"); + send_message(&single_instance,"l"); + exit(0); + } else +#endif if(i<argc-1 && strcmp(argv[i],"-wait4client")==0) { maxSecsToConnect = atoi(argv[i+1])/1000; startTime = time(0); |