Commit 87c12192 authored by dscho's avatar dscho

font corrections, displayHook

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