Commit 080ad356 authored by dscho's avatar dscho

try to make OSXvnc run again.

parent fb53d481
CC=gcc CC=cc
CFLAGS=-g -Wall CFLAGS=-g -Wall
#CFLAGS=-O2 -Wall #CFLAGS=-O2 -Wall
RANLIB=ranlib RANLIB=ranlib
......
...@@ -9,15 +9,7 @@ ...@@ -9,15 +9,7 @@
* *
* This file implements every system specific function for Mac OS X. * This file implements every system specific function for Mac OS X.
* *
* It includes the init function: * It includes the keyboard functions:
*
void rfbScreenInit(void)
*
* the function to get the address of the framebuffer:
*
char *rfbGetFramebuffer(void)
*
* keyboard functions:
* *
void KbdAddEvent(down, keySym, cl) void KbdAddEvent(down, keySym, cl)
Bool down; Bool down;
...@@ -33,85 +25,17 @@ ...@@ -33,85 +25,17 @@
int y; int y;
rfbClientPtr cl; rfbClientPtr cl;
* *
* and the EventLoop:
*
void runEventLoop()
*
* These six functions have to be defined by every VNC server using
* libvncserver.
*
* The main function just calls runVNCServer. This is different
* for more complex users of libvncserver.
*
*/ */
#include "rfb.h"
#include <ApplicationServices/ApplicationServices.h> #include <ApplicationServices/ApplicationServices.h>
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#include <X11/keysym.h> /* zlib doesn't like Byte already defined */
#undef Byte
void #undef TRUE
rfbScreenInit(void) #include "rfb.h"
{ #include "keysym.h"
int bitsPerSample;
int samplesPerPixel;
rfbScreen.width = CGDisplayPixelsWide(kCGDirectMainDisplay);
rfbScreen.height = CGDisplayPixelsHigh(kCGDirectMainDisplay);
rfbScreen.bitsPerPixel = rfbScreen.depth =
CGDisplayBitsPerPixel(kCGDirectMainDisplay);
gethostname(rfbThisHost, 255);
rfbScreen.paddedWidthInBytes = CGDisplayBytesPerRow(kCGDirectMainDisplay);
rfbServerFormat.bitsPerPixel = rfbScreen.bitsPerPixel;
rfbServerFormat.depth = rfbScreen.depth;
rfbServerFormat.bigEndian = !(*(char *)&rfbEndianTest);
rfbServerFormat.trueColour = TRUE;
bitsPerSample = CGDisplayBitsPerSample(kCGDirectMainDisplay);
samplesPerPixel = CGDisplaySamplesPerPixel(kCGDirectMainDisplay);
if (samplesPerPixel != 3) {
rfbLog("screen format not supported. exiting.\n");
exit(1);
}
/* This works for 16 and 32-bit, but not for 8-bit.
What should it be for 8-bit? (Shouldn't 8-bit use a colormap?) */
rfbServerFormat.redMax = (1 << bitsPerSample) - 1;
rfbServerFormat.greenMax = (1 << bitsPerSample) - 1;
rfbServerFormat.blueMax = (1 << bitsPerSample) - 1;
rfbServerFormat.redShift = bitsPerSample * 2;
rfbServerFormat.greenShift = bitsPerSample;
rfbServerFormat.blueShift = 0;
/* We want to use the X11 REGION_* macros without having an actual
X11 ScreenPtr, so we do this. Pretty ugly, but at least it lets us
avoid hacking up regionstr.h, or changing every call to REGION_*
(which actually I should probably do eventually). */
hackScreen.RegionCreate = miRegionCreate;
hackScreen.RegionInit = miRegionInit;
hackScreen.RegionCopy = miRegionCopy;
hackScreen.RegionDestroy = miRegionDestroy;
hackScreen.RegionUninit = miRegionUninit;
hackScreen.Intersect = miIntersect;
hackScreen.Union = miUnion;
hackScreen.Subtract = miSubtract;
hackScreen.Inverse = miInverse;
hackScreen.RegionReset = miRegionReset;
hackScreen.TranslateRegion = miTranslateRegion;
hackScreen.RectIn = miRectIn;
hackScreen.PointInRegion = miPointInRegion;
hackScreen.RegionNotEmpty = miRegionNotEmpty;
hackScreen.RegionEmpty = miRegionEmpty;
hackScreen.RegionExtents = miRegionExtents;
hackScreen.RegionAppend = miRegionAppend;
hackScreen.RegionValidate = miRegionValidate;
}
char * rfbScreenInfoPtr rfbScreen;
rfbGetFramebuffer(void)
{
return (char *)CGDisplayBaseAddress(kCGDirectMainDisplay);
}
/* Where do I get the "official" list of Mac key codes? /* Where do I get the "official" list of Mac key codes?
Ripped these out of a Mac II emulator called Basilisk II Ripped these out of a Mac II emulator called Basilisk II
...@@ -339,50 +263,45 @@ PtrAddEvent(buttonMask, x, y, cl) ...@@ -339,50 +263,45 @@ PtrAddEvent(buttonMask, x, y, cl)
(buttonMask & (1 << 7)) ? TRUE : FALSE); (buttonMask & (1 << 7)) ? TRUE : FALSE);
} }
void void
KbdReleaseAllKeys() ScreenInit(int argc, char**argv)
{ {
/* Doesn't seem to be possible. */ rfbScreen = rfbGetScreen(argc,argv,
CGDisplayPixelsWide(kCGDirectMainDisplay),
CGDisplayPixelsHigh(kCGDirectMainDisplay),
CGDisplayBitsPerSample(kCGDirectMainDisplay),
CGDisplaySamplesPerPixel(kCGDirectMainDisplay),4);
gethostname(rfbScreen->rfbThisHost, 255);
rfbScreen->paddedWidthInBytes = CGDisplayBytesPerRow(kCGDirectMainDisplay);
rfbScreen->frameBuffer =
(char *)CGDisplayBaseAddress(kCGDirectMainDisplay);
rfbScreen->ptrAddEvent = PtrAddEvent;
rfbScreen->kbdAddEvent = KbdAddEvent;
rfbInitServer(rfbScreen);
} }
static void static void
refreshCallback(CGRectCount count, const CGRect *rectArray, void *ignore) refreshCallback(CGRectCount count, const CGRect *rectArray, void *ignore)
{ {
BoxRec box;
RegionRec region;
rfbClientIteratorPtr iterator;
rfbClientPtr cl;
int i; int i;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++)
box.x1 = rectArray[i].origin.x; rfbMarkRectAsModified(rfbScreen,
box.y1 = rectArray[i].origin.y; rectArray[i].origin.x,rectArray[i].origin.y,
box.x2 = box.x1 + rectArray[i].size.width; rectArray[i].origin.x + rectArray[i].size.width,
box.y2 = box.y1 + rectArray[i].size.height; rectArray[i].origin.y + rectArray[i].size.height);
SAFE_REGION_INIT(&hackScreen, &region, &box, 0);
iterator = rfbGetClientIterator();
while ((cl = rfbClientIteratorNext(iterator)) != NULL) {
pthread_mutex_lock(&cl->updateMutex);
REGION_UNION(&hackScreen,&cl->modifiedRegion,&cl->modifiedRegion,&region);
pthread_cond_signal(&cl->updateCond);
pthread_mutex_unlock(&cl->updateMutex);
}
rfbReleaseClientIterator(iterator);
REGION_UNINIT(&hackScreen, &region);
}
} }
void runEventLoop() int main(int argc,char *argv[])
{ {
CGRegisterScreenRefreshCallback(refreshCallback, NULL); ScreenInit(argc,argv);
/* enter background event loop */
rfbRunEventLoop(rfbScreen,40,TRUE);
RunApplicationEventLoop(); /* enter OS X loop */
} CGRegisterScreenRefreshCallback(refreshCallback, NULL);
RunApplicationEventLoop();
int main(int argc,char *argv[]) return(0); /* never ... */
{
runVNCServer(argc,argv);
} }
...@@ -56,8 +56,14 @@ int max(int,int); ...@@ -56,8 +56,14 @@ int max(int,int);
#ifdef __linux__ #ifdef __linux__
#include <endian.h> #include <endian.h>
#else #else
#ifdef __APPLE__
#include <machine/endian.h>
#define _BYTE_ORDER BYTE_ORDER
#define _LITTLE_ENDIAN LITTLE_ENDIAN
#else
#include <sys/endian.h> #include <sys/endian.h>
#endif #endif
#endif
#ifndef _BYTE_ORDER #ifndef _BYTE_ORDER
#define _BYTE_ORDER __BYTE_ORDER #define _BYTE_ORDER __BYTE_ORDER
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment