Consistently use spaces for indentation
This commit is contained in:
parent
f44c7089d2
commit
ab3210adb0
58
clipboard.cc
58
clipboard.cc
|
@ -32,15 +32,15 @@
|
|||
/* Update the Scrap Manager clipboard with new data sent from server.
|
||||
*/
|
||||
void DoServerCutText (void) {
|
||||
unsigned long textLen;
|
||||
unsigned long textLen;
|
||||
unsigned long i;
|
||||
|
||||
if (! DoWaitingReadTCP (3)) { /* Read & ignore padding */
|
||||
DoClose(vncWindow);
|
||||
if (! DoWaitingReadTCP (3)) { /* Read & ignore padding */
|
||||
DoClose(vncWindow);
|
||||
return;
|
||||
}
|
||||
if (! DoWaitingReadTCP (4)) {
|
||||
DoClose(vncWindow);
|
||||
if (! DoWaitingReadTCP (4)) {
|
||||
DoClose(vncWindow);
|
||||
return;
|
||||
}
|
||||
HLock(readBufferHndl);
|
||||
|
@ -48,65 +48,65 @@ void DoServerCutText (void) {
|
|||
HUnlock(readBufferHndl);
|
||||
|
||||
if (! DoWaitingReadTCP(textLen)) {
|
||||
DoClose(vncWindow);
|
||||
DoClose(vncWindow);
|
||||
return;
|
||||
};
|
||||
if (allowClipboardTransfers) {
|
||||
if (allowClipboardTransfers) {
|
||||
ZeroScrap();
|
||||
HLock(readBufferHndl);
|
||||
|
||||
/* Convert lf->cr; Use pointer arithmetic so we can go over 64k */
|
||||
for (i = 0; i < textLen; i++)
|
||||
if (*((*(char **)readBufferHndl)+i) == '\n')
|
||||
if (*((*(char **)readBufferHndl)+i) == '\n')
|
||||
*((*(char **)readBufferHndl)+i) = '\r';
|
||||
|
||||
/* Below function call requires <scrap.h> to be fixed */
|
||||
/* Below function call requires <scrap.h> to be fixed */
|
||||
PutScrap(textLen, textScrap, (Pointer) *readBufferHndl);
|
||||
/* Potential errors (e.g. out of memory) ignored */
|
||||
HUnlock(readBufferHndl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DoSendClipboard (void) {
|
||||
static struct clientCutText {
|
||||
unsigned char messageType;
|
||||
static struct clientCutText {
|
||||
unsigned char messageType;
|
||||
unsigned char padding1;
|
||||
unsigned int padding2;
|
||||
unsigned long length;
|
||||
} clientCutTextStruct = { 6 /* Message type 6 */ };
|
||||
} clientCutTextStruct = { 6 /* Message type 6 */ };
|
||||
|
||||
Handle scrapHandle;
|
||||
unsigned long i;
|
||||
|
||||
/* Only proceed if we're connected to the server and not view-only */
|
||||
if (vncConnected && !viewOnlyMode) {
|
||||
clientCutTextStruct.length = GetScrapSize(textScrap);
|
||||
/* Only proceed if we're connected to the server and not view-only */
|
||||
if (vncConnected && !viewOnlyMode) {
|
||||
clientCutTextStruct.length = GetScrapSize(textScrap);
|
||||
|
||||
if (clientCutTextStruct.length == 0)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
clientCutTextStruct.length = SwapBytes4(clientCutTextStruct.length);
|
||||
|
||||
|
||||
scrapHandle = NewHandle(1, userid(), 0x0000, NULL);
|
||||
GetScrap(scrapHandle, textScrap);
|
||||
if (toolerror())
|
||||
goto end; /* abort if error */
|
||||
if (TCPIPWriteTCP(hostIpid, &clientCutTextStruct.messageType,
|
||||
sizeof(clientCutTextStruct), FALSE, FALSE))
|
||||
goto end; /* abort if error */
|
||||
goto end; /* abort if error */
|
||||
if (TCPIPWriteTCP(hostIpid, &clientCutTextStruct.messageType,
|
||||
sizeof(clientCutTextStruct), FALSE, FALSE))
|
||||
goto end; /* abort if error */
|
||||
if (toolerror())
|
||||
goto end;
|
||||
|
||||
clientCutTextStruct.length = SwapBytes4(clientCutTextStruct.length);
|
||||
goto end;
|
||||
|
||||
clientCutTextStruct.length = SwapBytes4(clientCutTextStruct.length);
|
||||
|
||||
HLock(scrapHandle);
|
||||
/* Convert cr->lf; Use pointer arithmetic so we can go over 64k */
|
||||
for (i = 0; i < clientCutTextStruct.length; i++)
|
||||
if (*((*(char **)scrapHandle)+i) == '\r')
|
||||
if (*((*(char **)scrapHandle)+i) == '\r')
|
||||
*((*(char **)scrapHandle)+i) = '\n';
|
||||
|
||||
TCPIPWriteTCP(hostIpid, (Pointer) *scrapHandle,
|
||||
clientCutTextStruct.length, TRUE, FALSE);
|
||||
TCPIPWriteTCP(hostIpid, (Pointer) *scrapHandle,
|
||||
clientCutTextStruct.length, TRUE, FALSE);
|
||||
/* Can't handle errors usefully here */
|
||||
HUnlock(scrapHandle);
|
||||
|
||||
|
|
|
@ -98,8 +98,8 @@ BOOLEAN MakeBigColorTables (unsigned int iters)
|
|||
{
|
||||
static unsigned int i = 0;
|
||||
unsigned int iMax = i + iters;
|
||||
if (iMax < i) /* Deal with wraparound */
|
||||
iMax = 0;
|
||||
if (iMax < i) /* Deal with wraparound */
|
||||
iMax = 0;
|
||||
|
||||
/* The addressing scheme here depends on the IIgs's little-endianness */
|
||||
do {
|
||||
|
@ -110,9 +110,9 @@ BOOLEAN MakeBigColorTables (unsigned int iters)
|
|||
} while (i != iMax);
|
||||
|
||||
if (iMax == 0)
|
||||
return TRUE; /* Done */
|
||||
return TRUE; /* Done */
|
||||
else
|
||||
return FALSE; /* In progress */
|
||||
return FALSE; /* In progress */
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
22
copyrect.cc
22
copyrect.cc
|
@ -31,21 +31,21 @@
|
|||
|
||||
void DoCopyRect (void) {
|
||||
/* For use with GetContentOrigin() */
|
||||
unsigned long contentOrigin;
|
||||
Point * contentOriginPtr = (void *) &contentOrigin;
|
||||
|
||||
unsigned long contentOrigin;
|
||||
Point * contentOriginPtr = (void *) &contentOrigin;
|
||||
|
||||
Rect srcRect;
|
||||
unsigned int *dataPtr; /* Pointer to TCP data that was read */
|
||||
unsigned int *dataPtr; /* Pointer to TCP data that was read */
|
||||
|
||||
//printf("Processing CopyRect rectangle\n");
|
||||
|
||||
if (! DoReadTCP ((unsigned long) 4))
|
||||
return; /* Not ready yet; wait */
|
||||
if (! DoReadTCP ((unsigned long) 4))
|
||||
return; /* Not ready yet; wait */
|
||||
|
||||
contentOrigin = GetContentOrigin(vncWindow);
|
||||
|
||||
HLock(readBufferHndl);
|
||||
dataPtr = (unsigned int *) ((char *) (*readBufferHndl));
|
||||
dataPtr = (unsigned int *) ((char *) (*readBufferHndl));
|
||||
srcRect.h1 = SwapBytes2(dataPtr[0]) - contentOriginPtr->h;
|
||||
srcRect.v1 = SwapBytes2(dataPtr[1]) - contentOriginPtr->v;
|
||||
HUnlock(readBufferHndl);
|
||||
|
@ -57,7 +57,7 @@ void DoCopyRect (void) {
|
|||
to send the update using some other encoding.
|
||||
*/
|
||||
if (!RectInRgn(&srcRect, GetVisHandle())) {
|
||||
SendFBUpdateRequest(FALSE, rectX, rectY, rectWidth, rectHeight);
|
||||
SendFBUpdateRequest(FALSE, rectX, rectY, rectWidth, rectHeight);
|
||||
displayInProgress = FALSE;
|
||||
return;
|
||||
}
|
||||
|
@ -65,11 +65,11 @@ void DoCopyRect (void) {
|
|||
/* We can use the window pointer as a LocInfo pointer because it starts
|
||||
* with a grafPort structure, which in turn starts with a LocInfo structure.
|
||||
*/
|
||||
PPToPort((struct LocInfo *) vncWindow, &srcRect,
|
||||
rectX - contentOriginPtr->h, rectY - contentOriginPtr->v, modeCopy);
|
||||
PPToPort((struct LocInfo *) vncWindow, &srcRect,
|
||||
rectX - contentOriginPtr->h, rectY - contentOriginPtr->v, modeCopy);
|
||||
|
||||
displayInProgress = FALSE;
|
||||
|
||||
NextRect(); /* Prepare for next rect */
|
||||
NextRect(); /* Prepare for next rect */
|
||||
}
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
extern pascal void SetContentOrigin2(Word, Word, Word, GrafPortPtr) inline(0x570E,dispatcher);
|
||||
|
||||
void DoDesktopSize (void) {
|
||||
#define screenTooBigError 2010
|
||||
#define screenTooBigError 2010
|
||||
unsigned long contentOrigin;
|
||||
Point * contentOriginPtr = (void *) &contentOrigin;
|
||||
Point * contentOriginPtr = (void *) &contentOrigin;
|
||||
unsigned int newX, newY;
|
||||
Boolean changeOrigin = FALSE;
|
||||
unsigned int oldWinHeight, oldWinWidth;
|
||||
|
@ -45,7 +45,7 @@ void DoDesktopSize (void) {
|
|||
|
||||
if ((fbWidth > 16384) || (fbHeight > 16384)) {
|
||||
AlertWindow(awResource, NULL, screenTooBigError);
|
||||
DoClose(vncWindow);
|
||||
DoClose(vncWindow);
|
||||
}
|
||||
|
||||
oldWinHeight = winHeight;
|
||||
|
@ -53,11 +53,11 @@ void DoDesktopSize (void) {
|
|||
winHeight = 174;
|
||||
winWidth = (hRez == 640) ? 613 : 302;
|
||||
if (fbWidth < winWidth)
|
||||
winWidth = fbWidth;
|
||||
winWidth = fbWidth;
|
||||
if (fbHeight < winHeight)
|
||||
winHeight = fbHeight;
|
||||
winHeight = fbHeight;
|
||||
if (oldWinHeight != winHeight || oldWinWidth != winWidth)
|
||||
SizeWindow(winWidth, winHeight, vncWindow);
|
||||
SizeWindow(winWidth, winHeight, vncWindow);
|
||||
|
||||
/* Scroll if area displayed is going away */
|
||||
contentOrigin = GetContentOrigin(vncWindow);
|
||||
|
@ -65,11 +65,11 @@ void DoDesktopSize (void) {
|
|||
newY = contentOriginPtr->v;
|
||||
|
||||
if (contentOriginPtr->h + winWidth > fbWidth) {
|
||||
newX = fbWidth - winWidth;
|
||||
newX = fbWidth - winWidth;
|
||||
changeOrigin = TRUE;
|
||||
}
|
||||
if (contentOriginPtr->v + winHeight > fbHeight) {
|
||||
newY = fbHeight - winHeight;
|
||||
newY = fbHeight - winHeight;
|
||||
changeOrigin = TRUE;
|
||||
}
|
||||
SetContentOrigin2(1, newX, newY, vncWindow);
|
||||
|
@ -79,6 +79,6 @@ void DoDesktopSize (void) {
|
|||
|
||||
displayInProgress = FALSE;
|
||||
|
||||
NextRect(); /* Prepare for next rect */
|
||||
}
|
||||
NextRect(); /* Prepare for next rect */
|
||||
}
|
||||
|
||||
|
|
306
hextile.cc
306
hextile.cc
|
@ -29,7 +29,7 @@
|
|||
#include "raw.h"
|
||||
#include "hextile.h"
|
||||
|
||||
unsigned int hexXTiles, hexYTiles; /* For in-process hextile processing */
|
||||
unsigned int hexXTiles, hexYTiles; /* For in-process hextile processing */
|
||||
unsigned int hexXTileNum, hexYTileNum;
|
||||
unsigned int hexTileWidth, hexTileHeight;
|
||||
unsigned char hexBackground, hexForeground;
|
||||
|
@ -37,40 +37,40 @@ unsigned char hexBackground, hexForeground;
|
|||
static BOOLEAN extraByteAdvance;
|
||||
|
||||
/* Used in Hextile encoding */
|
||||
#define Raw 0x01
|
||||
#define BackgroundSpecified 0x02
|
||||
#define ForegroundSpecified 0x04
|
||||
#define AnySubrects 0x08
|
||||
#define SubrectsColoured 0x10
|
||||
|
||||
#define hexWaitingForSubencoding 1
|
||||
#define hexWaitingForMoreInfo 2
|
||||
#define hexWaitingForSubrect 4
|
||||
#define hexWaitingForRawData 8
|
||||
#define Raw 0x01
|
||||
#define BackgroundSpecified 0x02
|
||||
#define ForegroundSpecified 0x04
|
||||
#define AnySubrects 0x08
|
||||
#define SubrectsColoured 0x10
|
||||
|
||||
#define hexWaitingForSubencoding 1
|
||||
#define hexWaitingForMoreInfo 2
|
||||
#define hexWaitingForSubrect 4
|
||||
#define hexWaitingForRawData 8
|
||||
|
||||
void HexNextTile (void) {
|
||||
hexXTileNum++;
|
||||
if (hexXTileNum == hexXTiles) {
|
||||
hexYTileNum++;
|
||||
if (hexYTileNum == hexYTiles) { /* Done with this Hextile rect */
|
||||
displayInProgress = FALSE;
|
||||
if (hexYTileNum == hexYTiles) { /* Done with this Hextile rect */
|
||||
displayInProgress = FALSE;
|
||||
NextRect();
|
||||
return;
|
||||
}
|
||||
hexXTileNum = 0;
|
||||
hexXTileNum = 0;
|
||||
}
|
||||
|
||||
hexTileWidth = (hexXTileNum == hexXTiles - 1) ?
|
||||
rectWidth - 16 * (hexXTiles - 1) : 16;
|
||||
rectWidth - 16 * (hexXTiles - 1) : 16;
|
||||
hexTileHeight = (hexYTileNum == hexYTiles - 1) ?
|
||||
rectHeight - 16 * (hexYTiles - 1) : 16;
|
||||
rectHeight - 16 * (hexYTiles - 1) : 16;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void HexRawDraw (Point *contentOriginPtr, int rectWidth, int rectHeight) {
|
||||
unsigned int i, j; /* Loop indices */
|
||||
unsigned int i, j; /* Loop indices */
|
||||
unsigned int n = 0;
|
||||
unsigned char *dataPtr;
|
||||
unsigned char *dataPtr;
|
||||
unsigned char pixels[128];
|
||||
|
||||
static Rect srcRect = {0,0,0,0};
|
||||
|
@ -83,53 +83,53 @@ void HexRawDraw (Point *contentOriginPtr, int rectWidth, int rectHeight) {
|
|||
extraByteAdvance = FALSE;
|
||||
|
||||
for (j = 0; j < rectHeight; j++) {
|
||||
for (i = 0; i < rectWidth; i++) {
|
||||
if (hRez == 640) {
|
||||
switch (i & 0x03) {
|
||||
case 0x00: /* pixels 0, 4, 8, ... */
|
||||
pixels[n] = pixTransTbl[ *(dataPtr +
|
||||
(unsigned long) j*rectWidth + i)
|
||||
] & 0xC0;
|
||||
break;
|
||||
case 0x01: /* pixels 1, 5, 9, ... */
|
||||
pixels[n] += pixTransTbl[ *(dataPtr +
|
||||
(unsigned long) j*rectWidth + i)
|
||||
] & 0x30;
|
||||
break;
|
||||
case 0x02: /* pixels 2, 6, 10, ... */
|
||||
pixels[n] += pixTransTbl[ *(dataPtr +
|
||||
(unsigned long) j*rectWidth + i)
|
||||
] & 0x0C;
|
||||
break;
|
||||
case 0x03: /* pixels 3, 7, 11, ... */
|
||||
pixels[n] += pixTransTbl[ *(dataPtr +
|
||||
(unsigned long) j*rectWidth + i)
|
||||
] & 0x03;
|
||||
n++;
|
||||
} /* switch */
|
||||
} /* if */
|
||||
else { /* 320 mode */
|
||||
switch(i & 0x01) {
|
||||
case 0x00: /* pixels 0, 2, 4, ... */
|
||||
pixels[n] = pixTransTbl[ *(dataPtr +
|
||||
(unsigned long) j*rectWidth + i)
|
||||
] & 0xF0;
|
||||
break;
|
||||
case 0x01: /* pixels 1, 3, 5, ... */
|
||||
pixels[n] += pixTransTbl[ *(dataPtr +
|
||||
(unsigned long) j*rectWidth + i)
|
||||
] & 0x0F;
|
||||
n++;
|
||||
} /* switch */
|
||||
} /* else */
|
||||
} /* i loop */
|
||||
for (i = 0; i < rectWidth; i++) {
|
||||
if (hRez == 640) {
|
||||
switch (i & 0x03) {
|
||||
case 0x00: /* pixels 0, 4, 8, ... */
|
||||
pixels[n] = pixTransTbl[ *(dataPtr +
|
||||
(unsigned long) j*rectWidth + i)
|
||||
] & 0xC0;
|
||||
break;
|
||||
case 0x01: /* pixels 1, 5, 9, ... */
|
||||
pixels[n] += pixTransTbl[ *(dataPtr +
|
||||
(unsigned long) j*rectWidth + i)
|
||||
] & 0x30;
|
||||
break;
|
||||
case 0x02: /* pixels 2, 6, 10, ... */
|
||||
pixels[n] += pixTransTbl[ *(dataPtr +
|
||||
(unsigned long) j*rectWidth + i)
|
||||
] & 0x0C;
|
||||
break;
|
||||
case 0x03: /* pixels 3, 7, 11, ... */
|
||||
pixels[n] += pixTransTbl[ *(dataPtr +
|
||||
(unsigned long) j*rectWidth + i)
|
||||
] & 0x03;
|
||||
n++;
|
||||
} /* switch */
|
||||
} /* if */
|
||||
else { /* 320 mode */
|
||||
switch(i & 0x01) {
|
||||
case 0x00: /* pixels 0, 2, 4, ... */
|
||||
pixels[n] = pixTransTbl[ *(dataPtr +
|
||||
(unsigned long) j*rectWidth + i)
|
||||
] & 0xF0;
|
||||
break;
|
||||
case 0x01: /* pixels 1, 3, 5, ... */
|
||||
pixels[n] += pixTransTbl[ *(dataPtr +
|
||||
(unsigned long) j*rectWidth + i)
|
||||
] & 0x0F;
|
||||
n++;
|
||||
} /* switch */
|
||||
} /* else */
|
||||
} /* i loop */
|
||||
|
||||
/* When not ending a line on a byte boundary, the index isn't updated,
|
||||
* so we do it here.
|
||||
*/
|
||||
if (extraByteAdvance)
|
||||
n++;
|
||||
} /* j loop */
|
||||
/* When not ending a line on a byte boundary, the index isn't updated,
|
||||
* so we do it here.
|
||||
*/
|
||||
if (extraByteAdvance)
|
||||
n++;
|
||||
} /* j loop */
|
||||
|
||||
srcLocInfo.ptrToPixImage = (void *) pixels;
|
||||
srcLocInfo.boundsRect.v2 = rectHeight;
|
||||
|
@ -137,65 +137,65 @@ void HexRawDraw (Point *contentOriginPtr, int rectWidth, int rectHeight) {
|
|||
* padding must be accounted for here.
|
||||
*/
|
||||
if (hRez == 640) {
|
||||
switch (rectWidth & 0x03) {
|
||||
case 0x00: srcLocInfo.boundsRect.h2 = rectWidth;
|
||||
srcLocInfo.width = rectWidth/4; break;
|
||||
case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+3;
|
||||
srcLocInfo.width = rectWidth/4 + 1; break;
|
||||
case 0x02: srcLocInfo.boundsRect.h2 = rectWidth+2;
|
||||
srcLocInfo.width = rectWidth/4 + 1; break;
|
||||
case 0x03: srcLocInfo.boundsRect.h2 = rectWidth+1;
|
||||
srcLocInfo.width = rectWidth/4 + 1;
|
||||
}
|
||||
switch (rectWidth & 0x03) {
|
||||
case 0x00: srcLocInfo.boundsRect.h2 = rectWidth;
|
||||
srcLocInfo.width = rectWidth/4; break;
|
||||
case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+3;
|
||||
srcLocInfo.width = rectWidth/4 + 1; break;
|
||||
case 0x02: srcLocInfo.boundsRect.h2 = rectWidth+2;
|
||||
srcLocInfo.width = rectWidth/4 + 1; break;
|
||||
case 0x03: srcLocInfo.boundsRect.h2 = rectWidth+1;
|
||||
srcLocInfo.width = rectWidth/4 + 1;
|
||||
}
|
||||
}
|
||||
else { /* hRez == 320 */
|
||||
switch (rectWidth & 0x01) {
|
||||
case 0x00: srcLocInfo.boundsRect.h2 = rectWidth;
|
||||
srcLocInfo.width = rectWidth/2; break;
|
||||
case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+1;
|
||||
srcLocInfo.width = rectWidth/2 + 1;
|
||||
}
|
||||
}
|
||||
switch (rectWidth & 0x01) {
|
||||
case 0x00: srcLocInfo.boundsRect.h2 = rectWidth;
|
||||
srcLocInfo.width = rectWidth/2; break;
|
||||
case 0x01: srcLocInfo.boundsRect.h2 = rectWidth+1;
|
||||
srcLocInfo.width = rectWidth/2 + 1;
|
||||
}
|
||||
}
|
||||
|
||||
srcRect.v2 = hexTileHeight;
|
||||
srcRect.h2 = hexTileWidth;
|
||||
|
||||
PPToPort(&srcLocInfo, &srcRect,
|
||||
rectX + hexXTileNum * 16 - contentOriginPtr->h,
|
||||
PPToPort(&srcLocInfo, &srcRect,
|
||||
rectX + hexXTileNum * 16 - contentOriginPtr->h,
|
||||
rectY + hexYTileNum * 16 - contentOriginPtr->v, modeCopy);
|
||||
}
|
||||
|
||||
/* The macros below are used in HexDispatch() */
|
||||
#define HexDispatch_NextTile() do { \
|
||||
#define HexDispatch_NextTile() do { \
|
||||
HexNextTile(); \
|
||||
HUnlock(readBufferHndl); \
|
||||
HUnlock(readBufferHndl); \
|
||||
/* Set up for next time */ \
|
||||
status = hexWaitingForSubencoding; \
|
||||
bytesNeeded = 1; \
|
||||
return; \
|
||||
return; \
|
||||
} while (0)
|
||||
|
||||
#define HexDispatch_DrawRect(color, X, Y, width, height) do { \
|
||||
SetSolidPenPat((color)); \
|
||||
#define HexDispatch_DrawRect(color, X, Y, width, height) do { \
|
||||
SetSolidPenPat((color)); \
|
||||
drawingRect.h1 = rectX + hexXTileNum * 16 + (X) - contentOriginPtr->h; \
|
||||
drawingRect.v1 = rectY + hexYTileNum * 16 + (Y) - contentOriginPtr->v; \
|
||||
drawingRect.h2 = rectX + hexXTileNum * 16 + (X) + (width) - contentOriginPtr->h; \
|
||||
drawingRect.v2 = rectY + hexYTileNum * 16 + (Y) + (height) - contentOriginPtr->v; \
|
||||
PaintRect(&drawingRect); \
|
||||
} while (0)
|
||||
} while (0)
|
||||
|
||||
#define HexDispatch_DrawBackground() \
|
||||
HexDispatch_DrawRect(hexBackground, 0, 0, hexTileWidth, hexTileHeight)
|
||||
HexDispatch_DrawRect(hexBackground, 0, 0, hexTileWidth, hexTileHeight)
|
||||
|
||||
void HexDispatch (void) {
|
||||
static unsigned char status = hexWaitingForSubencoding;
|
||||
static unsigned char status = hexWaitingForSubencoding;
|
||||
static unsigned long bytesNeeded = 1;
|
||||
static unsigned char subencoding;
|
||||
static unsigned int numSubrects;
|
||||
int i;
|
||||
/* For use with GetContentOrigin() */
|
||||
unsigned long contentOrigin;
|
||||
Point * contentOriginPtr = (void *) &contentOrigin;
|
||||
unsigned long contentOrigin;
|
||||
Point * contentOriginPtr = (void *) &contentOrigin;
|
||||
int tileBytes;
|
||||
unsigned int srX, srY, srWidth, srHeight;
|
||||
Rect drawingRect;
|
||||
|
@ -209,93 +209,93 @@ void HexDispatch (void) {
|
|||
while (DoReadTCP(bytesNeeded)) {
|
||||
HLock(readBufferHndl);
|
||||
dataPtr = *(unsigned char **) readBufferHndl;
|
||||
/* If we're here, readBufferHndl contains bytesNeeded bytes of data. */
|
||||
switch (status) {
|
||||
case hexWaitingForSubencoding:
|
||||
/* If we're here, readBufferHndl contains bytesNeeded bytes of data. */
|
||||
switch (status) {
|
||||
case hexWaitingForSubencoding:
|
||||
subencoding = *dataPtr;
|
||||
if (subencoding & Raw) {
|
||||
bytesNeeded = hexTileWidth * hexTileHeight;
|
||||
if (subencoding & Raw) {
|
||||
bytesNeeded = hexTileWidth * hexTileHeight;
|
||||
status = hexWaitingForRawData;
|
||||
}
|
||||
else {
|
||||
bytesNeeded = 0;
|
||||
if (subencoding & BackgroundSpecified)
|
||||
bytesNeeded++;
|
||||
if (subencoding & ForegroundSpecified)
|
||||
bytesNeeded++;
|
||||
if (subencoding & AnySubrects)
|
||||
bytesNeeded++;
|
||||
else if (bytesNeeded == 0) {
|
||||
/* No more data - just draw background */
|
||||
}
|
||||
else {
|
||||
bytesNeeded = 0;
|
||||
if (subencoding & BackgroundSpecified)
|
||||
bytesNeeded++;
|
||||
if (subencoding & ForegroundSpecified)
|
||||
bytesNeeded++;
|
||||
if (subencoding & AnySubrects)
|
||||
bytesNeeded++;
|
||||
else if (bytesNeeded == 0) {
|
||||
/* No more data - just draw background */
|
||||
HexDispatch_DrawBackground();
|
||||
HexDispatch_NextTile();
|
||||
HexDispatch_NextTile();
|
||||
}
|
||||
status = hexWaitingForMoreInfo;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case hexWaitingForRawData:
|
||||
HexRawDraw(contentOriginPtr, hexTileWidth, hexTileHeight);
|
||||
case hexWaitingForRawData:
|
||||
HexRawDraw(contentOriginPtr, hexTileWidth, hexTileHeight);
|
||||
HexDispatch_NextTile();
|
||||
break;
|
||||
break;
|
||||
|
||||
case hexWaitingForMoreInfo:
|
||||
if (subencoding & BackgroundSpecified) {
|
||||
hexBackground = pixTransTbl[*(dataPtr++)];
|
||||
}
|
||||
if (subencoding & ForegroundSpecified) {
|
||||
if (subencoding & BackgroundSpecified) {
|
||||
hexBackground = pixTransTbl[*(dataPtr++)];
|
||||
}
|
||||
if (subencoding & ForegroundSpecified) {
|
||||
hexForeground = pixTransTbl[*(dataPtr++)];
|
||||
}
|
||||
if (subencoding & AnySubrects) {
|
||||
numSubrects = *dataPtr;
|
||||
if (numSubrects) {
|
||||
status = hexWaitingForSubrect;
|
||||
bytesNeeded = numSubrects * ((subencoding & SubrectsColoured) ? 3 : 2);
|
||||
break;
|
||||
}
|
||||
if (subencoding & AnySubrects) {
|
||||
numSubrects = *dataPtr;
|
||||
if (numSubrects) {
|
||||
status = hexWaitingForSubrect;
|
||||
bytesNeeded = numSubrects * ((subencoding & SubrectsColoured) ? 3 : 2);
|
||||
break;
|
||||
}
|
||||
else
|
||||
HexDispatch_NextTile();
|
||||
}
|
||||
else { /* no subrects */
|
||||
HexDispatch_DrawBackground();
|
||||
else
|
||||
HexDispatch_NextTile();
|
||||
}
|
||||
else { /* no subrects */
|
||||
HexDispatch_DrawBackground();
|
||||
HexDispatch_NextTile();
|
||||
}
|
||||
}
|
||||
|
||||
case hexWaitingForSubrect: {
|
||||
HexDispatch_DrawBackground();
|
||||
case hexWaitingForSubrect: {
|
||||
HexDispatch_DrawBackground();
|
||||
while (numSubrects-- > 0) {
|
||||
if (subencoding & SubrectsColoured) {
|
||||
hexForeground = pixTransTbl[*(dataPtr++)];
|
||||
}
|
||||
srX = *dataPtr >> 4;
|
||||
srY = *(dataPtr++) & 0x0F;
|
||||
srWidth = (*dataPtr >> 4) + 1;
|
||||
srHeight = (*(dataPtr++) & 0x0F) + 1;
|
||||
HexDispatch_DrawRect(hexForeground, srX, srY, srWidth, srHeight);
|
||||
}
|
||||
HexDispatch_NextTile();
|
||||
}
|
||||
}
|
||||
HUnlock(readBufferHndl);
|
||||
if (subencoding & SubrectsColoured) {
|
||||
hexForeground = pixTransTbl[*(dataPtr++)];
|
||||
}
|
||||
srX = *dataPtr >> 4;
|
||||
srY = *(dataPtr++) & 0x0F;
|
||||
srWidth = (*dataPtr >> 4) + 1;
|
||||
srHeight = (*(dataPtr++) & 0x0F) + 1;
|
||||
HexDispatch_DrawRect(hexForeground, srX, srY, srWidth, srHeight);
|
||||
}
|
||||
HexDispatch_NextTile();
|
||||
}
|
||||
}
|
||||
HUnlock(readBufferHndl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Called when we initially get a Hextile rect; set up to process it */
|
||||
void DoHextileRect (void) {
|
||||
hexXTiles = (rectWidth + 15) / 16;
|
||||
hexXTiles = (rectWidth + 15) / 16;
|
||||
hexYTiles = (rectHeight + 15) / 16;
|
||||
|
||||
hexXTileNum = 0;
|
||||
hexYTileNum = 0;
|
||||
|
||||
displayInProgress = TRUE;
|
||||
|
||||
|
||||
hexTileWidth = (hexYTileNum == hexXTiles - 1) ?
|
||||
rectWidth - 16 * (hexXTiles - 1) : 16;
|
||||
rectWidth - 16 * (hexXTiles - 1) : 16;
|
||||
hexTileHeight = (hexYTileNum == hexYTiles - 1) ?
|
||||
rectHeight - 16 * (hexYTiles - 1) : 16;
|
||||
rectHeight - 16 * (hexYTiles - 1) : 16;
|
||||
|
||||
/* Set up for Hextile drawing */
|
||||
srcRect.v1 = 0;
|
||||
srcRect.h1 = 0;
|
||||
}
|
||||
}
|
||||
|
|
78
keyboard.cc
78
keyboard.cc
|
@ -33,36 +33,36 @@
|
|||
*/
|
||||
void SendKeyEvent (BOOLEAN keyDownFlag, unsigned long key)
|
||||
{
|
||||
struct KeyEvent {
|
||||
unsigned char messageType;
|
||||
struct KeyEvent {
|
||||
unsigned char messageType;
|
||||
unsigned char keyDownFlag;
|
||||
unsigned int padding;
|
||||
unsigned long key;
|
||||
} keyEvent = { 4 /* Message Type 4 */,
|
||||
0,
|
||||
} keyEvent = { 4 /* Message Type 4 */,
|
||||
0,
|
||||
0 /* Zero the padding */
|
||||
};
|
||||
};
|
||||
|
||||
keyEvent.keyDownFlag = !!keyDownFlag;
|
||||
keyEvent.key = SwapBytes4(key);
|
||||
TCPIPWriteTCP(hostIpid, &keyEvent.messageType, sizeof(keyEvent),
|
||||
TRUE, FALSE);
|
||||
/* No error checking here -- Can't respond to one usefully. */
|
||||
TRUE, FALSE);
|
||||
/* No error checking here -- Can't respond to one usefully. */
|
||||
}
|
||||
|
||||
|
||||
/* Process a key down event and send it on to the server. */
|
||||
void ProcessKeyEvent (void)
|
||||
{
|
||||
unsigned long key = myEvent.message & 0x0000007F;
|
||||
unsigned long key = myEvent.message & 0x0000007F;
|
||||
|
||||
if (viewOnlyMode)
|
||||
return;
|
||||
return;
|
||||
|
||||
/* Deal with extended keys that are mapped as keypad keys */
|
||||
if (myEvent.modifiers & keyPad) {
|
||||
switch (key) {
|
||||
case 0x7A: key = 0xFFBE; break; /* F1 */
|
||||
switch (key) {
|
||||
case 0x7A: key = 0xFFBE; break; /* F1 */
|
||||
case 0x78: key = 0xFFBF; break; /* F2 */
|
||||
case 0x63: key = 0xFFC0; break; /* F3 */
|
||||
case 0x76: key = 0xFFC1; break; /* F4 */
|
||||
|
@ -74,7 +74,7 @@ void ProcessKeyEvent (void)
|
|||
case 0x6D: key = 0xFFC7; break; /* F10 */
|
||||
case 0x67: key = 0xFFC8; break; /* F11 */
|
||||
case 0x6F: key = 0xFFC9; break; /* F12 */
|
||||
case 0x69: key = 0xFF15; break; /* F13 / PrintScr -> SysRq */
|
||||
case 0x69: key = 0xFF15; break; /* F13 / PrintScr -> SysRq */
|
||||
case 0x6B: key = 0xFF14; break; /* F14 / ScrLock -> ScrLock */
|
||||
case 0x71: key = 0xFF13; break; /* F15 / Pause -> Pause */
|
||||
case 0x72: key = 0xFF63; break; /* Help / Insert -> Insert */
|
||||
|
@ -83,32 +83,32 @@ void ProcessKeyEvent (void)
|
|||
case 0x77: key = 0xFF57; break; /* End */
|
||||
case 0x74: key = 0xFF55; break; /* Page Up */
|
||||
case 0x79: key = 0xFF56; break; /* Page Down */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key == 0x7f)
|
||||
key = 0xFF08; /* Delete -> BackSpace */
|
||||
key = 0xFF08; /* Delete -> BackSpace */
|
||||
|
||||
if (key < 0x20) {
|
||||
if (myEvent.modifiers & controlKey) {
|
||||
if (((myEvent.modifiers & shiftKey) ||
|
||||
(myEvent.modifiers & capsLock))
|
||||
&& !((myEvent.modifiers & shiftKey) &&
|
||||
(myEvent.modifiers & capsLock)))
|
||||
key += 0x40; /* Undo effect of control on upper-case char. */
|
||||
else
|
||||
key += 0x60; /* Undo effect of control */
|
||||
}
|
||||
if (myEvent.modifiers & controlKey) {
|
||||
if (((myEvent.modifiers & shiftKey) ||
|
||||
(myEvent.modifiers & capsLock))
|
||||
&& !((myEvent.modifiers & shiftKey) &&
|
||||
(myEvent.modifiers & capsLock)))
|
||||
key += 0x40; /* Undo effect of control on upper-case char. */
|
||||
else
|
||||
key += 0x60; /* Undo effect of control */
|
||||
}
|
||||
else switch (key) {
|
||||
case 0x1B: key = 0xFF1B; break; /* Escape */
|
||||
case 0x09: key = 0xFF09; break; /* Tab */
|
||||
case 0x0D: key = 0xFF0D; break; /* Return / Enter */
|
||||
case 0x08: key = 0xFF51; break; /* Left arrow */
|
||||
case 0x0B: key = 0xFF52; break; /* Up arrow */
|
||||
case 0x15: key = 0xFF53; break; /* Right arrow */
|
||||
case 0x0A: key = 0xFF54; break; /* Down arrow */
|
||||
case 0x18: key = 0xFF0B; break; /* Clear / NumLock -> Clear */
|
||||
}
|
||||
case 0x1B: key = 0xFF1B; break; /* Escape */
|
||||
case 0x09: key = 0xFF09; break; /* Tab */
|
||||
case 0x0D: key = 0xFF0D; break; /* Return / Enter */
|
||||
case 0x08: key = 0xFF51; break; /* Left arrow */
|
||||
case 0x0B: key = 0xFF52; break; /* Up arrow */
|
||||
case 0x15: key = 0xFF53; break; /* Right arrow */
|
||||
case 0x0A: key = 0xFF54; break; /* Down arrow */
|
||||
case 0x18: key = 0xFF0B; break; /* Clear / NumLock -> Clear */
|
||||
}
|
||||
}
|
||||
|
||||
/* Test if we seem to have a valid character and return if we don't.
|
||||
|
@ -117,7 +117,7 @@ void ProcessKeyEvent (void)
|
|||
if we ever start generating valid keycodes outside of these ranges.
|
||||
*/
|
||||
if ((key & 0xFF80) != 0xFF00 && (key & 0xFF80) != 0x0000)
|
||||
return;
|
||||
return;
|
||||
|
||||
SendKeyEvent(TRUE, key);
|
||||
SendKeyEvent(FALSE, key);
|
||||
|
@ -125,28 +125,28 @@ void ProcessKeyEvent (void)
|
|||
|
||||
/* Send modifier keys that have changed since last update */
|
||||
void SendModifiers (void) {
|
||||
static unsigned int oldModifiers = 0x00FF; /* So it runs 1st time */
|
||||
static unsigned int oldModifiers = 0x00FF; /* So it runs 1st time */
|
||||
unsigned int modifiers;
|
||||
|
||||
modifiers = myEvent.modifiers & 0x1B00;
|
||||
|
||||
/* If unchanged, do nothing. */
|
||||
if (modifiers == oldModifiers)
|
||||
return;
|
||||
return;
|
||||
|
||||
/* Apple key is sent as "meta" */
|
||||
if ((modifiers & appleKey) != (oldModifiers & appleKey))
|
||||
SendKeyEvent(modifiers & appleKey, 0xFFE7);
|
||||
SendKeyEvent(modifiers & appleKey, 0xFFE7);
|
||||
|
||||
if ((modifiers & shiftKey) != (oldModifiers & shiftKey))
|
||||
SendKeyEvent(modifiers & shiftKey, 0xFFE1);
|
||||
SendKeyEvent(modifiers & shiftKey, 0xFFE1);
|
||||
|
||||
/* Option key is sent as "alt," as per its labelling on some keyboards */
|
||||
if ((modifiers & optionKey) != (oldModifiers & optionKey))
|
||||
SendKeyEvent(modifiers & optionKey, 0xFFE9);
|
||||
SendKeyEvent(modifiers & optionKey, 0xFFE9);
|
||||
|
||||
if ((modifiers & controlKey) != (oldModifiers & controlKey))
|
||||
SendKeyEvent(modifiers & controlKey, 0xFFE3);
|
||||
SendKeyEvent(modifiers & controlKey, 0xFFE3);
|
||||
|
||||
oldModifiers = modifiers;
|
||||
}
|
||||
|
|
24
make
24
make
|
@ -7,21 +7,21 @@ clearmem
|
|||
|
||||
for {header} in vncview vncsession vncdisplay colortables menus \
|
||||
desktopsize mouse keyboard copyrect raw hextile clipboard
|
||||
unset exit
|
||||
unset exit
|
||||
newer VNCview.GS {header}.h
|
||||
if {status} != 0
|
||||
set exit on
|
||||
delete -P -W =.a
|
||||
end
|
||||
if {status} != 0
|
||||
set exit on
|
||||
delete -P -W =.a
|
||||
end
|
||||
end
|
||||
|
||||
for file in vncview vncsession vncdisplay colortables \
|
||||
desktopsize mouse keyboard copyrect raw hextile clipboard
|
||||
unset exit
|
||||
unset exit
|
||||
newer {file}.a {file}.cc
|
||||
if {status} != 0
|
||||
set exit on
|
||||
compile +O {file}.cc keep={file}
|
||||
set exit on
|
||||
compile +O {file}.cc keep={file}
|
||||
set link true
|
||||
end
|
||||
end
|
||||
|
@ -29,14 +29,14 @@ end
|
|||
unset exit
|
||||
newer vncview.rezfork vncview.rez
|
||||
if {status} != 0
|
||||
set exit on
|
||||
compile vncview.rez keep=vncview.rezfork
|
||||
set exit on
|
||||
compile vncview.rez keep=vncview.rezfork
|
||||
copy -C -P -R vncview.rezfork VNCview.GS
|
||||
end
|
||||
|
||||
if {link} == true
|
||||
link vncview vncsession vncdisplay colortables \
|
||||
link vncview vncsession vncdisplay colortables \
|
||||
desktopsize mouse keyboard copyrect raw hextile clipboard \
|
||||
keep=VNCview.GS
|
||||
filetype VNCview.GS S16 $DB03
|
||||
filetype VNCview.GS S16 $DB03
|
||||
end
|
||||
|
|
28
menus.h
28
menus.h
|
@ -1,19 +1,19 @@
|
|||
#define appleMenu 1
|
||||
#define fileMenu 2
|
||||
#define editMenu 3
|
||||
#define appleMenu 1
|
||||
#define fileMenu 2
|
||||
#define editMenu 3
|
||||
|
||||
#define appleAbout 257
|
||||
#define appleAbout 257
|
||||
|
||||
#define fileNewConnection 260
|
||||
#define fileClose 255
|
||||
#define fileQuit 256
|
||||
#define fileClose 255
|
||||
#define fileQuit 256
|
||||
|
||||
#define editUndo 250
|
||||
#define editCut 251
|
||||
#define editCopy 252
|
||||
#define editPaste 253
|
||||
#define editClear 254
|
||||
#define editSendClipboard 262
|
||||
#define editShowClipboard 261
|
||||
#define editUndo 250
|
||||
#define editCut 251
|
||||
#define editCopy 252
|
||||
#define editPaste 253
|
||||
#define editClear 254
|
||||
#define editSendClipboard 262
|
||||
#define editShowClipboard 261
|
||||
|
||||
#define noKB 100
|
||||
#define noKB 100
|
||||
|
|
130
mouse.cc
130
mouse.cc
|
@ -29,29 +29,29 @@
|
|||
#include "raw.h"
|
||||
#include "hextile.h"
|
||||
|
||||
unsigned char * cursor = NULL; /* Cursor from server */
|
||||
unsigned char * cursor = NULL; /* Cursor from server */
|
||||
|
||||
/* Send a DoPointerEvent reflecting the status of the mouse to the server */
|
||||
/* This routine also maintains the appropriate cursor when using local cursor */
|
||||
void DoPointerEvent (void) {
|
||||
static struct {
|
||||
unsigned char messageType;
|
||||
static struct {
|
||||
unsigned char messageType;
|
||||
unsigned char buttonMask;
|
||||
unsigned int xPos;
|
||||
unsigned int yPos;
|
||||
} pointerEventStruct = { 5 /* message type */ };
|
||||
|
||||
Point mouseCoords;
|
||||
unsigned long contentOrigin;
|
||||
unsigned long contentOrigin;
|
||||
Point * contentOriginPtr = (void *) &contentOrigin;
|
||||
RegionHndl contentRgnHndl;
|
||||
unsigned int oldButtonMask;
|
||||
GrafPortPtr winPtr;
|
||||
unsigned long key1 = 0x0000; /* Keys to release & re-press, if any */
|
||||
unsigned long key1 = 0x0000; /* Keys to release & re-press, if any */
|
||||
unsigned long key2 = 0x0000;
|
||||
|
||||
if (viewOnlyMode)
|
||||
return;
|
||||
return;
|
||||
|
||||
mouseCoords = myEvent.where;
|
||||
|
||||
|
@ -61,15 +61,15 @@ void DoPointerEvent (void) {
|
|||
* updates if it isn't.
|
||||
*/
|
||||
if (FindWindow(&winPtr, myEvent.where.h, myEvent.where.v) != wInContent ||
|
||||
winPtr != vncWindow) {
|
||||
if (cursor && GetCursorAdr() == cursor)
|
||||
InitCursor();
|
||||
return;
|
||||
winPtr != vncWindow) {
|
||||
if (cursor && GetCursorAdr() == cursor)
|
||||
InitCursor();
|
||||
return;
|
||||
}
|
||||
|
||||
GlobalToLocal(&mouseCoords);
|
||||
|
||||
contentOrigin = GetContentOrigin(vncWindow);
|
||||
contentOrigin = GetContentOrigin(vncWindow);
|
||||
mouseCoords.h += contentOriginPtr->h;
|
||||
mouseCoords.v += contentOriginPtr->v;
|
||||
|
||||
|
@ -80,51 +80,51 @@ void DoPointerEvent (void) {
|
|||
oldButtonMask = pointerEventStruct.buttonMask;
|
||||
pointerEventStruct.buttonMask = 0x00;
|
||||
|
||||
if ((myEvent.modifiers & btn0State) == 0x00) { /* Mouse button pressed */
|
||||
if (emulate3ButtonMouse) {
|
||||
if (myEvent.modifiers & optionKey) {
|
||||
pointerEventStruct.buttonMask = 0x02;
|
||||
key1 = 0xFFE9;
|
||||
}
|
||||
if (myEvent.modifiers & appleKey) {
|
||||
pointerEventStruct.buttonMask |= 0x04;
|
||||
key2 = 0xFFE7;
|
||||
}
|
||||
}
|
||||
if ((myEvent.modifiers & btn0State) == 0x00) { /* Mouse button pressed */
|
||||
if (emulate3ButtonMouse) {
|
||||
if (myEvent.modifiers & optionKey) {
|
||||
pointerEventStruct.buttonMask = 0x02;
|
||||
key1 = 0xFFE9;
|
||||
}
|
||||
if (myEvent.modifiers & appleKey) {
|
||||
pointerEventStruct.buttonMask |= 0x04;
|
||||
key2 = 0xFFE7;
|
||||
}
|
||||
}
|
||||
|
||||
/* If no modifiers, just send a normal left click. */
|
||||
if (pointerEventStruct.buttonMask == 0x00)
|
||||
pointerEventStruct.buttonMask = 0x01;
|
||||
/* If no modifiers, just send a normal left click. */
|
||||
if (pointerEventStruct.buttonMask == 0x00)
|
||||
pointerEventStruct.buttonMask = 0x01;
|
||||
}
|
||||
if ((myEvent.modifiers & btn1State) == 0x00) /* If 2nd (right) */
|
||||
pointerEventStruct.buttonMask |= 0x04; /* button is pressed */
|
||||
if ((myEvent.modifiers & btn1State) == 0x00) /* If 2nd (right) */
|
||||
pointerEventStruct.buttonMask |= 0x04; /* button is pressed */
|
||||
|
||||
/* Don't waste bandwidth by sending update if mouse hasn't changed.
|
||||
* This may occasionally result in an initial mouse update not being
|
||||
* sent. If this occurs, the user can simply move the mouse slightly
|
||||
* in order to send it.
|
||||
*/
|
||||
if ( (pointerEventStruct.xPos == mouseCoords.h) &&
|
||||
(pointerEventStruct.yPos == mouseCoords.v) &&
|
||||
if ( (pointerEventStruct.xPos == mouseCoords.h) &&
|
||||
(pointerEventStruct.yPos == mouseCoords.v) &&
|
||||
(pointerEventStruct.buttonMask == oldButtonMask) )
|
||||
return;
|
||||
return;
|
||||
|
||||
pointerEventStruct.xPos = mouseCoords.h;
|
||||
pointerEventStruct.xPos = mouseCoords.h;
|
||||
pointerEventStruct.yPos = mouseCoords.v;
|
||||
|
||||
if (key1)
|
||||
SendKeyEvent(FALSE, key1);
|
||||
SendKeyEvent(FALSE, key1);
|
||||
if (key2)
|
||||
SendKeyEvent(FALSE, key2);
|
||||
SendKeyEvent(FALSE, key2);
|
||||
|
||||
TCPIPWriteTCP(hostIpid, (Pointer) &pointerEventStruct.messageType,
|
||||
sizeof(pointerEventStruct), TRUE, FALSE);
|
||||
sizeof(pointerEventStruct), TRUE, FALSE);
|
||||
/* Can't do useful error checking here */
|
||||
|
||||
if (key1)
|
||||
SendKeyEvent(TRUE, key1);
|
||||
SendKeyEvent(TRUE, key1);
|
||||
if (key2)
|
||||
SendKeyEvent(TRUE, key2);
|
||||
SendKeyEvent(TRUE, key2);
|
||||
|
||||
//printf("Sent mouse update: x = %u, y = %u\n", mouseCoords.h, mouseCoords.v);
|
||||
//printf(" xPos = %x, yPos = %x, buttons = %x\n", pointerEventStruct.xPos, pointerEventStruct.yPos, (int) pointerEventStruct.buttonMask);
|
||||
|
@ -134,7 +134,7 @@ void DoPointerEvent (void) {
|
|||
*/
|
||||
|
||||
if (cursor && GetCursorAdr() != cursor)
|
||||
SetCursor(cursor);
|
||||
SetCursor(cursor);
|
||||
}
|
||||
|
||||
void DoCursor (void) {
|
||||
|
@ -147,16 +147,16 @@ void DoCursor (void) {
|
|||
unsigned int *hotSpotYPtr, *hotSpotXPtr;
|
||||
unsigned long bitmaskByte;
|
||||
unsigned long bitmaskLineBytes, lineWords;
|
||||
unsigned int line, n, j; /* Loop counters */
|
||||
unsigned int line, n, j; /* Loop counters */
|
||||
unsigned char *maskLine, *imageLine;
|
||||
unsigned char *oldCursor = cursor; /* So we can free() it later */
|
||||
unsigned char *oldCursor = cursor; /* So we can free() it later */
|
||||
unsigned int outBytes640;
|
||||
unsigned long outBytes320;
|
||||
|
||||
bitmaskLineBytes = (rectWidth + 7) / 8;
|
||||
|
||||
if (!DoReadTCP(rectWidth*rectHeight + bitmaskLineBytes*rectHeight))
|
||||
return; /* Try again later */
|
||||
return; /* Try again later */
|
||||
|
||||
HLock(readBufferHndl);
|
||||
|
||||
|
@ -164,17 +164,17 @@ void DoCursor (void) {
|
|||
bitmask = (unsigned char *)(*readBufferHndl) + rectWidth*rectHeight;
|
||||
|
||||
if (hRez == 640)
|
||||
lineWords = (rectWidth + 7) / 8 + 1;
|
||||
lineWords = (rectWidth + 7) / 8 + 1;
|
||||
else /* hRez == 320 */
|
||||
lineWords = (rectWidth + 3) / 4 + 1;
|
||||
|
||||
cursor = malloc(8 + 4 * lineWords * rectHeight);
|
||||
/* Sub-optimal error handling */
|
||||
if (cursor == NULL)
|
||||
return;
|
||||
return;
|
||||
/* Don't overflow loop indices */
|
||||
if ((lineWords > UINT_MAX) || (rectHeight > UINT_MAX))
|
||||
return;
|
||||
if ((lineWords > UINT_MAX) || (rectHeight > UINT_MAX))
|
||||
return;
|
||||
cursorHeightPtr = (unsigned int *)(void *)cursor;
|
||||
cursorWidthPtr = cursorHeightPtr + 1;
|
||||
cursorImage = cursor + 4;
|
||||
|
@ -193,16 +193,16 @@ void DoCursor (void) {
|
|||
dataPtr = cursorPixels;
|
||||
|
||||
if (hRez == 320) {
|
||||
for (line = 0; line < rectHeight; line++) { /* for each line ... */
|
||||
for (line = 0; line < rectHeight; line++) { /* for each line ... */
|
||||
maskLine = cursorMask + line * lineWords * 2;
|
||||
imageLine = cursorImage + line * lineWords * 2;
|
||||
|
||||
for (j = 0; j < bitmaskLineBytes; j++) {
|
||||
for (j = 0; j < bitmaskLineBytes; j++) {
|
||||
bitmaskByte = *(bitmask + line*bitmaskLineBytes + j);
|
||||
outBytes320 =
|
||||
((bitmaskByte & 0x80) ) + ((bitmaskByte & 0x80) >> 1) +
|
||||
((bitmaskByte & 0x80) ) + ((bitmaskByte & 0x80) >> 1) +
|
||||
((bitmaskByte & 0x80) >> 2) + ((bitmaskByte & 0x80) >> 3) +
|
||||
((bitmaskByte & 0x40) >> 3) + ((bitmaskByte & 0x40) >> 4) +
|
||||
((bitmaskByte & 0x40) >> 3) + ((bitmaskByte & 0x40) >> 4) +
|
||||
((bitmaskByte & 0x40) >> 5) + ((bitmaskByte & 0x40) >> 6) +
|
||||
((bitmaskByte & 0x20) << 10) + ((bitmaskByte & 0x20) << 9) +
|
||||
((bitmaskByte & 0x20) << 8) + ((bitmaskByte & 0x20) << 7) +
|
||||
|
@ -223,12 +223,12 @@ void DoCursor (void) {
|
|||
for (n = 0; n < rectWidth/2; n++) {
|
||||
*(imageLine + n) = coltab320[*(dataPtr++)] & 0xF0;
|
||||
*(imageLine + n) += coltab320[*(dataPtr++)] & 0x0F;
|
||||
*(imageLine + n) ^= 0xFF; /* Reverse color */
|
||||
*(imageLine + n) ^= 0xFF; /* Reverse color */
|
||||
*(imageLine + n) &= *(maskLine + n);
|
||||
}
|
||||
if (rectWidth % 2) {
|
||||
*(imageLine + n) = coltab320[*(dataPtr++)] & 0xF0;
|
||||
*(imageLine + n) ^= 0xFF; /* Reverse color */
|
||||
*(imageLine + n) = coltab320[*(dataPtr++)] & 0xF0;
|
||||
*(imageLine + n) ^= 0xFF; /* Reverse color */
|
||||
*(imageLine + n) &= *(maskLine + n);
|
||||
n++;
|
||||
}
|
||||
|
@ -237,16 +237,16 @@ void DoCursor (void) {
|
|||
}
|
||||
}
|
||||
else { /* hRez == 640 */
|
||||
for (line = 0; line < rectHeight; line++) { /* for each line ... */
|
||||
for (line = 0; line < rectHeight; line++) { /* for each line ... */
|
||||
maskLine = cursorMask + line * lineWords * 2;
|
||||
imageLine = cursorImage + line * lineWords * 2;
|
||||
|
||||
for (j = 0; j < bitmaskLineBytes; j++) {
|
||||
bitmaskByte = *(bitmask + line*bitmaskLineBytes + j);
|
||||
outBytes640 =
|
||||
((bitmaskByte & 0x80) ) + ((bitmaskByte & 0xC0) >> 1) +
|
||||
((bitmaskByte & 0x60) >> 2) + ((bitmaskByte & 0x30) >> 3) +
|
||||
((bitmaskByte & 0x10) >> 4) + ((bitmaskByte & 0x08) << 12) +
|
||||
((bitmaskByte & 0x80) ) + ((bitmaskByte & 0xC0) >> 1) +
|
||||
((bitmaskByte & 0x60) >> 2) + ((bitmaskByte & 0x30) >> 3) +
|
||||
((bitmaskByte & 0x10) >> 4) + ((bitmaskByte & 0x08) << 12) +
|
||||
((bitmaskByte & 0x0C) << 11) + ((bitmaskByte & 0x06) << 10) +
|
||||
((bitmaskByte & 0x03) << 9) + ((bitmaskByte & 0x01) << 8);
|
||||
*((unsigned int *)maskLine + j) = outBytes640;
|
||||
|
@ -258,7 +258,7 @@ void DoCursor (void) {
|
|||
*(imageLine + n) += coltab640[*(dataPtr++)] & 0x30;
|
||||
*(imageLine + n) += coltab640[*(dataPtr++)] & 0x0C;
|
||||
*(imageLine + n) += coltab640[*(dataPtr++)] & 0x03;
|
||||
*(imageLine + n) ^= 0xFF; /* Reverse color */
|
||||
*(imageLine + n) ^= 0xFF; /* Reverse color */
|
||||
*(imageLine + n) &= *(maskLine + n);
|
||||
}
|
||||
*(imageLine + n) = 0;
|
||||
|
@ -275,7 +275,7 @@ void DoCursor (void) {
|
|||
}
|
||||
}
|
||||
}
|
||||
*(imageLine + n) ^= 0xFF; /* Reverse color */
|
||||
*(imageLine + n) ^= 0xFF; /* Reverse color */
|
||||
*(imageLine + n) &= *(maskLine + n);
|
||||
*(unsigned int *)(imageLine + n + 1) = 0;
|
||||
}
|
||||
|
@ -283,10 +283,10 @@ void DoCursor (void) {
|
|||
|
||||
HUnlock(readBufferHndl);
|
||||
|
||||
if (GetCursorAdr() == oldCursor)
|
||||
SetCursor(cursor);
|
||||
if (GetCursorAdr() == oldCursor)
|
||||
SetCursor(cursor);
|
||||
if (oldCursor)
|
||||
free(oldCursor);
|
||||
free(oldCursor);
|
||||
|
||||
#if 0
|
||||
/***************/
|
||||
|
@ -297,18 +297,18 @@ void DoCursor (void) {
|
|||
rectWidth, rectHeight, rectX, rectY);
|
||||
fprintf(foo, "\n");
|
||||
for (k = cursor; k < cursorImage; k++)
|
||||
fprintf(foo, "%02X ", *k);
|
||||
fprintf(foo, "%02X ", *k);
|
||||
for (j = 0; j < lineWords * rectHeight * 4; j++) {
|
||||
fprintf(foo, "%02X", *(cursorImage + j));
|
||||
fprintf(foo, "%02X", *(cursorImage + j));
|
||||
if ((j+1) % (lineWords * 2) == 0)
|
||||
fprintf(foo, "\n");
|
||||
fprintf(foo, "\n");
|
||||
}
|
||||
for (k = cursorImage + j; k < cursorImage + j + 4; k = k + 1)
|
||||
fprintf(foo, "%02X ", *k);
|
||||
fprintf(foo, "%02X ", *k);
|
||||
//for (j = 0; j < bitmaskLineBytes*rectHeight; j++) {
|
||||
// fprintf(foo, "%02X", *(bitmask + j));
|
||||
// if ((j+1) % bitmaskLineBytes == 0)
|
||||
// fprintf(foo, "\n");
|
||||
// fprintf(foo, "\n");
|
||||
// }
|
||||
fprintf(foo, "\n");
|
||||
fclose(foo);
|
||||
|
|
2
mouse.h
2
mouse.h
|
@ -1,3 +1,3 @@
|
|||
extern unsigned char * cursor; /* Cursor from server */
|
||||
extern unsigned char * cursor; /* Cursor from server */
|
||||
extern void DoPointerEvent (void);
|
||||
extern void DoCursor (void);
|
||||
|
|
372
raw.cc
372
raw.cc
|
@ -30,10 +30,10 @@
|
|||
#include "hextile.h"
|
||||
|
||||
/* Data on state of raw rectangle drawing routines */
|
||||
unsigned int lineBytes; /* Number of bytes in a line of GS pixels */
|
||||
unsigned int lineBytes; /* Number of bytes in a line of GS pixels */
|
||||
unsigned long pixels;
|
||||
|
||||
unsigned int drawingLine; /* Line to be drawn while displaying */
|
||||
unsigned int drawingLine; /* Line to be drawn while displaying */
|
||||
static BOOLEAN extraByteAdvance;
|
||||
|
||||
unsigned char *destPtr;
|
||||
|
@ -42,120 +42,120 @@ unsigned char *destPtr;
|
|||
* because the rectangle is not visible.
|
||||
*/
|
||||
void StopRawDrawing (void) {
|
||||
HUnlock(readBufferHndl);
|
||||
free(srcLocInfo.ptrToPixImage); /* Allocated as destPtr */
|
||||
HUnlock(readBufferHndl);
|
||||
free(srcLocInfo.ptrToPixImage); /* Allocated as destPtr */
|
||||
|
||||
displayInProgress = FALSE;
|
||||
|
||||
NextRect(); /* Prepare for next rect */
|
||||
NextRect(); /* Prepare for next rect */
|
||||
}
|
||||
|
||||
#pragma optimize 95 /* To work around an ORCA/C optimizer bug */
|
||||
#pragma optimize 95 /* To work around an ORCA/C optimizer bug */
|
||||
|
||||
/* Draw one or more lines from a raw rectangle
|
||||
*/
|
||||
void RawDraw (void) {
|
||||
unsigned int i; /* Loop indices */
|
||||
unsigned char *dataPtr;
|
||||
unsigned int i; /* Loop indices */
|
||||
unsigned char *dataPtr;
|
||||
unsigned char *lineDataPtr, *initialLineDataPtr;
|
||||
unsigned char *finalDestPtr;
|
||||
static EventRecord unusedEventRec;
|
||||
|
||||
/* For use with GetContentOrigin() */
|
||||
unsigned long contentOrigin;
|
||||
Point * contentOriginPtr = (void *) &contentOrigin;
|
||||
unsigned long contentOrigin;
|
||||
Point * contentOriginPtr = (void *) &contentOrigin;
|
||||
|
||||
SetPort(vncWindow); /* Drawing in VNC window */
|
||||
SetPort(vncWindow); /* Drawing in VNC window */
|
||||
dataPtr = (unsigned char *) *readBufferHndl;
|
||||
|
||||
/* Check if what we're drawing is visible, and skip any invisible part
|
||||
* by skipping some lines or completely aborting drawing the rectangle.
|
||||
*/
|
||||
if (checkBounds) {
|
||||
Rect drawingRect;
|
||||
Rect drawingRect;
|
||||
|
||||
contentOrigin = GetContentOrigin(vncWindow);
|
||||
contentOrigin = GetContentOrigin(vncWindow);
|
||||
drawingRect.h1 = rectX - contentOriginPtr->h;
|
||||
drawingRect.h2 = rectX - contentOriginPtr->h + rectWidth;
|
||||
drawingRect.v1 = rectY - contentOriginPtr->v + drawingLine;
|
||||
drawingRect.v2 = rectY - contentOriginPtr->v + rectHeight;
|
||||
|
||||
if (!RectInRgn(&drawingRect, GetVisHandle())) {
|
||||
StopRawDrawing();
|
||||
StopRawDrawing();
|
||||
return;
|
||||
}
|
||||
else if (rectY + drawingLine < contentOriginPtr->v) {
|
||||
destPtr += (unsigned long)lineBytes *
|
||||
(contentOriginPtr->v - rectY - drawingLine);
|
||||
drawingLine = contentOriginPtr->v - rectY;
|
||||
|
||||
if (drawingLine >= rectHeight) { /* Sanity check */
|
||||
StopRawDrawing();
|
||||
return;
|
||||
}
|
||||
(contentOriginPtr->v - rectY - drawingLine);
|
||||
drawingLine = contentOriginPtr->v - rectY;
|
||||
|
||||
if (drawingLine >= rectHeight) { /* Sanity check */
|
||||
StopRawDrawing();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (rectY + rectHeight - 1 > contentOriginPtr->v + winHeight)
|
||||
rectHeight = contentOriginPtr->v + winHeight - rectY + 1;
|
||||
rectHeight = contentOriginPtr->v + winHeight - rectY + 1;
|
||||
|
||||
checkBounds = FALSE;
|
||||
}
|
||||
|
||||
lineDataPtr = dataPtr + (unsigned long) drawingLine * rectWidth;
|
||||
|
||||
do { /* We short-circuit back to here if there are no events pending */
|
||||
|
||||
do { /* We short-circuit back to here if there are no events pending */
|
||||
|
||||
finalDestPtr = destPtr + lineBytes - 1;
|
||||
finalDestPtr = destPtr + lineBytes - 1;
|
||||
if (hRez == 640) {
|
||||
initialLineDataPtr = lineDataPtr;
|
||||
while (destPtr + 7 < finalDestPtr) { /* Unrolled loop */
|
||||
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
|
||||
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
|
||||
lineDataPtr += 4;
|
||||
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
|
||||
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
|
||||
lineDataPtr += 4;
|
||||
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
|
||||
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
|
||||
lineDataPtr += 4;
|
||||
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
|
||||
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
|
||||
lineDataPtr += 4;
|
||||
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr]
|
||||
+ bigcoltab640b[*(unsigned int*)(void*)(lineDataPtr+2)];
|
||||
lineDataPtr += 4;
|
||||
*(destPtr++) = bigcoltab640a[*(unsigned int*)(void*)lineDataPtr |