2 * Message queues related functions
4 * Copyright 1993, 1994 Alexandre Julliard
11 #include <sys/types.h>
18 #include "wine/server.h"
32 #include "debugtools.h"
34 DEFAULT_DEBUG_CHANNEL(msg
);
35 DECLARE_DEBUG_CHANNEL(key
);
37 #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
38 #define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK
40 static UINT doubleClickSpeed
= 452;
43 /***********************************************************************
46 inline static BOOL
is_keyboard_message( UINT message
)
48 return (message
>= WM_KEYFIRST
&& message
<= WM_KEYLAST
);
52 /***********************************************************************
55 inline static BOOL
is_mouse_message( UINT message
)
57 return ((message
>= WM_NCMOUSEFIRST
&& message
<= WM_NCMOUSELAST
) ||
58 (message
>= WM_MOUSEFIRST
&& message
<= WM_MOUSELAST
));
62 /***********************************************************************
63 * check_message_filter
65 inline static BOOL
check_message_filter( const MSG
*msg
, HWND hwnd
, UINT first
, UINT last
)
69 if (msg
->hwnd
!= hwnd
&& !IsChild( hwnd
, msg
->hwnd
)) return FALSE
;
73 return (msg
->message
>= first
&& msg
->message
<= last
);
79 /***********************************************************************
80 * process_sent_messages
82 * Process all pending sent messages.
84 inline static void process_sent_messages(void)
87 MSG_peek_message( &msg
, 0, 0, 0, GET_MSG_REMOVE
| GET_MSG_SENT_ONLY
);
91 /***********************************************************************
92 * queue_hardware_message
94 * store a hardware message in the thread queue
96 static void queue_hardware_message( MSG
*msg
, ULONG_PTR extra_info
, enum message_type type
)
98 SERVER_START_REQ( send_message
)
101 req
->id
= (void *)GetWindowThreadProcessId( msg
->hwnd
, NULL
);
102 req
->win
= msg
->hwnd
;
103 req
->msg
= msg
->message
;
104 req
->wparam
= msg
->wParam
;
105 req
->lparam
= msg
->lParam
;
108 req
->time
= msg
->time
;
109 req
->info
= extra_info
;
117 /***********************************************************************
118 * MSG_SendParentNotify
120 * Send a WM_PARENTNOTIFY to all ancestors of the given window, unless
121 * the window has the WS_EX_NOPARENTNOTIFY style.
123 static void MSG_SendParentNotify( HWND hwnd
, WORD event
, WORD idChild
, POINT pt
)
125 WND
*tmpWnd
= WIN_FindWndPtr(hwnd
);
127 /* pt has to be in the client coordinates of the parent window */
128 MapWindowPoints( 0, tmpWnd
->hwndSelf
, &pt
, 1 );
131 if (!(tmpWnd
->dwStyle
& WS_CHILD
) || (tmpWnd
->dwExStyle
& WS_EX_NOPARENTNOTIFY
))
133 WIN_ReleaseWndPtr(tmpWnd
);
136 pt
.x
+= tmpWnd
->rectClient
.left
;
137 pt
.y
+= tmpWnd
->rectClient
.top
;
138 WIN_UpdateWndPtr(&tmpWnd
,tmpWnd
->parent
);
139 SendMessageA( tmpWnd
->hwndSelf
, WM_PARENTNOTIFY
,
140 MAKEWPARAM( event
, idChild
), MAKELPARAM( pt
.x
, pt
.y
) );
145 /***********************************************************************
146 * MSG_JournalPlayBackMsg
148 * Get an EVENTMSG struct via call JOURNALPLAYBACK hook function
150 void MSG_JournalPlayBackMsg(void)
157 if (!HOOK_IsHooked( WH_JOURNALPLAYBACK
)) return;
159 wtime
=HOOK_CallHooksA( WH_JOURNALPLAYBACK
, HC_GETNEXT
, 0, (LPARAM
)&tmpMsg
);
160 /* TRACE(msg,"Playback wait time =%ld\n",wtime); */
164 msg
.message
= tmpMsg
.message
;
165 msg
.hwnd
= tmpMsg
.hwnd
;
166 msg
.time
= tmpMsg
.time
;
167 if ((tmpMsg
.message
>= WM_KEYFIRST
) && (tmpMsg
.message
<= WM_KEYLAST
))
169 msg
.wParam
= tmpMsg
.paramL
& 0xFF;
170 msg
.lParam
= MAKELONG(tmpMsg
.paramH
&0x7ffff,tmpMsg
.paramL
>>8);
171 if (tmpMsg
.message
== WM_KEYDOWN
|| tmpMsg
.message
== WM_SYSKEYDOWN
)
173 for (keyDown
=i
=0; i
<256 && !keyDown
; i
++)
174 if (InputKeyStateTable
[i
] & 0x80)
177 msg
.lParam
|= 0x40000000;
178 AsyncKeyStateTable
[msg
.wParam
]=InputKeyStateTable
[msg
.wParam
] |= 0x80;
180 else /* WM_KEYUP, WM_SYSKEYUP */
182 msg
.lParam
|= 0xC0000000;
183 AsyncKeyStateTable
[msg
.wParam
]=InputKeyStateTable
[msg
.wParam
] &= ~0x80;
185 if (InputKeyStateTable
[VK_MENU
] & 0x80)
186 msg
.lParam
|= 0x20000000;
187 if (tmpMsg
.paramH
& 0x8000) /*special_key bit*/
188 msg
.lParam
|= 0x01000000;
190 msg
.pt
.x
= msg
.pt
.y
= 0;
191 queue_hardware_message( &msg
, 0, MSG_HARDWARE_RAW
);
193 else if ((tmpMsg
.message
>= WM_MOUSEFIRST
) && (tmpMsg
.message
<= WM_MOUSELAST
))
195 switch (tmpMsg
.message
)
198 MouseButtonsStates
[0]=AsyncMouseButtonsStates
[0]=TRUE
;break;
200 MouseButtonsStates
[0]=AsyncMouseButtonsStates
[0]=FALSE
;break;
202 MouseButtonsStates
[1]=AsyncMouseButtonsStates
[1]=TRUE
;break;
204 MouseButtonsStates
[1]=AsyncMouseButtonsStates
[1]=FALSE
;break;
206 MouseButtonsStates
[2]=AsyncMouseButtonsStates
[2]=TRUE
;break;
208 MouseButtonsStates
[2]=AsyncMouseButtonsStates
[2]=FALSE
;break;
210 AsyncKeyStateTable
[VK_LBUTTON
]= InputKeyStateTable
[VK_LBUTTON
] = MouseButtonsStates
[0] ? 0x80 : 0;
211 AsyncKeyStateTable
[VK_MBUTTON
]= InputKeyStateTable
[VK_MBUTTON
] = MouseButtonsStates
[1] ? 0x80 : 0;
212 AsyncKeyStateTable
[VK_RBUTTON
]= InputKeyStateTable
[VK_RBUTTON
] = MouseButtonsStates
[2] ? 0x80 : 0;
213 SetCursorPos(tmpMsg
.paramL
,tmpMsg
.paramH
);
214 msg
.lParam
=MAKELONG(tmpMsg
.paramL
,tmpMsg
.paramH
);
216 if (MouseButtonsStates
[0]) msg
.wParam
|= MK_LBUTTON
;
217 if (MouseButtonsStates
[1]) msg
.wParam
|= MK_MBUTTON
;
218 if (MouseButtonsStates
[2]) msg
.wParam
|= MK_RBUTTON
;
220 msg
.pt
.x
= tmpMsg
.paramL
;
221 msg
.pt
.y
= tmpMsg
.paramH
;
222 queue_hardware_message( &msg
, 0, MSG_HARDWARE_RAW
);
224 HOOK_CallHooksA( WH_JOURNALPLAYBACK
, HC_SKIP
, 0, (LPARAM
)&tmpMsg
);
228 if( tmpMsg
.message
== WM_QUEUESYNC
)
229 if (HOOK_IsHooked( WH_CBT
))
230 HOOK_CallHooksA( WH_CBT
, HCBT_QS
, 0, 0L);
235 /***********************************************************************
236 * process_raw_keyboard_message
238 * returns TRUE if the contents of 'msg' should be passed to the application
240 static BOOL
process_raw_keyboard_message( MSG
*msg
, ULONG_PTR extra_info
)
242 if (!(msg
->hwnd
= GetFocus()))
244 /* Send the message to the active window instead, */
245 /* translating messages to their WM_SYS equivalent */
246 msg
->hwnd
= GetActiveWindow();
247 if (msg
->message
< WM_SYSKEYDOWN
) msg
->message
+= WM_SYSKEYDOWN
- WM_KEYDOWN
;
250 if (HOOK_IsHooked( WH_JOURNALRECORD
))
254 event
.message
= msg
->message
;
255 event
.hwnd
= msg
->hwnd
;
256 event
.time
= msg
->time
;
257 event
.paramL
= (msg
->wParam
& 0xFF) | (HIWORD(msg
->lParam
) << 8);
258 event
.paramH
= msg
->lParam
& 0x7FFF;
259 if (HIWORD(msg
->lParam
) & 0x0100) event
.paramH
|= 0x8000; /* special_key - bit */
260 HOOK_CallHooksA( WH_JOURNALRECORD
, HC_ACTION
, 0, (LPARAM
)&event
);
263 return (msg
->hwnd
!= 0);
267 /***********************************************************************
268 * process_cooked_keyboard_message
270 * returns TRUE if the contents of 'msg' should be passed to the application
272 static BOOL
process_cooked_keyboard_message( MSG
*msg
, BOOL remove
)
276 /* Handle F1 key by sending out WM_HELP message */
277 if ((msg
->message
== WM_KEYUP
) &&
278 (msg
->wParam
== VK_F1
) &&
279 (msg
->hwnd
!= GetDesktopWindow()) &&
280 !MENU_IsMenuActive())
283 hi
.cbSize
= sizeof(HELPINFO
);
284 hi
.iContextType
= HELPINFO_WINDOW
;
285 hi
.iCtrlId
= GetWindowLongA( msg
->hwnd
, GWL_ID
);
286 hi
.hItemHandle
= msg
->hwnd
;
287 hi
.dwContextId
= GetWindowContextHelpId( msg
->hwnd
);
288 hi
.MousePos
= msg
->pt
;
289 SendMessageA(msg
->hwnd
, WM_HELP
, 0, (LPARAM
)&hi
);
293 if (HOOK_CallHooksA( WH_KEYBOARD
, remove
? HC_ACTION
: HC_NOREMOVE
,
294 LOWORD(msg
->wParam
), msg
->lParam
))
296 /* skip this message */
297 HOOK_CallHooksA( WH_CBT
, HCBT_KEYSKIPPED
, LOWORD(msg
->wParam
), msg
->lParam
);
304 /***********************************************************************
305 * process_raw_mouse_message
307 * returns TRUE if the contents of 'msg' should be passed to the application
309 static BOOL
process_raw_mouse_message( MSG
*msg
, ULONG_PTR extra_info
)
316 /* find the window to dispatch this mouse message to */
319 if (!(msg
->hwnd
= PERQDATA_GetCaptureWnd( &ht
)))
321 /* If no capture HWND, find window which contains the mouse position.
322 * Also find the position of the cursor hot spot (hittest) */
323 HWND hWndScope
= (HWND
)extra_info
;
325 if (!IsWindow(hWndScope
)) hWndScope
= 0;
326 if (!(msg
->hwnd
= WINPOS_WindowFromPoint( hWndScope
, msg
->pt
, &hittest
)))
327 msg
->hwnd
= GetDesktopWindow();
331 if (HOOK_IsHooked( WH_JOURNALRECORD
))
334 event
.message
= msg
->message
;
335 event
.time
= msg
->time
;
336 event
.hwnd
= msg
->hwnd
;
337 event
.paramL
= msg
->pt
.x
;
338 event
.paramH
= msg
->pt
.y
;
339 HOOK_CallHooksA( WH_JOURNALRECORD
, HC_ACTION
, 0, (LPARAM
)&event
);
342 /* translate double clicks */
344 if ((msg
->message
== WM_LBUTTONDOWN
) ||
345 (msg
->message
== WM_RBUTTONDOWN
) ||
346 (msg
->message
== WM_MBUTTONDOWN
))
349 /* translate double clicks -
350 * note that ...MOUSEMOVEs can slip in between
351 * ...BUTTONDOWN and ...BUTTONDBLCLK messages */
353 if (GetClassLongA( msg
->hwnd
, GCL_STYLE
) & CS_DBLCLKS
|| ht
!= HTCLIENT
)
355 if ((msg
->message
== clk_msg
.message
) &&
356 (msg
->hwnd
== clk_msg
.hwnd
) &&
357 (msg
->time
- clk_msg
.time
< doubleClickSpeed
) &&
358 (abs(msg
->pt
.x
- clk_msg
.pt
.x
) < GetSystemMetrics(SM_CXDOUBLECLK
)/2) &&
359 (abs(msg
->pt
.y
- clk_msg
.pt
.y
) < GetSystemMetrics(SM_CYDOUBLECLK
)/2))
361 msg
->message
+= (WM_LBUTTONDBLCLK
- WM_LBUTTONDOWN
);
366 /* update static double click conditions */
367 if (update
) clk_msg
= *msg
;
371 /* Note: windows has no concept of a non-client wheel message */
372 if (hittest
!= HTCLIENT
&& msg
->message
!= WM_MOUSEWHEEL
)
374 msg
->message
+= WM_NCMOUSEMOVE
- WM_MOUSEMOVE
;
375 msg
->wParam
= hittest
;
377 else ScreenToClient( msg
->hwnd
, &pt
);
378 msg
->lParam
= MAKELONG( pt
.x
, pt
.y
);
383 /***********************************************************************
384 * process_cooked_mouse_message
386 * returns TRUE if the contents of 'msg' should be passed to the application
388 static BOOL
process_cooked_mouse_message( MSG
*msg
, BOOL remove
)
390 INT hittest
= HTCLIENT
;
391 UINT raw_message
= msg
->message
;
394 if (msg
->message
>= WM_NCMOUSEFIRST
&& msg
->message
<= WM_NCMOUSELAST
)
396 raw_message
+= WM_MOUSEFIRST
- WM_NCMOUSEFIRST
;
397 hittest
= msg
->wParam
;
399 if (raw_message
== WM_LBUTTONDBLCLK
||
400 raw_message
== WM_RBUTTONDBLCLK
||
401 raw_message
== WM_MBUTTONDBLCLK
)
403 raw_message
+= WM_LBUTTONDOWN
- WM_LBUTTONDBLCLK
;
406 if (HOOK_IsHooked( WH_MOUSE
))
408 MOUSEHOOKSTRUCT hook
;
410 hook
.hwnd
= msg
->hwnd
;
411 hook
.wHitTestCode
= hittest
;
412 hook
.dwExtraInfo
= 0;
413 if (HOOK_CallHooksA( WH_MOUSE
, remove
? HC_ACTION
: HC_NOREMOVE
,
414 msg
->message
, (LPARAM
)&hook
))
417 hook
.hwnd
= msg
->hwnd
;
418 hook
.wHitTestCode
= hittest
;
419 hook
.dwExtraInfo
= 0;
420 HOOK_CallHooksA( WH_CBT
, HCBT_CLICKSKIPPED
, msg
->message
, (LPARAM
)&hook
);
425 if ((hittest
== HTERROR
) || (hittest
== HTNOWHERE
))
427 SendMessageA( msg
->hwnd
, WM_SETCURSOR
, msg
->hwnd
, MAKELONG( hittest
, raw_message
));
431 if (!remove
|| GetCapture()) return TRUE
;
435 if ((raw_message
== WM_LBUTTONDOWN
) ||
436 (raw_message
== WM_RBUTTONDOWN
) ||
437 (raw_message
== WM_MBUTTONDOWN
))
439 HWND hwndTop
= WIN_GetTopParent( msg
->hwnd
);
441 /* Send the WM_PARENTNOTIFY,
442 * note that even for double/nonclient clicks
443 * notification message is still WM_L/M/RBUTTONDOWN.
445 MSG_SendParentNotify( msg
->hwnd
, raw_message
, 0, msg
->pt
);
447 /* Activate the window if needed */
449 if (msg
->hwnd
!= GetActiveWindow() && hwndTop
!= GetDesktopWindow())
451 LONG ret
= SendMessageA( msg
->hwnd
, WM_MOUSEACTIVATE
, hwndTop
,
452 MAKELONG( hittest
, raw_message
) );
456 case MA_NOACTIVATEANDEAT
:
461 case MA_ACTIVATEANDEAT
:
465 if (hwndTop
!= GetForegroundWindow() )
467 if (!WINPOS_SetActiveWindow( hwndTop
, TRUE
, TRUE
))
472 WARN( "unknown WM_MOUSEACTIVATE code %ld\n", ret
);
478 /* send the WM_SETCURSOR message */
480 /* Windows sends the normal mouse message as the message parameter
481 in the WM_SETCURSOR message even if it's non-client mouse message */
482 SendMessageA( msg
->hwnd
, WM_SETCURSOR
, msg
->hwnd
, MAKELONG( hittest
, raw_message
));
488 /***********************************************************************
489 * process_hardware_message
491 * returns TRUE if the contents of 'msg' should be passed to the application
493 BOOL
MSG_process_raw_hardware_message( MSG
*msg
, ULONG_PTR extra_info
, HWND hwnd_filter
,
494 UINT first
, UINT last
, BOOL remove
)
496 if (is_keyboard_message( msg
->message
))
498 if (!process_raw_keyboard_message( msg
, extra_info
)) return FALSE
;
500 else if (is_mouse_message( msg
->message
))
502 if (!process_raw_mouse_message( msg
, extra_info
)) return FALSE
;
506 ERR( "unknown message type %x\n", msg
->message
);
510 /* check destination thread and filters */
511 if (!check_message_filter( msg
, hwnd_filter
, first
, last
) ||
512 GetWindowThreadProcessId( msg
->hwnd
, NULL
) != GetCurrentThreadId())
514 /* queue it for later, or for another thread */
515 queue_hardware_message( msg
, extra_info
, MSG_HARDWARE_COOKED
);
519 /* save the message in the cooked queue if we didn't want to remove it */
520 if (!remove
) queue_hardware_message( msg
, extra_info
, MSG_HARDWARE_COOKED
);
525 /***********************************************************************
526 * MSG_process_cooked_hardware_message
528 * returns TRUE if the contents of 'msg' should be passed to the application
530 BOOL
MSG_process_cooked_hardware_message( MSG
*msg
, BOOL remove
)
532 if (is_keyboard_message( msg
->message
))
533 return process_cooked_keyboard_message( msg
, remove
);
535 if (is_mouse_message( msg
->message
))
536 return process_cooked_mouse_message( msg
, remove
);
538 ERR( "unknown message type %x\n", msg
->message
);
543 /**********************************************************************
544 * SetDoubleClickTime (USER32.@)
546 BOOL WINAPI
SetDoubleClickTime( UINT interval
)
548 doubleClickSpeed
= interval
? interval
: 500;
553 /**********************************************************************
554 * GetDoubleClickTime (USER32.@)
556 UINT WINAPI
GetDoubleClickTime(void)
558 return doubleClickSpeed
;
562 /***********************************************************************
563 * WaitMessage (USER.112) Suspend thread pending messages
564 * WaitMessage (USER32.@) Suspend thread pending messages
566 * WaitMessage() suspends a thread until events appear in the thread's
569 BOOL WINAPI
WaitMessage(void)
571 return (MsgWaitForMultipleObjectsEx( 0, NULL
, INFINITE
, QS_ALLINPUT
, 0 ) != WAIT_FAILED
);
575 /***********************************************************************
576 * MsgWaitForMultipleObjectsEx (USER32.@)
578 DWORD WINAPI
MsgWaitForMultipleObjectsEx( DWORD count
, CONST HANDLE
*pHandles
,
579 DWORD timeout
, DWORD mask
, DWORD flags
)
581 HANDLE handles
[MAXIMUM_WAIT_OBJECTS
];
583 MESSAGEQUEUE
*msgQueue
;
585 if (count
> MAXIMUM_WAIT_OBJECTS
-1)
587 SetLastError( ERROR_INVALID_PARAMETER
);
591 if (!(msgQueue
= QUEUE_Current())) return WAIT_FAILED
;
593 /* set the queue mask */
594 SERVER_START_REQ( set_queue_mask
)
596 req
->wake_mask
= (flags
& MWMO_INPUTAVAILABLE
) ? mask
: 0;
597 req
->changed_mask
= mask
;
603 /* Add the thread event to the handle list */
604 for (i
= 0; i
< count
; i
++) handles
[i
] = pHandles
[i
];
605 handles
[count
] = msgQueue
->server_queue
;
608 if (USER_Driver
.pMsgWaitForMultipleObjectsEx
)
610 ret
= USER_Driver
.pMsgWaitForMultipleObjectsEx( count
+1, handles
, timeout
, mask
, flags
);
611 if (ret
== count
+1) ret
= count
; /* pretend the msg queue is ready */
614 ret
= WaitForMultipleObjectsEx( count
+1, handles
, flags
& MWMO_WAITALL
,
615 timeout
, flags
& MWMO_ALERTABLE
);
620 /***********************************************************************
621 * MsgWaitForMultipleObjects (USER32.@)
623 DWORD WINAPI
MsgWaitForMultipleObjects( DWORD count
, CONST HANDLE
*handles
,
624 BOOL wait_all
, DWORD timeout
, DWORD mask
)
626 return MsgWaitForMultipleObjectsEx( count
, handles
, timeout
, mask
,
627 wait_all
? MWMO_WAITALL
: 0 );
631 /***********************************************************************
632 * WaitForInputIdle (USER32.@)
634 DWORD WINAPI
WaitForInputIdle( HANDLE hProcess
, DWORD dwTimeOut
)
637 HANDLE idle_event
= -1;
639 SERVER_START_REQ( wait_input_idle
)
641 req
->handle
= hProcess
;
642 req
->timeout
= dwTimeOut
;
643 if (!(ret
= SERVER_CALL_ERR())) idle_event
= req
->event
;
646 if (ret
) return 0xffffffff; /* error */
647 if (!idle_event
) return 0; /* no event to wait on */
649 cur_time
= GetTickCount();
651 TRACE("waiting for %x\n", idle_event
);
652 while ( dwTimeOut
> GetTickCount() - cur_time
|| dwTimeOut
== INFINITE
)
654 ret
= MsgWaitForMultipleObjects ( 1, &idle_event
, FALSE
, dwTimeOut
, QS_SENDMESSAGE
);
655 if ( ret
== ( WAIT_OBJECT_0
+ 1 ))
657 process_sent_messages();
660 if ( ret
== WAIT_TIMEOUT
|| ret
== 0xFFFFFFFF )
662 TRACE("timeout or error\n");
676 /***********************************************************************
677 * UserYield (USER.332)
678 * UserYield16 (USER32.@)
680 void WINAPI
UserYield16(void)
684 /* Handle sent messages */
685 process_sent_messages();
688 ReleaseThunkLock(&count
);
691 RestoreThunkLock(count
);
692 /* Handle sent messages again */
693 process_sent_messages();
705 static const struct accent_char accent_chars
[] =
707 /* A good idea should be to read /usr/X11/lib/X11/locale/iso8859-x/Compose */
708 {'`', 'A', '\300'}, {'`', 'a', '\340'},
709 {'\'', 'A', '\301'}, {'\'', 'a', '\341'},
710 {'^', 'A', '\302'}, {'^', 'a', '\342'},
711 {'~', 'A', '\303'}, {'~', 'a', '\343'},
712 {'"', 'A', '\304'}, {'"', 'a', '\344'},
713 {'O', 'A', '\305'}, {'o', 'a', '\345'},
714 {'0', 'A', '\305'}, {'0', 'a', '\345'},
715 {'A', 'A', '\305'}, {'a', 'a', '\345'},
716 {'A', 'E', '\306'}, {'a', 'e', '\346'},
717 {',', 'C', '\307'}, {',', 'c', '\347'},
718 {'`', 'E', '\310'}, {'`', 'e', '\350'},
719 {'\'', 'E', '\311'}, {'\'', 'e', '\351'},
720 {'^', 'E', '\312'}, {'^', 'e', '\352'},
721 {'"', 'E', '\313'}, {'"', 'e', '\353'},
722 {'`', 'I', '\314'}, {'`', 'i', '\354'},
723 {'\'', 'I', '\315'}, {'\'', 'i', '\355'},
724 {'^', 'I', '\316'}, {'^', 'i', '\356'},
725 {'"', 'I', '\317'}, {'"', 'i', '\357'},
726 {'-', 'D', '\320'}, {'-', 'd', '\360'},
727 {'~', 'N', '\321'}, {'~', 'n', '\361'},
728 {'`', 'O', '\322'}, {'`', 'o', '\362'},
729 {'\'', 'O', '\323'}, {'\'', 'o', '\363'},
730 {'^', 'O', '\324'}, {'^', 'o', '\364'},
731 {'~', 'O', '\325'}, {'~', 'o', '\365'},
732 {'"', 'O', '\326'}, {'"', 'o', '\366'},
733 {'/', 'O', '\330'}, {'/', 'o', '\370'},
734 {'`', 'U', '\331'}, {'`', 'u', '\371'},
735 {'\'', 'U', '\332'}, {'\'', 'u', '\372'},
736 {'^', 'U', '\333'}, {'^', 'u', '\373'},
737 {'"', 'U', '\334'}, {'"', 'u', '\374'},
738 {'\'', 'Y', '\335'}, {'\'', 'y', '\375'},
739 {'T', 'H', '\336'}, {'t', 'h', '\376'},
740 {'s', 's', '\337'}, {'"', 'y', '\377'},
741 {'s', 'z', '\337'}, {'i', 'j', '\377'},
742 /* iso-8859-2 uses this */
743 {'<', 'L', '\245'}, {'<', 'l', '\265'}, /* caron */
744 {'<', 'S', '\251'}, {'<', 's', '\271'},
745 {'<', 'T', '\253'}, {'<', 't', '\273'},
746 {'<', 'Z', '\256'}, {'<', 'z', '\276'},
747 {'<', 'C', '\310'}, {'<', 'c', '\350'},
748 {'<', 'E', '\314'}, {'<', 'e', '\354'},
749 {'<', 'D', '\317'}, {'<', 'd', '\357'},
750 {'<', 'N', '\322'}, {'<', 'n', '\362'},
751 {'<', 'R', '\330'}, {'<', 'r', '\370'},
752 {';', 'A', '\241'}, {';', 'a', '\261'}, /* ogonek */
753 {';', 'E', '\312'}, {';', 'e', '\332'},
754 {'\'', 'Z', '\254'}, {'\'', 'z', '\274'}, /* acute */
755 {'\'', 'R', '\300'}, {'\'', 'r', '\340'},
756 {'\'', 'L', '\305'}, {'\'', 'l', '\345'},
757 {'\'', 'C', '\306'}, {'\'', 'c', '\346'},
758 {'\'', 'N', '\321'}, {'\'', 'n', '\361'},
759 /* collision whith S, from iso-8859-9 !!! */
760 {',', 'S', '\252'}, {',', 's', '\272'}, /* cedilla */
761 {',', 'T', '\336'}, {',', 't', '\376'},
762 {'.', 'Z', '\257'}, {'.', 'z', '\277'}, /* dot above */
763 {'/', 'L', '\243'}, {'/', 'l', '\263'}, /* slash */
764 {'/', 'D', '\320'}, {'/', 'd', '\360'},
765 {'(', 'A', '\303'}, {'(', 'a', '\343'}, /* breve */
766 {'\275', 'O', '\325'}, {'\275', 'o', '\365'}, /* double acute */
767 {'\275', 'U', '\334'}, {'\275', 'u', '\374'},
768 {'0', 'U', '\332'}, {'0', 'u', '\372'}, /* ring above */
769 /* iso-8859-3 uses this */
770 {'/', 'H', '\241'}, {'/', 'h', '\261'}, /* slash */
771 {'>', 'H', '\246'}, {'>', 'h', '\266'}, /* circumflex */
772 {'>', 'J', '\254'}, {'>', 'j', '\274'},
773 {'>', 'C', '\306'}, {'>', 'c', '\346'},
774 {'>', 'G', '\330'}, {'>', 'g', '\370'},
775 {'>', 'S', '\336'}, {'>', 's', '\376'},
776 /* collision whith G( from iso-8859-9 !!! */
777 {'(', 'G', '\253'}, {'(', 'g', '\273'}, /* breve */
778 {'(', 'U', '\335'}, {'(', 'u', '\375'},
779 /* collision whith I. from iso-8859-3 !!! */
780 {'.', 'I', '\251'}, {'.', 'i', '\271'}, /* dot above */
781 {'.', 'C', '\305'}, {'.', 'c', '\345'},
782 {'.', 'G', '\325'}, {'.', 'g', '\365'},
783 /* iso-8859-4 uses this */
784 {',', 'R', '\243'}, {',', 'r', '\263'}, /* cedilla */
785 {',', 'L', '\246'}, {',', 'l', '\266'},
786 {',', 'G', '\253'}, {',', 'g', '\273'},
787 {',', 'N', '\321'}, {',', 'n', '\361'},
788 {',', 'K', '\323'}, {',', 'k', '\363'},
789 {'~', 'I', '\245'}, {'~', 'i', '\265'}, /* tilde */
790 {'-', 'E', '\252'}, {'-', 'e', '\272'}, /* macron */
791 {'-', 'A', '\300'}, {'-', 'a', '\340'},
792 {'-', 'I', '\317'}, {'-', 'i', '\357'},
793 {'-', 'O', '\322'}, {'-', 'o', '\362'},
794 {'-', 'U', '\336'}, {'-', 'u', '\376'},
795 {'/', 'T', '\254'}, {'/', 't', '\274'}, /* slash */
796 {'.', 'E', '\314'}, {'.', 'e', '\344'}, /* dot above */
797 {';', 'I', '\307'}, {';', 'i', '\347'}, /* ogonek */
798 {';', 'U', '\331'}, {';', 'u', '\371'},
799 /* iso-8859-9 uses this */
800 /* iso-8859-9 has really bad choosen G( S, and I. as they collide
801 * whith the same letters on other iso-8859-x (that is they are on
802 * different places :-( ), if you use turkish uncomment these and
803 * comment out the lines in iso-8859-2 and iso-8859-3 sections
804 * FIXME: should be dynamic according to chosen language
805 * if/when Wine has turkish support.
807 /* collision whith G( from iso-8859-3 !!! */
808 /* {'(', 'G', '\320'}, {'(', 'g', '\360'}, */ /* breve */
809 /* collision whith S, from iso-8859-2 !!! */
810 /* {',', 'S', '\336'}, {',', 's', '\376'}, */ /* cedilla */
811 /* collision whith I. from iso-8859-3 !!! */
812 /* {'.', 'I', '\335'}, {'.', 'i', '\375'}, */ /* dot above */
816 /***********************************************************************
817 * TranslateMessage (USER32.@)
819 * Implementation of TranslateMessage.
821 * TranslateMessage translates virtual-key messages into character-messages,
823 * WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message.
824 * ditto replacing WM_* with WM_SYS*
825 * This produces WM_CHAR messages only for keys mapped to ASCII characters
826 * by the keyboard driver.
828 BOOL WINAPI
TranslateMessage( const MSG
*msg
)
830 static int dead_char
;
834 if (msg
->message
>= WM_KEYFIRST
&& msg
->message
<= WM_KEYLAST
)
835 TRACE_(key
)("(%s, %04X, %08lX)\n",
836 SPY_GetMsgName(msg
->message
), msg
->wParam
, msg
->lParam
);
838 if ((msg
->message
!= WM_KEYDOWN
) && (msg
->message
!= WM_SYSKEYDOWN
)) return FALSE
;
840 TRACE_(key
)("Translating key %s (%04x), scancode %02x\n",
841 SPY_GetVKeyName(msg
->wParam
), msg
->wParam
, LOBYTE(HIWORD(msg
->lParam
)));
843 /* FIXME : should handle ToUnicode yielding 2 */
844 switch (ToUnicode(msg
->wParam
, HIWORD(msg
->lParam
), QueueKeyStateTable
, wp
, 2, 0))
847 message
= (msg
->message
== WM_KEYDOWN
) ? WM_CHAR
: WM_SYSCHAR
;
848 /* Should dead chars handling go in ToAscii ? */
853 if (wp
[0] == ' ') wp
[0] = dead_char
;
854 if (dead_char
== 0xa2) dead_char
= '(';
855 else if (dead_char
== 0xa8) dead_char
= '"';
856 else if (dead_char
== 0xb2) dead_char
= ';';
857 else if (dead_char
== 0xb4) dead_char
= '\'';
858 else if (dead_char
== 0xb7) dead_char
= '<';
859 else if (dead_char
== 0xb8) dead_char
= ',';
860 else if (dead_char
== 0xff) dead_char
= '.';
861 for (i
= 0; i
< sizeof(accent_chars
)/sizeof(accent_chars
[0]); i
++)
862 if ((accent_chars
[i
].ac_accent
== dead_char
) &&
863 (accent_chars
[i
].ac_char
== wp
[0]))
865 wp
[0] = accent_chars
[i
].ac_result
;
870 TRACE_(key
)("1 -> PostMessage(%s)\n", SPY_GetMsgName(message
));
871 PostMessageW( msg
->hwnd
, message
, wp
[0], msg
->lParam
);
875 message
= (msg
->message
== WM_KEYDOWN
) ? WM_DEADCHAR
: WM_SYSDEADCHAR
;
877 TRACE_(key
)("-1 -> PostMessage(%s)\n", SPY_GetMsgName(message
));
878 PostMessageW( msg
->hwnd
, message
, wp
[0], msg
->lParam
);
885 /***********************************************************************
886 * DispatchMessageA (USER32.@)
888 LONG WINAPI
DispatchMessageA( const MSG
* msg
)
894 /* Process timer messages */
895 if ((msg
->message
== WM_TIMER
) || (msg
->message
== WM_SYSTIMER
))
899 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
901 /* before calling window proc, verify whether timer is still valid;
902 there's a slim chance that the application kills the timer
903 between GetMessage and DispatchMessage API calls */
904 if (!TIMER_IsTimerValid(msg
->hwnd
, (UINT
) msg
->wParam
, (HWINDOWPROC
) msg
->lParam
))
905 return 0; /* invalid winproc */
907 return CallWindowProcA( (WNDPROC
)msg
->lParam
, msg
->hwnd
,
908 msg
->message
, msg
->wParam
, GetTickCount() );
912 if (!msg
->hwnd
) return 0;
913 if (!(wndPtr
= WIN_FindWndPtr( msg
->hwnd
))) return 0;
914 if (!wndPtr
->winproc
)
919 painting
= (msg
->message
== WM_PAINT
);
920 if (painting
) wndPtr
->flags
|= WIN_NEEDS_BEGINPAINT
;
921 /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
923 SPY_EnterMessage( SPY_DISPATCHMESSAGE
, msg
->hwnd
, msg
->message
,
924 msg
->wParam
, msg
->lParam
);
925 retval
= CallWindowProcA( (WNDPROC
)wndPtr
->winproc
,
926 msg
->hwnd
, msg
->message
,
927 msg
->wParam
, msg
->lParam
);
928 SPY_ExitMessage( SPY_RESULT_OK
, msg
->hwnd
, msg
->message
, retval
,
929 msg
->wParam
, msg
->lParam
);
931 WIN_ReleaseWndPtr(wndPtr
);
932 wndPtr
= WIN_FindWndPtr(msg
->hwnd
);
934 if (painting
&& wndPtr
&&
935 (wndPtr
->flags
& WIN_NEEDS_BEGINPAINT
) && wndPtr
->hrgnUpdate
)
937 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
939 wndPtr
->flags
&= ~WIN_NEEDS_BEGINPAINT
;
940 /* Validate the update region to avoid infinite WM_PAINT loop */
941 RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0,
942 RDW_NOFRAME
| RDW_VALIDATE
| RDW_NOCHILDREN
| RDW_NOINTERNALPAINT
);
945 WIN_ReleaseWndPtr(wndPtr
);
950 /***********************************************************************
951 * DispatchMessageW (USER32.@) Process Message
953 * Process the message specified in the structure *_msg_.
955 * If the lpMsg parameter points to a WM_TIMER message and the
956 * parameter of the WM_TIMER message is not NULL, the lParam parameter
957 * points to the function that is called instead of the window
960 * The message must be valid.
964 * DispatchMessage() returns the result of the window procedure invoked.
971 LONG WINAPI
DispatchMessageW( const MSG
* msg
)
977 /* Process timer messages */
978 if ((msg
->message
== WM_TIMER
) || (msg
->message
== WM_SYSTIMER
))
982 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
984 /* before calling window proc, verify whether timer is still valid;
985 there's a slim chance that the application kills the timer
986 between GetMessage and DispatchMessage API calls */
987 if (!TIMER_IsTimerValid(msg
->hwnd
, (UINT
) msg
->wParam
, (HWINDOWPROC
) msg
->lParam
))
988 return 0; /* invalid winproc */
990 return CallWindowProcW( (WNDPROC
)msg
->lParam
, msg
->hwnd
,
991 msg
->message
, msg
->wParam
, GetTickCount() );
995 if (!msg
->hwnd
) return 0;
996 if (!(wndPtr
= WIN_FindWndPtr( msg
->hwnd
))) return 0;
997 if (!wndPtr
->winproc
)
1002 painting
= (msg
->message
== WM_PAINT
);
1003 if (painting
) wndPtr
->flags
|= WIN_NEEDS_BEGINPAINT
;
1004 /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
1006 SPY_EnterMessage( SPY_DISPATCHMESSAGE
, msg
->hwnd
, msg
->message
,
1007 msg
->wParam
, msg
->lParam
);
1008 retval
= CallWindowProcW( (WNDPROC
)wndPtr
->winproc
,
1009 msg
->hwnd
, msg
->message
,
1010 msg
->wParam
, msg
->lParam
);
1011 SPY_ExitMessage( SPY_RESULT_OK
, msg
->hwnd
, msg
->message
, retval
,
1012 msg
->wParam
, msg
->lParam
);
1014 WIN_ReleaseWndPtr(wndPtr
);
1015 wndPtr
= WIN_FindWndPtr(msg
->hwnd
);
1017 if (painting
&& wndPtr
&&
1018 (wndPtr
->flags
& WIN_NEEDS_BEGINPAINT
) && wndPtr
->hrgnUpdate
)
1020 ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n",
1022 wndPtr
->flags
&= ~WIN_NEEDS_BEGINPAINT
;
1023 /* Validate the update region to avoid infinite WM_PAINT loop */
1024 RedrawWindow( wndPtr
->hwndSelf
, NULL
, 0,
1025 RDW_NOFRAME
| RDW_VALIDATE
| RDW_NOCHILDREN
| RDW_NOINTERNALPAINT
);
1028 WIN_ReleaseWndPtr(wndPtr
);
1033 /***********************************************************************
1034 * RegisterWindowMessage (USER.118)
1035 * RegisterWindowMessageA (USER32.@)
1037 WORD WINAPI
RegisterWindowMessageA( LPCSTR str
)
1039 TRACE("%s\n", str
);
1040 return GlobalAddAtomA( str
);
1044 /***********************************************************************
1045 * RegisterWindowMessageW (USER32.@)
1047 WORD WINAPI
RegisterWindowMessageW( LPCWSTR str
)
1049 TRACE("%p\n", str
);
1050 return GlobalAddAtomW( str
);
1054 /***********************************************************************
1055 * BroadcastSystemMessage (USER32.@)
1057 LONG WINAPI
BroadcastSystemMessage(
1058 DWORD dwFlags
,LPDWORD recipients
,UINT uMessage
,WPARAM wParam
,
1061 FIXME("(%08lx,%08lx,%08x,%08x,%08lx): stub!\n",
1062 dwFlags
,*recipients
,uMessage
,wParam
,lParam