From e5efcf823942529cf1491cc4b677b0c01126a39c Mon Sep 17 00:00:00 2001 From: reinelt <> Date: Fri, 31 Mar 2000 04:41:22 +0000 Subject: [lcd4linux @ 2000-03-31 04:41:22 by reinelt] X11 driver: semaphore bug fixed --- XWindow.c | 131 ++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 68 insertions(+), 63 deletions(-) (limited to 'XWindow.c') diff --git a/XWindow.c b/XWindow.c index b169192..87dd84e 100644 --- a/XWindow.c +++ b/XWindow.c @@ -1,4 +1,4 @@ -/* $Id: XWindow.c,v 1.9 2000/03/30 16:46:57 reinelt Exp $ +/* $Id: XWindow.c,v 1.10 2000/03/31 04:41:22 reinelt Exp $ * * X11 Driver for LCD4Linux * @@ -20,6 +20,14 @@ * * * $Log: XWindow.c,v $ + * Revision 1.10 2000/03/31 04:41:22 reinelt + * + * X11 driver: semaphore bug fixed + * + * Revision 1.10 2000/03/31 01:42:11 herp + * + * semaphore bug fixed + * * Revision 1.9 2000/03/30 16:46:57 reinelt * * configure now handles '--with-x' and '--without-x' correct @@ -47,6 +55,7 @@ /* * + * Fri Mar 31 01:42:11 MET 2000 semaphore bug fixed * Sun Mar 26 15:28:23 MET 2000 various rewrites * Sat Mar 25 23:58:19 MET 2000 use generic pixmap driver * Thu Mar 23 01:05:07 MET 2000 multithreading, synchronization @@ -75,34 +84,33 @@ #define BARS ( BAR_L | BAR_R | BAR_U | BAR_D | BAR_H2 | BAR_V2 ) static LCD Lcd; -Display *dp; -int sc; -Window w,rw; -Visual *vi; -int dd; -Colormap cm; -GC gc,gcb,gch; -XColor co[3]; -XColor db; -Pixmap pmback; - -unsigned char *BackupLCDpixmap; -char *rgbfg,*rgbbg,*rgbhg; -int pixel=-1; /*pointsize in pixel*/ -int pgap=0; /*gap between points */ -int rgap=0; /*row gap between lines*/ -int cgap=0; /*column gap between characters*/ -int border=0; /*window border*/ -int rows=-1,cols=-1; /*rows+cols without background*/ -int xres=-1,yres=-1; /*xres+yres (same as self->...)*/ -int dimx,dimy; /*total window dimension in pixel*/ -int boxw,boxh; /*box width, box height*/ -void async_update(); /*PROTO*/ -pid_t async_updater_pid=1; -int semid=-1; -int shmid=-1; - -void acquire_lock() { +static Display *dp; +static int sc; +static Window w,rw; +static Visual *vi; +static int dd; +static Colormap cm; +static GC gc,gcb,gch; +static XColor co[3]; +static Pixmap pmback; + +static unsigned char *BackupLCDpixmap; +static char *rgbfg,*rgbbg,*rgbhg; +static int pixel=-1; /*pointsize in pixel*/ +static int pgap=0; /*gap between points */ +static int rgap=0; /*row gap between lines*/ +static int cgap=0; /*column gap between characters*/ +static int border=0; /*window border*/ +static int rows=-1,cols=-1; /*rows+cols without background*/ +static int xres=-1,yres=-1; /*xres+yres (same as self->...)*/ +static int dimx,dimy; /*total window dimension in pixel*/ +static int boxw,boxh; /*box width, box height*/ +static void async_update(); /*PROTO*/ +static pid_t async_updater_pid=1; +static int semid=-1; +static int shmid=-1; + +static void acquire_lock() { struct sembuf sembuf; sembuf.sem_num=0; sembuf.sem_op=-1; @@ -110,7 +118,7 @@ struct sembuf sembuf; semop(semid,&sembuf,1); /* get mutex */ } -void release_lock() { +static void release_lock() { struct sembuf sembuf; sembuf.sem_num=0; sembuf.sem_op=1; @@ -118,28 +126,27 @@ struct sembuf sembuf; semop(semid,&sembuf,1); /* free mutex */ } -void semcleanup() { +static void semcleanup() { union semun arg; if (semid>-1) semctl(semid,0,IPC_RMID,arg); } -void shmcleanup() { +static void shmcleanup() { if (shmid>-1) shmctl(shmid,IPC_RMID,NULL); } -void quit(int nsig) { - printf("X11: pid %d got signal %d\n",getpid(),nsig); +static void quit(int nsig) { semcleanup(); shmcleanup(); exit(0); } -void quit_updater() { +static void quit_updater() { if (async_updater_pid>1) kill(async_updater_pid,15); } -void init_signals() { +static void init_signals() { unsigned int oksig=(1<=dimx || y>=dimy || x+width<0 || y+height<0) { - // printf("border only\n"); + if (x>=dimx || y>=dimy || x+width<0 || y+height<0) return; /*border doesnt need update*/ - } if (x<0) x=0; if (y<0) y=0; if (x+width>dimx) width=dimx-x; @@ -409,25 +412,27 @@ int dx,wx,wy; pos=yfrom*xres*cols+xfrom; wy=border+yfrom*(pixel+pgap)+rgap*(yfrom/yres); wx=border+xfrom*(pixel+pgap)+cgap*(xfrom/xres); - wpos=pos; + wpos=pos; xpix=xres*cols; + igap=yfrom%yres; wjgap=xfrom%xres; for(i=yfrom;i<=yto;i++) { dx=wx; + jgap=wjgap; for(j=xfrom;j<=xto;j++) { XFillRectangle(dp,w, BackupLCDpixmap[wpos++]?gc:gch, dx,wy, pixel,pixel); dx+=pixel+pgap; - if ((j+1)%xres==0) dx+=cgap; + if (++jgap==xres) { dx+=cgap; jgap=0; } } wy+=pixel+pgap; - if ((i+1)%yres==0) wy+=rgap; - pos+=xres*cols; + if (++igap==yres) { wy+=rgap; igap=0; } + pos+=xpix; wpos=pos; } } -void async_update() { +static void async_update() { XEvent ev; for(;;) { -- cgit v1.2.3