Release 970112
[wine.git] / windows / queue.c
blob83a8c7d232700c4f6c385786b31199757ffd04ca
1 /*
2 * Message queues related functions
4 * Copyright 1993, 1994 Alexandre Julliard
5 */
7 #include <stdlib.h>
8 #include <signal.h>
9 #include "module.h"
10 #include "queue.h"
11 #include "task.h"
12 #include "win.h"
13 #include "hook.h"
14 #include "stddebug.h"
15 #include "debug.h"
17 #define MAX_QUEUE_SIZE 120 /* Max. size of a message queue */
19 static HQUEUE16 hFirstQueue = 0;
20 static HQUEUE16 hDoomedQueue = 0;
21 static HQUEUE16 hmemSysMsgQueue = 0;
22 static MESSAGEQUEUE *sysMsgQueue = NULL;
24 static MESSAGEQUEUE *pMouseQueue = NULL; /* Queue for last mouse message */
25 static MESSAGEQUEUE *pKbdQueue = NULL; /* Queue for last kbd message */
27 extern void SIGNAL_MaskAsyncEvents(BOOL32);
29 MESSAGEQUEUE *pCursorQueue = NULL;
30 MESSAGEQUEUE *pActiveQueue = NULL;
32 /***********************************************************************
33 * QUEUE_DumpQueue
35 void QUEUE_DumpQueue( HQUEUE16 hQueue )
37 MESSAGEQUEUE *pq;
39 if (!(pq = (MESSAGEQUEUE*) GlobalLock16( hQueue )) ||
40 GlobalSize16(hQueue) < sizeof(MESSAGEQUEUE)+pq->queueSize*sizeof(QMSG))
42 fprintf( stderr, "%04x is not a queue handle\n", hQueue );
43 return;
46 fprintf( stderr,
47 "next: %12.4x Intertask SendMessage:\n"
48 "hTask: %11.4x ----------------------\n"
49 "msgSize: %9.4x hWnd: %10.4x\n"
50 "msgCount: %8.4x msg: %11.4x\n"
51 "msgNext: %9.4x wParam: %8.4x\n"
52 "msgFree: %9.4x lParam: %8.8x\n"
53 "qSize: %11.4x lRet: %10.8x\n"
54 "wWinVer: %9.4x ISMH: %10.4x\n"
55 "paints: %10.4x hSendTask: %5.4x\n"
56 "timers: %10.4x hPrevSend: %5.4x\n"
57 "wakeBits: %8.4x\n"
58 "wakeMask: %8.4x\n"
59 "hCurHook: %8.4x\n",
60 pq->next, pq->hTask, pq->msgSize, pq->hWnd,
61 pq->msgCount, pq->msg, pq->nextMessage, pq->wParam,
62 pq->nextFreeMessage, (unsigned)pq->lParam, pq->queueSize,
63 (unsigned)pq->SendMessageReturn, pq->wWinVersion, pq->InSendMessageHandle,
64 pq->wPaintCount, pq->hSendingTask, pq->wTimerCount,
65 pq->hPrevSendingTask, pq->wakeBits, pq->wakeMask, pq->hCurHook);
69 /***********************************************************************
70 * QUEUE_WalkQueues
72 void QUEUE_WalkQueues(void)
74 HQUEUE16 hQueue = hFirstQueue;
76 fprintf( stderr, "Queue Size Msgs Task\n" );
77 while (hQueue)
79 MESSAGEQUEUE *queue = (MESSAGEQUEUE *)GlobalLock16( hQueue );
80 if (!queue)
82 fprintf( stderr, "*** Bad queue handle %04x\n", hQueue );
83 return;
85 fprintf( stderr, "%04x %5d %4d %04x %s\n",
86 hQueue, queue->msgSize, queue->msgCount, queue->hTask,
87 MODULE_GetModuleName( GetExePtr(queue->hTask) ) );
88 hQueue = queue->next;
90 fprintf( stderr, "\n" );
94 /***********************************************************************
95 * QUEUE_IsDoomedQueue
97 BOOL32 QUEUE_IsDoomedQueue( HQUEUE16 hQueue )
99 return (hDoomedQueue && (hQueue == hDoomedQueue));
103 /***********************************************************************
104 * QUEUE_SetDoomedQueue
106 void QUEUE_SetDoomedQueue( HQUEUE16 hQueue )
108 hDoomedQueue = hQueue;
112 /***********************************************************************
113 * QUEUE_CreateMsgQueue
115 * Creates a message queue. Doesn't link it into queue list!
117 static HQUEUE16 QUEUE_CreateMsgQueue( int size )
119 HQUEUE16 hQueue;
120 MESSAGEQUEUE * msgQueue;
121 int queueSize;
122 TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
124 dprintf_msg(stddeb,"Creating message queue...\n");
126 queueSize = sizeof(MESSAGEQUEUE) + size * sizeof(QMSG);
127 if (!(hQueue = GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, queueSize )))
128 return 0;
129 msgQueue = (MESSAGEQUEUE *) GlobalLock16( hQueue );
130 msgQueue->self = hQueue;
131 msgQueue->msgSize = sizeof(QMSG);
132 msgQueue->queueSize = size;
133 msgQueue->wakeBits = msgQueue->changeBits = QS_SMPARAMSFREE;
134 msgQueue->wWinVersion = pTask ? pTask->version : 0;
135 GlobalUnlock16( hQueue );
136 return hQueue;
140 /***********************************************************************
141 * QUEUE_DeleteMsgQueue
143 * Unlinks and deletes a message queue.
145 * Note: We need to mask asynchronous events to make sure PostMessage works
146 * even in the signal handler.
148 BOOL32 QUEUE_DeleteMsgQueue( HQUEUE16 hQueue )
150 MESSAGEQUEUE * msgQueue = (MESSAGEQUEUE*)GlobalLock16(hQueue);
151 HQUEUE16 senderQ;
152 HQUEUE16 *pPrev;
154 dprintf_msg(stddeb,"Deleting message queue %04x\n", hQueue);
156 if (!hQueue || !msgQueue)
158 dprintf_msg(stddeb,"DeleteMsgQueue: invalid argument.\n");
159 return 0;
161 if( pCursorQueue == msgQueue ) pCursorQueue = NULL;
162 if( pActiveQueue == msgQueue ) pActiveQueue = NULL;
164 /* flush sent messages */
165 senderQ = msgQueue->hSendingTask;
166 while( senderQ )
168 MESSAGEQUEUE* sq = (MESSAGEQUEUE*)GlobalLock16(senderQ);
169 if( !sq ) break;
170 sq->SendMessageReturn = 0L;
171 QUEUE_SetWakeBit( sq, QS_SMRESULT );
172 senderQ = sq->hPrevSendingTask;
175 SIGNAL_MaskAsyncEvents( TRUE );
177 pPrev = &hFirstQueue;
178 while (*pPrev && (*pPrev != hQueue))
180 MESSAGEQUEUE *msgQ = (MESSAGEQUEUE*)GlobalLock16(*pPrev);
181 pPrev = &msgQ->next;
183 if (*pPrev) *pPrev = msgQueue->next;
184 msgQueue->self = 0;
186 SIGNAL_MaskAsyncEvents( FALSE );
188 GlobalFree16( hQueue );
189 return 1;
193 /***********************************************************************
194 * QUEUE_CreateSysMsgQueue
196 * Create the system message queue, and set the double-click speed.
197 * Must be called only once.
199 BOOL32 QUEUE_CreateSysMsgQueue( int size )
201 if (size > MAX_QUEUE_SIZE) size = MAX_QUEUE_SIZE;
202 else if (size <= 0) size = 1;
203 if (!(hmemSysMsgQueue = QUEUE_CreateMsgQueue( size ))) return FALSE;
204 sysMsgQueue = (MESSAGEQUEUE *) GlobalLock16( hmemSysMsgQueue );
205 return TRUE;
209 /***********************************************************************
210 * QUEUE_GetSysQueue
212 MESSAGEQUEUE *QUEUE_GetSysQueue(void)
214 return sysMsgQueue;
218 /***********************************************************************
219 * QUEUE_SetWakeBit
221 * See "Windows Internals", p.449
223 void QUEUE_SetWakeBit( MESSAGEQUEUE *queue, WORD bit )
225 dprintf_msg(stddeb,"SetWakeBit: queue = %04x (wm=%04x), bit = %04x\n",
226 queue->self, queue->wakeMask, bit );
228 if (bit & QS_MOUSE) pMouseQueue = queue;
229 if (bit & QS_KEY) pKbdQueue = queue;
230 queue->changeBits |= bit;
231 queue->wakeBits |= bit;
232 if (queue->wakeMask & bit)
234 queue->wakeMask = 0;
235 PostEvent( queue->hTask );
240 /***********************************************************************
241 * QUEUE_ClearWakeBit
243 void QUEUE_ClearWakeBit( MESSAGEQUEUE *queue, WORD bit )
245 queue->changeBits &= ~bit;
246 queue->wakeBits &= ~bit;
250 /***********************************************************************
251 * QUEUE_WaitBits
253 * See "Windows Internals", p.447
255 void QUEUE_WaitBits( WORD bits )
257 MESSAGEQUEUE *queue;
259 dprintf_msg(stddeb,"WaitBits: q %04x waiting for %04x\n", GetTaskQueue(0), bits);
261 for (;;)
263 if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return;
265 if (queue->changeBits & bits)
267 /* One of the bits is set; we can return */
268 queue->wakeMask = 0;
269 return;
271 if (queue->wakeBits & QS_SENDMESSAGE)
273 /* Process the sent message immediately */
275 queue->wakeMask = 0;
276 QUEUE_ReceiveMessage( queue );
277 continue; /* nested sm crux */
280 queue->wakeMask = bits | QS_SENDMESSAGE;
281 if(queue->changeBits & bits) continue;
283 dprintf_msg(stddeb,"wb: (%04x) wakeMask is %04x, waiting\n", queue->self, queue->wakeMask);
285 WaitEvent( 0 );
290 /***********************************************************************
291 * QUEUE_ReceiveMessage
293 * This routine is called when a sent message is waiting for the queue.
295 void QUEUE_ReceiveMessage( MESSAGEQUEUE *queue )
297 MESSAGEQUEUE *senderQ = NULL;
298 HQUEUE16 prevSender = 0;
299 QSMCTRL* prevCtrlPtr = NULL;
300 LRESULT result = 0;
302 dprintf_msg(stddeb, "ReceiveMessage, queue %04x\n", queue->self );
303 if (!(queue->wakeBits & QS_SENDMESSAGE) ||
304 !(senderQ = (MESSAGEQUEUE*)GlobalLock16( queue->hSendingTask)))
305 { dprintf_msg(stddeb,"\trcm: nothing to do\n"); return; }
307 queue->InSendMessageHandle = queue->hSendingTask;
308 if( !(queue->hSendingTask = senderQ->hPrevSendingTask) )
310 queue->wakeBits &= ~QS_SENDMESSAGE; /* no more sent messages */
311 queue->changeBits &= ~QS_SENDMESSAGE;
314 /* Remove sending queue from the list */
315 prevSender = queue->InSendMessageHandle;
316 prevCtrlPtr = queue->smResultCurrent;
317 queue->smResultCurrent = senderQ->smResultInit;
319 dprintf_msg(stddeb, "\trcm: smResultCurrent = %08x, prevCtrl = %08x\n",
320 (unsigned)queue->smResultCurrent, (unsigned)prevCtrlPtr );
321 QUEUE_SetWakeBit( senderQ, QS_SMPARAMSFREE );
323 dprintf_msg(stddeb, "\trcm: calling wndproc - %04x %04x %04x %08x\n",
324 senderQ->hWnd, senderQ->msg, senderQ->wParam, (unsigned)senderQ->lParam );
326 if (IsWindow( senderQ->hWnd ))
328 DWORD extraInfo = queue->GetMessageExtraInfoVal;
329 queue->GetMessageExtraInfoVal = senderQ->GetMessageExtraInfoVal;
331 result = CallWindowProc16( (WNDPROC16)GetWindowLong16(senderQ->hWnd, GWL_WNDPROC),
332 senderQ->hWnd, senderQ->msg, senderQ->wParam, senderQ->lParam );
334 queue->GetMessageExtraInfoVal = extraInfo; /* Restore extra info */
335 dprintf_msg(stddeb,"\trcm: result = %08x\n", (unsigned)result );
337 else dprintf_msg(stddeb,"\trcm: bad hWnd\n");
339 /* Return the result to the sender task */
340 ReplyMessage( result );
342 queue->InSendMessageHandle = prevSender;
343 queue->smResultCurrent = prevCtrlPtr;
345 dprintf_msg(stddeb,"ReceiveMessage: done!\n");
348 /***********************************************************************
349 * QUEUE_FlushMessage
351 * Try to reply to all pending sent messages on exit.
353 void QUEUE_FlushMessages( HQUEUE16 hQueue )
355 MESSAGEQUEUE *queue = (MESSAGEQUEUE*)GlobalLock16( hQueue );
357 if( queue )
359 MESSAGEQUEUE *senderQ = (MESSAGEQUEUE*)GlobalLock16( queue->hSendingTask);
360 QSMCTRL* CtrlPtr = queue->smResultCurrent;
362 while( senderQ )
364 if( !(queue->hSendingTask = senderQ->hPrevSendingTask) )
365 queue->wakeBits &= ~QS_SENDMESSAGE;
366 QUEUE_SetWakeBit( senderQ, QS_SMPARAMSFREE );
368 queue->smResultCurrent = CtrlPtr;
369 while( senderQ->wakeBits & QS_SMRESULT ) OldYield();
371 senderQ->SendMessageReturn = 0;
372 senderQ->smResult = queue->smResultCurrent;
373 QUEUE_SetWakeBit( senderQ, QS_SMRESULT);
375 if( (senderQ = (MESSAGEQUEUE*)GlobalLock16( queue->hSendingTask)) )
376 CtrlPtr = senderQ->smResultInit;
378 queue->InSendMessageHandle = 0;
382 /***********************************************************************
383 * QUEUE_AddMsg
385 * Add a message to the queue. Return FALSE if queue is full.
387 BOOL32 QUEUE_AddMsg( HQUEUE16 hQueue, MSG16 * msg, DWORD extraInfo )
389 int pos;
390 MESSAGEQUEUE *msgQueue;
392 SIGNAL_MaskAsyncEvents( TRUE );
394 if (!(msgQueue = (MESSAGEQUEUE *)GlobalLock16( hQueue ))) return FALSE;
395 pos = msgQueue->nextFreeMessage;
397 /* Check if queue is full */
398 if ((pos == msgQueue->nextMessage) && (msgQueue->msgCount > 0))
400 SIGNAL_MaskAsyncEvents( FALSE );
401 fprintf(stderr,"MSG_AddMsg // queue is full !\n");
402 return FALSE;
405 /* Store message */
406 msgQueue->messages[pos].msg = *msg;
407 msgQueue->messages[pos].extraInfo = extraInfo;
408 if (pos < msgQueue->queueSize-1) pos++;
409 else pos = 0;
410 msgQueue->nextFreeMessage = pos;
411 msgQueue->msgCount++;
413 SIGNAL_MaskAsyncEvents( FALSE );
415 QUEUE_SetWakeBit( msgQueue, QS_POSTMESSAGE );
416 return TRUE;
420 /***********************************************************************
421 * QUEUE_FindMsg
423 * Find a message matching the given parameters. Return -1 if none available.
425 int QUEUE_FindMsg( MESSAGEQUEUE * msgQueue, HWND32 hwnd, int first, int last )
427 int i, pos = msgQueue->nextMessage;
429 dprintf_msg(stddeb,"QUEUE_FindMsg: hwnd=%04x pos=%d\n", hwnd, pos );
431 if (!msgQueue->msgCount) return -1;
432 if (!hwnd && !first && !last) return pos;
434 for (i = 0; i < msgQueue->msgCount; i++)
436 MSG16 * msg = &msgQueue->messages[pos].msg;
438 if (!hwnd || (msg->hwnd == hwnd))
440 if (!first && !last) return pos;
441 if ((msg->message >= first) && (msg->message <= last)) return pos;
443 if (pos < msgQueue->queueSize-1) pos++;
444 else pos = 0;
446 return -1;
450 /***********************************************************************
451 * QUEUE_RemoveMsg
453 * Remove a message from the queue (pos must be a valid position).
455 void QUEUE_RemoveMsg( MESSAGEQUEUE * msgQueue, int pos )
457 SIGNAL_MaskAsyncEvents( TRUE );
459 if (pos >= msgQueue->nextMessage)
461 for ( ; pos > msgQueue->nextMessage; pos--)
462 msgQueue->messages[pos] = msgQueue->messages[pos-1];
463 msgQueue->nextMessage++;
464 if (msgQueue->nextMessage >= msgQueue->queueSize)
465 msgQueue->nextMessage = 0;
467 else
469 for ( ; pos < msgQueue->nextFreeMessage; pos++)
470 msgQueue->messages[pos] = msgQueue->messages[pos+1];
471 if (msgQueue->nextFreeMessage) msgQueue->nextFreeMessage--;
472 else msgQueue->nextFreeMessage = msgQueue->queueSize-1;
474 msgQueue->msgCount--;
475 if (!msgQueue->msgCount) msgQueue->wakeBits &= ~QS_POSTMESSAGE;
477 SIGNAL_MaskAsyncEvents( FALSE );
481 /***********************************************************************
482 * QUEUE_WakeSomeone
484 * Wake a queue upon reception of a hardware event.
486 static void QUEUE_WakeSomeone( UINT message )
488 WND* wndPtr = NULL;
489 HWND hwnd;
490 WORD wakeBit;
491 MESSAGEQUEUE *queue = pCursorQueue;
493 if( (message >= WM_KEYFIRST) && (message <= WM_KEYLAST) )
495 wakeBit = QS_KEY;
496 if( pActiveQueue ) queue = pActiveQueue;
498 else
500 wakeBit = (message == WM_MOUSEMOVE) ? QS_MOUSEMOVE : QS_MOUSEBUTTON;
501 if( (hwnd = GetCapture32()) )
502 if( (wndPtr = WIN_FindWndPtr( hwnd )) )
503 queue = (MESSAGEQUEUE *)GlobalLock16( wndPtr->hmemTaskQ );
506 if( (hwnd = GetSysModalWindow16()) )
507 if( (wndPtr = WIN_FindWndPtr( hwnd )) )
508 queue = (MESSAGEQUEUE *)GlobalLock16( wndPtr->hmemTaskQ );
510 if( !queue )
512 queue = GlobalLock16( hFirstQueue );
513 while( queue )
515 if (queue->wakeMask & wakeBit) break;
516 queue = GlobalLock16( queue->next );
518 if( !queue )
520 dprintf_msg(stddeb,"WakeSomeone: couldn't find queue\n");
521 return;
525 QUEUE_SetWakeBit( queue, wakeBit );
529 /***********************************************************************
530 * hardware_event
532 * Add an event to the system message queue.
533 * Note: the position is relative to the desktop window.
535 void hardware_event( WORD message, WORD wParam, LONG lParam,
536 int xPos, int yPos, DWORD time, DWORD extraInfo )
538 MSG16 *msg;
539 int pos;
541 if (!sysMsgQueue) return;
542 pos = sysMsgQueue->nextFreeMessage;
544 /* Merge with previous event if possible */
546 if ((message == WM_MOUSEMOVE) && sysMsgQueue->msgCount)
548 if (pos > 0) pos--;
549 else pos = sysMsgQueue->queueSize - 1;
550 msg = &sysMsgQueue->messages[pos].msg;
551 if ((msg->message == message) && (msg->wParam == wParam))
552 sysMsgQueue->msgCount--; /* Merge events */
553 else
554 pos = sysMsgQueue->nextFreeMessage; /* Don't merge */
557 /* Check if queue is full */
559 if ((pos == sysMsgQueue->nextMessage) && sysMsgQueue->msgCount)
561 /* Queue is full, beep (but not on every mouse motion...) */
562 if (message != WM_MOUSEMOVE) MessageBeep(0);
563 return;
566 /* Store message */
568 msg = &sysMsgQueue->messages[pos].msg;
569 msg->hwnd = 0;
570 msg->message = message;
571 msg->wParam = wParam;
572 msg->lParam = lParam;
573 msg->time = time;
574 msg->pt.x = xPos & 0xffff;
575 msg->pt.y = yPos & 0xffff;
576 sysMsgQueue->messages[pos].extraInfo = extraInfo;
577 if (pos < sysMsgQueue->queueSize - 1) pos++;
578 else pos = 0;
579 sysMsgQueue->nextFreeMessage = pos;
580 sysMsgQueue->msgCount++;
581 QUEUE_WakeSomeone( message );
585 /***********************************************************************
586 * QUEUE_GetQueueTask
588 HTASK16 QUEUE_GetQueueTask( HQUEUE16 hQueue )
590 MESSAGEQUEUE *queue = GlobalLock16( hQueue );
591 return (queue) ? queue->hTask : 0 ;
595 /***********************************************************************
596 * QUEUE_IncPaintCount
598 void QUEUE_IncPaintCount( HQUEUE16 hQueue )
600 MESSAGEQUEUE *queue;
602 if (!(queue = (MESSAGEQUEUE *)GlobalLock16( hQueue ))) return;
603 queue->wPaintCount++;
604 QUEUE_SetWakeBit( queue, QS_PAINT );
608 /***********************************************************************
609 * QUEUE_DecPaintCount
611 void QUEUE_DecPaintCount( HQUEUE16 hQueue )
613 MESSAGEQUEUE *queue;
615 if (!(queue = (MESSAGEQUEUE *)GlobalLock16( hQueue ))) return;
616 queue->wPaintCount--;
617 if (!queue->wPaintCount) queue->wakeBits &= ~QS_PAINT;
621 /***********************************************************************
622 * QUEUE_IncTimerCount
624 void QUEUE_IncTimerCount( HQUEUE16 hQueue )
626 MESSAGEQUEUE *queue;
628 if (!(queue = (MESSAGEQUEUE *)GlobalLock16( hQueue ))) return;
629 queue->wTimerCount++;
630 QUEUE_SetWakeBit( queue, QS_TIMER );
634 /***********************************************************************
635 * QUEUE_DecTimerCount
637 void QUEUE_DecTimerCount( HQUEUE16 hQueue )
639 MESSAGEQUEUE *queue;
641 if (!(queue = (MESSAGEQUEUE *)GlobalLock16( hQueue ))) return;
642 queue->wTimerCount--;
643 if (!queue->wTimerCount) queue->wakeBits &= ~QS_TIMER;
647 /***********************************************************************
648 * PostQuitMessage (USER.6)
650 void PostQuitMessage( INT exitCode )
652 MESSAGEQUEUE *queue;
654 if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return;
655 queue->wPostQMsg = TRUE;
656 queue->wExitCode = (WORD)exitCode;
660 /***********************************************************************
661 * GetWindowTask16 (USER.224)
663 HTASK16 GetWindowTask16( HWND16 hwnd )
665 WND *wndPtr = WIN_FindWndPtr( hwnd );
667 if (!wndPtr) return 0;
668 return QUEUE_GetQueueTask( wndPtr->hmemTaskQ );
672 /***********************************************************************
673 * SetMessageQueue (USER.266)
675 BOOL SetMessageQueue( int size )
677 HQUEUE16 hQueue, hNewQueue;
678 MESSAGEQUEUE *queuePtr;
680 dprintf_msg(stddeb,"SetMessageQueue: task %04x size %i\n", GetCurrentTask(), size);
682 if ((size > MAX_QUEUE_SIZE) || (size <= 0)) return TRUE;
684 if( !(hNewQueue = QUEUE_CreateMsgQueue( size )))
686 dprintf_msg(stddeb,"SetMessageQueue: failed!\n");
687 return FALSE;
689 queuePtr = (MESSAGEQUEUE *)GlobalLock16( hNewQueue );
691 SIGNAL_MaskAsyncEvents( TRUE );
693 /* Copy data and free the old message queue */
694 if ((hQueue = GetTaskQueue(0)) != 0)
696 MESSAGEQUEUE *oldQ = (MESSAGEQUEUE *)GlobalLock16( hQueue );
697 memcpy( &queuePtr->reserved2, &oldQ->reserved2,
698 (int)oldQ->messages - (int)(&oldQ->reserved2) );
699 HOOK_ResetQueueHooks( hNewQueue );
700 if( WIN_GetDesktop()->hmemTaskQ == hQueue )
701 WIN_GetDesktop()->hmemTaskQ = hNewQueue;
702 WIN_ResetQueueWindows( WIN_GetDesktop()->child, hQueue, hNewQueue );
703 QUEUE_DeleteMsgQueue( hQueue );
706 /* Link new queue into list */
707 queuePtr->hTask = GetCurrentTask();
708 queuePtr->next = hFirstQueue;
709 hFirstQueue = hNewQueue;
711 if( !queuePtr->next ) pCursorQueue = queuePtr;
712 SetTaskQueue( 0, hNewQueue );
714 SIGNAL_MaskAsyncEvents( FALSE );
715 return TRUE;
719 /***********************************************************************
720 * GetQueueStatus (USER.334)
722 DWORD GetQueueStatus( UINT flags )
724 MESSAGEQUEUE *queue;
725 DWORD ret;
727 if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return 0;
728 ret = MAKELONG( queue->changeBits, queue->wakeBits );
729 queue->changeBits = 0;
730 return ret & MAKELONG( flags, flags );
734 /***********************************************************************
735 * GetInputState (USER.335)
737 BOOL GetInputState()
739 MESSAGEQUEUE *queue;
741 if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return FALSE;
742 return queue->wakeBits & (QS_KEY | QS_MOUSEBUTTON);
746 /***********************************************************************
747 * GetMessagePos (USER.119)
749 DWORD GetMessagePos(void)
751 MESSAGEQUEUE *queue;
753 if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return 0;
754 return queue->GetMessagePosVal;
758 /***********************************************************************
759 * GetMessageTime (USER.120)
761 LONG GetMessageTime(void)
763 MESSAGEQUEUE *queue;
765 if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return 0;
766 return queue->GetMessageTimeVal;
770 /***********************************************************************
771 * GetMessageExtraInfo (USER.288)
773 LONG GetMessageExtraInfo(void)
775 MESSAGEQUEUE *queue;
777 if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return 0;
778 return queue->GetMessageExtraInfoVal;