diff --git a/if1632/user.spec b/if1632/user.spec index d2349e67bcb..ffb96f39438 100644 --- a/if1632/user.spec +++ b/if1632/user.spec @@ -375,7 +375,7 @@ file user.exe 407 pascal16 CreateIcon(word word word word word ptr ptr) CreateIcon16 408 pascal16 CreateCursorIconIndirect(word ptr ptr ptr) CreateCursorIconIndirect -409 stub InitThreadInput +409 pascal16 InitThreadInput(word word) InitThreadInput 410 pascal16 InsertMenu(word word word word segptr) InsertMenu16 411 pascal16 AppendMenu(word word word segptr) AppendMenu16 412 pascal16 RemoveMenu(word word word) RemoveMenu16 diff --git a/include/queue.h b/include/queue.h index a5189ce4423..89f234b83f9 100644 --- a/include/queue.h +++ b/include/queue.h @@ -100,4 +100,6 @@ extern void QUEUE_FlushMessages(HQUEUE16); extern void hardware_event( WORD message, WORD wParam, LONG lParam, int xPos, int yPos, DWORD time, DWORD extraInfo ); +extern HQUEUE16 WINAPI InitThreadInput( WORD unknown, WORD flags ); + #endif /* __WINE_QUEUE_H */ diff --git a/include/task.h b/include/task.h index 98d980c5601..090620090bc 100644 --- a/include/task.h +++ b/include/task.h @@ -155,4 +155,10 @@ extern HTASK16 TASK_GetNextTask( HTASK16 hTask ); extern BOOL32 TASK_Reschedule(void); extern void TASK_InstallTHHook( THHOOK *pNewThook ); +extern HQUEUE16 WINAPI SetThreadQueue( DWORD thread, HQUEUE16 hQueue ); +extern HQUEUE16 WINAPI GetThreadQueue( DWORD thread ); +extern VOID WINAPI SetFastQueue( DWORD thread, HANDLE32 hQueue ); +extern HANDLE32 WINAPI GetFastQueue( void ); + + #endif /* __WINE_TASK_H */ diff --git a/windows/message.c b/windows/message.c index edaca9c5f2e..5da24fdde6e 100644 --- a/windows/message.c +++ b/windows/message.c @@ -102,7 +102,7 @@ static DWORD MSG_TranslateMouseMsg( HWND16 hTopWnd, DWORD filter, INT16 ht, hittest, sendSC = 0; UINT16 message = msg->message; POINT16 screen_pt, pt; - HANDLE16 hQ = GetTaskQueue(0); + HANDLE16 hQ = GetFastQueue(); MESSAGEQUEUE *queue = (MESSAGEQUEUE *)GlobalLock16(hQ); BOOL32 eatMsg = FALSE; BOOL32 mouseClick = ((message == WM_LBUTTONDOWN) || @@ -278,10 +278,10 @@ static DWORD MSG_TranslateKbdMsg( HWND16 hTopWnd, DWORD filter, message += WM_SYSKEYDOWN - WM_KEYDOWN; } pWnd = WIN_FindWndPtr( hWnd ); - if (pWnd && (pWnd->hmemTaskQ != GetTaskQueue(0))) + if (pWnd && (pWnd->hmemTaskQ != GetFastQueue())) { /* Not for the current task */ - MESSAGEQUEUE *queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ); + MESSAGEQUEUE *queue = (MESSAGEQUEUE *)GlobalLock16( GetFastQueue() ); if (queue) QUEUE_ClearWakeBit( queue, QS_KEY ); /* Wake up the other task */ queue = (MESSAGEQUEUE *)GlobalLock16( pWnd->hmemTaskQ ); @@ -596,7 +596,7 @@ static LRESULT MSG_SendMessage( HQUEUE16 hDestQueue, HWND16 hwnd, UINT16 msg, QSMCTRL qCtrl = { 0, 1}; MESSAGEQUEUE *queue, *destQ; - if (!(queue = (MESSAGEQUEUE*)GlobalLock16( GetTaskQueue(0) ))) return 0; + if (!(queue = (MESSAGEQUEUE*)GlobalLock16( GetFastQueue() ))) return 0; if (!(destQ = (MESSAGEQUEUE*)GlobalLock16( hDestQueue ))) return 0; if (IsTaskLocked() || !IsWindow32(hwnd)) return 0; @@ -619,7 +619,7 @@ static LRESULT MSG_SendMessage( HQUEUE16 hDestQueue, HWND16 hwnd, UINT16 msg, queue->wParamHigh = HIWORD(wParam); queue->lParam = lParam; queue->hPrevSendingTask = destQ->hSendingTask; - destQ->hSendingTask = GetTaskQueue(0); + destQ->hSendingTask = GetFastQueue(); QUEUE_ClearWakeBit( queue, QS_SMPARAMSFREE ); queue->flags = (queue->flags & ~(QUEUE_SM_WIN32|QUEUE_SM_UNICODE)) | flags; @@ -670,7 +670,7 @@ void WINAPI ReplyMessage16( LRESULT result ) MESSAGEQUEUE *senderQ; MESSAGEQUEUE *queue; - if (!(queue = (MESSAGEQUEUE*)GlobalLock16( GetTaskQueue(0) ))) return; + if (!(queue = (MESSAGEQUEUE*)GlobalLock16( GetFastQueue() ))) return; TRACE(msg,"ReplyMessage, queue %04x\n", queue->self); @@ -736,7 +736,7 @@ static BOOL32 MSG_PeekMessage( LPMSG16 msg, HWND16 hwnd, WORD first, WORD last, while(1) { - hQueue = GetTaskQueue(0); + hQueue = GetFastQueue(); msgQueue = (MESSAGEQUEUE *)GlobalLock16( hQueue ); if (!msgQueue) return FALSE; msgQueue->changeBits = 0; @@ -1222,7 +1222,7 @@ LRESULT WINAPI SendMessage16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, SPY_EnterMessage( SPY_SENDMESSAGE16, hwnd, msg, wParam, lParam ); - if (wndPtr->hmemTaskQ != GetTaskQueue(0)) + if (wndPtr->hmemTaskQ != GetFastQueue()) ret = MSG_SendMessage( wndPtr->hmemTaskQ, hwnd, msg, wParam, lParam, 0 ); else @@ -1329,7 +1329,7 @@ LRESULT WINAPI SendMessage32A( HWND32 hwnd, UINT32 msg, WPARAM32 wParam, SPY_EnterMessage( SPY_SENDMESSAGE32, hwnd, msg, wParam, lParam ); - if (wndPtr->hmemTaskQ != GetTaskQueue(0)) + if (wndPtr->hmemTaskQ != GetFastQueue()) ret = MSG_SendMessage( wndPtr->hmemTaskQ, hwnd, msg, wParam, lParam, QUEUE_SM_WIN32 ); else @@ -1400,7 +1400,7 @@ LRESULT WINAPI SendMessage32W( SPY_EnterMessage( SPY_SENDMESSAGE32, hwnd, msg, wParam, lParam ); - if (wndPtr->hmemTaskQ != GetTaskQueue(0)) + if (wndPtr->hmemTaskQ != GetFastQueue()) ret = MSG_SendMessage( wndPtr->hmemTaskQ, hwnd, msg, wParam, lParam, QUEUE_SM_WIN32 | QUEUE_SM_UNICODE ); else @@ -1938,7 +1938,7 @@ BOOL32 WINAPI InSendMessage32(void) { MESSAGEQUEUE *queue; - if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) + if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetFastQueue() ))) return 0; return (BOOL32)queue->InSendMessageHandle; } diff --git a/windows/queue.c b/windows/queue.c index cb562d22064..eee5c8a6f2c 100644 --- a/windows/queue.c +++ b/windows/queue.c @@ -312,11 +312,11 @@ void QUEUE_WaitBits( WORD bits ) { MESSAGEQUEUE *queue; - TRACE(msg,"q %04x waiting for %04x\n", GetTaskQueue(0), bits); + TRACE(msg,"q %04x waiting for %04x\n", GetFastQueue(), bits); for (;;) { - if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return; + if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetFastQueue() ))) return; if (queue->changeBits & bits) { @@ -752,7 +752,7 @@ void WINAPI PostQuitMessage32( INT32 exitCode ) { MESSAGEQUEUE *queue; - if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return; + if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetFastQueue() ))) return; queue->wPostQMsg = TRUE; queue->wExitCode = (WORD)exitCode; } @@ -819,7 +819,7 @@ BOOL32 WINAPI SetMessageQueue32( INT32 size ) SIGNAL_MaskAsyncEvents( TRUE ); /* Copy data and free the old message queue */ - if ((hQueue = GetTaskQueue(0)) != 0) + if ((hQueue = GetThreadQueue(0)) != 0) { MESSAGEQUEUE *oldQ = (MESSAGEQUEUE *)GlobalLock16( hQueue ); memcpy( &queuePtr->wParamHigh, &oldQ->wParamHigh, @@ -838,12 +838,25 @@ BOOL32 WINAPI SetMessageQueue32( INT32 size ) hFirstQueue = hNewQueue; if( !queuePtr->next ) pCursorQueue = queuePtr; - SetTaskQueue( 0, hNewQueue ); + SetThreadQueue( 0, hNewQueue ); SIGNAL_MaskAsyncEvents( FALSE ); return TRUE; } +/*********************************************************************** + * InitThreadInput (USER.409) + */ +HQUEUE16 WINAPI InitThreadInput( WORD unknown, WORD flags ) +{ + HQUEUE16 hQueue = GetTaskQueue( 0 ); + + FIXME( msg, "(%04X,%04X): should create thread-local message queue!\n", + unknown, flags ); + + SetFastQueue( 0, hQueue ); + return hQueue; +} /*********************************************************************** * GetQueueStatus16 (USER.334) @@ -853,7 +866,7 @@ DWORD WINAPI GetQueueStatus16( UINT16 flags ) MESSAGEQUEUE *queue; DWORD ret; - if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return 0; + if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetFastQueue() ))) return 0; ret = MAKELONG( queue->changeBits, queue->wakeBits ); queue->changeBits = 0; return ret & MAKELONG( flags, flags ); @@ -867,7 +880,7 @@ DWORD WINAPI GetQueueStatus32( UINT32 flags ) MESSAGEQUEUE *queue; DWORD ret; - if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return 0; + if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetFastQueue() ))) return 0; ret = MAKELONG( queue->changeBits, queue->wakeBits ); queue->changeBits = 0; return ret & MAKELONG( flags, flags ); @@ -900,11 +913,35 @@ BOOL32 WINAPI GetInputState32(void) { MESSAGEQUEUE *queue; - if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) + if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetFastQueue() ))) return FALSE; return queue->wakeBits & (QS_KEY | QS_MOUSEBUTTON); } +/*********************************************************************** + * UserYield (USER.332) + */ +void WINAPI UserYield(void) +{ + TDB *pCurTask = (TDB *)GlobalLock16( GetCurrentTask() ); + MESSAGEQUEUE *queue = (MESSAGEQUEUE *)GlobalLock16( pCurTask->hQueue ); + + if ( !THREAD_IsWin16( THREAD_Current() ) ) + { + FIXME(task, "called for Win32 thread (%04x)!\n", THREAD_Current()->teb_sel); + return; + } + + /* Handle sent messages */ + while (queue && (queue->wakeBits & QS_SENDMESSAGE)) + QUEUE_ReceiveMessage( queue ); + + OldYield(); + + queue = (MESSAGEQUEUE *)GlobalLock16( pCurTask->hQueue ); + while (queue && (queue->wakeBits & QS_SENDMESSAGE)) + QUEUE_ReceiveMessage( queue ); +} /*********************************************************************** * GetMessagePos (USER.119) (USER32.272) @@ -931,7 +968,7 @@ DWORD WINAPI GetMessagePos(void) { MESSAGEQUEUE *queue; - if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return 0; + if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetFastQueue() ))) return 0; return queue->GetMessagePosVal; } @@ -959,7 +996,7 @@ LONG WINAPI GetMessageTime(void) { MESSAGEQUEUE *queue; - if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return 0; + if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetFastQueue() ))) return 0; return queue->GetMessageTimeVal; } @@ -971,6 +1008,6 @@ LONG WINAPI GetMessageExtraInfo(void) { MESSAGEQUEUE *queue; - if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return 0; + if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetFastQueue() ))) return 0; return queue->GetMessageExtraInfoVal; }