⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 srvmain.c

📁 在uClinux 2.4X 的GUI 驱动 microwindows-Drives 测试OK
💻 C
📖 第 1 页 / 共 2 页
字号:
{	/* If mouse data present, service it*/	if(mousedev.Poll())		while(GsCheckMouseEvent())			continue;   /* If keyboard data present, service it*/	if(kbddev.Poll())		while(GsCheckKeyboardEvent())			continue;}#elif UNIX && defined(HAVESELECT) && !CLEOPATRA voidGsSelect(GR_TIMEOUT timeout){	fd_set	rfds;	int 	e;	int	setsize = 0;	struct timeval tout, *to;	/* perform pre-select duties, if any*/	if(rootwp->psd->PreSelect)		rootwp->psd->PreSelect(rootwp->psd);	/* Set up the FDs for use in the main select(): */	FD_ZERO(&rfds);	if(mouse_fd >= 0) {		FD_SET(mouse_fd, &rfds);		if (mouse_fd > setsize)			setsize = mouse_fd;	}	if(keyb_fd >= 0) {		FD_SET(keyb_fd, &rfds);		if (keyb_fd > setsize)			setsize = keyb_fd;	}#if NONETWORK	/* handle registered input file descriptors*/	if (regfd != -1) {		FD_SET(regfd, &rfds);		if (regfd > setsize) setsize = regfd;	}#else /* not NONETWORK */	/* handle client socket connections*/	FD_SET(un_sock, &rfds);	if (un_sock > setsize) setsize = un_sock;	curclient = root_client;	while(curclient) {		if(curclient->waiting_for_event && curclient->eventhead) {			curclient->waiting_for_event = FALSE;			GrGetNextEventWrapperFinish(curclient->id);			return;		}		FD_SET(curclient->id, &rfds);		if(curclient->id > setsize) setsize = curclient->id;		curclient = curclient->next;	}#endif /* NONETWORK */	/* Set up the timeout for the main select(): */	if(GdGetNextTimeout(&tout, timeout) == TRUE)		to = &tout;	else to = NULL;	/* Wait for some input on any of the fds in the set or a timeout: */	//--------------------------------------	// 增加代码以便处理触摸屏的消息。	while(GsCheckMouseEvent())		continue;	//--------------------------------------	if ((e = select(setsize+1, &rfds, NULL, NULL, to)) > 0) 	{		/* 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))			while(GsCheckKeyboardEvent())				continue;#if NONETWORK		/* If registered input descriptor, handle it*/		if(regfd != -1 && FD_ISSET(regfd, &rfds)) {			GR_EVENT_FDINPUT *	gp;			gp = (GR_EVENT_FDINPUT *)GsAllocEvent(curclient);			if(gp) {				gp->type = GR_EVENT_TYPE_FDINPUT;				gp->fd = regfd;			}		}#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;		}#endif /* NONETWORK */	}	else if (e == 0) {#if NONETWORK		/* 		 * Timeout has occured.  Currently return		 * a timeout event regardless of whether		 * client has selected for it.		 */		if(GdTimeout() == TRUE) {			GR_EVENT_GENERAL *	gp;			gp = (GR_EVENT_GENERAL *)GsAllocEvent(curclient);			if(gp)				gp->type = GR_EVENT_TYPE_TIMEOUT;		}#else /* not NONETWORK */		GdTimeout();#endif /* NONETWORK */	} else		if(errno != EINTR)			EPRINTF("Select() call in main failed\n");}#endif /* UNIX && defined(HAVESELECT)*/#if VTSWITCHstatic voidCheckVtChange(void *arg){	if(MwCheckVtChange())		GsRedrawScreen();	GdAddTimer(50, CheckVtChange, NULL);}#endif/* * Initialize the graphics and mouse devices at startup. * Returns nonzero with a message printed if the initialization failed. */intGsInitialize(void){	GR_WINDOW	*wp;		/* root window */	PSD		psd;	static MWIMAGEBITS cursorbits[16] = {	      0xe000, 0x9800, 0x8600, 0x4180,	      0x4060, 0x2018, 0x2004, 0x107c,	      0x1020, 0x0910, 0x0988, 0x0544,	      0x0522, 0x0211, 0x000a, 0x0004	};	static MWIMAGEBITS cursormask[16] = {	      0xe000, 0xf800, 0xfe00, 0x7f80,	      0x7fe0, 0x3ff8, 0x3ffc, 0x1ffc,	      0x1fe0, 0x0ff0, 0x0ff8, 0x077c,	      0x073e, 0x021f, 0x000e, 0x0004	};	wp = (GR_WINDOW *) malloc(sizeof(GR_WINDOW));	if (wp == NULL) {		EPRINTF("Cannot allocate root window\n");		return -1;	}	startTicks = GsGetTickCount();	/* catch terminate signal to restore tty state*/	signal(SIGTERM, (void *)GsTerminate);	screensaver_delay = 0;	screensaver_active = GR_FALSE;	selection_owner.wid = 0;	selection_owner.typelist = NULL;#if !NONETWORK	/* ignore pipe signal, sent when clients exit*/	signal(SIGPIPE, SIG_IGN);	signal(SIGHUP, SIG_IGN);	if (GsOpenSocket() < 0) {		EPRINTF("Cannot bind to named socket\n");		free(wp);		return -1;	}#endif	if ((keyb_fd = GdOpenKeyboard()) == -1) {		EPRINTF("Cannot initialise keyboard\n");		/*GsCloseSocket();*/		free(wp);		return -1;	}	if ((psd = GdOpenScreen()) == NULL) {		EPRINTF("Cannot initialise screen\n");		/*GsCloseSocket();*/		GdCloseKeyboard();		free(wp);		return -1;	}	if ((mouse_fd = GdOpenMouse()) == -1) {		EPRINTF("Cannot initialise mouse\n");		/*GsCloseSocket();*/		GdCloseScreen(psd);		GdCloseKeyboard();		free(wp);		return -1;	}	/*	 * Get screen dimensions for our own use,	 */	GdGetScreenInfo(psd, &sinfo);#if (HAVE_BIG5_SUPPORT | HAVE_GB2312_SUPPORT)	/* system fixed font looks better when mixed with chinese fonts*/	stdfont = GdCreateFont(psd, MWFONT_SYSTEM_FIXED, 0, NULL);#else	stdfont = GdCreateFont(psd, MWFONT_SYSTEM_VAR, 0, NULL);#endif	/*	 * Initialize the root window.	 */	wp->psd = psd;	wp->id = GR_ROOT_WINDOW_ID;	wp->parent = NULL;		/* changed: was = NULL*/	wp->owner = NULL;	wp->children = NULL;	wp->siblings = NULL;	wp->next = NULL;	wp->x = 0;	wp->y = 0;	wp->width = sinfo.cols;	wp->height = sinfo.rows;	wp->bordersize = 0;	wp->background = BLACK;	wp->bordercolor = BLACK;	wp->nopropmask = 0;	wp->bgpixmap = NULL;	wp->bgpixmapflags = GR_BACKGROUND_TILE;	wp->eventclients = NULL;	wp->cursor = NULL;	wp->mapped = GR_TRUE;	wp->unmapcount = 0;	wp->output = GR_TRUE;	wp->props = 0;	wp->title = NULL;        listpp = NULL;	listwp = wp;	rootwp = wp;	focuswp = wp;	mousewp = wp;	focusfixed = GR_FALSE;	/*	 * Initialize and position the default cursor.	 */	curcursor = NULL;	cursorx = -1;	cursory = -1;	GdShowCursor(psd);	GrMoveCursor(sinfo.cols / 2, sinfo.rows / 2);	GrSetCursor(GR_ROOT_WINDOW_ID, 16, 16, 0, 0, WHITE, BLACK,		cursorbits, cursormask);#if VTSWITCH	MwInitVt();	/* Check for VT change every 50 ms: */	GdAddTimer(50, CheckVtChange, NULL);#endif   psd->FillRect(psd, 0, 0, sinfo.cols-1, sinfo.rows-1,		GdFindColor(BLACK));	/*	 * Tell the mouse driver some things.	 */	curbuttons = 0;	GdRestrictMouse(0, 0, sinfo.cols - 1, sinfo.rows - 1);	GdMoveMouse(sinfo.cols / 2, sinfo.rows / 2);	/* Force root window screen paint*/	GsRedrawScreen();	/*	 * Force the cursor to appear on the screen at startup.	 * (not required with above GsRedrawScreen)	GdHideCursor(&scrdev);	GdShowCursor(&scrdev);	 */	/*	 * All done.	 */	connectcount = 0;	return 0;}/* * Here to close down the server. */voidGsTerminate(void){#if !NONETWORK	GsCloseSocket();#endif	GdCloseScreen(rootwp->psd);	GdCloseMouse();	GdCloseKeyboard();#if VTSWITCH	MwRedrawVt(mwvterm);#endif	exit(0);}/* * Return # milliseconds elapsed since start of Microwindows * Granularity is 25 msec */GR_TIMEOUTGsGetTickCount(void){#if MSDOS#include <time.h>	return (DWORD)(clock() * 1000 / CLOCKS_PER_SEC);#else#if _MINIX	struct tms	t;		return (DWORD)times(&t) * 16;#else#if UNIX	struct timeval t;	gettimeofday(&t, NULL);	return ((t.tv_sec * 1000) + (t.tv_usec / 25000) * 25) - startTicks;#else	return 0L;#endif#endif#endif}voidGrBell(void){	write(2, "\7", 1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -