Example #1
0
BOOL GUIAPI EmptyMessageQueue (HWND hWnd)
{
    PMSGQUEUE   pMsgQueue;
    PQMSG       pQMsg, temp;

    if (!(pMsgQueue = GetMsgQueue(hWnd)))
        return FALSE;

    if (pMsgQueue->pFirstNotifyMsg) {
        pQMsg = pMsgQueue->pFirstNotifyMsg;
        while (pQMsg) {
            temp = pQMsg->next;
            FreeQMSG (pQMsg);
            pQMsg = temp;
        }
    }

    pMsgQueue->pFirstNotifyMsg = NULL;
    pMsgQueue->pLastNotifyMsg = NULL;

    pMsgQueue->readpos = 0;
    pMsgQueue->writepos = 0;

    TerminateTimer ();

    pMsgQueue->dwState = QS_EMPTY;
    pMsgQueue->TimerMask = 0;

    return TRUE;
}
Example #2
0
int GUIAPI PostMessage (HWND hWnd, int iMsg, WPARAM wParam, LPARAM lParam)
{
    PMSGQUEUE pMsgQueue;
    MSG msg;

    if (!(pMsgQueue = GetMsgQueue(hWnd)))
        return ERR_INV_HWND;

    if (iMsg == MSG_PAINT) {
        LOCK_MSGQ (pMsgQueue);
        pMsgQueue->dwState |= QS_PAINT;
        UNLOCK_MSGQ (pMsgQueue);
#ifndef _LITE_VERSION
        if ( !BE_THIS_THREAD(hWnd) )
            POST_MSGQ(pMsgQueue);
#endif
        return ERR_OK;
    }

    msg.hwnd = hWnd;
    msg.message = iMsg;
    msg.wParam = wParam;
    msg.lParam = lParam;

    if (!QueueMessage(pMsgQueue, &msg))
        return ERR_QUEUE_FULL;

    return ERR_OK;
}
Example #3
0
static void
input_task(void *arg)
{
	unsigned char scode;
	unsigned ch;

	while (true)
	{
		if ( !GetMsgQueue(scan_mq, &scode) )
			continue;

		/* Perform make/break processing. */
		if ( (ch = make_break(scode)) == NONE )
			continue;

		if (1 <= ch && ch <= 0xFF)
			/* A normal character. */
			PutMsgQueue(key_mq, &ch);
		else if (HOME <= ch && ch <= INSRT)
		{
			/* An ASCII escape sequence generated by the numeric pad. */
			unsigned c = ESC;
			PutMsgQueue(key_mq, &c);
			c = '[';
			PutMsgQueue(key_mq, &c);
			c = numpad_map[ch - HOME];
			PutMsgQueue(key_mq, &c);
		}
		else
		{
			// Aquí deberían procesarse teclas especiales de procesamiento
			// inmediato como Fn, Alt-Fn, etc.
		}
	}
}
Example #4
0
static void
input_task(void *arg){
    unsigned char scode;
    unsigned ch;
	int tty_num=-1;

    while (true)
    {
	tty_num=-1;
        if ( !GetMsgQueue(scan_mq, &scode) )
            continue;

        /* Perform make/break processing. */
        if ( (ch = make_break(scode)) == NONE )
            continue;

        if (1 <= ch && ch <= 0xFF)
            /* A normal character. */
            PutMsgQueue(key_mq, &ch);
        else if (HOME <= ch && ch <= INSRT)
        {
            /* An ASCII escape sequence generated by the numeric pad. */
            unsigned c = ESC;
            PutMsgQueue(key_mq, &c);
            c = '[';
            PutMsgQueue(key_mq, &c);
            c = numpad_map[ch - HOME];
            PutMsgQueue(key_mq, &c);
        }else{
            // Aquí deberían procesarse teclas especiales de procesamiento
            // inmediato como Fn, Alt-Fn, etc.
            switch( ch ){
                case AF1:
                    tty_num = 0;
                    break;
                case AF2:
                    tty_num = 1;
                    break;
                case AF3:
                    tty_num = 2;
                    break;
                case AF4:
                    tty_num = 3;
                    break;
            }
            if(tty_num != -1){
                clearAllTabs();
                turnOnOFFTab(ON, tty_num+1);
                 turnOffMouse();
                switch_focus(tty_num);
                turnOnMouse();
            }
        }
    }
}
Example #5
0
/* send a synchronous message to a window in a different thread */
int SendSyncMessage (HWND hWnd, int msg, WPARAM wParam, LPARAM lParam)
{
    PMSGQUEUE pMsgQueue, thinfo = NULL;
    SYNCMSG SyncMsg;
    sem_t sync_msg;

    if (!(pMsgQueue = GetMsgQueue(hWnd)))
        return ERR_INV_HWND;

    if ((thinfo = GetMsgQueueThisThread ())) {
        /* avoid to create a new semaphore object */
        SyncMsg.sem_handle = &thinfo->sync_msg;
    }
    else {
        /* this is not a GUI thread */
        sem_init (&sync_msg, 0, 0);
        SyncMsg.sem_handle = &sync_msg;
    }

    /* queue the sync message. */
    SyncMsg.Msg.hwnd = hWnd;
    SyncMsg.Msg.message = msg;
    SyncMsg.Msg.wParam = wParam;
    SyncMsg.Msg.lParam = lParam;
    SyncMsg.retval = ERR_MSG_CANCELED;
    SyncMsg.pNext = NULL;

    LOCK_MSGQ (pMsgQueue);

    if (pMsgQueue->pFirstSyncMsg == NULL) {
        pMsgQueue->pFirstSyncMsg = pMsgQueue->pLastSyncMsg = &SyncMsg;
    }
    else {
        pMsgQueue->pLastSyncMsg->pNext = &SyncMsg;
        pMsgQueue->pLastSyncMsg = &SyncMsg;
    }

    pMsgQueue->dwState |= QS_SYNCMSG;

    UNLOCK_MSGQ (pMsgQueue);
    POST_MSGQ (pMsgQueue);

    /* suspend until the message has been handled. */
    if (sem_wait (SyncMsg.sem_handle) < 0) {
        fprintf (stderr, 
            "SendSyncMessage: thread is interrupted abnormally!\n");
    }

    if (thinfo == NULL)
        sem_destroy (&sync_msg);

    return SyncMsg.retval;
}
Example #6
0
BOOL GUIAPI PeekPostMessage (PMSG pMsg, HWND hWnd, int iMsgFilterMin, 
                        int iMsgFilterMax, UINT uRemoveMsg)
{
    PMSGQUEUE pMsgQueue;
    PMSG pPostMsg;

    if (!pMsg)
        return FALSE;

    if (!(pMsgQueue = GetMsgQueue(hWnd)))
        return FALSE;

    LOCK_MSGQ (pMsgQueue);
    memset (pMsg, 0, sizeof(MSG));
	
    if (pMsgQueue->dwState & QS_POSTMSG) {
    
        if (pMsgQueue->readpos != pMsgQueue->writepos) {

            pPostMsg = pMsgQueue->msg + pMsgQueue->readpos;

            if (iMsgFilterMin == 0 && iMsgFilterMax == 0)
                *pMsg = *pPostMsg;
            else if (pPostMsg->message <= iMsgFilterMax &&
                    pPostMsg->message >= iMsgFilterMin)
                *pMsg = *pPostMsg;
            else {
                UNLOCK_MSGQ (pMsgQueue);
                return FALSE;
            }
            
            SET_PADD (NULL);

            if (uRemoveMsg == PM_REMOVE) {
                pMsgQueue->readpos++;
                if (pMsgQueue->readpos >= pMsgQueue->len) 
                    pMsgQueue->readpos = 0;
            }

            UNLOCK_MSGQ (pMsgQueue);
            return TRUE;
        }

    }

    UNLOCK_MSGQ (pMsgQueue);
    return FALSE;
}
Example #7
0
int GUIAPI SendNotifyMessage (HWND hWnd, int iMsg, WPARAM wParam, LPARAM lParam)
{
    PMSGQUEUE pMsgQueue;
    PQMSG pqmsg;

    MG_CHECK_RET (MG_IS_WINDOW(hWnd), ERR_INV_HWND);

    if (!(pMsgQueue = GetMsgQueue(hWnd)))
        return ERR_INV_HWND;
  
    pqmsg = QMSGAlloc();

    LOCK_MSGQ (pMsgQueue);

    /* queue the notification message. */
    pqmsg->Msg.hwnd = hWnd;
    pqmsg->Msg.message = iMsg;
    pqmsg->Msg.wParam = wParam;
    pqmsg->Msg.lParam = lParam;
    pqmsg->next = NULL;

    if (pMsgQueue->pFirstNotifyMsg == NULL) {
        pMsgQueue->pFirstNotifyMsg = pMsgQueue->pLastNotifyMsg = pqmsg;
    }
    else {
        pMsgQueue->pLastNotifyMsg->next = pqmsg;
        pMsgQueue->pLastNotifyMsg = pqmsg;
    }

    pMsgQueue->dwState |= QS_NOTIFYMSG;

    UNLOCK_MSGQ (pMsgQueue);
#ifndef _LITE_VERSION
    if ( !BE_THIS_THREAD(hWnd) )
        POST_MSGQ(pMsgQueue);
#endif

    return ERR_OK;
}
Example #8
0
/* wait for message */
BOOL GUIAPI WaitMessage (PMSG pMsg, HWND hWnd)
{
    PMSGQUEUE pMsgQueue;

    if (!pMsg)
        return FALSE;

    if (!(pMsgQueue = GetMsgQueue(hWnd)))
        return FALSE;

    memset (pMsg, 0, sizeof(MSG));

checkagain:

    LOCK_MSGQ (pMsgQueue);

    if (pMsgQueue->dwState & QS_QUIT) {
        goto getit;
    }

#ifndef _LITE_VERSION
    if (pMsgQueue->dwState & QS_SYNCMSG) {
        if (pMsgQueue->pFirstSyncMsg) {
            goto getit;
        }
    }
#endif

    if (pMsgQueue->dwState & QS_NOTIFYMSG) {
        if (pMsgQueue->pFirstNotifyMsg) {
            goto getit;
        }
    }

    if (pMsgQueue->dwState & QS_POSTMSG) {
        if (pMsgQueue->readpos != pMsgQueue->writepos) {
            goto getit;
        }
    }

    if (pMsgQueue->dwState & QS_PAINT) {
        goto getit;
    }
    
#ifdef _LITE_VERSION
    if (pMsgQueue->dwState & QS_DESKTIMER) {
        goto getit;
    }
#endif

    if (pMsgQueue->TimerMask) {
        goto getit;
    }

#ifndef _LITE_VERSION
    /* no message, wait again. */
    UNLOCK_MSGQ (pMsgQueue);
    sem_wait (&pMsgQueue->wait);
#else
    /* no message, idle */
    pMsgQueue->OnIdle (pMsgQueue);
#endif

    goto checkagain;

getit:
    UNLOCK_MSGQ (pMsgQueue);
    return TRUE;
}
Example #9
0
BOOL GUIAPI HavePendingMessageEx (HWND hWnd, BOOL bNoDeskTimer)
{
    PMSGQUEUE pMsgQueue;

    if (hWnd == 0) {
#ifndef _LITE_VERSION
        if (!(pMsgQueue = GetMsgQueueThisThread ()))
            return FALSE;
#else
        pMsgQueue = __mg_dsk_msg_queue;
#endif
    }
    else {
        if (!(pMsgQueue = GetMsgQueue(hWnd)))
            return FALSE;
    }

    LOCK_MSGQ (pMsgQueue);

#ifndef _LITE_VERSION
    if (pMsgQueue->dwState & QS_SYNCMSG) {
        if (pMsgQueue->pFirstSyncMsg) goto retok;
    }
#endif

    if (pMsgQueue->dwState & QS_NOTIFYMSG) {
        if (pMsgQueue->pFirstNotifyMsg) goto retok;
    }

    if (pMsgQueue->dwState & QS_POSTMSG) {
        if (pMsgQueue->readpos != pMsgQueue->writepos) goto retok;
    }

    if (pMsgQueue->dwState & (QS_QUIT | QS_PAINT)) {
        goto retok;
    }

    if (pMsgQueue->TimerMask)
        goto retok;
#ifdef _LITE_VERSION
    /* 
     * FIXME
     * We do not need to check QS_DESKTIMER, because it is for the 
     * desktop window, and user don't care it.
     */
    if (!bNoDeskTimer && (pMsgQueue->dwState & QS_DESKTIMER)) {
        goto retok;
    }
#endif

    UNLOCK_MSGQ (pMsgQueue);
#ifdef _LITE_VERSION
    return pMsgQueue->OnIdle (NULL);
#else
    return FALSE;
#endif

retok:
    UNLOCK_MSGQ (pMsgQueue);
    return TRUE;
}
Example #10
0
bool 
mt_kbd_getch(unsigned *c){
    *c = 0;
    return GetMsgQueue(mt_curr_task->ttyp->key_mq, c);
}
Example #11
0
bool 
mt_kbd_getch(unsigned *c)
{
	*c = 0;
	return GetMsgQueue(key_mq, c);
}