Commit 8c599f70 authored by dscho's avatar dscho

Now you can write something in addition to mouse movements ...

parent 26343799
......@@ -9,7 +9,7 @@ VNCSERVERLIB=-L. -lvncserver -lz -ljpeg
# These two lines enable useage of PThreads
#CFLAGS += -DHAVE_PTHREADS
VNCSERVERLIB += -lpthread
#VNCSERVERLIB += -lpthread
LIBS=$(LDFLAGS) $(VNCSERVERLIB) $(VNCAUTHLIB)
......@@ -17,7 +17,6 @@ LIBS=$(LDFLAGS) $(VNCSERVERLIB) $(VNCAUTHLIB)
OSX_LIBS = -framework ApplicationServices -framework Carbon
# for Example
PTHREAD_LIBS = -lpthread
SOURCES=main.c rfbserver.c miregion.c auth.c sockets.c xalloc.c \
stats.c corre.c hextile.c rre.c translate.c cutpaste.c \
......@@ -39,10 +38,10 @@ libvncserver.a: $(OBJS)
$(RANLIB) $@
example: example.o libvncauth/libvncauth.a libvncserver.a
$(CC) -o example example.o $(LIBS) $(PTHREAD_LIBS)
$(CC) -o example example.o $(LIBS)
pnmshow: pnmshow.o libvncauth/libvncauth.a libvncserver.a
$(CC) -o pnmshow pnmshow.o $(LIBS) $(PTHREAD_LIBS)
$(CC) -o pnmshow pnmshow.o $(LIBS)
OSXvnc-server: mac.o libvncauth/libvncauth.a libvncserver.a
$(CC) -o OSXvnc-server mac.o $(LIBS) $(OSX_LIBS)
......
#!/usr/bin/perl
@encodings=();
for($i=0;$i<256*5;$i++) {
$encodings[$i]="0";
}
$out="";
$counter=0;
$i=0;
$searchfor="";
$nullx="0x";
while(<>) {
if(/^ENCODING (.*)$/) {
$glyphindex=$1;
$searchfor="BBX";
} elsif(/^BBX (.*) (.*) (.*) (.*)$/) {
($width,$height,$x,$y)=($1,$2,$3,$4);
@encodings[$glyphindex*5..($glyphindex*5+4)]=($counter,$width,$height,$x,$y);
$searchfor="BITMAP";
} elsif(/^BITMAP/) {
$i=1;
} elsif($i>0) {
if($i>$height) {
$i=0;
$out.=" /* $glyphindex */\n";
} else {
$_=substr($_,0,length($_)-1);
$counter+=length($_)/2;
s/(..)/$nullx$1,/g;
$out.=$_;
$i++;
}
}
}
print "unsigned char bdffontdata[$counter]={\n" . $out;
print "};\nint bdffontmetadata[256*5]={\n";
for($i=0;$i<256*5;$i++) {
print $encodings[$i] . ",";
}
print "};\n";
......@@ -39,8 +39,8 @@ void initBuffer(unsigned char* buffer)
int i,j;
for(i=0;i<maxx;++i)
for(j=0;j<maxy;++j) {
buffer[(j*maxx+i)*bpp+1]=(i+j)*256/(maxx+maxy); /* red */
buffer[(j*maxx+i)*bpp+2]=i*256/maxx; /* green */
buffer[(j*maxx+i)*bpp+1]=(i+j)*128/(maxx+maxy); /* red */
buffer[(j*maxx+i)*bpp+2]=i*128/maxx; /* green */
buffer[(j*maxx+i)*bpp+3]=j*256/maxy; /* blue */
}
}
......@@ -111,25 +111,92 @@ void doptr(int buttonMask,int x,int y,rfbClientPtr cl)
/* we could get a selection like that:
rfbGotXCutText(cl->screen,"Hallo",5);
*/
cd->oldx=x; cd->oldy=y; cd->oldButton=buttonMask;
} else
cd->oldButton=0;
cd->oldx=x; cd->oldy=y; cd->oldButton=buttonMask;
}
/* aux function to draw a character to x, y */
#include "radon.h"
int drawchar(unsigned char* buffer,int rowstride,int bpp,int x,int y,char c)
{
int i,j,k,width,height;
unsigned char d;
unsigned char* data=bdffontdata+bdffontmetadata[c*5];
width=bdffontmetadata[c*5+1];
height=bdffontmetadata[c*5+2];
x+=bdffontmetadata[c*5+3];
y+=bdffontmetadata[c*5+4]-height+1;
for(j=0;j<height;j++) {
for(i=0;i<width;i++) {
if((i&7)==0) {
d=*data;
data++;
}
if(d&0x80) {
for(k=0;k<bpp;k++)
buffer[(y+j)*rowstride+(x+i)*bpp+k]=0xff;
}
d<<=1;
}
if((i&7)==0)
data++;
}
return(width);
}
void drawstring(unsigned char* buffer,int rowstride,int bpp,int x,int y,char* string)
{
while(*string) {
x+=drawchar(buffer,rowstride,bpp,x,y,*string);
string++;
}
}
int bdflength(char* string)
{
int i;
while(*string) {
i+=bdffontmetadata[*string*5+1];
string++;
}
return(i);
}
void bdfbbox(char c,int* x1,int* y1,int* x2,int* y2)
{
*x1+=bdffontmetadata[c*5+3];
*y1+=bdffontmetadata[c*5+4]-bdffontmetadata[c*5+2]+1;
*x2=*x1+bdffontmetadata[c*5+1];
*y2=*y1+bdffontmetadata[c*5+2];
}
/* Here the key events are handled */
void dokey(Bool down,KeySym key,rfbClientPtr cl)
{
if(down && key==XK_Escape)
if(down) {
if(key==XK_Escape)
rfbCloseClient(cl);
else if(down && key=='c') {
else if(key==XK_Page_Up) {
initBuffer(cl->screen->frameBuffer);
rfbMarkRectAsModified(cl->screen,0,0,maxx,maxy);
} else if(key>=' ' && key<0x100) {
ClientData* cd=cl->clientData;
int x1=cd->oldx,y1=cd->oldy,x2,y2;
cd->oldx+=drawchar(cl->screen->frameBuffer,
cl->screen->paddedWidthInBytes,bpp,cd->oldx,cd->oldy,
key);
bdfbbox(key,&x1,&y1,&x2,&y2);
rfbMarkRectAsModified(cl->screen,x1,y1,x2-1,y2-1);
}
}
}
/* Initialisation */
/* Initialization */
int main(int argc,char** argv)
{
......@@ -144,6 +211,8 @@ int main(int argc,char** argv)
initBuffer(rfbScreen->frameBuffer);
drawstring(rfbScreen->frameBuffer,maxx*bpp,bpp,20,100,"Hallo, Welt!");
/* this is the blocking event loop, i.e. it never returns */
/* 40000 are the microseconds, i.e. 0.04 seconds */
runEventLoop(rfbScreen,40000,FALSE);
......
This diff is collapsed.
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