Example #1
0
void MwSelect (void)
{
        struct MW_UID_MESSAGE m;
	int rc;
	unsigned int timeout = 0;

	/* perform pre-select duties, if any*/
	if (scrdev.PreSelect)
		scrdev.PreSelect (&scrdev);

	/* Set up the timeout for the main select().
	 * If the mouse is captured we're probably moving a window,
	 * so poll quickly to allow other windows to repaint while
	 * checking for more event input.
	 */
	if (!dragwp) {
	        timeout = MwGetNextTimeoutValue ();     /* returns ms*/
		        if (timeout < 10)
		                timeout = 10;       /* 10ms required for vt fb switch*/
	}										
	/* let's make sure that the type is invalid */
	m.type = MV_UID_INVALID;
	
	/* wait up to 100 milisecons for events */
	rc = uid_read_message (&m, timeout);

	/* return if timed-out or something went wrong */
	if (rc < 0) {
	        if ( errno != ETIMEDOUT )
		        EPRINTF (" rc= %d, errno=%d\n", rc, errno);
		else {
			MwHandleTimers ();
		}
		return;
	}

	/* let's pass the event up to microwindows */
	switch (m.type) {
	case MV_UID_REL_POS:	/* Mouse or Touch Screen event */
	case MV_UID_ABS_POS:
	        m_mou = m;
		while (MwCheckMouseEvent ()) continue;
		break;
	case MV_UID_KBD:	/* KBD event */
	        m_kbd = m;
		MwCheckKeyboardEvent();
		break;
        case MV_UID_TIMER:	/* Microwindows does nothing with these.. */
	case MV_UID_INVALID:
	default:
	        break;
	}
}
Example #2
0
void
MwSelect(void)
{
	/* If mouse data present, service it*/
	if(mousedev.Poll())
		while(MwCheckMouseEvent())
			continue;

	/* If keyboard data present, service it*/
	if(kbddev.Poll())
		while(MwCheckKeyboardEvent())
			continue;

	MwHandleTimers();
}
Example #3
0
void
MwSelect(void)
{
	fd_set	rfds;
	fd_set	wfds;
	fd_set	efds;
	int 	fd;
	int 	e;
	int	setsize = 0;
	UINT	timeout;
	struct timeval to;

	/* perform pre-select duties, if any*/
	if(scrdev.PreSelect)
		scrdev.PreSelect(&scrdev);

	/* Set up the FDs for use in the main select(): */
	FD_ZERO(&rfds);
	FD_ZERO(&wfds);
	FD_ZERO(&efds);

	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;
	}

	/* handle registered file descriptors */
	fd = userregfd_head;
	while (fd != -1) {
		if (userregfd[fd].read) FD_SET(fd, &rfds);
		if (userregfd[fd].write) FD_SET(fd, &wfds);
		if (userregfd[fd].except) FD_SET(fd, &efds);
		if(fd > setsize) setsize = fd;
		fd = userregfd[fd].next;
	}

	++setsize;

	/* Set up the timeout for the main select().  If
	 * the mouse is captured we're probably moving a window,
	 * so poll quickly to allow other windows to repaint while
	 * checking for more event input.
	 */
	if(dragwp)
		timeout = to.tv_sec = to.tv_usec = 0L;
	else {
		timeout = MwGetNextTimeoutValue();	/* returns ms*/
#if ANIMATEPALETTE
		if(fade < 100)
			timeout = 40;
#endif
if (!timeout) timeout = 10;	/* temp kluge required for mdemo to run ok*/
#if MW_FEATURE_TIMERS
		GdGetNextTimeout(&to, timeout);
#else /* if ! MW_FEATURE_TIMERS */
		to.tv_sec = timeout / 1000;
		to.tv_usec = (timeout % 1000) * 1000;
#endif /* ! MW_FEATURE_TIMERS */
	}

	/* Wait for some input on any of the fds in the set or a timeout: */
	if((e = select(setsize, &rfds, &wfds, &efds, &to)) > 0) {
		
		/* If data is present on the mouse fd, service it: */
		if(mouse_fd >= 0 && FD_ISSET(mouse_fd, &rfds))
			while(MwCheckMouseEvent())
				continue;

		/* If data is present on the keyboard fd, service it: */
		if(keyb_fd >= 0 && FD_ISSET(keyb_fd, &rfds))
			while(MwCheckKeyboardEvent())
				continue;

		/* If registered descriptor, handle it */
		fd = userregfd_head;
		while (fd != -1) {
			if (userregfd[fd].read && FD_ISSET(fd, &rfds))
				PostMessage(userregfd[fd].read, WM_FDINPUT, fd, 0);
			if (userregfd[fd].write && FD_ISSET(fd, &wfds))
				PostMessage(userregfd[fd].write, WM_FDOUTPUT, fd, 0);
			if (userregfd[fd].except && FD_ISSET(fd, &efds))
				PostMessage(userregfd[fd].except, WM_FDEXCEPT, fd, 0);
			fd = userregfd[fd].next;
		}
	} 
	else if(e == 0) {
		/* timeout has occured*/
#if MW_FEATURE_TIMERS
		if(GdTimeout() == FALSE)
			return;
#endif /* MW_FEATURE_TIMERS */
#if ANIMATEPALETTE
		if(fade <= 100) {
			setfadelevel(&scrdev, fade);
			fade += 5;
		}
#endif
		MwHandleTimers();
	} else
		if(errno != EINTR)
			EPRINTF("Select() call in main failed\n");
}