Commit 87c12192 authored by dscho's avatar dscho

font corrections, displayHook

parent 446f334c
...@@ -16,6 +16,7 @@ $nullx="0x"; ...@@ -16,6 +16,7 @@ $nullx="0x";
while(<>) { while(<>) {
if(/^FONT (.*)$/) { if(/^FONT (.*)$/) {
$fontname=$1; $fontname=$1;
$fontname=~y/\"//d;
} elsif(/^ENCODING (.*)$/) { } elsif(/^ENCODING (.*)$/) {
$glyphindex=$1; $glyphindex=$1;
$searchfor="BBX"; $searchfor="BBX";
......
#include "rfb.h" #include "rfb.h"
int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font, int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
int x,int y,char c,CARD32 colour) int x,int y,unsigned char c,CARD32 colour)
{ {
int i,j,k,width,height; int i,j,k,width,height;
unsigned char d; unsigned char d;
...@@ -12,7 +12,7 @@ int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font, ...@@ -12,7 +12,7 @@ int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
width=font->metaData[c*5+1]; width=font->metaData[c*5+1];
height=font->metaData[c*5+2]; height=font->metaData[c*5+2];
x+=font->metaData[c*5+3]; x+=font->metaData[c*5+3];
y+=font->metaData[c*5+4]-height+1; y+=-font->metaData[c*5+4]-height+1;
for(j=0;j<height;j++) { for(j=0;j<height;j++) {
for(i=0;i<width;i++) { for(i=0;i<width;i++) {
...@@ -23,7 +23,7 @@ int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font, ...@@ -23,7 +23,7 @@ int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
if(d&0x80) { if(d&0x80) {
for(k=0;k<bpp;k++) for(k=0;k<bpp;k++)
rfbScreen->frameBuffer[(y+j)*rowstride+(x+i)*bpp+k]= rfbScreen->frameBuffer[(y+j)*rowstride+(x+i)*bpp+k]=
((colour>>(8*bpp))&0xff); ((colour>>(8*k))&0xff);
} }
d<<=1; d<<=1;
} }
...@@ -34,7 +34,7 @@ int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font, ...@@ -34,7 +34,7 @@ int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
} }
void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font, void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
int x,int y,char* string,CARD32 colour) int x,int y,unsigned char* string,CARD32 colour)
{ {
while(*string) { while(*string) {
x+=rfbDrawChar(rfbScreen,font,x,y,*string,colour); x+=rfbDrawChar(rfbScreen,font,x,y,*string,colour);
...@@ -42,7 +42,7 @@ void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font, ...@@ -42,7 +42,7 @@ void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,
} }
} }
int rfbWidth(rfbFontDataPtr font,char* string) int rfbWidth(rfbFontDataPtr font,unsigned char* string)
{ {
int i=0; int i=0;
while(*string) { while(*string) {
...@@ -52,10 +52,15 @@ int rfbWidth(rfbFontDataPtr font,char* string) ...@@ -52,10 +52,15 @@ int rfbWidth(rfbFontDataPtr font,char* string)
return(i); return(i);
} }
void rfbFontBBox(rfbFontDataPtr font,char c,int* x1,int* y1,int* x2,int* y2) int rfbWidthOfChar(rfbFontDataPtr font,unsigned char c)
{
return(font->metaData[c*5+1]+font->metaData[c*5+3]);
}
void rfbFontBBox(rfbFontDataPtr font,unsigned char c,int* x1,int* y1,int* x2,int* y2)
{ {
*x1+=font->metaData[c*5+3]; *x1+=font->metaData[c*5+3];
*y1+=font->metaData[c*5+4]-font->metaData[c*5+2]+1; *y1+=-font->metaData[c*5+4]-font->metaData[c*5+2]+1;
*x2=*x1+font->metaData[c*5+1]; *x2=*x1+font->metaData[c*5+1];
*y2=*y1+font->metaData[c*5+2]; *y2=*y1+font->metaData[c*5+2];
} }
......
...@@ -75,10 +75,15 @@ void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,in ...@@ -75,10 +75,15 @@ void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,in
while((cl=rfbClientIteratorNext(iterator))) { while((cl=rfbClientIteratorNext(iterator))) {
LOCK(cl->updateMutex); LOCK(cl->updateMutex);
if(cl->useCopyRect) { if(cl->useCopyRect) {
if(!sraRgnEmpty(cl->copyRegion) && (cl->copyDX!=dx || cl->copyDY!=dy)) {
sraRgnOr(cl->copyRegion,cl->modifiedRegion);
sraRgnMakeEmpty(cl->copyRegion);
}
sraRgnOr(cl->copyRegion,copyRegion); sraRgnOr(cl->copyRegion,copyRegion);
cl->copyDX = dx; cl->copyDX = dx;
cl->copyDY = dy; cl->copyDY = dy;
/* while(!sraRgnEmpty(cl->copyRegion)) */ {
#ifdef HAVE_PTHREADS #ifdef HAVE_PTHREADS
if(cl->screen->backgroundLoop) { if(cl->screen->backgroundLoop) {
SIGNAL(cl->updateCond); SIGNAL(cl->updateCond);
...@@ -92,6 +97,7 @@ void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,in ...@@ -92,6 +97,7 @@ void rfbScheduleCopyRegion(rfbScreenInfoPtr rfbScreen,sraRegionPtr copyRegion,in
rfbSendFramebufferUpdate(cl,updateRegion); rfbSendFramebufferUpdate(cl,updateRegion);
sraRgnDestroy(updateRegion); sraRgnDestroy(updateRegion);
} }
}
} else { } else {
sraRgnOr(cl->modifiedRegion,copyRegion); sraRgnOr(cl->modifiedRegion,copyRegion);
} }
...@@ -457,7 +463,7 @@ rfbScreenInfoPtr rfbGetScreen(int argc,char** argv, ...@@ -457,7 +463,7 @@ rfbScreenInfoPtr rfbGetScreen(int argc,char** argv,
rfbScreen->colourMap.is16 = 0; rfbScreen->colourMap.is16 = 0;
rfbScreen->colourMap.data.bytes = NULL; rfbScreen->colourMap.data.bytes = NULL;
if(bytesPerPixel == 8) { if(bytesPerPixel == 1) {
format->redMax = 7; format->redMax = 7;
format->greenMax = 7; format->greenMax = 7;
format->blueMax = 3; format->blueMax = 3;
...@@ -500,6 +506,7 @@ rfbScreenInfoPtr rfbGetScreen(int argc,char** argv, ...@@ -500,6 +506,7 @@ rfbScreenInfoPtr rfbGetScreen(int argc,char** argv,
rfbScreen->getCursorPtr = defaultGetCursorPtr; rfbScreen->getCursorPtr = defaultGetCursorPtr;
rfbScreen->setTranslateFunction = rfbSetTranslateFunction; rfbScreen->setTranslateFunction = rfbSetTranslateFunction;
rfbScreen->newClientHook = doNothingWithClient; rfbScreen->newClientHook = doNothingWithClient;
rfbScreen->displayHook = 0;
/* initialize client list and iterator mutex */ /* initialize client list and iterator mutex */
rfbClientListInit(rfbScreen); rfbClientListInit(rfbScreen);
......
...@@ -147,6 +147,7 @@ typedef void (*SetXCutTextProcPtr) (char* str,int len, struct rfbClientRec* cl); ...@@ -147,6 +147,7 @@ typedef void (*SetXCutTextProcPtr) (char* str,int len, struct rfbClientRec* cl);
typedef struct rfbCursor* (*GetCursorProcPtr) (struct rfbClientRec* pScreen); typedef struct rfbCursor* (*GetCursorProcPtr) (struct rfbClientRec* pScreen);
typedef Bool (*SetTranslateFunctionProcPtr)(struct rfbClientRec* cl); typedef Bool (*SetTranslateFunctionProcPtr)(struct rfbClientRec* cl);
typedef void (*NewClientHookPtr)(struct rfbClientRec* cl); typedef void (*NewClientHookPtr)(struct rfbClientRec* cl);
typedef void (*DisplayHookPtr)(struct rfbClientRec* cl);
typedef struct { typedef struct {
CARD32 count; CARD32 count;
...@@ -296,6 +297,8 @@ typedef struct ...@@ -296,6 +297,8 @@ typedef struct
/* newClientHook is called just after a new client is created */ /* newClientHook is called just after a new client is created */
NewClientHookPtr newClientHook; NewClientHookPtr newClientHook;
/* displayHook is called just before a frame buffer update */
DisplayHookPtr displayHook;
} rfbScreenInfo, *rfbScreenInfoPtr; } rfbScreenInfo, *rfbScreenInfoPtr;
...@@ -714,7 +717,7 @@ extern void rfbDisconnectUDPSock(rfbScreenInfoPtr cl); ...@@ -714,7 +717,7 @@ extern void rfbDisconnectUDPSock(rfbScreenInfoPtr cl);
/* font.c */ /* font.c */
typedef struct rfbFontData { typedef struct rfbFontData {
char* data; unsigned char* data;
/* /*
metaData is a 256*5 array: metaData is a 256*5 array:
for each character for each character
...@@ -723,10 +726,11 @@ typedef struct rfbFontData { ...@@ -723,10 +726,11 @@ typedef struct rfbFontData {
int* metaData; int* metaData;
} rfbFontData,* rfbFontDataPtr; } rfbFontData,* rfbFontDataPtr;
int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,char c,CARD32 colour); int rfbDrawChar(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,unsigned char c,CARD32 colour);
void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,char* string,CARD32 colour); void rfbDrawString(rfbScreenInfoPtr rfbScreen,rfbFontDataPtr font,int x,int y,unsigned char* string,CARD32 colour);
int rfbWidth(rfbFontDataPtr font,char* string); int rfbWidth(rfbFontDataPtr font,unsigned char* string);
void rfbFontBBox(rfbFontDataPtr font,char c,int* x1,int* y1,int* x2,int* y2); int rfbWidthOfChar(rfbFontDataPtr font,unsigned char c);
void rfbFontBBox(rfbFontDataPtr font,unsigned char c,int* x1,int* y1,int* x2,int* y2);
/* main.c */ /* main.c */
......
...@@ -854,6 +854,9 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion) ...@@ -854,6 +854,9 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
int dx, dy; int dx, dy;
Bool sendCursorShape = FALSE; Bool sendCursorShape = FALSE;
if(cl->screen->displayHook)
cl->screen->displayHook(cl);
/* /*
* If this client understands cursor shape updates, cursor should be * If this client understands cursor shape updates, cursor should be
* removed from the framebuffer. Otherwise, make sure it's put up. * removed from the framebuffer. Otherwise, make sure it's put up.
...@@ -1097,6 +1100,7 @@ rfbSendCopyRegion(cl, reg, dx, dy) ...@@ -1097,6 +1100,7 @@ rfbSendCopyRegion(cl, reg, dx, dy)
sraRectangleIterator* i; sraRectangleIterator* i;
sraRect rect1; sraRect rect1;
/* printf("copyrect: "); sraRgnPrint(reg); putchar('\n'); fflush(stdout); */
i = sraRgnGetReverseIterator(reg,dx>0,dy>0); i = sraRgnGetReverseIterator(reg,dx>0,dy>0);
while(sraRgnIteratorNext(i,&rect1)) { while(sraRgnIteratorNext(i,&rect1)) {
......
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