コード例 #1
0
ファイル: winmain.c プロジェクト: lepton-distribution/lepton
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;
	}
}
コード例 #2
0
ファイル: winmain.c プロジェクト: OPSF/uClinux
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();
}
コード例 #3
0
ファイル: winuser.c プロジェクト: alex-sever-h/microwin
BOOL WINAPI
GetMessage(LPMSG lpMsg,HWND hwnd,UINT wMsgFilterMin,UINT wMsgFilterMax)
{
	/*
	 * currently MwSelect() must poll for VT switch reasons,
	 * so this code will work
	 */
	while(!PeekMessage(lpMsg, hwnd, wMsgFilterMin, wMsgFilterMax,PM_REMOVE)) {
		/* Call select to suspend process until user input or scheduled timer */
		MwSelect(TRUE);
	    MwHandleTimers();
#if MW_CALL_IDLE_HANDLER	    
	    idle_handler();
#endif
		continue;
	}
	return lpMsg->message != WM_QUIT;
}
コード例 #4
0
ファイル: windlg.c プロジェクト: BadrElh/microwindows
static INT
DIALOG_DoDialogBox( HWND hDlg, HWND hWndParent )
{
	int retV = 0;
	MSG msg;
	DWORD ltm = 0;
	PMWDLGDATA params;

	if (hDlg) {
		BOOL bSendIdle = TRUE;
		params = DLG_PMWDLGDATA(hDlg);
		params->running = TRUE;

		if (hWndParent)
			EnableWindow(hWndParent, FALSE);

		ShowWindow(hDlg, SW_SHOW);
		SetActiveWindow(hDlg);
		if ((params->hWndFocus != NULL)
		    && IsWindowEnabled(params->hWndFocus))
			SetFocus(params->hWndFocus);
		else
			PostMessage(hDlg, WM_NEXTDLGCTL, 0, 0);

		UpdateWindow(hDlg);

		while (IsWindow(hDlg) && params->running) {
			if (!PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
				if (bSendIdle) {
					SendMessage(hDlg, WM_ENTERIDLE, 0, 0);
					bSendIdle = FALSE;
				}
				if (!GetMessage (&msg, NULL, 0, 0))
					break;
#if MW_CALL_IDLE_HANDLER
				idle_handler();
#endif
			}

			if (!IsDialogMessage(hDlg, &msg)) {
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			bSendIdle = TRUE;
			if (msg.message == WM_QUIT)
				break;

			if (msg.time != ltm)
				MwHandleTimers();
			ltm = msg.time;
		}
		if (!params->running) {
			retV = params->nResult;
			DestroyWindow(hDlg);
		}

		if (hWndParent)
			EnableWindow(hWndParent, TRUE);
	}

	return retV;
}
コード例 #5
0
ファイル: winmain.c プロジェクト: OPSF/uClinux
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");
}