-Fixed MESSAGE functions that were thunking down to 16 bits implementation.

So PeekMessage32, GetMessage32, PostMessage32, PostThreadMessage are fixed
with this patch. Unicode version of those functions is currently only
calling the ASCII version.
-Fixed queue signaling using a new EVENT object in the queue for 32 bits
thread. MsgWaitForMultipleObject has been fixed and is now blocking on the
right EVENT.
This commit is contained in:
Stephane Lussier 1999-02-09 15:35:12 +00:00 committed by Alexandre Julliard
parent 7bb6fd1db3
commit b3a99de50d
8 changed files with 199 additions and 179 deletions

View File

@ -2344,7 +2344,7 @@ static void MENU_KeyRight( MTRACKER* pmt )
static BOOL32 MENU_TrackMenu( HMENU32 hmenu, UINT32 wFlags, INT32 x, INT32 y, static BOOL32 MENU_TrackMenu( HMENU32 hmenu, UINT32 wFlags, INT32 x, INT32 y,
HWND32 hwnd, const RECT32 *lprect ) HWND32 hwnd, const RECT32 *lprect )
{ {
MSG16 msg; MSG32 msg;
POPUPMENU *menu; POPUPMENU *menu;
BOOL32 fRemove; BOOL32 fRemove;
MTRACKER mt = { 0, hmenu, hmenu, hwnd, {x, y} }; /* control struct */ MTRACKER mt = { 0, hmenu, hmenu, hwnd, {x, y} }; /* control struct */
@ -2367,15 +2367,16 @@ static BOOL32 MENU_TrackMenu( HMENU32 hmenu, UINT32 wFlags, INT32 x, INT32 y,
if (!MSG_InternalGetMessage( &msg, msg.hwnd, mt.hOwnerWnd, if (!MSG_InternalGetMessage( &msg, msg.hwnd, mt.hOwnerWnd,
MSGF_MENU, PM_NOREMOVE, TRUE )) break; MSGF_MENU, PM_NOREMOVE, TRUE )) break;
TranslateMessage16( &msg ); TranslateMessage32( &msg );
CONV_POINT16TO32( &msg.pt, &mt.pt ); mt.pt = msg.pt;
fRemove = FALSE; fRemove = FALSE;
if ((msg.message >= WM_MOUSEFIRST) && (msg.message <= WM_MOUSELAST)) if ((msg.message >= WM_MOUSEFIRST) && (msg.message <= WM_MOUSELAST))
{ {
/* Find a menu for this mouse event */ /* Find a menu for this mouse event */
POINT16 pt16;
hmenu = MENU_PtMenu( mt.hTopMenu, msg.pt ); CONV_POINT32TO16( &msg.pt, &pt16 );
hmenu = MENU_PtMenu( mt.hTopMenu, pt16 );
switch(msg.message) switch(msg.message)
{ {
@ -2483,7 +2484,7 @@ static BOOL32 MENU_TrackMenu( HMENU32 hmenu, UINT32 wFlags, INT32 x, INT32 y,
if ((msg.wParam <= 32) || (msg.wParam >= 127)) break; if ((msg.wParam <= 32) || (msg.wParam >= 127)) break;
pos = MENU_FindItemByKey( mt.hOwnerWnd, mt.hCurrentMenu, pos = MENU_FindItemByKey( mt.hOwnerWnd, mt.hCurrentMenu,
msg.wParam, FALSE ); LOWORD(msg.wParam), FALSE );
if (pos == (UINT32)-2) fEndMenu = TRUE; if (pos == (UINT32)-2) fEndMenu = TRUE;
else if (pos == (UINT32)-1) MessageBeep32(0); else if (pos == (UINT32)-1) MessageBeep32(0);
else else
@ -2497,7 +2498,7 @@ static BOOL32 MENU_TrackMenu( HMENU32 hmenu, UINT32 wFlags, INT32 x, INT32 y,
} }
else else
{ {
DispatchMessage16( &msg ); DispatchMessage32A( &msg );
} }
if (!fEndMenu) fRemove = TRUE; if (!fEndMenu) fRemove = TRUE;
@ -2505,7 +2506,7 @@ static BOOL32 MENU_TrackMenu( HMENU32 hmenu, UINT32 wFlags, INT32 x, INT32 y,
/* finally remove message from the queue */ /* finally remove message from the queue */
if (fRemove && !(mt.trackFlags & TF_SKIPREMOVE) ) if (fRemove && !(mt.trackFlags & TF_SKIPREMOVE) )
PeekMessage16( &msg, 0, msg.message, msg.message, PM_REMOVE ); PeekMessage32A( &msg, 0, msg.message, msg.message, PM_REMOVE );
else mt.trackFlags &= ~TF_SKIPREMOVE; else mt.trackFlags &= ~TF_SKIPREMOVE;
} }

View File

@ -14,7 +14,7 @@
extern DWORD MSG_WineStartTicks; /* Ticks at Wine startup */ extern DWORD MSG_WineStartTicks; /* Ticks at Wine startup */
/* message.c */ /* message.c */
extern BOOL32 MSG_InternalGetMessage( MSG16 *msg, HWND32 hwnd, extern BOOL32 MSG_InternalGetMessage( MSG32 *msg, HWND32 hwnd,
HWND32 hwndOwner, WPARAM32 code, HWND32 hwndOwner, WPARAM32 code,
WORD flags, BOOL32 sendIdle ); WORD flags, BOOL32 sendIdle );
@ -24,7 +24,7 @@ extern void TIMER_RemoveQueueTimers( HQUEUE16 hqueue );
extern void TIMER_SwitchQueue( HQUEUE16 hOldQueue, HQUEUE16 hNewQueue ); extern void TIMER_SwitchQueue( HQUEUE16 hOldQueue, HQUEUE16 hNewQueue );
extern LONG TIMER_GetNextExpiration(void); extern LONG TIMER_GetNextExpiration(void);
extern void TIMER_ExpireTimers(void); extern void TIMER_ExpireTimers(void);
extern BOOL32 TIMER_GetTimerMsg( MSG16 *msg, HWND32 hwnd, extern BOOL32 TIMER_GetTimerMsg( MSG32 *msg, HWND32 hwnd,
HQUEUE16 hQueue, BOOL32 remove ); HQUEUE16 hQueue, BOOL32 remove );
#define EVENT_IO_READ 0 #define EVENT_IO_READ 0

View File

@ -129,7 +129,6 @@ extern void QUEUE_WalkQueues(void);
extern BOOL32 QUEUE_IsExitingQueue( HQUEUE16 hQueue ); extern BOOL32 QUEUE_IsExitingQueue( HQUEUE16 hQueue );
extern void QUEUE_SetExitingQueue( HQUEUE16 hQueue ); extern void QUEUE_SetExitingQueue( HQUEUE16 hQueue );
extern MESSAGEQUEUE *QUEUE_GetSysQueue(void); extern MESSAGEQUEUE *QUEUE_GetSysQueue(void);
extern void QUEUE_Signal( THDB *thdb );
extern void QUEUE_SetWakeBit( MESSAGEQUEUE *queue, WORD bit ); extern void QUEUE_SetWakeBit( MESSAGEQUEUE *queue, WORD bit );
extern void QUEUE_ClearWakeBit( MESSAGEQUEUE *queue, WORD bit ); extern void QUEUE_ClearWakeBit( MESSAGEQUEUE *queue, WORD bit );
extern void QUEUE_ReceiveMessage( MESSAGEQUEUE *queue ); extern void QUEUE_ReceiveMessage( MESSAGEQUEUE *queue );
@ -138,7 +137,7 @@ extern void QUEUE_IncPaintCount( HQUEUE16 hQueue );
extern void QUEUE_DecPaintCount( HQUEUE16 hQueue ); extern void QUEUE_DecPaintCount( HQUEUE16 hQueue );
extern void QUEUE_IncTimerCount( HQUEUE16 hQueue ); extern void QUEUE_IncTimerCount( HQUEUE16 hQueue );
extern void QUEUE_DecTimerCount( HQUEUE16 hQueue ); extern void QUEUE_DecTimerCount( HQUEUE16 hQueue );
extern BOOL32 QUEUE_CreateSysMsgQueue( ); extern BOOL32 QUEUE_CreateSysMsgQueue( int size );
extern BOOL32 QUEUE_DeleteMsgQueue( HQUEUE16 hQueue ); extern BOOL32 QUEUE_DeleteMsgQueue( HQUEUE16 hQueue );
extern HTASK16 QUEUE_GetQueueTask( HQUEUE16 hQueue ); extern HTASK16 QUEUE_GetQueueTask( HQUEUE16 hQueue );
extern BOOL32 QUEUE_AddMsg( HQUEUE16 hQueue, MSG32 * msg, DWORD extraInfo ); extern BOOL32 QUEUE_AddMsg( HQUEUE16 hQueue, MSG32 * msg, DWORD extraInfo );

View File

@ -847,7 +847,7 @@ INT32 DIALOG_DoDialogBox( HWND32 hwnd, HWND32 owner )
{ {
WND * wndPtr; WND * wndPtr;
DIALOGINFO * dlgInfo; DIALOGINFO * dlgInfo;
MSG16 msg; MSG32 msg;
INT32 retval; INT32 retval;
/* Owner must be a top-level window */ /* Owner must be a top-level window */
@ -860,10 +860,10 @@ INT32 DIALOG_DoDialogBox( HWND32 hwnd, HWND32 owner )
while (MSG_InternalGetMessage(&msg, hwnd, owner, MSGF_DIALOGBOX, PM_REMOVE, while (MSG_InternalGetMessage(&msg, hwnd, owner, MSGF_DIALOGBOX, PM_REMOVE,
!(wndPtr->dwStyle & DS_NOIDLEMSG) )) !(wndPtr->dwStyle & DS_NOIDLEMSG) ))
{ {
if (!IsDialogMessage16( hwnd, &msg)) if (!IsDialogMessage32A( hwnd, &msg))
{ {
TranslateMessage16( &msg ); TranslateMessage32( &msg );
DispatchMessage16( &msg ); DispatchMessage32A( &msg );
} }
if (dlgInfo->flags & DF_END) break; if (dlgInfo->flags & DF_END) break;
} }

View File

@ -33,6 +33,7 @@
#define WM_NCMOUSEFIRST WM_NCMOUSEMOVE #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
#define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK #define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK
typedef enum { SYSQ_MSG_ABANDON, SYSQ_MSG_SKIP, typedef enum { SYSQ_MSG_ABANDON, SYSQ_MSG_SKIP,
SYSQ_MSG_ACCEPT, SYSQ_MSG_CONTINUE } SYSQ_STATUS; SYSQ_MSG_ACCEPT, SYSQ_MSG_CONTINUE } SYSQ_STATUS;
@ -46,10 +47,10 @@ static INT32 debugSMRL = 0; /* intertask SendMessage() recursion level */
/*********************************************************************** /***********************************************************************
* MSG_CheckFilter * MSG_CheckFilter
*/ */
BOOL32 MSG_CheckFilter(WORD uMsg, DWORD filter) BOOL32 MSG_CheckFilter(DWORD uMsg, DWORD first, DWORD last)
{ {
if( filter ) if( first || last )
return (uMsg >= LOWORD(filter) && uMsg <= HIWORD(filter)); return (uMsg >= first && uMsg <= last);
return TRUE; return TRUE;
} }
@ -87,8 +88,8 @@ static void MSG_SendParentNotify(WND* wndPtr, WORD event, WORD idChild, LPARAM l
* to the user, left in the queue, or skipped entirely (in this case * to the user, left in the queue, or skipped entirely (in this case
* HIWORD contains hit test code). * HIWORD contains hit test code).
*/ */
static DWORD MSG_TranslateMouseMsg( HWND16 hTopWnd, DWORD filter, static DWORD MSG_TranslateMouseMsg( HWND32 hTopWnd, DWORD first, DWORD last,
MSG16 *msg, BOOL32 remove, WND* pWndScope ) MSG32 *msg, BOOL32 remove, WND* pWndScope )
{ {
static DWORD dblclk_time_limit = 0; static DWORD dblclk_time_limit = 0;
static UINT16 clk_message = 0; static UINT16 clk_message = 0;
@ -96,9 +97,9 @@ static DWORD MSG_TranslateMouseMsg( HWND16 hTopWnd, DWORD filter,
static POINT16 clk_pos = { 0, 0 }; static POINT16 clk_pos = { 0, 0 };
WND *pWnd; WND *pWnd;
HWND16 hWnd; HWND32 hWnd;
INT16 ht, hittest, sendSC = 0; INT16 ht, hittest, sendSC = 0;
UINT16 message = msg->message; UINT32 message = msg->message;
POINT16 screen_pt, pt; POINT16 screen_pt, pt;
HANDLE16 hQ = GetFastQueue(); HANDLE16 hQ = GetFastQueue();
MESSAGEQUEUE *queue = (MESSAGEQUEUE *)QUEUE_Lock(hQ); MESSAGEQUEUE *queue = (MESSAGEQUEUE *)QUEUE_Lock(hQ);
@ -110,11 +111,13 @@ static DWORD MSG_TranslateMouseMsg( HWND16 hTopWnd, DWORD filter,
/* Find the window */ /* Find the window */
CONV_POINT32TO16( &msg->pt, &pt );
ht = hittest = HTCLIENT; ht = hittest = HTCLIENT;
hWnd = GetCapture16(); hWnd = GetCapture32();
if( !hWnd ) if( !hWnd )
{ {
ht = hittest = WINPOS_WindowFromPoint( pWndScope, msg->pt, &pWnd ); ht = hittest = WINPOS_WindowFromPoint( pWndScope, pt, &pWnd );
if( !pWnd ) pWnd = WIN_GetDesktop(); if( !pWnd ) pWnd = WIN_GetDesktop();
hWnd = pWnd->hwndSelf; hWnd = pWnd->hwndSelf;
sendSC = 1; sendSC = 1;
@ -144,7 +147,7 @@ static DWORD MSG_TranslateMouseMsg( HWND16 hTopWnd, DWORD filter,
/* check if hWnd is within hWndScope */ /* check if hWnd is within hWndScope */
if( hTopWnd && hWnd != hTopWnd ) if( hTopWnd && hWnd != hTopWnd )
if( !IsChild16(hTopWnd, hWnd) ) if( !IsChild32(hTopWnd, hWnd) )
{ {
QUEUE_Unlock( queue ); QUEUE_Unlock( queue );
return SYSQ_MSG_CONTINUE; return SYSQ_MSG_CONTINUE;
@ -168,18 +171,18 @@ static DWORD MSG_TranslateMouseMsg( HWND16 hTopWnd, DWORD filter,
} }
} }
} }
screen_pt = pt = msg->pt; screen_pt = pt;
if (hittest != HTCLIENT) if (hittest != HTCLIENT)
{ {
message += ((INT16)WM_NCMOUSEMOVE - WM_MOUSEMOVE); message += WM_NCMOUSEMOVE - WM_MOUSEMOVE;
msg->wParam = hittest; msg->wParam = hittest;
} }
else ScreenToClient16( hWnd, &pt ); else ScreenToClient16( hWnd, &pt );
/* check message filter */ /* check message filter */
if (!MSG_CheckFilter(message, filter)) if (!MSG_CheckFilter(message, first, last))
{ {
QUEUE_Unlock(queue); QUEUE_Unlock(queue);
return SYSQ_MSG_CONTINUE; return SYSQ_MSG_CONTINUE;
@ -230,20 +233,20 @@ static DWORD MSG_TranslateMouseMsg( HWND16 hTopWnd, DWORD filter,
* notification message is still WM_L/M/RBUTTONDOWN. * notification message is still WM_L/M/RBUTTONDOWN.
*/ */
MSG_SendParentNotify( pWnd, msg->message, 0, MAKELPARAM(screen_pt.x, screen_pt.y) ); MSG_SendParentNotify( pWnd, msg->message & 0xffff, 0, MAKELPARAM(screen_pt.x, screen_pt.y) );
/* Activate the window if needed */ /* Activate the window if needed */
if (hWnd != GetActiveWindow16() && hWnd != GetDesktopWindow16()) if (hWnd != GetActiveWindow32() && hWnd != GetDesktopWindow32())
{ {
LONG ret = SendMessage16( hWnd, WM_MOUSEACTIVATE, hwndTop, LONG ret = SendMessage32A( hWnd, WM_MOUSEACTIVATE, hwndTop,
MAKELONG( hittest, message ) ); MAKELONG( hittest, message ) );
if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT)) if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
eatMsg = TRUE; eatMsg = TRUE;
if (((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT)) if (((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT))
&& hwndTop != GetActiveWindow16() ) && hwndTop != GetActiveWindow32() )
if (!WINPOS_SetActiveWindow( hwndTop, TRUE , TRUE )) if (!WINPOS_SetActiveWindow( hwndTop, TRUE , TRUE ))
eatMsg = TRUE; eatMsg = TRUE;
} }
@ -253,7 +256,7 @@ static DWORD MSG_TranslateMouseMsg( HWND16 hTopWnd, DWORD filter,
/* Send the WM_SETCURSOR message */ /* Send the WM_SETCURSOR message */
if (sendSC) if (sendSC)
SendMessage16( hWnd, WM_SETCURSOR, (WPARAM16)hWnd, SendMessage32A( hWnd, WM_SETCURSOR, hWnd,
MAKELONG( hittest, message )); MAKELONG( hittest, message ));
if (eatMsg) return MAKELONG( (UINT16)SYSQ_MSG_SKIP, hittest); if (eatMsg) return MAKELONG( (UINT16)SYSQ_MSG_SKIP, hittest);
@ -269,11 +272,11 @@ static DWORD MSG_TranslateMouseMsg( HWND16 hTopWnd, DWORD filter,
* *
* Translate an keyboard hardware event into a real message. * Translate an keyboard hardware event into a real message.
*/ */
static DWORD MSG_TranslateKbdMsg( HWND16 hTopWnd, DWORD filter, static DWORD MSG_TranslateKbdMsg( HWND32 hTopWnd, DWORD first, DWORD last,
MSG16 *msg, BOOL32 remove ) MSG32 *msg, BOOL32 remove )
{ {
WORD message = msg->message; WORD message = msg->message;
HWND16 hWnd = GetFocus16(); HWND32 hWnd = GetFocus32();
WND *pWnd; WND *pWnd;
/* Should check Ctrl-Esc and PrintScreen here */ /* Should check Ctrl-Esc and PrintScreen here */
@ -283,7 +286,7 @@ static DWORD MSG_TranslateKbdMsg( HWND16 hTopWnd, DWORD filter,
/* Send the message to the active window instead, */ /* Send the message to the active window instead, */
/* translating messages to their WM_SYS equivalent */ /* translating messages to their WM_SYS equivalent */
hWnd = GetActiveWindow16(); hWnd = GetActiveWindow32();
if( message < WM_SYSKEYDOWN ) if( message < WM_SYSKEYDOWN )
message += WM_SYSKEYDOWN - WM_KEYDOWN; message += WM_SYSKEYDOWN - WM_KEYDOWN;
@ -304,14 +307,14 @@ static DWORD MSG_TranslateKbdMsg( HWND16 hTopWnd, DWORD filter,
} }
if (hTopWnd && hWnd != hTopWnd) if (hTopWnd && hWnd != hTopWnd)
if (!IsChild16(hTopWnd, hWnd)) return SYSQ_MSG_CONTINUE; if (!IsChild32(hTopWnd, hWnd)) return SYSQ_MSG_CONTINUE;
if (!MSG_CheckFilter(message, filter)) return SYSQ_MSG_CONTINUE; if (!MSG_CheckFilter(message, first, last)) return SYSQ_MSG_CONTINUE;
msg->hwnd = hWnd; msg->hwnd = hWnd;
msg->message = message; msg->message = message;
return (HOOK_CallHooks16( WH_KEYBOARD, remove ? HC_ACTION : HC_NOREMOVE, return (HOOK_CallHooks16( WH_KEYBOARD, remove ? HC_ACTION : HC_NOREMOVE,
msg->wParam, msg->lParam ) LOWORD (msg->wParam), msg->lParam )
? SYSQ_MSG_SKIP : SYSQ_MSG_ACCEPT); ? SYSQ_MSG_SKIP : SYSQ_MSG_ACCEPT);
} }
@ -321,9 +324,9 @@ static DWORD MSG_TranslateKbdMsg( HWND16 hTopWnd, DWORD filter,
* *
* Build an EVENTMSG structure and call JOURNALRECORD hook * Build an EVENTMSG structure and call JOURNALRECORD hook
*/ */
static void MSG_JournalRecordMsg( MSG16 *msg ) static void MSG_JournalRecordMsg( MSG32 *msg )
{ {
EVENTMSG16 *event = SEGPTR_NEW(EVENTMSG16); EVENTMSG32 *event = (EVENTMSG32 *) HeapAlloc(SystemHeap, 0, sizeof(EVENTMSG32));
if (!event) return; if (!event) return;
event->message = msg->message; event->message = msg->message;
event->time = msg->time; event->time = msg->time;
@ -333,16 +336,14 @@ static void MSG_JournalRecordMsg( MSG16 *msg )
event->paramH = msg->lParam & 0x7FFF; event->paramH = msg->lParam & 0x7FFF;
if (HIWORD(msg->lParam) & 0x0100) if (HIWORD(msg->lParam) & 0x0100)
event->paramH |= 0x8000; /* special_key - bit */ event->paramH |= 0x8000; /* special_key - bit */
HOOK_CallHooks16( WH_JOURNALRECORD, HC_ACTION, 0, HOOK_CallHooks32A( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
(LPARAM)SEGPTR_GET(event) );
} }
else if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST)) else if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST))
{ {
event->paramL = LOWORD(msg->lParam); /* X pos */ event->paramL = LOWORD(msg->lParam); /* X pos */
event->paramH = HIWORD(msg->lParam); /* Y pos */ event->paramH = HIWORD(msg->lParam); /* Y pos */
ClientToScreen16( msg->hwnd, (LPPOINT16)&event->paramL ); ClientToScreen16( msg->hwnd, (LPPOINT16)&event->paramL );
HOOK_CallHooks16( WH_JOURNALRECORD, HC_ACTION, 0, HOOK_CallHooks32A( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
(LPARAM)SEGPTR_GET(event) );
} }
else if ((msg->message >= WM_NCMOUSEFIRST) && else if ((msg->message >= WM_NCMOUSEFIRST) &&
(msg->message <= WM_NCMOUSELAST)) (msg->message <= WM_NCMOUSELAST))
@ -350,10 +351,10 @@ static void MSG_JournalRecordMsg( MSG16 *msg )
event->paramL = LOWORD(msg->lParam); /* X pos */ event->paramL = LOWORD(msg->lParam); /* X pos */
event->paramH = HIWORD(msg->lParam); /* Y pos */ event->paramH = HIWORD(msg->lParam); /* Y pos */
event->message += WM_MOUSEMOVE-WM_NCMOUSEMOVE;/* give no info about NC area */ event->message += WM_MOUSEMOVE-WM_NCMOUSEMOVE;/* give no info about NC area */
HOOK_CallHooks16( WH_JOURNALRECORD, HC_ACTION, 0, HOOK_CallHooks32A( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)event );
(LPARAM)SEGPTR_GET(event) );
} }
SEGPTR_FREE(event);
HeapFree(SystemHeap, 0, event);
} }
/*********************************************************************** /***********************************************************************
@ -363,15 +364,17 @@ static void MSG_JournalRecordMsg( MSG16 *msg )
*/ */
static int MSG_JournalPlayBackMsg(void) static int MSG_JournalPlayBackMsg(void)
{ {
EVENTMSG16 *tmpMsg; EVENTMSG32 *tmpMsg;
long wtime,lParam; long wtime,lParam,wParam;
WORD keyDown,i,wParam,result=0; WORD keyDown,i,result=0;
if ( HOOK_IsHooked( WH_JOURNALPLAYBACK ) ) if ( HOOK_IsHooked( WH_JOURNALPLAYBACK ) )
{ {
tmpMsg = SEGPTR_NEW(EVENTMSG16); tmpMsg = (EVENTMSG32 *) HeapAlloc(SystemHeap, 0, sizeof(EVENTMSG32));
wtime=HOOK_CallHooks16( WH_JOURNALPLAYBACK, HC_GETNEXT, 0, if (!tmpMsg) return result;
(LPARAM)SEGPTR_GET(tmpMsg));
wtime=HOOK_CallHooks32A( WH_JOURNALPLAYBACK, HC_GETNEXT, 0,
(LPARAM) tmpMsg );
/* TRACE(msg,"Playback wait time =%ld\n",wtime); */ /* TRACE(msg,"Playback wait time =%ld\n",wtime); */
if (wtime<=0) if (wtime<=0)
{ {
@ -398,7 +401,8 @@ static int MSG_JournalPlayBackMsg(void)
lParam |= 0x20000000; lParam |= 0x20000000;
if (tmpMsg->paramH & 0x8000) /*special_key bit*/ if (tmpMsg->paramH & 0x8000) /*special_key bit*/
lParam |= 0x01000000; lParam |= 0x01000000;
hardware_event( tmpMsg->message, wParam, lParam,0, 0, tmpMsg->time, 0 ); hardware_event( tmpMsg->message & 0xffff, LOWORD(wParam), lParam,
0, 0, tmpMsg->time, 0 );
} }
else else
{ {
@ -428,22 +432,23 @@ static int MSG_JournalPlayBackMsg(void)
if (MouseButtonsStates[0]) wParam |= MK_LBUTTON; if (MouseButtonsStates[0]) wParam |= MK_LBUTTON;
if (MouseButtonsStates[1]) wParam |= MK_MBUTTON; if (MouseButtonsStates[1]) wParam |= MK_MBUTTON;
if (MouseButtonsStates[2]) wParam |= MK_RBUTTON; if (MouseButtonsStates[2]) wParam |= MK_RBUTTON;
hardware_event( tmpMsg->message, wParam, lParam, hardware_event( tmpMsg->message & 0xffff, LOWORD (wParam), lParam,
tmpMsg->paramL, tmpMsg->paramH, tmpMsg->time, 0 ); tmpMsg->paramL, tmpMsg->paramH, tmpMsg->time, 0 );
} }
} }
HOOK_CallHooks16( WH_JOURNALPLAYBACK, HC_SKIP, 0, HOOK_CallHooks32A( WH_JOURNALPLAYBACK, HC_SKIP, 0,
(LPARAM)SEGPTR_GET(tmpMsg)); (LPARAM) tmpMsg);
} }
else else
{ {
if( tmpMsg->message == WM_QUEUESYNC ) if( tmpMsg->message == WM_QUEUESYNC )
if (HOOK_IsHooked( WH_CBT )) if (HOOK_IsHooked( WH_CBT ))
HOOK_CallHooks16( WH_CBT, HCBT_QS, 0, 0L); HOOK_CallHooks32A( WH_CBT, HCBT_QS, 0, 0L);
result= QS_MOUSE | QS_KEY; /* ? */ result= QS_MOUSE | QS_KEY; /* ? */
} }
SEGPTR_FREE(tmpMsg); HeapFree(SystemHeap, 0, tmpMsg);
} }
return result; return result;
} }
@ -453,7 +458,7 @@ static int MSG_JournalPlayBackMsg(void)
* *
* Peek for a hardware message matching the hwnd and message filters. * Peek for a hardware message matching the hwnd and message filters.
*/ */
static BOOL32 MSG_PeekHardwareMsg( MSG16 *msg, HWND16 hwnd, DWORD filter, static BOOL32 MSG_PeekHardwareMsg( MSG32 *msg, HWND32 hwnd, DWORD first, DWORD last,
BOOL32 remove ) BOOL32 remove )
{ {
/* FIXME: should deal with MSG32 instead of MSG16 */ /* FIXME: should deal with MSG32 instead of MSG16 */
@ -474,9 +479,7 @@ static BOOL32 MSG_PeekHardwareMsg( MSG16 *msg, HWND16 hwnd, DWORD filter,
for ( kbd_msg = 0; qmsg; qmsg = nextqmsg) for ( kbd_msg = 0; qmsg; qmsg = nextqmsg)
{ {
/* FIXME: this line will be reenabled when msg will be a MSG32 */ *msg = qmsg->msg;
/* *msg = qmsg->msg; */
STRUCT32_MSG32to16(&qmsg->msg, msg);
nextqmsg = qmsg->nextMsg; nextqmsg = qmsg->nextMsg;
@ -486,14 +489,14 @@ static BOOL32 MSG_PeekHardwareMsg( MSG16 *msg, HWND16 hwnd, DWORD filter,
{ {
HWND32 hWndScope = (HWND32)qmsg->extraInfo; HWND32 hWndScope = (HWND32)qmsg->extraInfo;
status = MSG_TranslateMouseMsg(hwnd, filter, msg, remove, status = MSG_TranslateMouseMsg(hwnd, first, last, msg, remove,
(Options.managed && IsWindow32(hWndScope) ) (Options.managed && IsWindow32(hWndScope) )
? WIN_FindWndPtr(hWndScope) : WIN_GetDesktop() ); ? WIN_FindWndPtr(hWndScope) : WIN_GetDesktop() );
kbd_msg = 0; kbd_msg = 0;
} }
else if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST)) else if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST))
{ {
status = MSG_TranslateKbdMsg(hwnd, filter, msg, remove); status = MSG_TranslateKbdMsg(hwnd, first, last, msg, remove);
kbd_msg = 1; kbd_msg = 1;
} }
else /* Non-standard hardware event */ else /* Non-standard hardware event */
@ -503,8 +506,8 @@ static BOOL32 MSG_PeekHardwareMsg( MSG16 *msg, HWND16 hwnd, DWORD filter,
{ {
BOOL32 ret; BOOL32 ret;
hook->hWnd = msg->hwnd; hook->hWnd = msg->hwnd;
hook->wMessage = msg->message; hook->wMessage = msg->message & 0xffff;
hook->wParam = msg->wParam; hook->wParam = LOWORD (msg->wParam);
hook->lParam = msg->lParam; hook->lParam = msg->lParam;
ret = HOOK_CallHooks16( WH_HARDWARE, ret = HOOK_CallHooks16( WH_HARDWARE,
remove ? HC_ACTION : HC_NOREMOVE, remove ? HC_ACTION : HC_NOREMOVE,
@ -529,17 +532,17 @@ static BOOL32 MSG_PeekHardwareMsg( MSG16 *msg, HWND16 hwnd, DWORD filter,
{ {
if( kbd_msg ) if( kbd_msg )
HOOK_CallHooks16( WH_CBT, HCBT_KEYSKIPPED, HOOK_CallHooks16( WH_CBT, HCBT_KEYSKIPPED,
msg->wParam, msg->lParam ); LOWORD (msg->wParam), msg->lParam );
else else
{ {
MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16); MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16);
if (hook) if (hook)
{ {
hook->pt = msg->pt; CONV_POINT32TO16( &msg->pt,&hook->pt );
hook->hwnd = msg->hwnd; hook->hwnd = msg->hwnd;
hook->wHitTestCode = HIWORD(status); hook->wHitTestCode = HIWORD(status);
hook->dwExtraInfo = 0; hook->dwExtraInfo = 0;
HOOK_CallHooks16( WH_CBT, HCBT_CLICKSKIPPED ,msg->message, HOOK_CallHooks16( WH_CBT, HCBT_CLICKSKIPPED ,msg->message & 0xffff,
(LPARAM)SEGPTR_GET(hook) ); (LPARAM)SEGPTR_GET(hook) );
SEGPTR_FREE(hook); SEGPTR_FREE(hook);
} }
@ -568,7 +571,6 @@ static BOOL32 MSG_PeekHardwareMsg( MSG16 *msg, HWND16 hwnd, DWORD filter,
} }
/********************************************************************** /**********************************************************************
* SetDoubleClickTime16 (USER.20) * SetDoubleClickTime16 (USER.20)
*/ */
@ -747,12 +749,13 @@ void WINAPI ReplyMessage16( LRESULT result )
/*********************************************************************** /***********************************************************************
* MSG_PeekMessage * MSG_PeekMessage
*/ */
static BOOL32 MSG_PeekMessage( LPMSG16 msg, HWND16 hwnd, WORD first, WORD last, static BOOL32 MSG_PeekMessage( LPMSG32 msg, HWND32 hwnd, DWORD first, DWORD last,
WORD flags, BOOL32 peek ) WORD flags, BOOL32 peek )
{ {
int mask; int mask;
MESSAGEQUEUE *msgQueue; MESSAGEQUEUE *msgQueue;
HQUEUE16 hQueue; HQUEUE16 hQueue;
POINT16 pt16;
#ifdef CONFIG_IPC #ifdef CONFIG_IPC
DDE_TestDDE(hwnd); /* do we have dde handling in the window ?*/ DDE_TestDDE(hwnd); /* do we have dde handling in the window ?*/
@ -809,12 +812,11 @@ static BOOL32 MSG_PeekMessage( LPMSG16 msg, HWND16 hwnd, WORD first, WORD last,
if (((msgQueue->wakeBits & mask) & QS_POSTMESSAGE) && if (((msgQueue->wakeBits & mask) & QS_POSTMESSAGE) &&
((qmsg = QUEUE_FindMsg( msgQueue, hwnd, first, last )) != 0)) ((qmsg = QUEUE_FindMsg( msgQueue, hwnd, first, last )) != 0))
{ {
/* FIXME: this line will be reenabled when msg will be a MSG32 */ *msg = qmsg->msg;
/* *msg = qmsg->msg; */
STRUCT32_MSG32to16(&qmsg->msg, msg);
msgQueue->GetMessageTimeVal = msg->time; msgQueue->GetMessageTimeVal = msg->time;
msgQueue->GetMessagePosVal = *(DWORD *)&msg->pt; CONV_POINT32TO16(&msg->pt, &pt16);
msgQueue->GetMessagePosVal = *(DWORD *)&pt16;
msgQueue->GetMessageExtraInfoVal = qmsg->extraInfo; msgQueue->GetMessageExtraInfoVal = qmsg->extraInfo;
if (flags & PM_REMOVE) QUEUE_RemoveMsg( msgQueue, qmsg ); if (flags & PM_REMOVE) QUEUE_RemoveMsg( msgQueue, qmsg );
@ -826,11 +828,12 @@ static BOOL32 MSG_PeekMessage( LPMSG16 msg, HWND16 hwnd, WORD first, WORD last,
/* Now find a hardware event */ /* Now find a hardware event */
if (((msgQueue->wakeBits & mask) & (QS_MOUSE | QS_KEY)) && if (((msgQueue->wakeBits & mask) & (QS_MOUSE | QS_KEY)) &&
MSG_PeekHardwareMsg( msg, hwnd, MAKELONG(first,last), flags & PM_REMOVE )) MSG_PeekHardwareMsg( msg, hwnd, first, last, flags & PM_REMOVE ))
{ {
/* Got one */ /* Got one */
msgQueue->GetMessageTimeVal = msg->time; msgQueue->GetMessageTimeVal = msg->time;
msgQueue->GetMessagePosVal = *(DWORD *)&msg->pt; CONV_POINT32TO16(&msg->pt, &pt16);
msgQueue->GetMessagePosVal = *(DWORD *)&pt16;
msgQueue->GetMessageExtraInfoVal = 0; /* Always 0 for now */ msgQueue->GetMessageExtraInfoVal = 0; /* Always 0 for now */
break; break;
} }
@ -920,7 +923,6 @@ static BOOL32 MSG_PeekMessage( LPMSG16 msg, HWND16 hwnd, WORD first, WORD last,
else return (msg->message != WM_QUIT); else return (msg->message != WM_QUIT);
} }
/*********************************************************************** /***********************************************************************
* MSG_InternalGetMessage * MSG_InternalGetMessage
* *
@ -929,7 +931,7 @@ static BOOL32 MSG_PeekMessage( LPMSG16 msg, HWND16 hwnd, WORD first, WORD last,
* 'hwnd' must be the handle of the dialog or menu window. * 'hwnd' must be the handle of the dialog or menu window.
* 'code' is the message filter value (MSGF_??? codes). * 'code' is the message filter value (MSGF_??? codes).
*/ */
BOOL32 MSG_InternalGetMessage( MSG16 *msg, HWND32 hwnd, HWND32 hwndOwner, BOOL32 MSG_InternalGetMessage( MSG32 *msg, HWND32 hwnd, HWND32 hwndOwner,
WPARAM32 code, WORD flags, BOOL32 sendIdle ) WPARAM32 code, WORD flags, BOOL32 sendIdle )
{ {
for (;;) for (;;)
@ -940,7 +942,7 @@ BOOL32 MSG_InternalGetMessage( MSG16 *msg, HWND32 hwnd, HWND32 hwndOwner,
{ {
/* No message present -> send ENTERIDLE and wait */ /* No message present -> send ENTERIDLE and wait */
if (IsWindow32(hwndOwner)) if (IsWindow32(hwndOwner))
SendMessage16( hwndOwner, WM_ENTERIDLE, SendMessage32A( hwndOwner, WM_ENTERIDLE,
code, (LPARAM)hwnd ); code, (LPARAM)hwnd );
MSG_PeekMessage( msg, 0, 0, 0, flags, FALSE ); MSG_PeekMessage( msg, 0, 0, 0, flags, FALSE );
} }
@ -952,16 +954,17 @@ BOOL32 MSG_InternalGetMessage( MSG16 *msg, HWND32 hwnd, HWND32 hwndOwner,
if (HOOK_IsHooked( WH_SYSMSGFILTER ) || HOOK_IsHooked( WH_MSGFILTER )) if (HOOK_IsHooked( WH_SYSMSGFILTER ) || HOOK_IsHooked( WH_MSGFILTER ))
{ {
MSG16 *pmsg = SEGPTR_NEW(MSG16); MSG32 *pmsg = HeapAlloc( SystemHeap, 0, sizeof(MSG32) );
if (pmsg) if (pmsg)
{ {
BOOL32 ret; BOOL32 ret;
*pmsg = *msg; *pmsg = *msg;
ret = ((BOOL16)HOOK_CallHooks16( WH_SYSMSGFILTER, code, 0, ret = (HOOK_CallHooks32A( WH_SYSMSGFILTER, code, 0,
(LPARAM)SEGPTR_GET(pmsg) ) || (LPARAM) pmsg ) ||
(BOOL16)HOOK_CallHooks16( WH_MSGFILTER, code, 0, HOOK_CallHooks32A( WH_MSGFILTER, code, 0,
(LPARAM)SEGPTR_GET(pmsg) )); (LPARAM) pmsg ));
SEGPTR_FREE(pmsg);
HeapFree( SystemHeap, 0, pmsg );
if (ret) if (ret)
{ {
/* Message filtered -> remove it from the queue */ /* Message filtered -> remove it from the queue */
@ -981,10 +984,14 @@ BOOL32 MSG_InternalGetMessage( MSG16 *msg, HWND32 hwnd, HWND32 hwndOwner,
/*********************************************************************** /***********************************************************************
* PeekMessage16 (USER.109) * PeekMessage16 (USER.109)
*/ */
BOOL16 WINAPI PeekMessage16( LPMSG16 msg, HWND16 hwnd, UINT16 first, BOOL16 WINAPI PeekMessage16( LPMSG16 lpmsg, HWND16 hwnd, UINT16 first,
UINT16 last, UINT16 flags ) UINT16 last, UINT16 flags )
{ {
return MSG_PeekMessage( msg, hwnd, first, last, flags, TRUE ); MSG32 msg32;
BOOL16 ret;
ret = PeekMessage32A(&msg32, hwnd, first, last, flags);
STRUCT32_MSG32to16(&msg32, lpmsg);
return ret;
} }
/*********************************************************************** /***********************************************************************
@ -1024,12 +1031,7 @@ BOOL16 WINAPI WIN16_PeekMessage32( LPMSG16_32 lpmsg16_32, HWND16 hwnd,
BOOL32 WINAPI PeekMessage32A( LPMSG32 lpmsg, HWND32 hwnd, BOOL32 WINAPI PeekMessage32A( LPMSG32 lpmsg, HWND32 hwnd,
UINT32 min,UINT32 max,UINT32 wRemoveMsg) UINT32 min,UINT32 max,UINT32 wRemoveMsg)
{ {
MSG16 msg; return MSG_PeekMessage( lpmsg, hwnd, min, max, wRemoveMsg, TRUE );
BOOL32 ret;
ret=PeekMessage16(&msg,hwnd,min,max,wRemoveMsg);
/* FIXME: should translate the message to Win32 */
STRUCT32_MSG16to32(&msg,lpmsg);
return ret;
} }
/*********************************************************************** /***********************************************************************
@ -1075,14 +1077,18 @@ BOOL32 WINAPI PeekMessage32W(
*/ */
BOOL16 WINAPI GetMessage16( SEGPTR msg, HWND16 hwnd, UINT16 first, UINT16 last) BOOL16 WINAPI GetMessage16( SEGPTR msg, HWND16 hwnd, UINT16 first, UINT16 last)
{ {
BOOL32 ret;
MSG16 *lpmsg = (MSG16 *)PTR_SEG_TO_LIN(msg); MSG16 *lpmsg = (MSG16 *)PTR_SEG_TO_LIN(msg);
MSG_PeekMessage( lpmsg, MSG32 msg32;
hwnd, first, last, PM_REMOVE, FALSE );
ret = GetMessage32A( &msg32, hwnd, first, last );
STRUCT32_MSG32to16( &msg32, lpmsg );
TRACE(msg,"message %04x, hwnd %04x, filter(%04x - %04x)\n", lpmsg->message, TRACE(msg,"message %04x, hwnd %04x, filter(%04x - %04x)\n", lpmsg->message,
hwnd, first, last ); hwnd, first, last );
HOOK_CallHooks16( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)msg );
return (lpmsg->message != WM_QUIT); return ret;
} }
/*********************************************************************** /***********************************************************************
@ -1123,14 +1129,14 @@ BOOL16 WINAPI WIN16_GetMessage32( SEGPTR msg16_32, HWND16 hWnd, UINT16 first,
*/ */
BOOL32 WINAPI GetMessage32A(MSG32* lpmsg,HWND32 hwnd,UINT32 min,UINT32 max) BOOL32 WINAPI GetMessage32A(MSG32* lpmsg,HWND32 hwnd,UINT32 min,UINT32 max)
{ {
BOOL32 ret; MSG_PeekMessage( lpmsg, hwnd, min, max, PM_REMOVE, FALSE );
MSG16 *msg = SEGPTR_NEW(MSG16);
if (!msg) return 0; TRACE(msg,"message %04x, hwnd %04x, filter(%04x - %04x)\n", lpmsg->message,
ret=GetMessage16(SEGPTR_GET(msg),(HWND16)hwnd,min,max); hwnd, min, max );
/* FIXME */
STRUCT32_MSG16to32(msg,lpmsg); HOOK_CallHooks32A( WH_GETMESSAGE, HC_ACTION, 0, (LPARAM)lpmsg );
SEGPTR_FREE(msg);
return ret; return (lpmsg->message != WM_QUIT);
} }
/*********************************************************************** /***********************************************************************
@ -1166,14 +1172,8 @@ BOOL32 WINAPI GetMessage32W(
UINT32 min, /* minimum message to receive */ UINT32 min, /* minimum message to receive */
UINT32 max /* maximum message to receive */ UINT32 max /* maximum message to receive */
) { ) {
BOOL32 ret;
MSG16 *msg = SEGPTR_NEW(MSG16);
if (!msg) return 0;
ret=GetMessage16(SEGPTR_GET(msg),(HWND16)hwnd,min,max);
/* FIXME */ /* FIXME */
STRUCT32_MSG16to32(msg,lpmsg); return GetMessage32A(lpmsg, hwnd, min, max);
SEGPTR_FREE(msg);
return ret;
} }
@ -1182,6 +1182,16 @@ BOOL32 WINAPI GetMessage32W(
*/ */
BOOL16 WINAPI PostMessage16( HWND16 hwnd, UINT16 message, WPARAM16 wParam, BOOL16 WINAPI PostMessage16( HWND16 hwnd, UINT16 message, WPARAM16 wParam,
LPARAM lParam ) LPARAM lParam )
{
return (BOOL16) PostMessage32A( hwnd, message, wParam, lParam );
}
/***********************************************************************
* PostMessage32A (USER32.419)
*/
BOOL32 WINAPI PostMessage32A( HWND32 hwnd, UINT32 message, WPARAM32 wParam,
LPARAM lParam )
{ {
MSG32 msg; MSG32 msg;
WND *wndPtr; WND *wndPtr;
@ -1208,7 +1218,7 @@ BOOL16 WINAPI PostMessage16( HWND16 hwnd, UINT16 message, WPARAM16 wParam,
{ {
TRACE(msg,"BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n", TRACE(msg,"BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n",
wndPtr->hwndSelf, message, wParam, lParam); wndPtr->hwndSelf, message, wParam, lParam);
PostMessage16( wndPtr->hwndSelf, message, wParam, lParam ); PostMessage32A( wndPtr->hwndSelf, message, wParam, lParam );
} }
} }
TRACE(msg,"End of HWND_BROADCAST !\n"); TRACE(msg,"End of HWND_BROADCAST !\n");
@ -1222,21 +1232,6 @@ BOOL16 WINAPI PostMessage16( HWND16 hwnd, UINT16 message, WPARAM16 wParam,
} }
/***********************************************************************
* PostMessage32A (USER32.419)
*/
BOOL32 WINAPI PostMessage32A( HWND32 hwnd, UINT32 message, WPARAM32 wParam,
LPARAM lParam )
{
/* FIXME */
if (message&0xffff0000)
FIXME(msg,"message is truncated from %d to %d\n", message, message&0xffff);
if (wParam&0xffff0000)
FIXME(msg,"wParam is truncated from %d to %d\n", wParam, wParam&0xffff);
return PostMessage16( hwnd, message, wParam, lParam );
}
/*********************************************************************** /***********************************************************************
* PostMessage32W (USER32.420) * PostMessage32W (USER32.420)
*/ */
@ -1244,11 +1239,7 @@ BOOL32 WINAPI PostMessage32W( HWND32 hwnd, UINT32 message, WPARAM32 wParam,
LPARAM lParam ) LPARAM lParam )
{ {
/* FIXME */ /* FIXME */
if (message&0xffff0000) return PostMessage32A( hwnd, message, wParam, lParam );
FIXME(msg,"message is truncated from %d to %d\n", message, message&0xffff);
if (wParam&0xffff0000)
FIXME(msg,"wParam is truncated from %d to %d\n", wParam, wParam&0xffff);
return PostMessage16( hwnd, message, wParam, lParam );
} }
@ -1382,11 +1373,21 @@ static void MSG_CallWndProcHook32( LPMSG32 pmsg, BOOL32 bUnicode )
BOOL32 WINAPI PostThreadMessage32A(DWORD idThread , UINT32 message, BOOL32 WINAPI PostThreadMessage32A(DWORD idThread , UINT32 message,
WPARAM32 wParam, LPARAM lParam ) WPARAM32 wParam, LPARAM lParam )
{ {
THDB *thdb = THREAD_ID_TO_THDB(idThread); MSG32 msg;
if (!thdb || !thdb->process) return FALSE; HQUEUE16 hQueue;
FIXME(sendmsg, "(...): Should use thread-local message queue!\n"); if ((hQueue = GetThreadQueue(idThread)) == 0)
return PostAppMessage16(thdb->process->task, message, wParam, lParam); return FALSE;
msg.hwnd = 0;
msg.message = message;
msg.wParam = wParam;
msg.lParam = lParam;
msg.time = GetTickCount();
msg.pt.x = 0;
msg.pt.y = 0;
return QUEUE_AddMsg( hQueue, &msg, 0 );
} }
/********************************************************************** /**********************************************************************
@ -1400,11 +1401,8 @@ BOOL32 WINAPI PostThreadMessage32A(DWORD idThread , UINT32 message,
BOOL32 WINAPI PostThreadMessage32W(DWORD idThread , UINT32 message, BOOL32 WINAPI PostThreadMessage32W(DWORD idThread , UINT32 message,
WPARAM32 wParam, LPARAM lParam ) WPARAM32 wParam, LPARAM lParam )
{ {
THDB *thdb = THREAD_ID_TO_THDB(idThread); FIXME(sendmsg, "(...): Should do unicode/ascii conversion!\n");
if (!thdb || !thdb->process) return FALSE; return PostThreadMessage32A(idThread, message, wParam, lParam);
FIXME(sendmsg, "(...): Should use thread-local message queue!\n");
return PostAppMessage16(thdb->process->task, message, wParam, lParam);
} }
/*********************************************************************** /***********************************************************************
@ -1596,9 +1594,9 @@ DWORD WINAPI MsgWaitForMultipleObjects( DWORD nCount, HANDLE32 *pHandles,
{ {
DWORD i; DWORD i;
HANDLE32 handles[MAXIMUM_WAIT_OBJECTS]; HANDLE32 handles[MAXIMUM_WAIT_OBJECTS];
DWORD ret;
TDB *currTask = (TDB *)GlobalLock16( GetCurrentTask() ); HQUEUE16 hQueue = GetFastQueue();
HQUEUE16 hQueue = currTask? currTask->hQueue : 0;
MESSAGEQUEUE *msgQueue = (MESSAGEQUEUE *)QUEUE_Lock( hQueue ); MESSAGEQUEUE *msgQueue = (MESSAGEQUEUE *)QUEUE_Lock( hQueue );
if (!msgQueue) return WAIT_FAILED; if (!msgQueue) return WAIT_FAILED;
@ -1612,12 +1610,14 @@ DWORD WINAPI MsgWaitForMultipleObjects( DWORD nCount, HANDLE32 *pHandles,
msgQueue->changeBits = 0; msgQueue->changeBits = 0;
msgQueue->wakeMask = dwWakeMask; msgQueue->wakeMask = dwWakeMask;
QUEUE_Unlock( msgQueue );
/* Add the thread event to the handle list */ /* Add the thread event to the handle list */
for (i = 0; i < nCount; i++) handles[i] = pHandles[i]; for (i = 0; i < nCount; i++) handles[i] = pHandles[i];
handles[nCount] = currTask->thdb->event; handles[nCount] = msgQueue->hEvent;
return WaitForMultipleObjects( nCount+1, handles, fWaitAll, dwMilliseconds ); ret = WaitForMultipleObjects( nCount+1, handles, fWaitAll, dwMilliseconds );
QUEUE_Unlock( msgQueue );
return ret;
} }

View File

@ -1881,7 +1881,7 @@ static LONG NC_StartSizeMove( WND* wndPtr, WPARAM16 wParam,
{ {
LONG hittest = 0; LONG hittest = 0;
POINT16 pt; POINT16 pt;
MSG16 msg; MSG32 msg;
if ((wParam & 0xfff0) == SC_MOVE) if ((wParam & 0xfff0) == SC_MOVE)
{ {
@ -1910,8 +1910,8 @@ static LONG NC_StartSizeMove( WND* wndPtr, WPARAM16 wParam,
switch(msg.message) switch(msg.message)
{ {
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
hittest = NC_HandleNCHitTest( wndPtr->hwndSelf, msg.pt ); CONV_POINT32TO16(&msg.pt, &pt);
pt = msg.pt; hittest = NC_HandleNCHitTest( wndPtr->hwndSelf, pt );
if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT)) if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT))
hittest = 0; hittest = 0;
break; break;
@ -1959,11 +1959,11 @@ static LONG NC_StartSizeMove( WND* wndPtr, WPARAM16 wParam,
/*********************************************************************** /***********************************************************************
* NC_DoSizeMove * NC_DoSizeMove
* *
* Perform SC_MOVE and SC_SIZE commands. * Perform SC_MOVE and SC_SIZE commands. `
*/ */
static void NC_DoSizeMove( HWND32 hwnd, WORD wParam ) static void NC_DoSizeMove( HWND32 hwnd, WORD wParam )
{ {
MSG16 msg; MSG32 msg;
RECT32 sizingRect, mouseRect; RECT32 sizingRect, mouseRect;
HDC32 hdc; HDC32 hdc;
LONG hittest = (LONG)(wParam & 0x0f); LONG hittest = (LONG)(wParam & 0x0f);
@ -2201,7 +2201,8 @@ static void NC_DoSizeMove( HWND32 hwnd, WORD wParam )
*/ */
static void NC_TrackMinMaxBox( HWND32 hwnd, WORD wParam ) static void NC_TrackMinMaxBox( HWND32 hwnd, WORD wParam )
{ {
MSG16 msg; MSG32 msg;
POINT16 pt16;
HDC32 hdc = GetWindowDC32( hwnd ); HDC32 hdc = GetWindowDC32( hwnd );
BOOL32 pressed = TRUE; BOOL32 pressed = TRUE;
void (*paintButton)(HWND32, HDC16, BOOL32); void (*paintButton)(HWND32, HDC16, BOOL32);
@ -2220,8 +2221,9 @@ static void NC_TrackMinMaxBox( HWND32 hwnd, WORD wParam )
{ {
BOOL32 oldstate = pressed; BOOL32 oldstate = pressed;
MSG_InternalGetMessage( &msg, 0, 0, 0, PM_REMOVE, FALSE ); MSG_InternalGetMessage( &msg, 0, 0, 0, PM_REMOVE, FALSE );
CONV_POINT32TO16( &msg.pt, &pt16 );
pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam); pressed = (NC_HandleNCHitTest( hwnd, pt16 ) == wParam);
if (pressed != oldstate) if (pressed != oldstate)
(*paintButton)( hwnd, hdc, pressed ); (*paintButton)( hwnd, hdc, pressed );
} while (msg.message != WM_LBUTTONUP); } while (msg.message != WM_LBUTTONUP);
@ -2233,10 +2235,10 @@ static void NC_TrackMinMaxBox( HWND32 hwnd, WORD wParam )
if (!pressed) return; if (!pressed) return;
if (wParam == HTMINBUTTON) if (wParam == HTMINBUTTON)
SendMessage16( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, *(LONG*)&msg.pt ); SendMessage16( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, *(LONG*)&pt16 );
else else
SendMessage16( hwnd, WM_SYSCOMMAND, SendMessage16( hwnd, WM_SYSCOMMAND,
IsZoomed32(hwnd) ? SC_RESTORE:SC_MAXIMIZE, *(LONG*)&msg.pt ); IsZoomed32(hwnd) ? SC_RESTORE:SC_MAXIMIZE, *(LONG*)&pt16 );
} }
@ -2248,7 +2250,8 @@ static void NC_TrackMinMaxBox( HWND32 hwnd, WORD wParam )
static void static void
NC_TrackCloseButton95 (HWND32 hwnd, WORD wParam) NC_TrackCloseButton95 (HWND32 hwnd, WORD wParam)
{ {
MSG16 msg; MSG32 msg;
POINT16 pt16;
HDC32 hdc = GetWindowDC32( hwnd ); HDC32 hdc = GetWindowDC32( hwnd );
BOOL32 pressed = TRUE; BOOL32 pressed = TRUE;
@ -2260,8 +2263,9 @@ NC_TrackCloseButton95 (HWND32 hwnd, WORD wParam)
{ {
BOOL32 oldstate = pressed; BOOL32 oldstate = pressed;
MSG_InternalGetMessage( &msg, 0, 0, 0, PM_REMOVE, FALSE ); MSG_InternalGetMessage( &msg, 0, 0, 0, PM_REMOVE, FALSE );
CONV_POINT32TO16( &msg.pt, &pt16 );
pressed = (NC_HandleNCHitTest( hwnd, msg.pt ) == wParam); pressed = (NC_HandleNCHitTest( hwnd, pt16 ) == wParam);
if (pressed != oldstate) if (pressed != oldstate)
NC_DrawCloseButton95 (hwnd, hdc, pressed); NC_DrawCloseButton95 (hwnd, hdc, pressed);
} while (msg.message != WM_LBUTTONUP); } while (msg.message != WM_LBUTTONUP);
@ -2272,7 +2276,7 @@ NC_TrackCloseButton95 (HWND32 hwnd, WORD wParam)
ReleaseDC32( hwnd, hdc ); ReleaseDC32( hwnd, hdc );
if (!pressed) return; if (!pressed) return;
SendMessage16( hwnd, WM_SYSCOMMAND, SC_CLOSE, *(LONG*)&msg.pt ); SendMessage16( hwnd, WM_SYSCOMMAND, SC_CLOSE, *(LONG*)&pt16 );
} }

View File

@ -332,6 +332,8 @@ void QUEUE_Unlock( MESSAGEQUEUE *queue )
if ( --queue->lockCount == 0 ) if ( --queue->lockCount == 0 )
{ {
DeleteCriticalSection ( &queue->cSection ); DeleteCriticalSection ( &queue->cSection );
if (queue->hEvent)
CloseHandle( queue->hEvent );
GlobalFree16( queue->self ); GlobalFree16( queue->self );
} }
@ -449,6 +451,23 @@ static HQUEUE16 QUEUE_CreateMsgQueue( BOOL16 bCreatePerQData )
msgQueue->wWinVersion = pTask ? pTask->version : 0; msgQueue->wWinVersion = pTask ? pTask->version : 0;
InitializeCriticalSection( &msgQueue->cSection ); InitializeCriticalSection( &msgQueue->cSection );
/* Create an Event object for waiting on message, used by win32 thread
only */
if ( !THREAD_IsWin16( THREAD_Current() ) )
{
msgQueue->hEvent = CreateEvent32A( NULL, FALSE, FALSE, NULL);
if (msgQueue->hEvent == 0)
{
WARN(msg, "CreateEvent32A is not able to create an event object");
return 0;
}
msgQueue->hEvent = ConvertToGlobalHandle( msgQueue->hEvent );
}
else
msgQueue->hEvent = 0;
msgQueue->lockCount = 1; msgQueue->lockCount = 1;
msgQueue->magic = QUEUE_MAGIC; msgQueue->magic = QUEUE_MAGIC;
@ -561,16 +580,6 @@ MESSAGEQUEUE *QUEUE_GetSysQueue(void)
return sysMsgQueue; return sysMsgQueue;
} }
/***********************************************************************
* QUEUE_Signal
*/
void QUEUE_Signal( THDB *thdb )
{
/* Wake up thread waiting for message */
SetEvent( thdb->event );
PostEvent( thdb->process->task );
}
/*********************************************************************** /***********************************************************************
* QUEUE_Wait * QUEUE_Wait
@ -604,7 +613,14 @@ void QUEUE_SetWakeBit( MESSAGEQUEUE *queue, WORD bit )
if (queue->wakeMask & bit) if (queue->wakeMask & bit)
{ {
queue->wakeMask = 0; queue->wakeMask = 0;
QUEUE_Signal( queue->thdb );
/* Wake up thread waiting for message */
if ( THREAD_IsWin16( queue->thdb ) )
PostEvent( queue->thdb->process->task );
else
{
SetEvent( queue->hEvent );
}
} }
} }

View File

@ -187,7 +187,7 @@ void TIMER_ExpireTimers(void)
* *
* Build a message for an expired timer. * Build a message for an expired timer.
*/ */
BOOL32 TIMER_GetTimerMsg( MSG16 *msg, HWND32 hwnd, BOOL32 TIMER_GetTimerMsg( MSG32 *msg, HWND32 hwnd,
HQUEUE16 hQueue, BOOL32 remove ) HQUEUE16 hQueue, BOOL32 remove )
{ {
TIMER *pTimer = pNextTimer; TIMER *pTimer = pNextTimer;
@ -205,9 +205,9 @@ BOOL32 TIMER_GetTimerMsg( MSG16 *msg, HWND32 hwnd,
pTimer->hwnd, pTimer->msg, pTimer->id, (DWORD)pTimer->proc); pTimer->hwnd, pTimer->msg, pTimer->id, (DWORD)pTimer->proc);
/* Build the message */ /* Build the message */
msg->hwnd = (HWND16)pTimer->hwnd; msg->hwnd = pTimer->hwnd;
msg->message = pTimer->msg; msg->message = pTimer->msg;
msg->wParam = (UINT16)pTimer->id; msg->wParam = pTimer->id;
msg->lParam = (LONG)pTimer->proc; msg->lParam = (LONG)pTimer->proc;
msg->time = curTime; msg->time = curTime;
return TRUE; return TRUE;