diff -urN --exclude-from=/export/home/ptr/STLport.lab/cvs.stlport.com/STLport/etc/cvsignore microwin/src/nanox/client.c microwin.dev/src/nanox/client.c --- microwin/src/nanox/client.c Tue Jul 26 19:41:40 2005 +++ microwin.dev/src/nanox/client.c Fri Jul 29 14:55:49 2005 @@ -846,6 +846,45 @@ } } +int +XXGrEvent( GR_EVENT *ev ) +{ + fd_set rfds; + int setsize = 0; + + FD_ZERO(&rfds); + GrPrepareSelect(&setsize, &rfds); + LOCK(&nxGlobalLock); + + /* Clean out any event that might have arrived while waiting + * for other data, for instance by doing Nano-X requests + * between GrPrepareSelect() and GrServiceSelect(), or when + * an event is generated in Nano-X at the same time as the + * client wakes up for some reason and calls Nano-X functions. + */ + if (evlist) { + /*DPRINTF("nxclient: Handling queued event\n");*/ + GetNextQueuedEvent(ev); + CheckErrorEvent(ev); + UNLOCK(&nxGlobalLock); + return 0; + } + UNLOCK(&nxGlobalLock); + + if(select(setsize+1, &rfds, NULL, NULL, NULL) > 0) { + LOCK(&nxGlobalLock); + if(FD_ISSET(nxSocket, &rfds)) { + TypedReadBlock(ev, sizeof(GR_EVENT),GrNumGetNextEvent); + CheckForClientData(ev); + CheckErrorEvent(ev); + UNLOCK(&nxGlobalLock); + return 0; + } + UNLOCK(&nxGlobalLock); + } + return 1; +} + /** * Queue an event in FIFO for later retrieval. * diff -urN --exclude-from=/export/home/ptr/STLport.lab/cvs.stlport.com/STLport/etc/cvsignore microwin/src/nanox/srvfunc.c microwin.dev/src/nanox/srvfunc.c --- microwin/src/nanox/srvfunc.c Tue Jul 26 19:41:40 2005 +++ microwin.dev/src/nanox/srvfunc.c Wed Aug 10 09:50:28 2005 @@ -7,6 +7,7 @@ #include #include #include +#include #define MWINCLUDECOLORS #include "serv.h" @@ -90,6 +91,111 @@ GsSelect(timeout); CheckNextEvent(ep, GR_FALSE); SERVER_UNLOCK(); +} + +extern int mouse_fd; +extern int keyb_fd; +extern int regfdmax; +extern fd_set regfdset; + +int +XXGrEvent( GR_EVENT *ev ) +{ + while ( 1 ) { + fd_set rfds; + int setsize = 0; + int e; +#if NONETWORK + int fd; +#endif +#if HAVE_VNCSERVER +#if VNCSERVER_PTHREADED + int dummy; +#else + rfbClientIteratorPtr i; + rfbClientPtr cl; +#endif +#endif + + SERVER_LOCK(); + if (curclient->eventhead != NULL) { + SERVER_UNLOCK(); + break; + } + SERVER_UNLOCK(); + + FD_ZERO(&rfds); + GrPrepareSelect(&setsize, &rfds); + + /* Wait for some input on any of the fds in the set or a timeout: */ + if((e = select(setsize+1, &rfds, NULL, NULL, NULL)) > 0) { + SERVER_LOCK(); + /* If data is present on the mouse fd, service it: */ + if(mouse_fd >= 0 && FD_ISSET(mouse_fd, &rfds)) + while(GsCheckMouseEvent()) + continue; + + /* If data is present on the keyboard fd, service it: */ + if( (keyb_fd >= 0 && FD_ISSET(keyb_fd, &rfds)) +#ifdef MW_FEATURE_TWO_KEYBOARDS + || (keyb2_fd >= 0 && FD_ISSET(keyb2_fd, &rfds)) +#endif + ) + while(GsCheckKeyboardEvent()) + continue; + +#if HAVE_VNCSERVER && VNCSERVER_PTHREADED + if ( vnc_thread_fd >= 0 && FD_ISSET(vnc_thread_fd, &rfds) ) + /* Read from vnc pipe */ + read( vnc_thread_fd, &dummy, sizeof(int)); + +#endif +#if NONETWORK + /* check for input on registered file descriptors */ + for (fd = 0; fd < regfdmax; fd++) { + GR_EVENT_FDINPUT * gp; + + if (!FD_ISSET(fd, ®fdset) || !FD_ISSET(fd, &rfds)) + continue; + + gp =(GR_EVENT_FDINPUT *)GsAllocEvent(curclient); + if(gp) { + gp->type = GR_EVENT_TYPE_FDINPUT; + gp->fd = fd; + } + } +#else /* not NONETWORK */ + + /* If a client is trying to connect, accept it: */ + if(FD_ISSET(un_sock, &rfds)) + GsAcceptClient(); + + /* If a client is sending us a command, handle it: */ + curclient = root_client; + while(curclient) { + GR_CLIENT *curclient_next; + + /* curclient may be freed in GsDropClient*/ + curclient_next = curclient->next; + if(FD_ISSET(curclient->id, &rfds)) + GsHandleClient(curclient->id); + curclient = curclient_next; + } + +#if HAVE_VNCSERVER && !VNCSERVER_PTHREADED + rfbProcessEvents(rfbScreen, 0); +#endif + +#endif /* NONETWORK */ + SERVER_UNLOCK(); + } else + if(errno != EINTR) + EPRINTF("Select() call in main failed\n"); + } + + SERVER_LOCK(); + CheckNextEvent(ev, GR_FALSE); + SERVER_UNLOCK(); } /* diff -urN --exclude-from=/export/home/ptr/STLport.lab/cvs.stlport.com/STLport/etc/cvsignore microwin/src/nanox/srvmain.c microwin.dev/src/nanox/srvmain.c --- microwin/src/nanox/srvmain.c Tue Jul 26 19:41:40 2005 +++ microwin.dev/src/nanox/srvmain.c Wed Aug 10 09:48:36 2005 @@ -89,11 +89,11 @@ GR_CLIENT *current_client; /* the client we are currently talking*/ char *current_shm_cmds; int current_shm_cmds_size; -static int keyb_fd; /* the keyboard file descriptor */ +int keyb_fd; /* the keyboard file descriptor */ #ifdef MW_FEATURE_TWO_KEYBOARDS static int keyb2_fd; /* the keyboard file descriptor */ #endif -static int mouse_fd; /* the mouse file descriptor */ +int mouse_fd; /* the mouse file descriptor */ char *curfunc; /* the name of the current server func*/ GR_BOOL screensaver_active; /* time before screensaver activates */ GR_SELECTIONOWNER selection_owner; /* the selection owner and typelist */ @@ -311,8 +311,8 @@ * when input is ready. */ -static int regfdmax = -1; -static fd_set regfdset; +int regfdmax = -1; +fd_set regfdset; void GrRegisterInput(int fd)