2 * Message queues related functions
4 * Copyright 1993, 1994 Alexandre Julliard
11 #include <sys/types.h>
13 #include "wine/winbase16.h"
29 #include "debugtools.h"
31 DEFAULT_DEBUG_CHANNEL(msg
);
32 DECLARE_DEBUG_CHANNEL(key
);
33 DECLARE_DEBUG_CHANNEL(sendmsg
);
35 #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
36 #define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK
39 typedef enum { SYSQ_MSG_ABANDON
, SYSQ_MSG_SKIP
,
40 SYSQ_MSG_ACCEPT
, SYSQ_MSG_CONTINUE
} SYSQ_STATUS
;
42 extern HQUEUE16 hCursorQueue
; /* queue.c */
44 static UINT doubleClickSpeed
= 452;
46 /***********************************************************************
49 static BOOL
MSG_CheckFilter(DWORD uMsg
, DWORD first
, DWORD last
)
52 return (uMsg
>= first
&& uMsg
<= last
);
56 /***********************************************************************
57 * MSG_SendParentNotify
59 * Send a WM_PARENTNOTIFY to all ancestors of the given window, unless
60 * the window has the WS_EX_NOPARENTNOTIFY style.
62 static void MSG_SendParentNotify(WND
* wndPtr
, WORD event
, WORD idChild
, LPARAM lValue
)
66 /* pt has to be in the client coordinates of the parent window */
67 WND
*tmpWnd
= WIN_LockWndPtr(wndPtr
);
69 pt
.x
= SLOWORD(lValue
);
70 pt
.y
= SHIWORD(lValue
);
71 MapWindowPoints( 0, tmpWnd
->hwndSelf
, &pt
, 1 );
74 if (!(tmpWnd
->dwStyle
& WS_CHILD
) || (tmpWnd
->dwExStyle
& WS_EX_NOPARENTNOTIFY
))
76 WIN_ReleaseWndPtr(tmpWnd
);
79 pt
.x
+= tmpWnd
->rectClient
.left
;
80 pt
.y
+= tmpWnd
->rectClient
.top
;
81 WIN_UpdateWndPtr(&tmpWnd
,tmpWnd
->parent
);
82 SendMessageA( tmpWnd
->hwndSelf
, WM_PARENTNOTIFY
,
83 MAKEWPARAM( event
, idChild
),
84 MAKELONG( pt
.x
, pt
.y
) );
89 /***********************************************************************
90 * MSG_TranslateMouseMsg
92 * Translate a mouse hardware event into a real mouse message.
96 * SYSQ_MSG_ABANDON - abandon the peek message loop
97 * SYSQ_MSG_CONTINUE - leave the message in the queue and
98 * continue with the translation loop
99 * SYSQ_MSG_ACCEPT - proceed to process the translated message
101 static DWORD
MSG_TranslateMouseMsg( HWND hTopWnd
, DWORD first
, DWORD last
,
102 MSG
*msg
, BOOL remove
, WND
* pWndScope
,
103 INT16
*pHitTest
, POINT16
*pScreen_pt
, BOOL
*pmouseClick
)
105 static DWORD dblclk_time_limit
= 0;
106 static UINT16 clk_message
= 0;
107 static HWND16 clk_hwnd
= 0;
108 static POINT16 clk_pos
= { 0, 0 };
113 UINT message
= msg
->message
;
114 POINT16 screen_pt
, pt
;
115 HANDLE16 hQ
= GetFastQueue16();
116 MESSAGEQUEUE
*queue
= QUEUE_Lock(hQ
);
117 BOOL mouseClick
= ((message
== WM_LBUTTONDOWN
) ||
118 (message
== WM_RBUTTONDOWN
) ||
119 (message
== WM_MBUTTONDOWN
))?1:0;
122 /* Find the window to dispatch this mouse message to */
124 CONV_POINT32TO16( &msg
->pt
, &pt
);
128 /* If no capture HWND, find window which contains the mouse position.
129 * Also find the position of the cursor hot spot (hittest) */
132 ht
= hittest
= WINPOS_WindowFromPoint( pWndScope
, pt
, &pWnd
);
133 if( !pWnd
) pWnd
= WIN_GetDesktop();
134 else WIN_LockWndPtr(pWnd
);
135 hWnd
= pWnd
->hwndSelf
;
139 ht
= hittest
= HTCLIENT
;
140 pWnd
= WIN_FindWndPtr(hWnd
);
142 ht
= PERQDATA_GetCaptureInfo( queue
->pQData
);
145 /* Save hittest for return */
148 /* stop if not the right queue */
150 if (pWnd
->hmemTaskQ
!= hQ
)
152 /* Not for the current task */
153 if (queue
) QUEUE_ClearWakeBit( queue
, QS_MOUSE
);
154 /* Wake up the other task */
155 QUEUE_Unlock( queue
);
156 queue
= QUEUE_Lock( pWnd
->hmemTaskQ
);
157 if (queue
) QUEUE_SetWakeBit( queue
, QS_MOUSE
);
159 QUEUE_Unlock( queue
);
160 retvalue
= SYSQ_MSG_ABANDON
;
164 /* check if hWnd is within hWndScope */
166 if( hTopWnd
&& hWnd
!= hTopWnd
)
167 if( !IsChild(hTopWnd
, hWnd
) )
169 QUEUE_Unlock( queue
);
170 retvalue
= SYSQ_MSG_CONTINUE
;
174 /* Was it a mouse click message */
177 /* translate double clicks -
178 * note that ...MOUSEMOVEs can slip in between
179 * ...BUTTONDOWN and ...BUTTONDBLCLK messages */
181 if(GetClassLongA(hWnd
, GCL_STYLE
) & CS_DBLCLKS
|| ht
!= HTCLIENT
)
183 if ((message
== clk_message
) && (hWnd
== clk_hwnd
) &&
184 (msg
->time
- dblclk_time_limit
< doubleClickSpeed
) &&
185 (abs(msg
->pt
.x
- clk_pos
.x
) < GetSystemMetrics(SM_CXDOUBLECLK
)/2) &&
186 (abs(msg
->pt
.y
- clk_pos
.y
) < GetSystemMetrics(SM_CYDOUBLECLK
)/2))
188 message
+= (WM_LBUTTONDBLCLK
- WM_LBUTTONDOWN
);
189 mouseClick
++; /* == 2 */
193 /* save mouse position */
197 if (hittest
!= HTCLIENT
)
199 message
+= WM_NCMOUSEMOVE
- WM_MOUSEMOVE
;
200 msg
->wParam
= hittest
;
203 ScreenToClient16( hWnd
, &pt
);
205 /* check message filter */
207 if (!MSG_CheckFilter(message
, first
, last
))
210 retvalue
= SYSQ_MSG_CONTINUE
;
214 /* Update global hCursorQueue */
215 hCursorQueue
= queue
->self
;
217 /* Update static double click conditions */
218 if( remove
&& mouseClick
)
220 if( mouseClick
== 1 )
223 dblclk_time_limit
= msg
->time
;
224 clk_message
= msg
->message
;
228 /* got double click - zero them out */
229 dblclk_time_limit
= clk_hwnd
= 0;
234 /* Update message params */
236 msg
->message
= message
;
237 msg
->lParam
= MAKELONG( pt
.x
, pt
.y
);
238 retvalue
= SYSQ_MSG_ACCEPT
;
241 WIN_ReleaseWndPtr(pWnd
);
243 /* Return mouseclick flag */
244 *pmouseClick
= mouseClick
;
250 /***********************************************************************
251 * MSG_ProcessMouseMsg
253 * Processes a translated mouse hardware event.
254 * The passed in msg structure should contain the updated hWnd,
255 * lParam, wParam and message fields from MSG_TranslateMouseMsg.
259 * SYSQ_MSG_SKIP - Message should be skipped entirely (in this case
260 * HIWORD contains hit test code). Continue translating..
261 * SYSQ_MSG_ACCEPT - the translated message must be passed to the user
262 * MSG_PeekHardwareMsg should return TRUE.
264 static DWORD
MSG_ProcessMouseMsg( MSG
*msg
, BOOL remove
, INT16 hittest
,
265 POINT16 screen_pt
, BOOL mouseClick
)
268 HWND hWnd
= msg
->hwnd
;
269 INT16 sendSC
= (GetCapture() == 0);
270 UINT message
= msg
->message
;
274 pWnd
= WIN_FindWndPtr(hWnd
);
278 if (HOOK_IsHooked( WH_MOUSE
))
281 MOUSEHOOKSTRUCT16
*hook
= SEGPTR_NEW(MOUSEHOOKSTRUCT16
);
284 hook
->pt
= screen_pt
;
286 hook
->wHitTestCode
= hittest
;
287 hook
->dwExtraInfo
= 0;
288 ret
= HOOK_CallHooks16( WH_MOUSE
, remove
? HC_ACTION
: HC_NOREMOVE
,
289 message
, (LPARAM
)SEGPTR_GET(hook
) );
294 retvalue
= MAKELONG((INT16
)SYSQ_MSG_SKIP
, hittest
);
299 if (message
>= WM_NCMOUSEFIRST
&& message
<= WM_NCMOUSELAST
)
300 message
+= WM_MOUSEFIRST
- WM_NCMOUSEFIRST
;
302 if ((hittest
== HTERROR
) || (hittest
== HTNOWHERE
))
304 else if( remove
&& mouseClick
)
306 HWND hwndTop
= WIN_GetTopParent( hWnd
);
310 /* Send the WM_PARENTNOTIFY,
311 * note that even for double/nonclient clicks
312 * notification message is still WM_L/M/RBUTTONDOWN.
315 MSG_SendParentNotify( pWnd
, message
, 0, MAKELPARAM(screen_pt
.x
, screen_pt
.y
) );
317 /* Activate the window if needed */
319 if (hWnd
!= GetActiveWindow() && hWnd
!= GetDesktopWindow())
321 LONG ret
= SendMessageA( hWnd
, WM_MOUSEACTIVATE
, hwndTop
,
322 MAKELONG( hittest
, message
) );
324 if ((ret
== MA_ACTIVATEANDEAT
) || (ret
== MA_NOACTIVATEANDEAT
))
327 if (((ret
== MA_ACTIVATE
) || (ret
== MA_ACTIVATEANDEAT
))
328 && hwndTop
!= GetForegroundWindow() )
330 if (!WINPOS_SetActiveWindow( hwndTop
, TRUE
, TRUE
))
335 } else sendSC
= (remove
&& sendSC
);
337 /* Send the WM_SETCURSOR message */
341 /* Windows sends the normal mouse message as the message parameter
342 in the WM_SETCURSOR message even if it's non-client mouse message */
343 SendMessageA( hWnd
, WM_SETCURSOR
, hWnd
,
344 MAKELONG( hittest
, message
));
348 retvalue
= MAKELONG( (UINT16
)SYSQ_MSG_SKIP
, hittest
);
352 retvalue
= SYSQ_MSG_ACCEPT
;
354 WIN_ReleaseWndPtr(pWnd
);
360 /***********************************************************************
361 * MSG_TranslateKbdMsg
363 * Translate a keyboard hardware event into a real message.
365 static DWORD
MSG_TranslateKbdMsg( HWND hTopWnd
, DWORD first
, DWORD last
,
366 MSG
*msg
, BOOL remove
)
368 WORD message
= msg
->message
;
369 HWND hWnd
= GetFocus();
372 /* Should check Ctrl-Esc and PrintScreen here */
376 /* Send the message to the active window instead, */
377 /* translating messages to their WM_SYS equivalent */
379 hWnd
= GetActiveWindow();
381 if( message
< WM_SYSKEYDOWN
)
382 message
+= WM_SYSKEYDOWN
- WM_KEYDOWN
;
384 if ( !hWnd
) return SYSQ_MSG_ABANDON
;
385 pWnd
= WIN_FindWndPtr( hWnd
);
387 if (pWnd
&& (pWnd
->hmemTaskQ
!= GetFastQueue16()))
389 /* Not for the current task */
390 MESSAGEQUEUE
*queue
= QUEUE_Lock( GetFastQueue16() );
391 if (queue
) QUEUE_ClearWakeBit( queue
, QS_KEY
);
392 QUEUE_Unlock( queue
);
394 /* Wake up the other task */
395 queue
= QUEUE_Lock( pWnd
->hmemTaskQ
);
396 if (queue
) QUEUE_SetWakeBit( queue
, QS_KEY
);
397 QUEUE_Unlock( queue
);
398 WIN_ReleaseWndPtr(pWnd
);
399 return SYSQ_MSG_ABANDON
;
401 WIN_ReleaseWndPtr(pWnd
);
403 if (hTopWnd
&& hWnd
!= hTopWnd
)
404 if (!IsChild(hTopWnd
, hWnd
)) return SYSQ_MSG_CONTINUE
;
405 if (!MSG_CheckFilter(message
, first
, last
)) return SYSQ_MSG_CONTINUE
;
408 msg
->message
= message
;
410 return SYSQ_MSG_ACCEPT
;
414 /***********************************************************************
417 * Processes a translated keyboard message
419 static DWORD
MSG_ProcessKbdMsg( MSG
*msg
, BOOL remove
)
421 /* Handle F1 key by sending out WM_HELP message */
422 if ((msg
->message
== WM_KEYUP
) &&
423 (msg
->wParam
== VK_F1
) &&
425 (msg
->hwnd
!= GetDesktopWindow()) &&
426 !MENU_IsMenuActive())
429 WND
*pWnd
= WIN_FindWndPtr(msg
->hwnd
);
433 hi
.cbSize
= sizeof(HELPINFO
);
434 hi
.iContextType
= HELPINFO_WINDOW
;
435 hi
.iCtrlId
= pWnd
->wIDmenu
;
436 hi
.hItemHandle
= msg
->hwnd
;
437 hi
.dwContextId
= pWnd
->helpContext
;
438 hi
.MousePos
= msg
->pt
;
439 SendMessageA(msg
->hwnd
, WM_HELP
, 0, (LPARAM
)&hi
);
441 WIN_ReleaseWndPtr(pWnd
);
444 return (HOOK_CallHooks16( WH_KEYBOARD
, remove
? HC_ACTION
: HC_NOREMOVE
,
445 LOWORD (msg
->wParam
), msg
->lParam
)
446 ? SYSQ_MSG_SKIP
: SYSQ_MSG_ACCEPT
);
450 /***********************************************************************
451 * MSG_JournalRecordMsg
453 * Build an EVENTMSG structure and call JOURNALRECORD hook
455 static void MSG_JournalRecordMsg( MSG
*msg
)
459 event
.message
= msg
->message
;
460 event
.time
= msg
->time
;
461 if ((msg
->message
>= WM_KEYFIRST
) && (msg
->message
<= WM_KEYLAST
))
463 event
.paramL
= (msg
->wParam
& 0xFF) | (HIWORD(msg
->lParam
) << 8);
464 event
.paramH
= msg
->lParam
& 0x7FFF;
465 if (HIWORD(msg
->lParam
) & 0x0100)
466 event
.paramH
|= 0x8000; /* special_key - bit */
467 HOOK_CallHooksA( WH_JOURNALRECORD
, HC_ACTION
, 0, (LPARAM
)&event
);
469 else if ((msg
->message
>= WM_MOUSEFIRST
) && (msg
->message
<= WM_MOUSELAST
))
472 pt
.x
= SLOWORD(msg
->lParam
);
473 pt
.y
= SHIWORD(msg
->lParam
);
474 ClientToScreen( msg
->hwnd
, &pt
);
477 HOOK_CallHooksA( WH_JOURNALRECORD
, HC_ACTION
, 0, (LPARAM
)&event
);
479 else if ((msg
->message
>= WM_NCMOUSEFIRST
) &&
480 (msg
->message
<= WM_NCMOUSELAST
))
482 event
.paramL
= LOWORD(msg
->lParam
); /* X pos */
483 event
.paramH
= HIWORD(msg
->lParam
); /* Y pos */
484 event
.message
+= WM_MOUSEMOVE
-WM_NCMOUSEMOVE
;/* give no info about NC area */
485 HOOK_CallHooksA( WH_JOURNALRECORD
, HC_ACTION
, 0, (LPARAM
)&event
);
489 /***********************************************************************
490 * MSG_JournalPlayBackMsg
492 * Get an EVENTMSG struct via call JOURNALPLAYBACK hook function
494 static int MSG_JournalPlayBackMsg(void)
502 if (!HOOK_IsHooked( WH_JOURNALPLAYBACK
)) return 0;
504 wtime
=HOOK_CallHooksA( WH_JOURNALPLAYBACK
, HC_GETNEXT
, 0, (LPARAM
)&tmpMsg
);
505 /* TRACE(msg,"Playback wait time =%ld\n",wtime); */
509 if ((tmpMsg
.message
>= WM_KEYFIRST
) && (tmpMsg
.message
<= WM_KEYLAST
))
511 wParam
=tmpMsg
.paramL
& 0xFF;
512 lParam
=MAKELONG(tmpMsg
.paramH
&0x7ffff,tmpMsg
.paramL
>>8);
513 if (tmpMsg
.message
== WM_KEYDOWN
|| tmpMsg
.message
== WM_SYSKEYDOWN
)
515 for (keyDown
=i
=0; i
<256 && !keyDown
; i
++)
516 if (InputKeyStateTable
[i
] & 0x80)
519 lParam
|= 0x40000000;
520 AsyncKeyStateTable
[wParam
]=InputKeyStateTable
[wParam
] |= 0x80;
522 else /* WM_KEYUP, WM_SYSKEYUP */
524 lParam
|= 0xC0000000;
525 AsyncKeyStateTable
[wParam
]=InputKeyStateTable
[wParam
] &= ~0x80;
527 if (InputKeyStateTable
[VK_MENU
] & 0x80)
528 lParam
|= 0x20000000;
529 if (tmpMsg
.paramH
& 0x8000) /*special_key bit*/
530 lParam
|= 0x01000000;
531 hardware_event( tmpMsg
.message
, wParam
, lParam
, 0, 0, tmpMsg
.time
, 0 );
533 else if ((tmpMsg
.message
>= WM_MOUSEFIRST
) && (tmpMsg
.message
<= WM_MOUSELAST
))
535 switch (tmpMsg
.message
)
538 MouseButtonsStates
[0]=AsyncMouseButtonsStates
[0]=TRUE
;break;
540 MouseButtonsStates
[0]=AsyncMouseButtonsStates
[0]=FALSE
;break;
542 MouseButtonsStates
[1]=AsyncMouseButtonsStates
[1]=TRUE
;break;
544 MouseButtonsStates
[1]=AsyncMouseButtonsStates
[1]=FALSE
;break;
546 MouseButtonsStates
[2]=AsyncMouseButtonsStates
[2]=TRUE
;break;
548 MouseButtonsStates
[2]=AsyncMouseButtonsStates
[2]=FALSE
;break;
550 AsyncKeyStateTable
[VK_LBUTTON
]= InputKeyStateTable
[VK_LBUTTON
] = MouseButtonsStates
[0] ? 0x80 : 0;
551 AsyncKeyStateTable
[VK_MBUTTON
]= InputKeyStateTable
[VK_MBUTTON
] = MouseButtonsStates
[1] ? 0x80 : 0;
552 AsyncKeyStateTable
[VK_RBUTTON
]= InputKeyStateTable
[VK_RBUTTON
] = MouseButtonsStates
[2] ? 0x80 : 0;
553 SetCursorPos(tmpMsg
.paramL
,tmpMsg
.paramH
);
554 lParam
=MAKELONG(tmpMsg
.paramL
,tmpMsg
.paramH
);
556 if (MouseButtonsStates
[0]) wParam
|= MK_LBUTTON
;
557 if (MouseButtonsStates
[1]) wParam
|= MK_MBUTTON
;
558 if (MouseButtonsStates
[2]) wParam
|= MK_RBUTTON
;
559 hardware_event( tmpMsg
.message
, wParam
, lParam
,
560 tmpMsg
.paramL
, tmpMsg
.paramH
, tmpMsg
.time
, 0 );
562 HOOK_CallHooksA( WH_JOURNALPLAYBACK
, HC_SKIP
, 0, (LPARAM
)&tmpMsg
);
567 if( tmpMsg
.message
== WM_QUEUESYNC
)
568 if (HOOK_IsHooked( WH_CBT
))
569 HOOK_CallHooksA( WH_CBT
, HCBT_QS
, 0, 0L);
571 return QS_MOUSE
| QS_KEY
; /* ? */
575 /***********************************************************************
576 * MSG_PeekHardwareMsg
578 * Peek for a hardware message matching the hwnd and message filters.
580 static BOOL
MSG_PeekHardwareMsg( MSG
*msg
, HWND hwnd
, DWORD first
, DWORD last
,
583 DWORD status
= SYSQ_MSG_ACCEPT
;
584 MESSAGEQUEUE
*sysMsgQueue
= QUEUE_GetSysQueue();
585 enum { MOUSE_MSG
= 0, KEYBOARD_MSG
, HARDWARE_MSG
} msgType
;
586 QMSG
*nextqmsg
, *qmsg
= 0;
589 EnterCriticalSection(&sysMsgQueue
->cSection
);
591 /* Loop through the Q and translate the message we wish to process
592 * while we own the lock. Based on the translation status (abandon/cont/accept)
593 * we then process the message accordingly
596 for ( qmsg
= sysMsgQueue
->firstMsg
; qmsg
; qmsg
= nextqmsg
)
604 nextqmsg
= qmsg
->nextMsg
;
606 /* Translate message */
608 if ((msg
->message
>= WM_MOUSEFIRST
) && (msg
->message
<= WM_MOUSELAST
))
610 HWND hWndScope
= (HWND
)qmsg
->extraInfo
;
611 WND
*tmpWnd
= (Options
.managed
&& IsWindow(hWndScope
) )
612 ? WIN_FindWndPtr(hWndScope
) : WIN_GetDesktop();
614 status
= MSG_TranslateMouseMsg(hwnd
, first
, last
, msg
, remove
, tmpWnd
,
615 &hittest
, &screen_pt
, &mouseClick
);
618 WIN_ReleaseWndPtr(tmpWnd
);
621 else if ((msg
->message
>= WM_KEYFIRST
) && (msg
->message
<= WM_KEYLAST
))
623 status
= MSG_TranslateKbdMsg(hwnd
, first
, last
, msg
, remove
);
624 msgType
= KEYBOARD_MSG
;
626 else /* Non-standard hardware event */
628 HARDWAREHOOKSTRUCT16
*hook
;
629 msgType
= HARDWARE_MSG
;
630 if ((hook
= SEGPTR_NEW(HARDWAREHOOKSTRUCT16
)))
633 hook
->hWnd
= msg
->hwnd
;
634 hook
->wMessage
= msg
->message
& 0xffff;
635 hook
->wParam
= LOWORD (msg
->wParam
);
636 hook
->lParam
= msg
->lParam
;
637 ret
= HOOK_CallHooks16( WH_HARDWARE
,
638 remove
? HC_ACTION
: HC_NOREMOVE
,
639 0, (LPARAM
)SEGPTR_GET(hook
) );
643 QUEUE_RemoveMsg( sysMsgQueue
, qmsg
);
646 status
= SYSQ_MSG_ACCEPT
;
651 switch (LOWORD(status
))
653 case SYSQ_MSG_ACCEPT
:
655 /* Remove the message from the system msg Q while it is still locked,
656 * before accepting it */
659 if (HOOK_IsHooked( WH_JOURNALRECORD
)) MSG_JournalRecordMsg( msg
);
660 QUEUE_RemoveMsg( sysMsgQueue
, qmsg
);
662 /* Now actually process the message, after we unlock the system msg Q.
663 * We should not hold on to the crst since SendMessage calls during processing
664 * will potentially cause callbacks to PeekMessage from the application.
665 * If we're holding the crst and QUEUE_WaitBits is called with a
666 * QS_SENDMESSAGE mask we will deadlock in hardware_event() when a
667 * message is being posted to the Q.
669 LeaveCriticalSection(&sysMsgQueue
->cSection
);
670 if( msgType
== KEYBOARD_MSG
)
671 status
= MSG_ProcessKbdMsg( msg
, remove
);
672 else if ( msgType
== MOUSE_MSG
)
673 status
= MSG_ProcessMouseMsg( msg
, remove
, hittest
, screen_pt
, mouseClick
);
675 /* Reclaim the sys msg Q crst */
676 EnterCriticalSection(&sysMsgQueue
->cSection
);
678 /* Pass the translated message to the user if it was accepted */
679 if (status
== SYSQ_MSG_ACCEPT
)
682 /* If not accepted, fall through into the SYSQ_MSG_SKIP case */
686 if (HOOK_IsHooked( WH_CBT
))
688 if( msgType
== KEYBOARD_MSG
)
689 HOOK_CallHooks16( WH_CBT
, HCBT_KEYSKIPPED
,
690 LOWORD (msg
->wParam
), msg
->lParam
);
691 else if ( msgType
== MOUSE_MSG
)
693 MOUSEHOOKSTRUCT16
*hook
= SEGPTR_NEW(MOUSEHOOKSTRUCT16
);
696 CONV_POINT32TO16( &msg
->pt
,&hook
->pt
);
697 hook
->hwnd
= msg
->hwnd
;
698 hook
->wHitTestCode
= HIWORD(status
);
699 hook
->dwExtraInfo
= 0;
700 HOOK_CallHooks16( WH_CBT
, HCBT_CLICKSKIPPED
,msg
->message
& 0xffff,
701 (LPARAM
)SEGPTR_GET(hook
) );
707 /* If the message was removed earlier set up nextqmsg so that we start
708 * at the top of the queue again. We need to do this since our next pointer
709 * could be invalid due to us unlocking the system message Q to process the message.
710 * If not removed just refresh nextqmsg to point to the next msg.
713 nextqmsg
= sysMsgQueue
->firstMsg
;
715 nextqmsg
= qmsg
->nextMsg
;
719 case SYSQ_MSG_CONTINUE
:
722 case SYSQ_MSG_ABANDON
:
732 LeaveCriticalSection(&sysMsgQueue
->cSection
);
737 /**********************************************************************
738 * SetDoubleClickTime (USER.20)
740 void WINAPI
SetDoubleClickTime16( UINT16 interval
)
742 SetDoubleClickTime( interval
);
746 /**********************************************************************
747 * SetDoubleClickTime (USER32.@)
749 BOOL WINAPI
SetDoubleClickTime( UINT interval
)
751 doubleClickSpeed
= interval
? interval
: 500;
756 /**********************************************************************
757 * GetDoubleClickTime (USER.21)
759 UINT16 WINAPI
GetDoubleClickTime16(void)
761 return doubleClickSpeed
;
765 /**********************************************************************
766 * GetDoubleClickTime (USER32.@)
768 UINT WINAPI
GetDoubleClickTime(void)
770 return doubleClickSpeed
;
774 /***********************************************************************
775 * MSG_SendMessageInterThread
777 * Implementation of an inter-task SendMessage.
779 * 0 if error or timeout
782 static LRESULT
MSG_SendMessageInterThread( HQUEUE16 hDestQueue
,
784 WPARAM wParam
, LPARAM lParam
,
785 DWORD timeout
, WORD flags
,
788 MESSAGEQUEUE
*queue
, *destQ
;
795 if (IsTaskLocked16() || !IsWindow(hwnd
))
798 /* create a SMSG structure to hold SendMessage() parameters */
799 if (! (smsg
= (SMSG
*) HeapAlloc( GetProcessHeap(), 0, sizeof(SMSG
) )) )
801 if (!(queue
= QUEUE_Lock( GetFastQueue16() ))) return 0;
803 if (!(destQ
= QUEUE_Lock( hDestQueue
)))
805 QUEUE_Unlock( queue
);
809 TRACE_(sendmsg
)("SM: %s [%04x] (%04x -> %04x)\n",
810 SPY_GetMsgName(msg
), msg
, queue
->self
, hDestQueue
);
812 /* fill up SMSG structure */
815 smsg
->wParam
= wParam
;
816 smsg
->lParam
= lParam
;
819 smsg
->hSrcQueue
= pRes
? GetFastQueue16() : 0;
820 smsg
->hDstQueue
= hDestQueue
;
824 /* add smsg struct in the processing SM list of the source queue */
825 QUEUE_AddSMSG(queue
, SM_PROCESSING_LIST
, smsg
);
827 /* this is a notification message, we don't need a reply */
828 smsg
->flags
|= SMSG_ALREADY_REPLIED
| SMSG_RECEIVER_CLEANS
;
831 /* add smsg struct in the pending list of the destination queue */
832 if (QUEUE_AddSMSG(destQ
, SM_PENDING_LIST
, smsg
) == FALSE
)
838 if (!pRes
) goto CLEANUP
; /* don't need a reply */
840 iWndsLocks
= WIN_SuspendWndsLock();
842 /* wait for the result */
846 * The sequence is crucial to avoid deadlock situations:
847 * - first, we clear the QS_SMRESULT bit
848 * - then, we check the SMSG_HAVE_RESULT bit
849 * - only if this isn't set, we enter the wait state.
851 * As the receiver first sets the SMSG_HAVE_RESULT and then wakes us,
852 * we are guaranteed that -should we now clear the QS_SMRESULT that
853 * was signalled already by the receiver- we will not start waiting.
856 if ( smsg
->flags
& SMSG_HAVE_RESULT
)
859 *pRes
= smsg
->lResult
;
860 TRACE_(sendmsg
)("smResult = %08x\n", (unsigned)*pRes
);
864 QUEUE_ClearWakeBit( queue
, QS_SMRESULT
);
866 if ( smsg
->flags
& SMSG_HAVE_RESULT
)
869 if( QUEUE_WaitBits( QS_SMRESULT
, timeout
) == 0 )
871 /* return with timeout */
877 WIN_RestoreWndsLock(iWndsLocks
);
879 /* remove the smsg from the processing list of the source queue */
880 QUEUE_RemoveSMSG( queue
, SM_PROCESSING_LIST
, smsg
);
882 /* Note: the destination thread is in charge of removing the smsg from
885 /* In the case of an early reply (or a timeout), sender thread will
886 released the smsg structure if the receiver thread is done
887 (SMSG_RECEIVED set). If the receiver thread isn't done,
888 SMSG_RECEIVER_CLEANS_UP flag is set, and it will be the receiver
889 responsibility to release smsg */
890 EnterCriticalSection( &queue
->cSection
);
892 if (smsg
->flags
& SMSG_RECEIVED
)
893 HeapFree(GetProcessHeap(), 0, smsg
);
895 smsg
->flags
|= SMSG_RECEIVER_CLEANS
;
897 LeaveCriticalSection( &queue
->cSection
);
901 QUEUE_Unlock( queue
);
902 QUEUE_Unlock( destQ
);
904 TRACE_(sendmsg
)("done!\n");
909 /***********************************************************************
910 * ReplyMessage (USER.115)
912 void WINAPI
ReplyMessage16( LRESULT result
)
914 ReplyMessage( result
);
917 /***********************************************************************
918 * ReplyMessage (USER32.@)
920 BOOL WINAPI
ReplyMessage( LRESULT result
)
922 MESSAGEQUEUE
*senderQ
= 0;
923 MESSAGEQUEUE
*queue
= 0;
927 if (!(queue
= QUEUE_Lock( GetFastQueue16() )))
930 TRACE_(sendmsg
)("ReplyMessage, queue %04x\n", queue
->self
);
933 if ( !(smsg
= queue
->smWaiting
)
934 || !( (senderQ
= QUEUE_Lock( smsg
->hSrcQueue
))
935 || (smsg
->flags
& SMSG_ALREADY_REPLIED
)) )
936 goto ReplyMessageEnd
;
938 if ( !(smsg
->flags
& SMSG_ALREADY_REPLIED
) )
940 /* This is the first reply, so pass result to sender */
942 TRACE_(sendmsg
)("\trpm: smResult = %08lx\n", (long) result
);
944 EnterCriticalSection(&senderQ
->cSection
);
946 smsg
->lResult
= result
;
947 smsg
->flags
|= SMSG_ALREADY_REPLIED
;
949 /* check if it's an early reply (called by the application) or
950 a regular reply (called by ReceiveMessage) */
951 if ( !(smsg
->flags
& SMSG_SENDING_REPLY
) )
952 smsg
->flags
|= SMSG_EARLY_REPLY
;
954 smsg
->flags
|= SMSG_HAVE_RESULT
;
956 LeaveCriticalSection(&senderQ
->cSection
);
958 /* tell the sending task that its reply is ready */
959 QUEUE_SetWakeBit( senderQ
, QS_SMRESULT
);
964 if (smsg
->flags
& SMSG_SENDING_REPLY
)
966 /* remove msg from the waiting list, since this is the last
968 QUEUE_RemoveSMSG( queue
, SM_WAITING_LIST
, smsg
);
970 if (senderQ
) EnterCriticalSection(&senderQ
->cSection
);
972 /* tell the sender we're all done with smsg structure */
973 smsg
->flags
|= SMSG_RECEIVED
;
975 /* sender will set SMSG_RECEIVER_CLEANS_UP if it wants the
976 receiver to clean up smsg, it could only happen when there is
977 an early reply or a timeout */
978 if ( smsg
->flags
& SMSG_RECEIVER_CLEANS
)
980 TRACE_(sendmsg
)("Receiver cleans up!\n" );
981 HeapFree( GetProcessHeap(), 0, smsg
);
984 if (senderQ
) LeaveCriticalSection(&senderQ
->cSection
);
989 QUEUE_Unlock( senderQ
);
991 QUEUE_Unlock( queue
);
996 /***********************************************************************
999 static BOOL
MSG_ConvertMsg( MSG
*msg
, int srcType
, int dstType
)
1004 switch ( MAKELONG( srcType
, dstType
) )
1006 case MAKELONG( QMSG_WIN16
, QMSG_WIN16
):
1007 case MAKELONG( QMSG_WIN32A
, QMSG_WIN32A
):
1008 case MAKELONG( QMSG_WIN32W
, QMSG_WIN32W
):
1011 case MAKELONG( QMSG_WIN16
, QMSG_WIN32A
):
1012 switch ( WINPROC_MapMsg16To32A( msg
->message
, msg
->wParam
,
1013 &msg
->message
, &msg
->wParam
, &msg
->lParam
) )
1018 /* Pointer messages were mapped --> need to free allocated memory and fail */
1019 WINPROC_UnmapMsg16To32A( msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
, 0 );
1024 case MAKELONG( QMSG_WIN16
, QMSG_WIN32W
):
1025 switch ( WINPROC_MapMsg16To32W( msg
->hwnd
, msg
->message
, msg
->wParam
,
1026 &msg
->message
, &msg
->wParam
, &msg
->lParam
) )
1031 /* Pointer messages were mapped --> need to free allocated memory and fail */
1032 WINPROC_UnmapMsg16To32W( msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
, 0 );
1037 case MAKELONG( QMSG_WIN32A
, QMSG_WIN16
):
1038 mp16
.lParam
= msg
->lParam
;
1039 switch ( WINPROC_MapMsg32ATo16( msg
->hwnd
, msg
->message
, msg
->wParam
,
1040 &msg16
, &mp16
.wParam
, &mp16
.lParam
) )
1043 msg
->message
= msg16
;
1044 msg
->wParam
= mp16
.wParam
;
1045 msg
->lParam
= mp16
.lParam
;
1048 /* Pointer messages were mapped --> need to free allocated memory and fail */
1049 WINPROC_UnmapMsg32ATo16( msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
, &mp16
);
1054 case MAKELONG( QMSG_WIN32W
, QMSG_WIN16
):
1055 mp16
.lParam
= msg
->lParam
;
1056 switch ( WINPROC_MapMsg32WTo16( msg
->hwnd
, msg
->message
, msg
->wParam
,
1057 &msg16
, &mp16
.wParam
, &mp16
.lParam
) )
1060 msg
->message
= msg16
;
1061 msg
->wParam
= mp16
.wParam
;
1062 msg
->lParam
= mp16
.lParam
;
1065 /* Pointer messages were mapped --> need to free allocated memory and fail */
1066 WINPROC_UnmapMsg32WTo16( msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
, &mp16
);
1071 case MAKELONG( QMSG_WIN32A
, QMSG_WIN32W
):
1072 switch ( WINPROC_MapMsg32ATo32W( msg
->hwnd
, msg
->message
, &msg
->wParam
, &msg
->lParam
) )
1077 /* Pointer messages were mapped --> need to free allocated memory and fail */
1078 WINPROC_UnmapMsg32ATo32W( msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
1083 case MAKELONG( QMSG_WIN32W
, QMSG_WIN32A
):
1084 switch ( WINPROC_MapMsg32WTo32A( msg
->hwnd
, msg
->message
, &msg
->wParam
, &msg
->lParam
) )
1089 /* Pointer messages were mapped --> need to free allocated memory and fail */
1090 WINPROC_UnmapMsg32WTo32A( msg
->hwnd
, msg
->message
, msg
->wParam
, msg
->lParam
);
1096 FIXME( "Invalid message type(s): %d / %d\n", srcType
, dstType
);
1101 /***********************************************************************
1104 static BOOL
MSG_PeekMessage( int type
, LPMSG msg_out
, HWND hwnd
,
1105 DWORD first
, DWORD last
, WORD flags
, BOOL peek
)
1107 int changeBits
, mask
;
1108 MESSAGEQUEUE
*msgQueue
;
1113 mask
= QS_POSTMESSAGE
| QS_SENDMESSAGE
; /* Always selected */
1116 if ((first
<= WM_KEYLAST
) && (last
>= WM_KEYFIRST
)) mask
|= QS_KEY
;
1117 if ( ((first
<= WM_MOUSELAST
) && (last
>= WM_MOUSEFIRST
)) ||
1118 ((first
<= WM_NCMOUSELAST
) && (last
>= WM_NCMOUSEFIRST
)) ) mask
|= QS_MOUSE
;
1119 if ((first
<= WM_TIMER
) && (last
>= WM_TIMER
)) mask
|= QS_TIMER
;
1120 if ((first
<= WM_SYSTIMER
) && (last
>= WM_SYSTIMER
)) mask
|= QS_TIMER
;
1121 if ((first
<= WM_PAINT
) && (last
>= WM_PAINT
)) mask
|= QS_PAINT
;
1123 else mask
|= QS_MOUSE
| QS_KEY
| QS_TIMER
| QS_PAINT
;
1125 if (IsTaskLocked16()) flags
|= PM_NOYIELD
;
1127 iWndsLocks
= WIN_SuspendWndsLock();
1133 hQueue
= GetFastQueue16();
1134 msgQueue
= QUEUE_Lock( hQueue
);
1137 WIN_RestoreWndsLock(iWndsLocks
);
1141 EnterCriticalSection( &msgQueue
->cSection
);
1142 msgQueue
->changeBits
= 0;
1143 LeaveCriticalSection( &msgQueue
->cSection
);
1145 /* First handle a message put by SendMessage() */
1147 while ( QUEUE_ReceiveMessage( msgQueue
) )
1150 /* Now handle a WM_QUIT message */
1152 EnterCriticalSection( &msgQueue
->cSection
);
1153 if (msgQueue
->wPostQMsg
&&
1154 (!first
|| WM_QUIT
>= first
) &&
1155 (!last
|| WM_QUIT
<= last
) )
1158 msg
.message
= WM_QUIT
;
1159 msg
.wParam
= msgQueue
->wExitCode
;
1161 if (flags
& PM_REMOVE
) msgQueue
->wPostQMsg
= 0;
1162 LeaveCriticalSection( &msgQueue
->cSection
);
1165 LeaveCriticalSection( &msgQueue
->cSection
);
1167 /* Now find a normal message */
1170 if ((QUEUE_TestWakeBit(msgQueue
, mask
& QS_POSTMESSAGE
)) &&
1171 ((qmsg
= QUEUE_FindMsg( msgQueue
, hwnd
, first
, last
)) != 0))
1173 /* Try to convert message to requested type */
1174 MSG tmpMsg
= qmsg
->msg
;
1175 if ( !MSG_ConvertMsg( &tmpMsg
, qmsg
->type
, type
) )
1177 ERR( "Message %s of wrong type contains pointer parameters. Skipped!\n",
1178 SPY_GetMsgName(tmpMsg
.message
));
1179 QUEUE_RemoveMsg( msgQueue
, qmsg
);
1184 msgQueue
->GetMessageTimeVal
= msg
.time
;
1185 msgQueue
->GetMessagePosVal
= MAKELONG( (INT16
)msg
.pt
.x
, (INT16
)msg
.pt
.y
);
1186 msgQueue
->GetMessageExtraInfoVal
= qmsg
->extraInfo
;
1188 if (flags
& PM_REMOVE
) QUEUE_RemoveMsg( msgQueue
, qmsg
);
1192 changeBits
= MSG_JournalPlayBackMsg();
1193 EnterCriticalSection( &msgQueue
->cSection
);
1194 msgQueue
->changeBits
|= changeBits
;
1195 LeaveCriticalSection( &msgQueue
->cSection
);
1197 /* Now find a hardware event */
1199 if (MSG_PeekHardwareMsg( &msg
, hwnd
, first
, last
, flags
& PM_REMOVE
))
1202 msgQueue
->GetMessageTimeVal
= msg
.time
;
1203 msgQueue
->GetMessagePosVal
= MAKELONG( (INT16
)msg
.pt
.x
, (INT16
)msg
.pt
.y
);
1204 msgQueue
->GetMessageExtraInfoVal
= 0; /* Always 0 for now */
1208 /* Check again for SendMessage */
1210 while ( QUEUE_ReceiveMessage( msgQueue
) )
1213 /* Now find a WM_PAINT message */
1215 if (QUEUE_TestWakeBit(msgQueue
, mask
& QS_PAINT
))
1218 msg
.hwnd
= WIN_FindWinToRepaint( hwnd
, hQueue
);
1219 msg
.message
= WM_PAINT
;
1223 if ((wndPtr
= WIN_FindWndPtr(msg
.hwnd
)))
1225 if( wndPtr
->dwStyle
& WS_MINIMIZE
&&
1226 (HICON
) GetClassLongA(wndPtr
->hwndSelf
, GCL_HICON
) )
1228 msg
.message
= WM_PAINTICON
;
1232 if( !hwnd
|| msg
.hwnd
== hwnd
|| IsChild16(hwnd
,msg
.hwnd
) )
1234 if( wndPtr
->flags
& WIN_INTERNAL_PAINT
&& !wndPtr
->hrgnUpdate
)
1236 wndPtr
->flags
&= ~WIN_INTERNAL_PAINT
;
1237 QUEUE_DecPaintCount( hQueue
);
1239 WIN_ReleaseWndPtr(wndPtr
);
1242 WIN_ReleaseWndPtr(wndPtr
);
1246 /* Check for timer messages, but yield first */
1249 if (!(flags
& PM_NOYIELD
))
1252 while ( QUEUE_ReceiveMessage( msgQueue
) )
1257 if (QUEUE_TestWakeBit(msgQueue
, mask
& QS_TIMER
))
1259 if (TIMER_GetTimerMsg(&msg
, hwnd
, hQueue
, flags
& PM_REMOVE
)) break;
1265 if (!(flags
& PM_NOYIELD
)) UserYield16();
1267 QUEUE_Unlock( msgQueue
);
1268 WIN_RestoreWndsLock(iWndsLocks
);
1272 QUEUE_WaitBits( mask
, INFINITE
);
1273 QUEUE_Unlock( msgQueue
);
1276 WIN_RestoreWndsLock(iWndsLocks
);
1278 /* instead of unlocking queue for every break condition, all break
1279 condition will fall here */
1280 QUEUE_Unlock( msgQueue
);
1282 /* We got a message */
1283 if (flags
& PM_REMOVE
)
1285 WORD message
= msg
.message
;
1287 if (message
== WM_KEYDOWN
|| message
== WM_SYSKEYDOWN
)
1289 BYTE
*p
= &QueueKeyStateTable
[msg
.wParam
& 0xff];
1295 else if (message
== WM_KEYUP
|| message
== WM_SYSKEYUP
)
1296 QueueKeyStateTable
[msg
.wParam
& 0xff] &= ~0x80;
1299 /* copy back our internal safe copy of message data to msg_out.
1300 * msg_out is a variable from the *program*, so it can't be used
1301 * internally as it can get "corrupted" by our use of SendMessage()
1302 * (back to the program) inside the message handling itself. */
1308 return (msg
.message
!= WM_QUIT
);
1311 /***********************************************************************
1312 * MSG_InternalGetMessage
1314 * GetMessage() function for internal use. Behave like GetMessage(),
1315 * but also call message filters and optionally send WM_ENTERIDLE messages.
1316 * 'hwnd' must be the handle of the dialog or menu window.
1317 * 'code' is the message filter value (MSGF_??? codes).
1319 BOOL
MSG_InternalGetMessage( MSG
*msg
, HWND hwnd
, HWND hwndOwner
, UINT first
, UINT last
,
1320 WPARAM code
, WORD flags
, BOOL sendIdle
, BOOL
* idleSent
)
1326 if (!MSG_PeekMessage( QMSG_WIN32A
, msg
, 0, first
, last
, flags
, TRUE
))
1328 /* No message present -> send ENTERIDLE and wait */
1329 if (IsWindow(hwndOwner
))
1331 SendMessageA( hwndOwner
, WM_ENTERIDLE
,
1332 code
, (LPARAM
)hwnd
);
1337 MSG_PeekMessage( QMSG_WIN32A
, msg
, 0, first
, last
, flags
, FALSE
);
1340 else /* Always wait for a message */
1341 MSG_PeekMessage( QMSG_WIN32A
, msg
, 0, first
, last
, flags
, FALSE
);
1343 /* Call message filters */
1345 if (HOOK_IsHooked( WH_SYSMSGFILTER
) || HOOK_IsHooked( WH_MSGFILTER
))
1347 MSG
*pmsg
= HeapAlloc( GetProcessHeap(), 0, sizeof(MSG
) );
1352 ret
= (HOOK_CallHooksA( WH_SYSMSGFILTER
, code
, 0,
1354 HOOK_CallHooksA( WH_MSGFILTER
, code
, 0,
1357 HeapFree( GetProcessHeap(), 0, pmsg
);
1360 /* Message filtered -> remove it from the queue */
1361 /* if it's still there. */
1362 if (!(flags
& PM_REMOVE
))
1363 MSG_PeekMessage( QMSG_WIN32A
, msg
, 0, first
, last
, PM_REMOVE
, TRUE
);
1369 return (msg
->message
!= WM_QUIT
);
1374 /***********************************************************************
1375 * PeekMessage32 (USER.819)
1377 BOOL16 WINAPI
PeekMessage32_16( SEGPTR msg16_32
, HWND16 hwnd
,
1378 UINT16 first
, UINT16 last
, UINT16 flags
,
1379 BOOL16 wHaveParamHigh
)
1382 MSG32_16
*lpmsg16_32
= MapSL(msg16_32
);
1385 ret
= MSG_PeekMessage( QMSG_WIN16
, &msg
, hwnd
, first
, last
, flags
, TRUE
);
1387 lpmsg16_32
->msg
.hwnd
= msg
.hwnd
;
1388 lpmsg16_32
->msg
.message
= msg
.message
;
1389 lpmsg16_32
->msg
.wParam
= LOWORD(msg
.wParam
);
1390 lpmsg16_32
->msg
.lParam
= msg
.lParam
;
1391 lpmsg16_32
->msg
.time
= msg
.time
;
1392 lpmsg16_32
->msg
.pt
.x
= (INT16
)msg
.pt
.x
;
1393 lpmsg16_32
->msg
.pt
.y
= (INT16
)msg
.pt
.y
;
1395 if ( wHaveParamHigh
)
1396 lpmsg16_32
->wParamHigh
= HIWORD(msg
.wParam
);
1398 HOOK_CallHooks16( WH_GETMESSAGE
, HC_ACTION
, flags
& PM_REMOVE
, (LPARAM
)msg16_32
);
1402 /***********************************************************************
1403 * PeekMessage (USER.109)
1405 BOOL16 WINAPI
PeekMessage16( SEGPTR msg
, HWND16 hwnd
,
1406 UINT16 first
, UINT16 last
, UINT16 flags
)
1408 return PeekMessage32_16( msg
, hwnd
, first
, last
, flags
, FALSE
);
1411 /***********************************************************************
1412 * PeekMessageA (USER32.@)
1414 BOOL WINAPI
PeekMessageA( LPMSG lpmsg
, HWND hwnd
,
1415 UINT min
, UINT max
, UINT wRemoveMsg
)
1417 BOOL ret
= MSG_PeekMessage( QMSG_WIN32A
, lpmsg
, hwnd
, min
, max
, wRemoveMsg
, TRUE
);
1419 TRACE( "peekmessage %04x, hwnd %04x, filter(%04x - %04x)\n",
1420 lpmsg
->message
, hwnd
, min
, max
);
1422 if (ret
) HOOK_CallHooksA( WH_GETMESSAGE
, HC_ACTION
,
1423 wRemoveMsg
& PM_REMOVE
, (LPARAM
)lpmsg
);
1427 /***********************************************************************
1428 * PeekMessageW (USER32.@) Check queue for messages
1430 * Checks for a message in the thread's queue, filtered as for
1431 * GetMessage(). Returns immediately whether a message is available
1434 * Whether a retrieved message is removed from the queue is set by the
1435 * _wRemoveMsg_ flags, which should be one of the following values:
1437 * PM_NOREMOVE Do not remove the message from the queue.
1439 * PM_REMOVE Remove the message from the queue.
1441 * In addition, PM_NOYIELD may be combined into _wRemoveMsg_ to
1442 * request that the system not yield control during PeekMessage();
1443 * however applications may not rely on scheduling behavior.
1447 * Nonzero if a message is available and is retrieved, zero otherwise.
1454 BOOL WINAPI
PeekMessageW(
1455 LPMSG lpmsg
, /* [out] buffer to receive message */
1456 HWND hwnd
, /* [in] restrict to messages for hwnd */
1457 UINT min
, /* [in] minimum message to receive */
1458 UINT max
, /* [in] maximum message to receive */
1459 UINT wRemoveMsg
/* [in] removal flags */
1462 BOOL ret
= MSG_PeekMessage( QMSG_WIN32W
, lpmsg
, hwnd
, min
, max
, wRemoveMsg
, TRUE
);
1463 if (ret
) HOOK_CallHooksW( WH_GETMESSAGE
, HC_ACTION
,
1464 wRemoveMsg
& PM_REMOVE
, (LPARAM
)lpmsg
);
1469 /***********************************************************************
1470 * GetMessage32 (USER.820)
1472 BOOL16 WINAPI
GetMessage32_16( SEGPTR msg16_32
, HWND16 hWnd
, UINT16 first
,
1473 UINT16 last
, BOOL16 wHaveParamHigh
)
1475 MSG32_16
*lpmsg16_32
= MapSL(msg16_32
);
1478 MSG_PeekMessage( QMSG_WIN16
, &msg
, hWnd
, first
, last
, PM_REMOVE
, FALSE
);
1480 lpmsg16_32
->msg
.hwnd
= msg
.hwnd
;
1481 lpmsg16_32
->msg
.message
= msg
.message
;
1482 lpmsg16_32
->msg
.wParam
= LOWORD(msg
.wParam
);
1483 lpmsg16_32
->msg
.lParam
= msg
.lParam
;
1484 lpmsg16_32
->msg
.time
= msg
.time
;
1485 lpmsg16_32
->msg
.pt
.x
= (INT16
)msg
.pt
.x
;
1486 lpmsg16_32
->msg
.pt
.y
= (INT16
)msg
.pt
.y
;
1488 if ( wHaveParamHigh
)
1489 lpmsg16_32
->wParamHigh
= HIWORD(msg
.wParam
);
1491 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1492 lpmsg16_32
->msg
.message
, hWnd
, first
, last
);
1494 HOOK_CallHooks16( WH_GETMESSAGE
, HC_ACTION
, PM_REMOVE
, (LPARAM
)msg16_32
);
1495 return lpmsg16_32
->msg
.message
!= WM_QUIT
;
1498 /***********************************************************************
1499 * GetMessage (USER.108)
1501 BOOL16 WINAPI
GetMessage16( SEGPTR msg
, HWND16 hwnd
, UINT16 first
, UINT16 last
)
1503 return GetMessage32_16( msg
, hwnd
, first
, last
, FALSE
);
1506 /***********************************************************************
1507 * GetMessageA (USER32.@)
1509 BOOL WINAPI
GetMessageA( MSG
*lpmsg
, HWND hwnd
, UINT min
, UINT max
)
1511 MSG_PeekMessage( QMSG_WIN32A
, lpmsg
, hwnd
, min
, max
, PM_REMOVE
, FALSE
);
1513 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1514 lpmsg
->message
, hwnd
, min
, max
);
1516 HOOK_CallHooksA( WH_GETMESSAGE
, HC_ACTION
, PM_REMOVE
, (LPARAM
)lpmsg
);
1517 return lpmsg
->message
!= WM_QUIT
;
1520 /***********************************************************************
1521 * GetMessageW (USER32.@) Retrieve next message
1523 * GetMessage retrieves the next event from the calling thread's
1524 * queue and deposits it in *lpmsg.
1526 * If _hwnd_ is not NULL, only messages for window _hwnd_ and its
1527 * children as specified by IsChild() are retrieved. If _hwnd_ is NULL
1528 * all application messages are retrieved.
1530 * _min_ and _max_ specify the range of messages of interest. If
1531 * min==max==0, no filtering is performed. Useful examples are
1532 * WM_KEYFIRST and WM_KEYLAST to retrieve keyboard input, and
1533 * WM_MOUSEFIRST and WM_MOUSELAST to retrieve mouse input.
1535 * WM_PAINT messages are not removed from the queue; they remain until
1536 * processed. Other messages are removed from the queue.
1540 * -1 on error, 0 if message is WM_QUIT, nonzero otherwise.
1547 BOOL WINAPI
GetMessageW(
1548 MSG
* lpmsg
, /* [out] buffer to receive message */
1549 HWND hwnd
, /* [in] restrict to messages for hwnd */
1550 UINT min
, /* [in] minimum message to receive */
1551 UINT max
/* [in] maximum message to receive */
1554 MSG_PeekMessage( QMSG_WIN32W
, lpmsg
, hwnd
, min
, max
, PM_REMOVE
, FALSE
);
1556 TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n",
1557 lpmsg
->message
, hwnd
, min
, max
);
1559 HOOK_CallHooksW( WH_GETMESSAGE
, HC_ACTION
, PM_REMOVE
, (LPARAM
)lpmsg
);
1560 return lpmsg
->message
!= WM_QUIT
;
1563 /***********************************************************************
1566 static BOOL
MSG_PostToQueue( HQUEUE16 hQueue
, int type
, HWND hwnd
,
1567 UINT message
, WPARAM wParam
, LPARAM lParam
)
1571 if ( !hQueue
) return FALSE
;
1574 msg
.message
= message
;
1575 msg
.wParam
= wParam
;
1576 msg
.lParam
= lParam
;
1577 msg
.time
= GetTickCount();
1578 GetCursorPos(&msg
.pt
);
1580 return QUEUE_AddMsg( hQueue
, type
, &msg
, 0 );
1583 /***********************************************************************
1584 * MSG_IsPointerMessage
1586 * Check whether this message (may) contain pointers.
1587 * Those messages may not be PostMessage()d or GetMessage()d, but are dropped.
1589 * FIXME: list of pointer messages might be incomplete.
1591 * (We could do a generic !IsBadWritePtr() check, but this would cause too
1592 * much slow down I think. MM20010206)
1594 static BOOL
MSG_IsPointerMessage(UINT message
, WPARAM wParam
, LPARAM lParam
) {
1598 case WM_COMPAREITEM
:
1600 case WM_MEASUREITEM
:
1602 case WM_GETMINMAXINFO
:
1606 case WM_MDIGETACTIVE
:
1608 case WM_WINDOWPOSCHANGING
:
1609 case WM_WINDOWPOSCHANGED
:
1612 case WM_WININICHANGE
:
1615 case WM_STYLECHANGING
:
1616 case WM_STYLECHANGED
:
1620 case WM_QUERYDROPOBJECT
:
1624 case CB_INSERTSTRING
:
1626 case CB_FINDSTRINGEXACT
:
1627 case CB_SELECTSTRING
:
1629 case CB_GETDROPPEDCONTROLRECT
:
1634 case LB_INSERTSTRING
:
1636 case LB_GETITEMRECT
:
1638 case LB_FINDSTRINGEXACT
:
1639 case LB_SELECTSTRING
:
1640 case LB_GETSELITEMS
:
1641 case LB_SETTABSTOPS
:
1649 case EM_SETTABSTOPS
:
1656 /***********************************************************************
1659 static BOOL
MSG_PostMessage( int type
, HWND hwnd
, UINT message
,
1660 WPARAM wParam
, LPARAM lParam
)
1665 /* See thread on wine-devel around 6.2.2001. Basically posted messages
1666 * that are known to contain pointers are dropped by the Windows 32bit
1667 * PostMessage() with return FALSE; and invalid parameter last error.
1668 * (tested against NT4 by Gerard Patel)
1669 * 16 bit does not care, so we don't either.
1671 if ( (type
!=QMSG_WIN16
) && MSG_IsPointerMessage(message
,wParam
,lParam
)) {
1672 FIXME("Ignoring posted pointer message 0x%04x to hwnd 0x%04x.\n",
1675 SetLastError(ERROR_INVALID_PARAMETER
);
1679 if (hwnd
== HWND_BROADCAST
)
1681 WND
*pDesktop
= WIN_GetDesktop();
1682 TRACE("HWND_BROADCAST !\n");
1684 for (wndPtr
=WIN_LockWndPtr(pDesktop
->child
); wndPtr
; WIN_UpdateWndPtr(&wndPtr
,wndPtr
->next
))
1686 if (wndPtr
->dwStyle
& WS_POPUP
|| wndPtr
->dwStyle
& WS_CAPTION
)
1688 TRACE("BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n",
1689 wndPtr
->hwndSelf
, message
, wParam
, lParam
);
1690 MSG_PostToQueue( wndPtr
->hmemTaskQ
, type
,
1691 wndPtr
->hwndSelf
, message
, wParam
, lParam
);
1694 WIN_ReleaseDesktop();
1695 TRACE("End of HWND_BROADCAST !\n");
1699 wndPtr
= WIN_FindWndPtr( hwnd
);
1700 hQueue
= wndPtr
? wndPtr
->hmemTaskQ
: 0;
1701 WIN_ReleaseWndPtr(wndPtr
);
1703 return MSG_PostToQueue( hQueue
, type
, hwnd
, message
, wParam
, lParam
);
1706 /***********************************************************************
1707 * PostMessage (USER.110)
1709 BOOL16 WINAPI
PostMessage16( HWND16 hwnd
, UINT16 message
, WPARAM16 wParam
,
1712 return (BOOL16
) MSG_PostMessage( QMSG_WIN16
, hwnd
, message
, wParam
, lParam
);
1715 /***********************************************************************
1716 * PostMessageA (USER32.@)
1718 BOOL WINAPI
PostMessageA( HWND hwnd
, UINT message
, WPARAM wParam
,
1721 return MSG_PostMessage( QMSG_WIN32A
, hwnd
, message
, wParam
, lParam
);
1724 /***********************************************************************
1725 * PostMessageW (USER32.@)
1727 BOOL WINAPI
PostMessageW( HWND hwnd
, UINT message
, WPARAM wParam
,
1730 return MSG_PostMessage( QMSG_WIN32W
, hwnd
, message
, wParam
, lParam
);
1733 /***********************************************************************
1734 * PostAppMessage (USER.116)
1735 * PostAppMessage16 (USER32.@)
1737 BOOL16 WINAPI
PostAppMessage16( HTASK16 hTask
, UINT16 message
,
1738 WPARAM16 wParam
, LPARAM lParam
)
1740 return MSG_PostToQueue( GetTaskQueue16(hTask
), QMSG_WIN16
,
1741 0, message
, wParam
, lParam
);
1744 /**********************************************************************
1745 * PostThreadMessageA (USER32.@)
1747 BOOL WINAPI
PostThreadMessageA( DWORD idThread
, UINT message
,
1748 WPARAM wParam
, LPARAM lParam
)
1750 return MSG_PostToQueue( GetThreadQueue16(idThread
), QMSG_WIN32A
,
1751 0, message
, wParam
, lParam
);
1754 /**********************************************************************
1755 * PostThreadMessageW (USER32.@)
1757 BOOL WINAPI
PostThreadMessageW( DWORD idThread
, UINT message
,
1758 WPARAM wParam
, LPARAM lParam
)
1760 return MSG_PostToQueue( GetThreadQueue16(idThread
), QMSG_WIN32W
,
1761 0, message
, wParam
, lParam
);
1765 /************************************************************************
1766 * MSG_CallWndProcHook32
1768 static void MSG_CallWndProcHook( LPMSG pmsg
, BOOL bUnicode
)
1772 cwp
.lParam
= pmsg
->lParam
;
1773 cwp
.wParam
= pmsg
->wParam
;
1774 cwp
.message
= pmsg
->message
;
1775 cwp
.hwnd
= pmsg
->hwnd
;
1777 if (bUnicode
) HOOK_CallHooksW(WH_CALLWNDPROC
, HC_ACTION
, 1, (LPARAM
)&cwp
);
1778 else HOOK_CallHooksA( WH_CALLWNDPROC
, HC_ACTION
, 1, (LPARAM
)&cwp
);
1780 pmsg
->lParam
= cwp
.lParam
;
1781 pmsg
->wParam
= cwp
.wParam
;
1782 pmsg
->message
= cwp
.message
;
1783 pmsg
->hwnd
= cwp
.hwnd
;
1787 /***********************************************************************
1790 * return values: 0 if timeout occurs
1793 static LRESULT
MSG_SendMessage( HWND hwnd
, UINT msg
, WPARAM wParam
,
1794 LPARAM lParam
, DWORD timeout
, WORD flags
,
1798 WND
**list
, **ppWnd
;
1801 if (pRes
) *pRes
= 0;
1803 if (hwnd
== HWND_BROADCAST
|| hwnd
== HWND_TOPMOST
)
1805 if (pRes
) *pRes
= 1;
1807 if (!(list
= WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL
)))
1809 WIN_ReleaseDesktop();
1812 WIN_ReleaseDesktop();
1814 TRACE("HWND_BROADCAST !\n");
1815 for (ppWnd
= list
; *ppWnd
; ppWnd
++)
1817 WIN_UpdateWndPtr(&wndPtr
,*ppWnd
);
1818 if (!IsWindow(wndPtr
->hwndSelf
)) continue;
1819 if (wndPtr
->dwStyle
& WS_POPUP
|| wndPtr
->dwStyle
& WS_CAPTION
)
1821 TRACE("BROADCAST Message to hWnd=%04x m=%04X w=%04lX l=%08lX !\n",
1822 wndPtr
->hwndSelf
, msg
, (DWORD
)wParam
, lParam
);
1823 MSG_SendMessage( wndPtr
->hwndSelf
, msg
, wParam
, lParam
,
1824 timeout
, flags
, pRes
);
1827 WIN_ReleaseWndPtr(wndPtr
);
1828 WIN_ReleaseWinArray(list
);
1829 TRACE("End of HWND_BROADCAST !\n");
1833 if (HOOK_IsHooked( WH_CALLWNDPROC
))
1835 if (flags
& SMSG_UNICODE
)
1836 MSG_CallWndProcHook( (LPMSG
)&hwnd
, TRUE
);
1837 else if (flags
& SMSG_WIN32
)
1838 MSG_CallWndProcHook( (LPMSG
)&hwnd
, FALSE
);
1843 if ((pmsg
= SEGPTR_NEW(CWPSTRUCT16
)))
1845 pmsg
->hwnd
= hwnd
& 0xffff;
1846 pmsg
->message
= msg
& 0xffff;
1847 pmsg
->wParam
= wParam
& 0xffff;
1848 pmsg
->lParam
= lParam
;
1849 HOOK_CallHooks16( WH_CALLWNDPROC
, HC_ACTION
, 1,
1850 (LPARAM
)SEGPTR_GET(pmsg
) );
1852 msg
= pmsg
->message
;
1853 wParam
= pmsg
->wParam
;
1854 lParam
= pmsg
->lParam
;
1855 SEGPTR_FREE( pmsg
);
1860 if (!(wndPtr
= WIN_FindWndPtr( hwnd
)))
1862 WARN("invalid hwnd %04x\n", hwnd
);
1865 if (QUEUE_IsExitingQueue(wndPtr
->hmemTaskQ
))
1867 ret
= 0; /* Don't send anything if the task is dying */
1870 if (flags
& SMSG_WIN32
)
1871 SPY_EnterMessage( SPY_SENDMESSAGE
, hwnd
, msg
, wParam
, lParam
);
1873 SPY_EnterMessage( SPY_SENDMESSAGE16
, hwnd
, msg
, wParam
, lParam
);
1875 if (wndPtr
->hmemTaskQ
!= GetFastQueue16())
1876 ret
= MSG_SendMessageInterThread( wndPtr
->hmemTaskQ
, hwnd
, msg
,
1877 wParam
, lParam
, timeout
, flags
, pRes
);
1882 /* Call the right CallWindowProc flavor */
1883 if (flags
& SMSG_UNICODE
)
1884 res
= CallWindowProcW( (WNDPROC
)wndPtr
->winproc
,
1885 hwnd
, msg
, wParam
, lParam
);
1886 else if (flags
& SMSG_WIN32
)
1887 res
= CallWindowProcA( (WNDPROC
)wndPtr
->winproc
,
1888 hwnd
, msg
, wParam
, lParam
);
1890 res
= CallWindowProc16( (WNDPROC16
)wndPtr
->winproc
,
1891 (HWND16
) hwnd
, (UINT16
) msg
,
1892 (WPARAM16
) wParam
, lParam
);
1893 if (pRes
) *pRes
= res
;
1896 if (flags
& SMSG_WIN32
)
1897 SPY_ExitMessage( SPY_RESULT_OK
, hwnd
, msg
, pRes
?*pRes
:0, wParam
, lParam
);
1899 SPY_ExitMessage( SPY_RESULT_OK16
, hwnd
, msg
, pRes
?*pRes
:0, wParam
, lParam
);
1901 WIN_ReleaseWndPtr(wndPtr
);
1906 /***********************************************************************
1907 * SendMessage (USER.111)
1909 LRESULT WINAPI
SendMessage16( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
,
1913 MSG_SendMessage(hwnd
, msg
, wParam
, lParam
, INFINITE
, 0, &res
);
1918 /***********************************************************************
1919 * SendMessageA (USER32.@)
1921 LRESULT WINAPI
SendMessageA( HWND hwnd
, UINT msg
, WPARAM wParam
,
1926 MSG_SendMessage(hwnd
, msg
, wParam
, lParam
, INFINITE
,
1933 /***********************************************************************
1934 * SendMessageW (USER32.@) Send Window Message
1936 * Sends a message to the window procedure of the specified window.
1937 * SendMessage() will not return until the called window procedure
1938 * either returns or calls ReplyMessage().
1940 * Use PostMessage() to send message and return immediately. A window
1941 * procedure may use InSendMessage() to detect
1942 * SendMessage()-originated messages.
1944 * Applications which communicate via HWND_BROADCAST may use
1945 * RegisterWindowMessage() to obtain a unique message to avoid conflicts
1946 * with other applications.
1952 LRESULT WINAPI
SendMessageW(
1953 HWND hwnd
, /* [in] Window to send message to. If HWND_BROADCAST,
1954 the message will be sent to all top-level windows. */
1956 UINT msg
, /* [in] message */
1957 WPARAM wParam
, /* [in] message parameter */
1958 LPARAM lParam
/* [in] additional message parameter */
1962 MSG_SendMessage(hwnd
, msg
, wParam
, lParam
, INFINITE
,
1963 SMSG_WIN32
| SMSG_UNICODE
, &res
);
1969 /***********************************************************************
1970 * SendMessageTimeout (not a WINAPI)
1972 LRESULT WINAPI
SendMessageTimeout16( HWND16 hwnd
, UINT16 msg
, WPARAM16 wParam
,
1973 LPARAM lParam
, UINT16 flags
,
1974 UINT16 timeout
, LPWORD resultp
)
1979 /* FIXME: need support for SMTO_BLOCK */
1981 ret
= MSG_SendMessage(hwnd
, msg
, wParam
, lParam
, timeout
, 0, &msgRet
);
1982 if (resultp
) *resultp
= (WORD
) msgRet
;
1987 /***********************************************************************
1988 * SendMessageTimeoutA (USER32.@)
1990 LRESULT WINAPI
SendMessageTimeoutA( HWND hwnd
, UINT msg
, WPARAM wParam
,
1991 LPARAM lParam
, UINT flags
,
1992 UINT timeout
, LPDWORD resultp
)
1997 /* FIXME: need support for SMTO_BLOCK */
1999 ret
= MSG_SendMessage(hwnd
, msg
, wParam
, lParam
, timeout
, SMSG_WIN32
,
2002 if (resultp
) *resultp
= (DWORD
) msgRet
;
2007 /***********************************************************************
2008 * SendMessageTimeoutW (USER32.@)
2010 LRESULT WINAPI
SendMessageTimeoutW( HWND hwnd
, UINT msg
, WPARAM wParam
,
2011 LPARAM lParam
, UINT flags
,
2012 UINT timeout
, LPDWORD resultp
)
2017 /* FIXME: need support for SMTO_BLOCK */
2019 ret
= MSG_SendMessage(hwnd
, msg
, wParam
, lParam
, timeout
,
2020 SMSG_WIN32
| SMSG_UNICODE
, &msgRet
);
2022 if (resultp
) *resultp
= (DWORD
) msgRet
;
2027 /***********************************************************************
2028 * WaitMessage (USER.112) (USER32.@) Suspend thread pending messages
2030 * WaitMessage() suspends a thread until events appear in the thread's
2035 * Is supposed to return BOOL under Win32.
2037 * Thread-local message queues are not supported.
2044 void WINAPI
WaitMessage( void )
2046 QUEUE_WaitBits( QS_ALLINPUT
, INFINITE
);
2049 /***********************************************************************
2050 * MsgWaitForMultipleObjects (USER32.@)
2052 DWORD WINAPI
MsgWaitForMultipleObjects( DWORD nCount
, HANDLE
*pHandles
,
2053 BOOL fWaitAll
, DWORD dwMilliseconds
,
2057 HANDLE handles
[MAXIMUM_WAIT_OBJECTS
];
2060 HQUEUE16 hQueue
= GetFastQueue16();
2061 MESSAGEQUEUE
*msgQueue
= QUEUE_Lock( hQueue
);
2062 if (!msgQueue
) return WAIT_FAILED
;
2064 if (nCount
> MAXIMUM_WAIT_OBJECTS
-1)
2066 SetLastError( ERROR_INVALID_PARAMETER
);
2067 QUEUE_Unlock( msgQueue
);
2071 EnterCriticalSection( &msgQueue
->cSection
);
2072 msgQueue
->changeBits
= 0;
2073 msgQueue
->wakeMask
= dwWakeMask
;
2074 LeaveCriticalSection( &msgQueue
->cSection
);
2076 /* Add the thread event to the handle list */
2077 for (i
= 0; i
< nCount
; i
++) handles
[i
] = pHandles
[i
];
2078 handles
[nCount
] = msgQueue
->server_queue
;
2079 ret
= WaitForMultipleObjects( nCount
+1, handles
, fWaitAll
, dwMilliseconds
);
2081 QUEUE_Unlock( msgQueue
);
2085 /***********************************************************************
2086 * MsgWaitForMultipleObjects (USER.640)
2088 DWORD WINAPI
MsgWaitForMultipleObjects16( DWORD nCount
, HANDLE
*pHandles
,
2089 BOOL fWaitAll
, DWORD dwMilliseconds
,
2092 TRACE("(%lu,%p,%u,%lu,0x%lx)\n",
2093 nCount
, pHandles
, fWaitAll
, dwMilliseconds
, dwWakeMask
);
2094 return MsgWaitForMultipleObjects(nCount
, pHandles
, fWaitAll
, dwMilliseconds
, dwWakeMask
);
2104 static const struct accent_char accent_chars
[] =
2106 /* A good idea should be to read /usr/X11/lib/X11/locale/iso8859-x/Compose */
2107 {'`', 'A', '\300'}, {'`', 'a', '\340'},
2108 {'\'', 'A', '\301'}, {'\'', 'a', '\341'},
2109 {'^', 'A', '\302'}, {'^', 'a', '\342'},
2110 {'~', 'A', '\303'}, {'~', 'a', '\343'},
2111 {'"', 'A', '\304'}, {'"', 'a', '\344'},
2112 {'O', 'A', '\305'}, {'o', 'a', '\345'},
2113 {'0', 'A', '\305'}, {'0', 'a', '\345'},
2114 {'A', 'A', '\305'}, {'a', 'a', '\345'},
2115 {'A', 'E', '\306'}, {'a', 'e', '\346'},
2116 {',', 'C', '\307'}, {',', 'c', '\347'},
2117 {'`', 'E', '\310'}, {'`', 'e', '\350'},
2118 {'\'', 'E', '\311'}, {'\'', 'e', '\351'},
2119 {'^', 'E', '\312'}, {'^', 'e', '\352'},
2120 {'"', 'E', '\313'}, {'"', 'e', '\353'},
2121 {'`', 'I', '\314'}, {'`', 'i', '\354'},
2122 {'\'', 'I', '\315'}, {'\'', 'i', '\355'},
2123 {'^', 'I', '\316'}, {'^', 'i', '\356'},
2124 {'"', 'I', '\317'}, {'"', 'i', '\357'},
2125 {'-', 'D', '\320'}, {'-', 'd', '\360'},
2126 {'~', 'N', '\321'}, {'~', 'n', '\361'},
2127 {'`', 'O', '\322'}, {'`', 'o', '\362'},
2128 {'\'', 'O', '\323'}, {'\'', 'o', '\363'},
2129 {'^', 'O', '\324'}, {'^', 'o', '\364'},
2130 {'~', 'O', '\325'}, {'~', 'o', '\365'},
2131 {'"', 'O', '\326'}, {'"', 'o', '\366'},
2132 {'/', 'O', '\330'}, {'/', 'o', '\370'},
2133 {'`', 'U', '\331'}, {'`', 'u', '\371'},
2134 {'\'', 'U', '\332'}, {'\'', 'u', '\372'},
2135 {'^', 'U', '\333'}, {'^', 'u', '\373'},
2136 {'"', 'U', '\334'}, {'"', 'u', '\374'},
2137 {'\'', 'Y', '\335'}, {'\'', 'y', '\375'},
2138 {'T', 'H', '\336'}, {'t', 'h', '\376'},
2139 {'s', 's', '\337'}, {'"', 'y', '\377'},
2140 {'s', 'z', '\337'}, {'i', 'j', '\377'},
2141 /* iso-8859-2 uses this */
2142 {'<', 'L', '\245'}, {'<', 'l', '\265'}, /* caron */
2143 {'<', 'S', '\251'}, {'<', 's', '\271'},
2144 {'<', 'T', '\253'}, {'<', 't', '\273'},
2145 {'<', 'Z', '\256'}, {'<', 'z', '\276'},
2146 {'<', 'C', '\310'}, {'<', 'c', '\350'},
2147 {'<', 'E', '\314'}, {'<', 'e', '\354'},
2148 {'<', 'D', '\317'}, {'<', 'd', '\357'},
2149 {'<', 'N', '\322'}, {'<', 'n', '\362'},
2150 {'<', 'R', '\330'}, {'<', 'r', '\370'},
2151 {';', 'A', '\241'}, {';', 'a', '\261'}, /* ogonek */
2152 {';', 'E', '\312'}, {';', 'e', '\332'},
2153 {'\'', 'Z', '\254'}, {'\'', 'z', '\274'}, /* acute */
2154 {'\'', 'R', '\300'}, {'\'', 'r', '\340'},
2155 {'\'', 'L', '\305'}, {'\'', 'l', '\345'},
2156 {'\'', 'C', '\306'}, {'\'', 'c', '\346'},
2157 {'\'', 'N', '\321'}, {'\'', 'n', '\361'},
2158 /* collision whith S, from iso-8859-9 !!! */
2159 {',', 'S', '\252'}, {',', 's', '\272'}, /* cedilla */
2160 {',', 'T', '\336'}, {',', 't', '\376'},
2161 {'.', 'Z', '\257'}, {'.', 'z', '\277'}, /* dot above */
2162 {'/', 'L', '\243'}, {'/', 'l', '\263'}, /* slash */
2163 {'/', 'D', '\320'}, {'/', 'd', '\360'},
2164 {'(', 'A', '\303'}, {'(', 'a', '\343'}, /* breve */
2165 {'\275', 'O', '\325'}, {'\275', 'o', '\365'}, /* double acute */
2166 {'\275', 'U', '\334'}, {'\275', 'u', '\374'},
2167 {'0', 'U', '\332'}, {'0', 'u', '\372'}, /* ring above */
2168 /* iso-8859-3 uses this */
2169 {'/', 'H', '\241'}, {'/', 'h', '\261'}, /* slash */
2170 {'>', 'H', '\246'}, {'>', 'h', '\266'}, /* circumflex */
2171 {'>', 'J', '\254'}, {'>', 'j', '\274'},
2172 {'>', 'C', '\306'}, {'>', 'c', '\346'},
2173 {'>', 'G', '\330'}, {'>', 'g', '\370'},
2174 {'>', 'S', '\336'}, {'>', 's', '\376'},
2175 /* collision whith G( from iso-8859-9 !!! */
2176 {'(', 'G', '\253'}, {'(', 'g', '\273'}, /* breve */
2177 {'(', 'U', '\335'}, {'(', 'u', '\375'},
2178 /* collision whith I. from iso-8859-3 !!! */
2179 {'.', 'I', '\251'}, {'.', 'i', '\271'}, /* dot above */
2180 {'.', 'C', '\305'}, {'.', 'c', '\345'},
2181 {'.', 'G', '\325'}, {'.', 'g', '\365'},
2182 /* iso-8859-4 uses this */
2183 {',', 'R', '\243'}, {',', 'r', '\263'}, /* cedilla */
2184 {',', 'L', '\246'}, {',', 'l', '\266'},
2185 {',', 'G', '\253'}, {',', 'g', '\273'},
2186 {',', 'N', '\321'}, {',', 'n', '\361'},
2187 {',', 'K', '\323'}, {',', 'k', '\363'},
2188 {'~', 'I', '\245'}, {'~', 'i', '\265'}, /* tilde */
2189 {'-', 'E', '\252'}, {'-', 'e', '\272'}, /* macron */
2190 {'-', 'A', '\300'}, {'-', 'a', '\340'},
2191 {'-', 'I', '\317'}, {'-', 'i', '\357'},
2192 {'-', 'O', '\322'}, {'-', 'o', '\362'},
2193 {'-', 'U', '\336'}, {'-', 'u', '\376'},
2194 {'/', 'T', '\254'}, {'/', 't', '\274'}, /* slash */
2195 {'.', 'E', '\314'}, {'.', 'e', '\344'}, /* dot above */
2196 {';', 'I', '\307'}, {';', 'i', '\347'}, /* ogonek */
2197 {';', 'U', '\331'}, {';', 'u', '\371'},
2198 /* iso-8859-9 uses this */
2199 /* iso-8859-9 has really bad choosen G( S, and I. as they collide
2200 * whith the same letters on other iso-8859-x (that is they are on
2201 * different places :-( ), if you use turkish uncomment these and
2202 * comment out the lines in iso-8859-2 and iso-8859-3 sections
2203 * FIXME: should be dynamic according to chosen language
2204 * if/when Wine has turkish support.
2206 /* collision whith G( from iso-8859-3 !!! */
2207 /* {'(', 'G', '\320'}, {'(', 'g', '\360'}, */ /* breve */
2208 /* collision whith S, from iso-8859-2 !!! */
2209 /* {',', 'S', '\336'}, {',', 's', '\376'}, */ /* cedilla */
2210 /* collision whith I. from iso-8859-3 !!! */
2211 /* {'.', 'I', '\335'}, {'.', 'i', '\375'}, */ /* dot above */
2215 /***********************************************************************
2216 * MSG_DoTranslateMessage
2218 * Implementation of TranslateMessage.
2220 * TranslateMessage translates virtual-key messages into character-messages,
2222 * WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message.
2223 * ditto replacing WM_* with WM_SYS*
2224 * This produces WM_CHAR messages only for keys mapped to ASCII characters
2225 * by the keyboard driver.
2227 static BOOL
MSG_DoTranslateMessage( UINT message
, HWND hwnd
,
2228 WPARAM wParam
, LPARAM lParam
)
2230 static int dead_char
;
2233 if (message
!= WM_MOUSEMOVE
&& message
!= WM_TIMER
)
2234 TRACE("(%s, %04X, %08lX)\n",
2235 SPY_GetMsgName(message
), wParam
, lParam
);
2236 if(message
>= WM_KEYFIRST
&& message
<= WM_KEYLAST
)
2237 TRACE_(key
)("(%s, %04X, %08lX)\n",
2238 SPY_GetMsgName(message
), wParam
, lParam
);
2240 if ((message
!= WM_KEYDOWN
) && (message
!= WM_SYSKEYDOWN
)) return FALSE
;
2242 TRACE_(key
)("Translating key %s (%04x), scancode %02x\n",
2243 SPY_GetVKeyName(wParam
), wParam
, LOBYTE(HIWORD(lParam
)));
2245 /* FIXME : should handle ToUnicode yielding 2 */
2246 switch (ToUnicode(wParam
, HIWORD(lParam
), QueueKeyStateTable
, wp
, 2, 0))
2249 message
= (message
== WM_KEYDOWN
) ? WM_CHAR
: WM_SYSCHAR
;
2250 /* Should dead chars handling go in ToAscii ? */
2255 if (wp
[0] == ' ') wp
[0] = dead_char
;
2256 if (dead_char
== 0xa2) dead_char
= '(';
2257 else if (dead_char
== 0xa8) dead_char
= '"';
2258 else if (dead_char
== 0xb2) dead_char
= ';';
2259 else if (dead_char
== 0xb4) dead_char
= '\'';
2260 else if (dead_char
== 0xb7) dead_char
= '<';
2261 else if (dead_char
== 0xb8) dead_char
= ',';
2262 else if (dead_char
== 0xff) dead_char
= '.';
2263 for (i
= 0; i
< sizeof(accent_chars
)/sizeof(accent_chars
[0]); i
++)
2264 if ((accent_chars
[i
].ac_accent
== dead_char
) &&
2265 (accent_chars
[i
].ac_char
== wp
[0]))
2267 wp
[0] = accent_chars
[i
].ac_result
;
2272 TRACE_(key
)("1 -> PostMessage(%s)\n", SPY_GetMsgName(message
));
2273 PostMessageW( hwnd
, message
, wp
[0], lParam
);
2277 message
= (message
== WM_KEYDOWN
) ? WM_DEADCHAR
: WM_SYSDEADCHAR
;
2279 TRACE_(key
)("-1 -> PostMessage(%s)\n", SPY_GetMsgName(message
));
2280 PostMessageW( hwnd
, message
, wp
[0], lParam
);
2287 /***********************************************************************
2288 * TranslateMessage (USER.113)
2290 BOOL16 WINAPI
TranslateMessage16( const MSG16
*msg
)
2292 return MSG_DoTranslateMessage( msg
->message
, msg
->hwnd
,
2293 msg
->wParam
, msg
->lParam
);
2297 /***********************************************************************
2298 * TranslateMessage32 (USER.821)
2300 BOOL16 WINAPI
TranslateMessage32_16( const MSG32_16
*msg
, BOOL16 wHaveParamHigh
)
2305 wParam
= MAKELONG(msg
->msg
.wParam
, msg
->wParamHigh
);
2307 wParam
= (WPARAM
)msg
->msg
.wParam
;
2309 return MSG_DoTranslateMessage( msg
->msg
.message
, msg
->msg
.hwnd
,
2310 wParam
, msg
->msg
.lParam
);
2313 /***********************************************************************
2314 * TranslateMessage (USER32.@)
2316 BOOL WINAPI
TranslateMessage( const MSG
*msg
)
2318 return MSG_DoTranslateMessage( msg
->message
, msg
->hwnd
,
2319 msg
->wParam
, msg
->lParam
);
2323 /***********************************************************************
2324 * DispatchMessage (USER.114)
2326 LONG WINAPI
DispatchMessage16( const MSG16
* msg
)
2332 /* Process timer messages */
2333 if ((msg
->message
== WM_TIMER
) || (msg
->message
== WM_SYSTIMER
))
2337 /* before calling window proc, verify whether timer is still valid;
2338 there's a slim chance that the application kills the timer
2339 between GetMessage and DispatchMessage API calls */
2340 if (!TIMER_IsTimerValid(msg
->hwnd
, (UINT
) msg
->wParam
, (HWINDOWPROC
) msg
->lParam
))
2341 return 0; /* invalid winproc */
2343 return CallWindowProc16( (WNDPROC16
)msg
->lParam
, msg
->hwnd
,
2344 msg
->message
, msg
->wParam
, GetTickCount() );
2348 if (!msg
->hwnd
) return 0;
2349 if (!(wndPtr
= WIN_FindWndPtr( msg
->hwnd
))) return 0;
2350 if (!wndPtr
->winproc
)
2355 painting
= (msg
->message
== WM_PAINT
);
2356 if (painting
) wndPtr
->flags
|= WIN_NEEDS_BEGINPAINT
;
2358 SPY_EnterMessage( SPY_DISPATCHMESSAGE16
, msg
->hwnd
, msg
->message
,
2359 msg
->wParam
, msg
->lParam
);
2360 retval
= CallWindowProc16( (WNDPROC16
)wndPtr
->winproc
,
2361 msg
->hwnd
, msg
->message
,
2362 msg
->wParam
, msg
->lParam
);
2363 SPY_ExitMessage( SPY_RESULT_OK16
, msg
->hwnd
, msg
->message
, retval
,
2364 msg
->wParam
, msg
->lParam
);
2366 WIN_ReleaseWndPtr(wndPtr
);
2367 wndPtr
= WIN_FindWndPtr(msg
->hwnd
);
2368 if (painting
&& wndPtr
&&
2369 (wndPtr
->flags
& WIN_NEEDS_BEGINPAINT
) && wndPtr
->hrgnUpdate
)
2371 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2373 wndPtr
->flags
&= ~WIN_NEEDS_BEGINPAINT
;
2374 /* Validate the update region to avoid infinite WM_PAINT loop */
2375 ValidateRect( msg
->hwnd
, NULL
);
2378 WIN_ReleaseWndPtr(wndPtr
);
2383 /***********************************************************************
2384 * DispatchMessage32 (USER.822)
2386 LONG WINAPI
DispatchMessage32_16( const MSG32_16
* lpmsg16_32
, BOOL16 wHaveParamHigh
)
2388 if (wHaveParamHigh
== FALSE
)
2389 return DispatchMessage16(&(lpmsg16_32
->msg
));
2394 msg
.hwnd
= lpmsg16_32
->msg
.hwnd
;
2395 msg
.message
= lpmsg16_32
->msg
.message
;
2396 msg
.wParam
= MAKELONG(lpmsg16_32
->msg
.wParam
, lpmsg16_32
->wParamHigh
);
2397 msg
.lParam
= lpmsg16_32
->msg
.lParam
;
2398 msg
.time
= lpmsg16_32
->msg
.time
;
2399 msg
.pt
.x
= (INT
)lpmsg16_32
->msg
.pt
.x
;
2400 msg
.pt
.y
= (INT
)lpmsg16_32
->msg
.pt
.y
;
2401 return DispatchMessageA(&msg
);
2405 /***********************************************************************
2406 * DispatchMessageA (USER32.@)
2408 LONG WINAPI
DispatchMessageA( const MSG
* msg
)
2414 /* Process timer messages */
2415 if ((msg
->message
== WM_TIMER
) || (msg
->message
== WM_SYSTIMER
))
2419 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2421 /* before calling window proc, verify whether timer is still valid;
2422 there's a slim chance that the application kills the timer
2423 between GetMessage and DispatchMessage API calls */
2424 if (!TIMER_IsTimerValid(msg
->hwnd
, (UINT
) msg
->wParam
, (HWINDOWPROC
) msg
->lParam
))
2425 return 0; /* invalid winproc */
2427 return CallWindowProcA( (WNDPROC
)msg
->lParam
, msg
->hwnd
,
2428 msg
->message
, msg
->wParam
, GetTickCount() );
2432 if (!msg
->hwnd
) return 0;
2433 if (!(wndPtr
= WIN_FindWndPtr( msg
->hwnd
))) return 0;
2434 if (!wndPtr
->winproc
)
2439 painting
= (msg
->message
== WM_PAINT
);
2440 if (painting
) wndPtr
->flags
|= WIN_NEEDS_BEGINPAINT
;
2441 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2443 SPY_EnterMessage( SPY_DISPATCHMESSAGE
, msg
->hwnd
, msg
->message
,
2444 msg
->wParam
, msg
->lParam
);
2445 retval
= CallWindowProcA( (WNDPROC
)wndPtr
->winproc
,
2446 msg
->hwnd
, msg
->message
,
2447 msg
->wParam
, msg
->lParam
);
2448 SPY_ExitMessage( SPY_RESULT_OK
, msg
->hwnd
, msg
->message
, retval
,
2449 msg
->wParam
, msg
->lParam
);
2451 WIN_ReleaseWndPtr(wndPtr
);
2452 wndPtr
= WIN_FindWndPtr(msg
->hwnd
);
2454 if (painting
&& wndPtr
&&
2455 (wndPtr
->flags
& WIN_NEEDS_BEGINPAINT
) && wndPtr
->hrgnUpdate
)
2457 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2459 wndPtr
->flags
&= ~WIN_NEEDS_BEGINPAINT
;
2460 /* Validate the update region to avoid infinite WM_PAINT loop */
2461 PAINT_RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0,
2462 RDW_FRAME
| RDW_VALIDATE
| RDW_NOCHILDREN
| RDW_NOINTERNALPAINT
, 0 );
2465 WIN_ReleaseWndPtr(wndPtr
);
2470 /***********************************************************************
2471 * DispatchMessageW (USER32.@) Process Message
2473 * Process the message specified in the structure *_msg_.
2475 * If the lpMsg parameter points to a WM_TIMER message and the
2476 * parameter of the WM_TIMER message is not NULL, the lParam parameter
2477 * points to the function that is called instead of the window
2480 * The message must be valid.
2484 * DispatchMessage() returns the result of the window procedure invoked.
2491 LONG WINAPI
DispatchMessageW( const MSG
* msg
)
2497 /* Process timer messages */
2498 if ((msg
->message
== WM_TIMER
) || (msg
->message
== WM_SYSTIMER
))
2502 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2504 /* before calling window proc, verify whether timer is still valid;
2505 there's a slim chance that the application kills the timer
2506 between GetMessage and DispatchMessage API calls */
2507 if (!TIMER_IsTimerValid(msg
->hwnd
, (UINT
) msg
->wParam
, (HWINDOWPROC
) msg
->lParam
))
2508 return 0; /* invalid winproc */
2510 return CallWindowProcW( (WNDPROC
)msg
->lParam
, msg
->hwnd
,
2511 msg
->message
, msg
->wParam
, GetTickCount() );
2515 if (!msg
->hwnd
) return 0;
2516 if (!(wndPtr
= WIN_FindWndPtr( msg
->hwnd
))) return 0;
2517 if (!wndPtr
->winproc
)
2522 painting
= (msg
->message
== WM_PAINT
);
2523 if (painting
) wndPtr
->flags
|= WIN_NEEDS_BEGINPAINT
;
2524 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
2526 SPY_EnterMessage( SPY_DISPATCHMESSAGE
, msg
->hwnd
, msg
->message
,
2527 msg
->wParam
, msg
->lParam
);
2528 retval
= CallWindowProcW( (WNDPROC
)wndPtr
->winproc
,
2529 msg
->hwnd
, msg
->message
,
2530 msg
->wParam
, msg
->lParam
);
2531 SPY_ExitMessage( SPY_RESULT_OK
, msg
->hwnd
, msg
->message
, retval
,
2532 msg
->wParam
, msg
->lParam
);
2534 WIN_ReleaseWndPtr(wndPtr
);
2535 wndPtr
= WIN_FindWndPtr(msg
->hwnd
);
2537 if (painting
&& wndPtr
&&
2538 (wndPtr
->flags
& WIN_NEEDS_BEGINPAINT
) && wndPtr
->hrgnUpdate
)
2540 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
2542 wndPtr
->flags
&= ~WIN_NEEDS_BEGINPAINT
;
2543 /* Validate the update region to avoid infinite WM_PAINT loop */
2544 ValidateRect( msg
->hwnd
, NULL
);
2547 WIN_ReleaseWndPtr(wndPtr
);
2552 /***********************************************************************
2553 * RegisterWindowMessage (USER.118)
2554 * RegisterWindowMessageA (USER32.@)
2556 WORD WINAPI
RegisterWindowMessageA( LPCSTR str
)
2558 TRACE("%s\n", str
);
2559 return GlobalAddAtomA( str
);
2563 /***********************************************************************
2564 * RegisterWindowMessageW (USER32.@)
2566 WORD WINAPI
RegisterWindowMessageW( LPCWSTR str
)
2568 TRACE("%p\n", str
);
2569 return GlobalAddAtomW( str
);
2573 /***********************************************************************
2574 * GetCurrentTime (USER.15)
2576 * (effectively identical to GetTickCount)
2578 DWORD WINAPI
GetCurrentTime16(void)
2580 return GetTickCount();
2584 /***********************************************************************
2585 * InSendMessage (USER.192)
2587 BOOL16 WINAPI
InSendMessage16(void)
2589 return InSendMessage();
2593 /***********************************************************************
2594 * InSendMessage (USER32.@)
2596 BOOL WINAPI
InSendMessage(void)
2598 MESSAGEQUEUE
*queue
;
2601 if (!(queue
= QUEUE_Lock( GetFastQueue16() )))
2603 ret
= (BOOL
)queue
->smWaiting
;
2605 QUEUE_Unlock( queue
);
2609 /***********************************************************************
2610 * BroadcastSystemMessage (USER32.@)
2612 LONG WINAPI
BroadcastSystemMessage(
2613 DWORD dwFlags
,LPDWORD recipients
,UINT uMessage
,WPARAM wParam
,
2616 FIXME_(sendmsg
)("(%08lx,%08lx,%08x,%08x,%08lx): stub!\n",
2617 dwFlags
,*recipients
,uMessage
,wParam
,lParam
2622 /***********************************************************************
2623 * SendNotifyMessageA (USER32.@)
2625 BOOL WINAPI
SendNotifyMessageA(HWND hwnd
,UINT msg
,WPARAM wParam
,LPARAM lParam
)
2627 return MSG_SendMessage(hwnd
, msg
, wParam
, lParam
, INFINITE
,
2631 /***********************************************************************
2632 * SendNotifyMessageW (USER32.@)
2634 BOOL WINAPI
SendNotifyMessageW(HWND hwnd
,UINT msg
,WPARAM wParam
,LPARAM lParam
)
2636 return MSG_SendMessage(hwnd
, msg
, wParam
, lParam
, INFINITE
,
2637 SMSG_WIN32
| SMSG_UNICODE
, NULL
);
2640 /***********************************************************************
2641 * SendMessageCallbackA (USER32.@)
2642 * FIXME: It's like PostMessage. The callback gets called when the message
2643 * is processed. We have to modify the message processing for an exact
2645 * The callback is only called when the thread that called us calls one of
2646 * Get/Peek/WaitMessage.
2648 BOOL WINAPI
SendMessageCallbackA(
2649 HWND hWnd
,UINT Msg
,WPARAM wParam
,LPARAM lParam
,
2650 FARPROC lpResultCallBack
,DWORD dwData
)
2652 FIXME("(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n",
2653 hWnd
,Msg
,wParam
,lParam
,lpResultCallBack
,dwData
);
2654 if ( hWnd
== HWND_BROADCAST
)
2655 { PostMessageA( hWnd
, Msg
, wParam
, lParam
);
2656 FIXME("Broadcast: Callback will not be called!\n");
2659 (lpResultCallBack
)( hWnd
, Msg
, dwData
, SendMessageA ( hWnd
, Msg
, wParam
, lParam
));
2662 /***********************************************************************
2663 * SendMessageCallbackW (USER32.@)
2664 * FIXME: see SendMessageCallbackA.
2666 BOOL WINAPI
SendMessageCallbackW(
2667 HWND hWnd
,UINT Msg
,WPARAM wParam
,LPARAM lParam
,
2668 FARPROC lpResultCallBack
,DWORD dwData
)
2670 FIXME("(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n",
2671 hWnd
,Msg
,wParam
,lParam
,lpResultCallBack
,dwData
);
2672 if ( hWnd
== HWND_BROADCAST
)
2673 { PostMessageW( hWnd
, Msg
, wParam
, lParam
);
2674 FIXME("Broadcast: Callback will not be called!\n");
2677 (lpResultCallBack
)( hWnd
, Msg
, dwData
, SendMessageA ( hWnd
, Msg
, wParam
, lParam
));