From 8c599f7005877a4d26a9b675cf6f4da2c1c061f0 Mon Sep 17 00:00:00 2001 From: dscho Date: Thu, 13 Sep 2001 09:49:46 +0000 Subject: Now you can write something in addition to mouse movements ... --- example.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 10 deletions(-) (limited to 'example.c') diff --git a/example.c b/example.c index 2ef78d8..1f1a4e3 100644 --- a/example.c +++ b/example.c @@ -39,8 +39,8 @@ void initBuffer(unsigned char* buffer) int i,j; for(i=0;iscreen,"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;jscreen->frameBuffer); - rfbMarkRectAsModified(cl->screen,0,0,maxx,maxy); + if(down) { + if(key==XK_Escape) + rfbCloseClient(cl); + 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); -- cgit v1.2.3