Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Message queues related functions |
| 3 | * |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 4 | * Copyright 1993, 1994 Alexandre Julliard |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 7 | #include <stdlib.h> |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 8 | #include <string.h> |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 9 | #include <ctype.h> |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 10 | #include <sys/time.h> |
| 11 | #include <sys/types.h> |
Alexandre Julliard | f41aeca | 1993-09-14 16:47:10 +0000 | [diff] [blame] | 12 | |
Marcus Meissner | 317af32 | 1999-02-17 13:51:06 +0000 | [diff] [blame] | 13 | #include "wine/winbase16.h" |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 14 | #include "message.h" |
Alexandre Julliard | dbf2bf0 | 1999-01-01 17:05:53 +0000 | [diff] [blame] | 15 | #include "winerror.h" |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 16 | #include "win.h" |
Alexandre Julliard | 8cc3a5e | 1996-08-11 15:49:51 +0000 | [diff] [blame] | 17 | #include "heap.h" |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 18 | #include "hook.h" |
Ulrich Weigand | a11ce32 | 1998-11-08 12:27:26 +0000 | [diff] [blame] | 19 | #include "input.h" |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 20 | #include "spy.h" |
Alexandre Julliard | 234bc24 | 1994-12-10 13:02:28 +0000 | [diff] [blame] | 21 | #include "winpos.h" |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 22 | #include "dde.h" |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 23 | #include "queue.h" |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 24 | #include "winproc.h" |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 25 | #include "thread.h" |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 26 | #include "options.h" |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 27 | #include "controls.h" |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 28 | #include "struct32.h" |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 29 | #include "debugtools.h" |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 30 | |
Alexandre Julliard | c5e433a | 2000-05-30 19:48:18 +0000 | [diff] [blame] | 31 | DEFAULT_DEBUG_CHANNEL(msg); |
| 32 | DECLARE_DEBUG_CHANNEL(key); |
| 33 | DECLARE_DEBUG_CHANNEL(sendmsg); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 34 | |
Alexandre Julliard | ac9c9b0 | 1996-07-28 18:50:11 +0000 | [diff] [blame] | 35 | #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE |
| 36 | #define WM_NCMOUSELAST WM_NCMBUTTONDBLCLK |
| 37 | |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 38 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 39 | typedef enum { SYSQ_MSG_ABANDON, SYSQ_MSG_SKIP, |
| 40 | SYSQ_MSG_ACCEPT, SYSQ_MSG_CONTINUE } SYSQ_STATUS; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 41 | |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 42 | extern HQUEUE16 hCursorQueue; /* queue.c */ |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 43 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 44 | static UINT doubleClickSpeed = 452; |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 45 | |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 46 | /*********************************************************************** |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 47 | * MSG_CheckFilter |
| 48 | */ |
Patrik Stridvall | 1ed4ecf | 1999-06-26 14:58:24 +0000 | [diff] [blame] | 49 | static BOOL MSG_CheckFilter(DWORD uMsg, DWORD first, DWORD last) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 50 | { |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 51 | if( first || last ) |
| 52 | return (uMsg >= first && uMsg <= last); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 53 | return TRUE; |
| 54 | } |
| 55 | |
| 56 | /*********************************************************************** |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 57 | * MSG_SendParentNotify |
| 58 | * |
| 59 | * Send a WM_PARENTNOTIFY to all ancestors of the given window, unless |
| 60 | * the window has the WS_EX_NOPARENTNOTIFY style. |
| 61 | */ |
| 62 | static void MSG_SendParentNotify(WND* wndPtr, WORD event, WORD idChild, LPARAM lValue) |
| 63 | { |
Ulrich Weigand | e27670e | 2001-01-11 00:52:50 +0000 | [diff] [blame] | 64 | POINT pt; |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 65 | |
| 66 | /* pt has to be in the client coordinates of the parent window */ |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 67 | WND *tmpWnd = WIN_LockWndPtr(wndPtr); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 68 | |
Ulrich Weigand | e27670e | 2001-01-11 00:52:50 +0000 | [diff] [blame] | 69 | pt.x = SLOWORD(lValue); |
| 70 | pt.y = SHIWORD(lValue); |
| 71 | MapWindowPoints( 0, tmpWnd->hwndSelf, &pt, 1 ); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 72 | while (tmpWnd) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 73 | { |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 74 | if (!(tmpWnd->dwStyle & WS_CHILD) || (tmpWnd->dwExStyle & WS_EX_NOPARENTNOTIFY)) |
Ulrich Weigand | e27670e | 2001-01-11 00:52:50 +0000 | [diff] [blame] | 75 | { |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 76 | WIN_ReleaseWndPtr(tmpWnd); |
| 77 | break; |
| 78 | } |
Ulrich Weigand | e27670e | 2001-01-11 00:52:50 +0000 | [diff] [blame] | 79 | pt.x += tmpWnd->rectClient.left; |
| 80 | pt.y += tmpWnd->rectClient.top; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 81 | WIN_UpdateWndPtr(&tmpWnd,tmpWnd->parent); |
| 82 | SendMessageA( tmpWnd->hwndSelf, WM_PARENTNOTIFY, |
Ulrich Weigand | e27670e | 2001-01-11 00:52:50 +0000 | [diff] [blame] | 83 | MAKEWPARAM( event, idChild ), |
| 84 | MAKELONG( pt.x, pt.y ) ); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 85 | } |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | |
| 89 | /*********************************************************************** |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 90 | * MSG_TranslateMouseMsg |
| 91 | * |
Andreas Mohr | 20cd935 | 2000-09-12 23:40:40 +0000 | [diff] [blame] | 92 | * Translate a mouse hardware event into a real mouse message. |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 93 | * |
| 94 | * Returns: |
| 95 | * |
| 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 |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 100 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 101 | static DWORD MSG_TranslateMouseMsg( HWND hTopWnd, DWORD first, DWORD last, |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 102 | MSG *msg, BOOL remove, WND* pWndScope, |
| 103 | INT16 *pHitTest, POINT16 *pScreen_pt, BOOL *pmouseClick ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 104 | { |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 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 }; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 109 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 110 | WND *pWnd; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 111 | HWND hWnd; |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 112 | INT16 ht, hittest; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 113 | UINT message = msg->message; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 114 | POINT16 screen_pt, pt; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 115 | HANDLE16 hQ = GetFastQueue16(); |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 116 | MESSAGEQUEUE *queue = QUEUE_Lock(hQ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 117 | BOOL mouseClick = ((message == WM_LBUTTONDOWN) || |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 118 | (message == WM_RBUTTONDOWN) || |
| 119 | (message == WM_MBUTTONDOWN))?1:0; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 120 | DWORD retvalue; |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 121 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 122 | /* Find the window to dispatch this mouse message to */ |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 123 | |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 124 | CONV_POINT32TO16( &msg->pt, &pt ); |
| 125 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 126 | hWnd = GetCapture(); |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 127 | |
| 128 | /* If no capture HWND, find window which contains the mouse position. |
| 129 | * Also find the position of the cursor hot spot (hittest) */ |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 130 | if( !hWnd ) |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 131 | { |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 132 | ht = hittest = WINPOS_WindowFromPoint( pWndScope, pt, &pWnd ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 133 | if( !pWnd ) pWnd = WIN_GetDesktop(); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 134 | else WIN_LockWndPtr(pWnd); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 135 | hWnd = pWnd->hwndSelf; |
| 136 | } |
| 137 | else |
| 138 | { |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 139 | ht = hittest = HTCLIENT; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 140 | pWnd = WIN_FindWndPtr(hWnd); |
Noel Borthwick | b427856 | 1999-02-05 10:37:53 +0000 | [diff] [blame] | 141 | if (queue) |
| 142 | ht = PERQDATA_GetCaptureInfo( queue->pQData ); |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 143 | } |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 144 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 145 | /* Save hittest for return */ |
| 146 | *pHitTest = hittest; |
| 147 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 148 | /* stop if not the right queue */ |
| 149 | |
| 150 | if (pWnd->hmemTaskQ != hQ) |
Alexandre Julliard | 8b91563 | 1996-06-16 16:16:05 +0000 | [diff] [blame] | 151 | { |
| 152 | /* Not for the current task */ |
Alexandre Julliard | 8b91563 | 1996-06-16 16:16:05 +0000 | [diff] [blame] | 153 | if (queue) QUEUE_ClearWakeBit( queue, QS_MOUSE ); |
| 154 | /* Wake up the other task */ |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 155 | QUEUE_Unlock( queue ); |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 156 | queue = QUEUE_Lock( pWnd->hmemTaskQ ); |
Alexandre Julliard | 8b91563 | 1996-06-16 16:16:05 +0000 | [diff] [blame] | 157 | if (queue) QUEUE_SetWakeBit( queue, QS_MOUSE ); |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 158 | |
| 159 | QUEUE_Unlock( queue ); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 160 | retvalue = SYSQ_MSG_ABANDON; |
| 161 | goto END; |
Alexandre Julliard | 8b91563 | 1996-06-16 16:16:05 +0000 | [diff] [blame] | 162 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 163 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 164 | /* check if hWnd is within hWndScope */ |
| 165 | |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 166 | if( hTopWnd && hWnd != hTopWnd ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 167 | if( !IsChild(hTopWnd, hWnd) ) |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 168 | { |
| 169 | QUEUE_Unlock( queue ); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 170 | retvalue = SYSQ_MSG_CONTINUE; |
| 171 | goto END; |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 172 | } |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 173 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 174 | /* Was it a mouse click message */ |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 175 | if( mouseClick ) |
Alexandre Julliard | dba420a | 1994-02-02 06:48:31 +0000 | [diff] [blame] | 176 | { |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 177 | /* translate double clicks - |
| 178 | * note that ...MOUSEMOVEs can slip in between |
| 179 | * ...BUTTONDOWN and ...BUTTONDBLCLK messages */ |
Alexandre Julliard | 329f068 | 1996-04-14 13:21:20 +0000 | [diff] [blame] | 180 | |
Patrik Stridvall | 4bf3354 | 1999-06-12 14:52:15 +0000 | [diff] [blame] | 181 | if(GetClassLongA(hWnd, GCL_STYLE) & CS_DBLCLKS || ht != HTCLIENT ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 182 | { |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 183 | if ((message == clk_message) && (hWnd == clk_hwnd) && |
| 184 | (msg->time - dblclk_time_limit < doubleClickSpeed) && |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 185 | (abs(msg->pt.x - clk_pos.x) < GetSystemMetrics(SM_CXDOUBLECLK)/2) && |
| 186 | (abs(msg->pt.y - clk_pos.y) < GetSystemMetrics(SM_CYDOUBLECLK)/2)) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 187 | { |
| 188 | message += (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); |
| 189 | mouseClick++; /* == 2 */ |
| 190 | } |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 191 | } |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 192 | } |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 193 | /* save mouse position */ |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 194 | screen_pt = pt; |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 195 | *pScreen_pt = pt; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 196 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 197 | if (hittest != HTCLIENT) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 198 | { |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 199 | message += WM_NCMOUSEMOVE - WM_MOUSEMOVE; |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 200 | msg->wParam = hittest; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 201 | } |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 202 | else |
| 203 | ScreenToClient16( hWnd, &pt ); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 204 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 205 | /* check message filter */ |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 206 | |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 207 | if (!MSG_CheckFilter(message, first, last)) |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 208 | { |
| 209 | QUEUE_Unlock(queue); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 210 | retvalue = SYSQ_MSG_CONTINUE; |
| 211 | goto END; |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 212 | } |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 213 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 214 | /* Update global hCursorQueue */ |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 215 | hCursorQueue = queue->self; |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 216 | |
| 217 | /* Update static double click conditions */ |
| 218 | if( remove && mouseClick ) |
| 219 | { |
| 220 | if( mouseClick == 1 ) |
| 221 | { |
| 222 | /* set conditions */ |
| 223 | dblclk_time_limit = msg->time; |
| 224 | clk_message = msg->message; |
| 225 | clk_hwnd = hWnd; |
| 226 | clk_pos = screen_pt; |
| 227 | } else |
| 228 | /* got double click - zero them out */ |
| 229 | dblclk_time_limit = clk_hwnd = 0; |
| 230 | } |
| 231 | |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 232 | QUEUE_Unlock(queue); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 233 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 234 | /* Update message params */ |
| 235 | msg->hwnd = hWnd; |
| 236 | msg->message = message; |
| 237 | msg->lParam = MAKELONG( pt.x, pt.y ); |
| 238 | retvalue = SYSQ_MSG_ACCEPT; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 239 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 240 | END: |
| 241 | WIN_ReleaseWndPtr(pWnd); |
| 242 | |
| 243 | /* Return mouseclick flag */ |
| 244 | *pmouseClick = mouseClick; |
| 245 | |
| 246 | return retvalue; |
| 247 | } |
| 248 | |
| 249 | |
| 250 | /*********************************************************************** |
| 251 | * MSG_ProcessMouseMsg |
| 252 | * |
| 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. |
| 256 | * |
| 257 | * Returns: |
| 258 | * |
| 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. |
| 263 | */ |
| 264 | static DWORD MSG_ProcessMouseMsg( MSG *msg, BOOL remove, INT16 hittest, |
| 265 | POINT16 screen_pt, BOOL mouseClick ) |
| 266 | { |
| 267 | WND *pWnd; |
| 268 | HWND hWnd = msg->hwnd; |
| 269 | INT16 sendSC = (GetCapture() == 0); |
| 270 | UINT message = msg->message; |
| 271 | BOOL eatMsg = FALSE; |
| 272 | DWORD retvalue; |
| 273 | |
| 274 | pWnd = WIN_FindWndPtr(hWnd); |
| 275 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 276 | /* call WH_MOUSE */ |
| 277 | |
| 278 | if (HOOK_IsHooked( WH_MOUSE )) |
| 279 | { |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 280 | SYSQ_STATUS ret = 0; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 281 | MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16); |
| 282 | if( hook ) |
| 283 | { |
| 284 | hook->pt = screen_pt; |
| 285 | hook->hwnd = hWnd; |
| 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) ); |
| 290 | SEGPTR_FREE(hook); |
| 291 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 292 | if( ret ) |
| 293 | { |
| 294 | retvalue = MAKELONG((INT16)SYSQ_MSG_SKIP, hittest); |
| 295 | goto END; |
Alexandre Julliard | 557d8af | 2000-05-23 23:43:02 +0000 | [diff] [blame] | 296 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 297 | } |
| 298 | |
Alexandre Julliard | 557d8af | 2000-05-23 23:43:02 +0000 | [diff] [blame] | 299 | if (message >= WM_NCMOUSEFIRST && message <= WM_NCMOUSELAST) |
| 300 | message += WM_MOUSEFIRST - WM_NCMOUSEFIRST; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 301 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 302 | if ((hittest == HTERROR) || (hittest == HTNOWHERE)) |
| 303 | eatMsg = sendSC = 1; |
| 304 | else if( remove && mouseClick ) |
| 305 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 306 | HWND hwndTop = WIN_GetTopParent( hWnd ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 307 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 308 | if( sendSC ) |
| 309 | { |
| 310 | /* Send the WM_PARENTNOTIFY, |
| 311 | * note that even for double/nonclient clicks |
| 312 | * notification message is still WM_L/M/RBUTTONDOWN. |
| 313 | */ |
| 314 | |
Alexandre Julliard | 557d8af | 2000-05-23 23:43:02 +0000 | [diff] [blame] | 315 | MSG_SendParentNotify( pWnd, message, 0, MAKELPARAM(screen_pt.x, screen_pt.y) ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 316 | |
| 317 | /* Activate the window if needed */ |
| 318 | |
Gerard Patel | 03c13bb | 1999-07-11 13:52:13 +0000 | [diff] [blame] | 319 | if (hWnd != GetActiveWindow() && hWnd != GetDesktopWindow()) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 320 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 321 | LONG ret = SendMessageA( hWnd, WM_MOUSEACTIVATE, hwndTop, |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 322 | MAKELONG( hittest, message ) ); |
| 323 | |
| 324 | if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT)) |
| 325 | eatMsg = TRUE; |
| 326 | |
Gerard Patel | 03c13bb | 1999-07-11 13:52:13 +0000 | [diff] [blame] | 327 | if (((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT)) |
| 328 | && hwndTop != GetForegroundWindow() ) |
Per Ångström | 53c2028 | 1999-07-04 12:46:37 +0000 | [diff] [blame] | 329 | { |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 330 | if (!WINPOS_SetActiveWindow( hwndTop, TRUE , TRUE )) |
| 331 | eatMsg = TRUE; |
Per Ångström | 53c2028 | 1999-07-04 12:46:37 +0000 | [diff] [blame] | 332 | } |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 333 | } |
| 334 | } |
| 335 | } else sendSC = (remove && sendSC); |
| 336 | |
| 337 | /* Send the WM_SETCURSOR message */ |
| 338 | |
| 339 | if (sendSC) |
Abey George | 9849f16 | 1999-07-27 17:06:55 +0000 | [diff] [blame] | 340 | { |
Abey George | 9849f16 | 1999-07-27 17:06:55 +0000 | [diff] [blame] | 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 */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 343 | SendMessageA( hWnd, WM_SETCURSOR, hWnd, |
Alexandre Julliard | 557d8af | 2000-05-23 23:43:02 +0000 | [diff] [blame] | 344 | MAKELONG( hittest, message )); |
Abey George | 9849f16 | 1999-07-27 17:06:55 +0000 | [diff] [blame] | 345 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 346 | if (eatMsg) |
| 347 | { |
| 348 | retvalue = MAKELONG( (UINT16)SYSQ_MSG_SKIP, hittest); |
| 349 | goto END; |
| 350 | } |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 351 | |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 352 | retvalue = SYSQ_MSG_ACCEPT; |
| 353 | END: |
| 354 | WIN_ReleaseWndPtr(pWnd); |
| 355 | |
| 356 | return retvalue; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 360 | /*********************************************************************** |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 361 | * MSG_TranslateKbdMsg |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 362 | * |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 363 | * Translate a keyboard hardware event into a real message. |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 364 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 365 | static DWORD MSG_TranslateKbdMsg( HWND hTopWnd, DWORD first, DWORD last, |
| 366 | MSG *msg, BOOL remove ) |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 367 | { |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 368 | WORD message = msg->message; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 369 | HWND hWnd = GetFocus(); |
Alexandre Julliard | 8b91563 | 1996-06-16 16:16:05 +0000 | [diff] [blame] | 370 | WND *pWnd; |
| 371 | |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 372 | /* Should check Ctrl-Esc and PrintScreen here */ |
| 373 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 374 | if (!hWnd) |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 375 | { |
| 376 | /* Send the message to the active window instead, */ |
| 377 | /* translating messages to their WM_SYS equivalent */ |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 378 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 379 | hWnd = GetActiveWindow(); |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 380 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 381 | if( message < WM_SYSKEYDOWN ) |
| 382 | message += WM_SYSKEYDOWN - WM_KEYDOWN; |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 383 | } |
Peter Ganten | 553e3c9 | 2000-08-14 20:53:00 +0000 | [diff] [blame] | 384 | if ( !hWnd ) return SYSQ_MSG_ABANDON; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 385 | pWnd = WIN_FindWndPtr( hWnd ); |
Peter Ganten | 553e3c9 | 2000-08-14 20:53:00 +0000 | [diff] [blame] | 386 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 387 | if (pWnd && (pWnd->hmemTaskQ != GetFastQueue16())) |
Alexandre Julliard | 8b91563 | 1996-06-16 16:16:05 +0000 | [diff] [blame] | 388 | { |
| 389 | /* Not for the current task */ |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 390 | MESSAGEQUEUE *queue = QUEUE_Lock( GetFastQueue16() ); |
Alexandre Julliard | 8b91563 | 1996-06-16 16:16:05 +0000 | [diff] [blame] | 391 | if (queue) QUEUE_ClearWakeBit( queue, QS_KEY ); |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 392 | QUEUE_Unlock( queue ); |
| 393 | |
Alexandre Julliard | 8b91563 | 1996-06-16 16:16:05 +0000 | [diff] [blame] | 394 | /* Wake up the other task */ |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 395 | queue = QUEUE_Lock( pWnd->hmemTaskQ ); |
Alexandre Julliard | 8b91563 | 1996-06-16 16:16:05 +0000 | [diff] [blame] | 396 | if (queue) QUEUE_SetWakeBit( queue, QS_KEY ); |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 397 | QUEUE_Unlock( queue ); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 398 | WIN_ReleaseWndPtr(pWnd); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 399 | return SYSQ_MSG_ABANDON; |
Alexandre Julliard | 8b91563 | 1996-06-16 16:16:05 +0000 | [diff] [blame] | 400 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 401 | WIN_ReleaseWndPtr(pWnd); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 402 | |
Alexandre Julliard | 84c70f5 | 1997-05-09 08:40:27 +0000 | [diff] [blame] | 403 | if (hTopWnd && hWnd != hTopWnd) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 404 | if (!IsChild(hTopWnd, hWnd)) return SYSQ_MSG_CONTINUE; |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 405 | if (!MSG_CheckFilter(message, first, last)) return SYSQ_MSG_CONTINUE; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 406 | |
| 407 | msg->hwnd = hWnd; |
| 408 | msg->message = message; |
| 409 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 410 | return SYSQ_MSG_ACCEPT; |
| 411 | } |
| 412 | |
| 413 | |
| 414 | /*********************************************************************** |
| 415 | * MSG_ProcessKbdMsg |
| 416 | * |
| 417 | * Processes a translated keyboard message |
| 418 | */ |
| 419 | static DWORD MSG_ProcessKbdMsg( MSG *msg, BOOL remove ) |
| 420 | { |
Ulrich Czekalla | 33026a2 | 2000-02-26 19:13:44 +0000 | [diff] [blame] | 421 | /* Handle F1 key by sending out WM_HELP message */ |
| 422 | if ((msg->message == WM_KEYUP) && |
| 423 | (msg->wParam == VK_F1) && |
Ulrich Czekalla | 2b569f6 | 2000-04-11 19:37:20 +0000 | [diff] [blame] | 424 | remove && |
Ulrich Czekalla | 33026a2 | 2000-02-26 19:13:44 +0000 | [diff] [blame] | 425 | (msg->hwnd != GetDesktopWindow()) && |
| 426 | !MENU_IsMenuActive()) |
| 427 | { |
| 428 | HELPINFO hi; |
| 429 | WND *pWnd = WIN_FindWndPtr(msg->hwnd); |
| 430 | |
| 431 | if (NULL != pWnd) |
| 432 | { |
| 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); |
| 440 | } |
| 441 | WIN_ReleaseWndPtr(pWnd); |
| 442 | } |
| 443 | |
Alexandre Julliard | 7e6ae4b | 1996-12-08 19:25:27 +0000 | [diff] [blame] | 444 | return (HOOK_CallHooks16( WH_KEYBOARD, remove ? HC_ACTION : HC_NOREMOVE, |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 445 | LOWORD (msg->wParam), msg->lParam ) |
Alexandre Julliard | 7e6ae4b | 1996-12-08 19:25:27 +0000 | [diff] [blame] | 446 | ? SYSQ_MSG_SKIP : SYSQ_MSG_ACCEPT); |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 447 | } |
| 448 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 449 | |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 450 | /*********************************************************************** |
| 451 | * MSG_JournalRecordMsg |
| 452 | * |
| 453 | * Build an EVENTMSG structure and call JOURNALRECORD hook |
| 454 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 455 | static void MSG_JournalRecordMsg( MSG *msg ) |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 456 | { |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 457 | EVENTMSG event; |
| 458 | |
| 459 | event.message = msg->message; |
| 460 | event.time = msg->time; |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 461 | if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST)) |
| 462 | { |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 463 | event.paramL = (msg->wParam & 0xFF) | (HIWORD(msg->lParam) << 8); |
| 464 | event.paramH = msg->lParam & 0x7FFF; |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 465 | if (HIWORD(msg->lParam) & 0x0100) |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 466 | event.paramH |= 0x8000; /* special_key - bit */ |
| 467 | HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&event ); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 468 | } |
| 469 | else if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST)) |
| 470 | { |
Ulrich Weigand | e27670e | 2001-01-11 00:52:50 +0000 | [diff] [blame] | 471 | POINT pt; |
| 472 | pt.x = SLOWORD(msg->lParam); |
| 473 | pt.y = SHIWORD(msg->lParam); |
| 474 | ClientToScreen( msg->hwnd, &pt ); |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 475 | event.paramL = pt.x; |
| 476 | event.paramH = pt.y; |
| 477 | HOOK_CallHooksA( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&event ); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 478 | } |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 479 | else if ((msg->message >= WM_NCMOUSEFIRST) && |
| 480 | (msg->message <= WM_NCMOUSELAST)) |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 481 | { |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 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 ); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 486 | } |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 487 | } |
| 488 | |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 489 | /*********************************************************************** |
| 490 | * MSG_JournalPlayBackMsg |
| 491 | * |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 492 | * Get an EVENTMSG struct via call JOURNALPLAYBACK hook function |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 493 | */ |
| 494 | static int MSG_JournalPlayBackMsg(void) |
| 495 | { |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 496 | EVENTMSG tmpMsg; |
| 497 | LPARAM lParam; |
| 498 | WPARAM wParam; |
| 499 | LRESULT wtime; |
| 500 | int keyDown,i; |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 501 | |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 502 | if (!HOOK_IsHooked( WH_JOURNALPLAYBACK )) return 0; |
| 503 | |
| 504 | wtime=HOOK_CallHooksA( WH_JOURNALPLAYBACK, HC_GETNEXT, 0, (LPARAM)&tmpMsg ); |
| 505 | /* TRACE(msg,"Playback wait time =%ld\n",wtime); */ |
| 506 | if (wtime<=0) |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 507 | { |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 508 | wtime=0; |
| 509 | if ((tmpMsg.message >= WM_KEYFIRST) && (tmpMsg.message <= WM_KEYLAST)) |
| 510 | { |
| 511 | wParam=tmpMsg.paramL & 0xFF; |
| 512 | lParam=MAKELONG(tmpMsg.paramH&0x7ffff,tmpMsg.paramL>>8); |
| 513 | if (tmpMsg.message == WM_KEYDOWN || tmpMsg.message == WM_SYSKEYDOWN) |
| 514 | { |
| 515 | for (keyDown=i=0; i<256 && !keyDown; i++) |
| 516 | if (InputKeyStateTable[i] & 0x80) |
| 517 | keyDown++; |
| 518 | if (!keyDown) |
| 519 | lParam |= 0x40000000; |
| 520 | AsyncKeyStateTable[wParam]=InputKeyStateTable[wParam] |= 0x80; |
| 521 | } |
| 522 | else /* WM_KEYUP, WM_SYSKEYUP */ |
| 523 | { |
| 524 | lParam |= 0xC0000000; |
| 525 | AsyncKeyStateTable[wParam]=InputKeyStateTable[wParam] &= ~0x80; |
| 526 | } |
| 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 ); |
| 532 | } |
| 533 | else if ((tmpMsg.message>= WM_MOUSEFIRST) && (tmpMsg.message <= WM_MOUSELAST)) |
| 534 | { |
| 535 | switch (tmpMsg.message) |
| 536 | { |
| 537 | case WM_LBUTTONDOWN: |
| 538 | MouseButtonsStates[0]=AsyncMouseButtonsStates[0]=TRUE;break; |
| 539 | case WM_LBUTTONUP: |
| 540 | MouseButtonsStates[0]=AsyncMouseButtonsStates[0]=FALSE;break; |
| 541 | case WM_MBUTTONDOWN: |
| 542 | MouseButtonsStates[1]=AsyncMouseButtonsStates[1]=TRUE;break; |
| 543 | case WM_MBUTTONUP: |
| 544 | MouseButtonsStates[1]=AsyncMouseButtonsStates[1]=FALSE;break; |
| 545 | case WM_RBUTTONDOWN: |
| 546 | MouseButtonsStates[2]=AsyncMouseButtonsStates[2]=TRUE;break; |
| 547 | case WM_RBUTTONUP: |
| 548 | MouseButtonsStates[2]=AsyncMouseButtonsStates[2]=FALSE;break; |
| 549 | } |
| 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); |
| 555 | wParam=0; |
| 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 ); |
| 561 | } |
| 562 | HOOK_CallHooksA( WH_JOURNALPLAYBACK, HC_SKIP, 0, (LPARAM)&tmpMsg); |
| 563 | return 0; |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 564 | } |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 565 | else |
| 566 | { |
| 567 | if( tmpMsg.message == WM_QUEUESYNC ) |
| 568 | if (HOOK_IsHooked( WH_CBT )) |
| 569 | HOOK_CallHooksA( WH_CBT, HCBT_QS, 0, 0L); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 570 | |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 571 | return QS_MOUSE | QS_KEY; /* ? */ |
| 572 | } |
| 573 | } |
Alexandre Julliard | 940d58c | 1994-09-16 09:24:37 +0000 | [diff] [blame] | 574 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 575 | /*********************************************************************** |
| 576 | * MSG_PeekHardwareMsg |
| 577 | * |
| 578 | * Peek for a hardware message matching the hwnd and message filters. |
| 579 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 580 | static BOOL MSG_PeekHardwareMsg( MSG *msg, HWND hwnd, DWORD first, DWORD last, |
| 581 | BOOL remove ) |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 582 | { |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 583 | DWORD status = SYSQ_MSG_ACCEPT; |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 584 | MESSAGEQUEUE *sysMsgQueue = QUEUE_GetSysQueue(); |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 585 | enum { MOUSE_MSG = 0, KEYBOARD_MSG, HARDWARE_MSG } msgType; |
Stephane Lussier | 1242311 | 1999-02-13 08:54:21 +0000 | [diff] [blame] | 586 | QMSG *nextqmsg, *qmsg = 0; |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 587 | BOOL bRet = FALSE; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 588 | |
Stephane Lussier | 1242311 | 1999-02-13 08:54:21 +0000 | [diff] [blame] | 589 | EnterCriticalSection(&sysMsgQueue->cSection); |
| 590 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 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 |
| 594 | */ |
| 595 | |
| 596 | for ( qmsg = sysMsgQueue->firstMsg; qmsg; qmsg = nextqmsg ) |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 597 | { |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 598 | INT16 hittest; |
| 599 | POINT16 screen_pt; |
| 600 | BOOL mouseClick; |
Stephane Lussier | a4c8445 | 1999-01-26 09:30:05 +0000 | [diff] [blame] | 601 | |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 602 | *msg = qmsg->msg; |
Stephane Lussier | a4c8445 | 1999-01-26 09:30:05 +0000 | [diff] [blame] | 603 | |
| 604 | nextqmsg = qmsg->nextMsg; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 605 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 606 | /* Translate message */ |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 607 | |
| 608 | if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST)) |
| 609 | { |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 610 | HWND hWndScope = (HWND)qmsg->extraInfo; |
| 611 | WND *tmpWnd = (Options.managed && IsWindow(hWndScope) ) |
| 612 | ? WIN_FindWndPtr(hWndScope) : WIN_GetDesktop(); |
| 613 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 614 | status = MSG_TranslateMouseMsg(hwnd, first, last, msg, remove, tmpWnd, |
| 615 | &hittest, &screen_pt, &mouseClick ); |
| 616 | msgType = MOUSE_MSG; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 617 | |
| 618 | WIN_ReleaseWndPtr(tmpWnd); |
| 619 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 620 | } |
| 621 | else if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST)) |
| 622 | { |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 623 | status = MSG_TranslateKbdMsg(hwnd, first, last, msg, remove); |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 624 | msgType = KEYBOARD_MSG; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 625 | } |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 626 | else /* Non-standard hardware event */ |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 627 | { |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 628 | HARDWAREHOOKSTRUCT16 *hook; |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 629 | msgType = HARDWARE_MSG; |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 630 | if ((hook = SEGPTR_NEW(HARDWAREHOOKSTRUCT16))) |
| 631 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 632 | BOOL ret; |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 633 | hook->hWnd = msg->hwnd; |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 634 | hook->wMessage = msg->message & 0xffff; |
| 635 | hook->wParam = LOWORD (msg->wParam); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 636 | hook->lParam = msg->lParam; |
Alexandre Julliard | 7e6ae4b | 1996-12-08 19:25:27 +0000 | [diff] [blame] | 637 | ret = HOOK_CallHooks16( WH_HARDWARE, |
| 638 | remove ? HC_ACTION : HC_NOREMOVE, |
| 639 | 0, (LPARAM)SEGPTR_GET(hook) ); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 640 | SEGPTR_FREE(hook); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 641 | if (ret) |
| 642 | { |
Stephane Lussier | a4c8445 | 1999-01-26 09:30:05 +0000 | [diff] [blame] | 643 | QUEUE_RemoveMsg( sysMsgQueue, qmsg ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 644 | continue; |
| 645 | } |
| 646 | status = SYSQ_MSG_ACCEPT; |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 647 | } |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 648 | } |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 649 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 650 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 651 | switch (LOWORD(status)) |
| 652 | { |
| 653 | case SYSQ_MSG_ACCEPT: |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 654 | { |
| 655 | /* Remove the message from the system msg Q while it is still locked, |
| 656 | * before accepting it */ |
| 657 | if (remove) |
| 658 | { |
| 659 | if (HOOK_IsHooked( WH_JOURNALRECORD )) MSG_JournalRecordMsg( msg ); |
| 660 | QUEUE_RemoveMsg( sysMsgQueue, qmsg ); |
| 661 | } |
| 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. |
| 668 | */ |
| 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 ); |
| 674 | |
| 675 | /* Reclaim the sys msg Q crst */ |
| 676 | EnterCriticalSection(&sysMsgQueue->cSection); |
| 677 | |
| 678 | /* Pass the translated message to the user if it was accepted */ |
| 679 | if (status == SYSQ_MSG_ACCEPT) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 680 | break; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 681 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 682 | /* If not accepted, fall through into the SYSQ_MSG_SKIP case */ |
| 683 | } |
| 684 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 685 | case SYSQ_MSG_SKIP: |
| 686 | if (HOOK_IsHooked( WH_CBT )) |
Jesper Skov | 5c3e457 | 1998-11-01 19:27:22 +0000 | [diff] [blame] | 687 | { |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 688 | if( msgType == KEYBOARD_MSG ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 689 | HOOK_CallHooks16( WH_CBT, HCBT_KEYSKIPPED, |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 690 | LOWORD (msg->wParam), msg->lParam ); |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 691 | else if ( msgType == MOUSE_MSG ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 692 | { |
| 693 | MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16); |
| 694 | if (hook) |
| 695 | { |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 696 | CONV_POINT32TO16( &msg->pt,&hook->pt ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 697 | hook->hwnd = msg->hwnd; |
| 698 | hook->wHitTestCode = HIWORD(status); |
| 699 | hook->dwExtraInfo = 0; |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 700 | HOOK_CallHooks16( WH_CBT, HCBT_CLICKSKIPPED ,msg->message & 0xffff, |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 701 | (LPARAM)SEGPTR_GET(hook) ); |
| 702 | SEGPTR_FREE(hook); |
| 703 | } |
| 704 | } |
Jesper Skov | 5c3e457 | 1998-11-01 19:27:22 +0000 | [diff] [blame] | 705 | } |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 706 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 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. |
| 711 | */ |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 712 | if (remove) |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 713 | nextqmsg = sysMsgQueue->firstMsg; |
| 714 | else |
| 715 | nextqmsg = qmsg->nextMsg; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 716 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 717 | continue; |
| 718 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 719 | case SYSQ_MSG_CONTINUE: |
| 720 | continue; |
| 721 | |
| 722 | case SYSQ_MSG_ABANDON: |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 723 | bRet = FALSE; |
| 724 | goto END; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 725 | } |
| 726 | |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 727 | bRet = TRUE; |
| 728 | goto END; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 729 | } |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 730 | |
| 731 | END: |
Stephane Lussier | 1242311 | 1999-02-13 08:54:21 +0000 | [diff] [blame] | 732 | LeaveCriticalSection(&sysMsgQueue->cSection); |
Noel Borthwick | c90243b | 1999-05-14 08:09:13 +0000 | [diff] [blame] | 733 | return bRet; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 737 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 738 | * SetDoubleClickTime (USER.20) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 739 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 740 | void WINAPI SetDoubleClickTime16( UINT16 interval ) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 741 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 742 | SetDoubleClickTime( interval ); |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 743 | } |
| 744 | |
| 745 | |
| 746 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 747 | * SetDoubleClickTime (USER32.@) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 748 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 749 | BOOL WINAPI SetDoubleClickTime( UINT interval ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 750 | { |
| 751 | doubleClickSpeed = interval ? interval : 500; |
| 752 | return TRUE; |
| 753 | } |
| 754 | |
| 755 | |
| 756 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 757 | * GetDoubleClickTime (USER.21) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 758 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 759 | UINT16 WINAPI GetDoubleClickTime16(void) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 760 | { |
| 761 | return doubleClickSpeed; |
| 762 | } |
| 763 | |
| 764 | |
| 765 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 766 | * GetDoubleClickTime (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 767 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 768 | UINT WINAPI GetDoubleClickTime(void) |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 769 | { |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 770 | return doubleClickSpeed; |
Alexandre Julliard | cdd0923 | 1994-01-12 11:12:51 +0000 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | |
| 774 | /*********************************************************************** |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 775 | * MSG_SendMessageInterThread |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 776 | * |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 777 | * Implementation of an inter-task SendMessage. |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 778 | * Return values: |
| 779 | * 0 if error or timeout |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 780 | * 1 if successful |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 781 | */ |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 782 | static LRESULT MSG_SendMessageInterThread( HQUEUE16 hDestQueue, |
| 783 | HWND hwnd, UINT msg, |
| 784 | WPARAM wParam, LPARAM lParam, |
| 785 | DWORD timeout, WORD flags, |
| 786 | LRESULT *pRes) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 787 | { |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 788 | MESSAGEQUEUE *queue, *destQ; |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 789 | SMSG *smsg; |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 790 | LRESULT retVal = 1; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 791 | int iWndsLocks; |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 792 | |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 793 | if (pRes) *pRes = 0; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 794 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 795 | if (IsTaskLocked16() || !IsWindow(hwnd)) |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 796 | return 0; |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 797 | |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 798 | /* create a SMSG structure to hold SendMessage() parameters */ |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 799 | if (! (smsg = (SMSG *) HeapAlloc( GetProcessHeap(), 0, sizeof(SMSG) )) ) |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 800 | return 0; |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 801 | if (!(queue = QUEUE_Lock( GetFastQueue16() ))) return 0; |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 802 | |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 803 | if (!(destQ = QUEUE_Lock( hDestQueue ))) |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 804 | { |
| 805 | QUEUE_Unlock( queue ); |
| 806 | return 0; |
| 807 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 808 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 809 | TRACE_(sendmsg)("SM: %s [%04x] (%04x -> %04x)\n", |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 810 | SPY_GetMsgName(msg), msg, queue->self, hDestQueue ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 811 | |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 812 | /* fill up SMSG structure */ |
| 813 | smsg->hWnd = hwnd; |
| 814 | smsg->msg = msg; |
| 815 | smsg->wParam = wParam; |
| 816 | smsg->lParam = lParam; |
| 817 | |
| 818 | smsg->lResult = 0; |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 819 | smsg->hSrcQueue = pRes ? GetFastQueue16() : 0; |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 820 | smsg->hDstQueue = hDestQueue; |
| 821 | smsg->flags = flags; |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 822 | |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 823 | if (pRes) { |
| 824 | /* add smsg struct in the processing SM list of the source queue */ |
| 825 | QUEUE_AddSMSG(queue, SM_PROCESSING_LIST, smsg); |
| 826 | } else { |
| 827 | /* this is a notification message, we don't need a reply */ |
| 828 | smsg->flags |= SMSG_ALREADY_REPLIED | SMSG_RECEIVER_CLEANS; |
| 829 | } |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 830 | |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 831 | /* add smsg struct in the pending list of the destination queue */ |
| 832 | if (QUEUE_AddSMSG(destQ, SM_PENDING_LIST, smsg) == FALSE) |
Andreas Mohr | 5e7fa02 | 2000-08-29 03:52:46 +0000 | [diff] [blame] | 833 | { |
| 834 | retVal = 0; |
| 835 | goto CLEANUP; |
| 836 | } |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 837 | |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 838 | if (!pRes) goto CLEANUP; /* don't need a reply */ |
| 839 | |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 840 | iWndsLocks = WIN_SuspendWndsLock(); |
| 841 | |
Ulrich Weigand | c68c4b1 | 1999-03-17 15:14:31 +0000 | [diff] [blame] | 842 | /* force destination task to run next, if 16 bit threads */ |
Alexandre Julliard | 0a860a0 | 1999-06-22 11:43:42 +0000 | [diff] [blame] | 843 | if ( THREAD_IsWin16(NtCurrentTeb()) && THREAD_IsWin16(destQ->teb) ) |
| 844 | DirectedYield16( destQ->teb->htask16 ); |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 845 | |
Alex Korobka | 073e3bc | 1999-03-28 09:19:31 +0000 | [diff] [blame] | 846 | /* wait for the result, note that 16-bit apps almost always get out of |
| 847 | * DirectedYield() with SMSG_HAVE_RESULT flag already set */ |
| 848 | |
| 849 | while ( TRUE ) |
Ulrich Weigand | c68c4b1 | 1999-03-17 15:14:31 +0000 | [diff] [blame] | 850 | { |
| 851 | /* |
| 852 | * The sequence is crucial to avoid deadlock situations: |
| 853 | * - first, we clear the QS_SMRESULT bit |
| 854 | * - then, we check the SMSG_HAVE_RESULT bit |
| 855 | * - only if this isn't set, we enter the wait state. |
| 856 | * |
| 857 | * As the receiver first sets the SMSG_HAVE_RESULT and then wakes us, |
| 858 | * we are guaranteed that -should we now clear the QS_SMRESULT that |
| 859 | * was signalled already by the receiver- we will not start waiting. |
| 860 | */ |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 861 | |
Ulrich Weigand | c68c4b1 | 1999-03-17 15:14:31 +0000 | [diff] [blame] | 862 | if ( smsg->flags & SMSG_HAVE_RESULT ) |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 863 | { |
Alex Korobka | 073e3bc | 1999-03-28 09:19:31 +0000 | [diff] [blame] | 864 | got: |
| 865 | *pRes = smsg->lResult; |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 866 | TRACE_(sendmsg)("smResult = %08x\n", (unsigned)*pRes ); |
Alex Korobka | 073e3bc | 1999-03-28 09:19:31 +0000 | [diff] [blame] | 867 | break; |
| 868 | } |
| 869 | |
| 870 | QUEUE_ClearWakeBit( queue, QS_SMRESULT ); |
| 871 | |
| 872 | if ( smsg->flags & SMSG_HAVE_RESULT ) |
| 873 | goto got; |
| 874 | |
| 875 | if( QUEUE_WaitBits( QS_SMRESULT, timeout ) == 0 ) |
| 876 | { |
| 877 | /* return with timeout */ |
| 878 | SetLastError( 0 ); |
| 879 | retVal = 0; |
| 880 | break; |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 881 | } |
Stephane Lussier | 110cdb1 | 1999-02-24 09:43:09 +0000 | [diff] [blame] | 882 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 883 | WIN_RestoreWndsLock(iWndsLocks); |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 884 | |
Andreas Mohr | 260f1a1 | 2000-09-22 20:59:29 +0000 | [diff] [blame] | 885 | /* remove the smsg from the processing list of the source queue */ |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 886 | QUEUE_RemoveSMSG( queue, SM_PROCESSING_LIST, smsg ); |
| 887 | |
| 888 | /* Note: the destination thread is in charge of removing the smsg from |
| 889 | the pending list */ |
| 890 | |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 891 | /* In the case of an early reply (or a timeout), sender thread will |
| 892 | released the smsg structure if the receiver thread is done |
| 893 | (SMSG_RECEIVED set). If the receiver thread isn't done, |
| 894 | SMSG_RECEIVER_CLEANS_UP flag is set, and it will be the receiver |
Andreas Mohr | 260f1a1 | 2000-09-22 20:59:29 +0000 | [diff] [blame] | 895 | responsibility to release smsg */ |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 896 | EnterCriticalSection( &queue->cSection ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 897 | |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 898 | if (smsg->flags & SMSG_RECEIVED) |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 899 | HeapFree(GetProcessHeap(), 0, smsg); |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 900 | else |
| 901 | smsg->flags |= SMSG_RECEIVER_CLEANS; |
| 902 | |
| 903 | LeaveCriticalSection( &queue->cSection ); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 904 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 905 | |
Andreas Mohr | 5e7fa02 | 2000-08-29 03:52:46 +0000 | [diff] [blame] | 906 | CLEANUP: |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 907 | QUEUE_Unlock( queue ); |
| 908 | QUEUE_Unlock( destQ ); |
| 909 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 910 | TRACE_(sendmsg)("done!\n"); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 911 | return retVal; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 912 | } |
| 913 | |
| 914 | |
| 915 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 916 | * ReplyMessage (USER.115) |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 917 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 918 | void WINAPI ReplyMessage16( LRESULT result ) |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 919 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 920 | ReplyMessage( result ); |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 921 | } |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 922 | |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 923 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 924 | * ReplyMessage (USER32.@) |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 925 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 926 | BOOL WINAPI ReplyMessage( LRESULT result ) |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 927 | { |
| 928 | MESSAGEQUEUE *senderQ = 0; |
| 929 | MESSAGEQUEUE *queue = 0; |
| 930 | SMSG *smsg; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 931 | BOOL ret = FALSE; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 932 | |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 933 | if (!(queue = QUEUE_Lock( GetFastQueue16() ))) |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 934 | return FALSE; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 935 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 936 | TRACE_(sendmsg)("ReplyMessage, queue %04x\n", queue->self); |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 937 | |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 938 | |
Ulrich Weigand | c68c4b1 | 1999-03-17 15:14:31 +0000 | [diff] [blame] | 939 | if ( !(smsg = queue->smWaiting) |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 940 | || !( (senderQ = QUEUE_Lock( smsg->hSrcQueue )) |
| 941 | || (smsg->flags & SMSG_ALREADY_REPLIED)) ) |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 942 | goto ReplyMessageEnd; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 943 | |
Ulrich Weigand | c68c4b1 | 1999-03-17 15:14:31 +0000 | [diff] [blame] | 944 | if ( !(smsg->flags & SMSG_ALREADY_REPLIED) ) |
| 945 | { |
| 946 | /* This is the first reply, so pass result to sender */ |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 947 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 948 | TRACE_(sendmsg)("\trpm: smResult = %08lx\n", (long) result ); |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 949 | |
Ulrich Weigand | c68c4b1 | 1999-03-17 15:14:31 +0000 | [diff] [blame] | 950 | EnterCriticalSection(&senderQ->cSection); |
| 951 | |
| 952 | smsg->lResult = result; |
| 953 | smsg->flags |= SMSG_ALREADY_REPLIED; |
Francis Beaudet | bfaf063 | 1999-02-28 10:02:57 +0000 | [diff] [blame] | 954 | |
Ulrich Weigand | c68c4b1 | 1999-03-17 15:14:31 +0000 | [diff] [blame] | 955 | /* check if it's an early reply (called by the application) or |
| 956 | a regular reply (called by ReceiveMessage) */ |
| 957 | if ( !(smsg->flags & SMSG_SENDING_REPLY) ) |
| 958 | smsg->flags |= SMSG_EARLY_REPLY; |
Francis Beaudet | bfaf063 | 1999-02-28 10:02:57 +0000 | [diff] [blame] | 959 | |
Ulrich Weigand | c68c4b1 | 1999-03-17 15:14:31 +0000 | [diff] [blame] | 960 | smsg->flags |= SMSG_HAVE_RESULT; |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 961 | |
Ulrich Weigand | c68c4b1 | 1999-03-17 15:14:31 +0000 | [diff] [blame] | 962 | LeaveCriticalSection(&senderQ->cSection); |
Francis Beaudet | bfaf063 | 1999-02-28 10:02:57 +0000 | [diff] [blame] | 963 | |
Ulrich Weigand | c68c4b1 | 1999-03-17 15:14:31 +0000 | [diff] [blame] | 964 | /* tell the sending task that its reply is ready */ |
| 965 | QUEUE_SetWakeBit( senderQ, QS_SMRESULT ); |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 966 | |
Ulrich Weigand | c68c4b1 | 1999-03-17 15:14:31 +0000 | [diff] [blame] | 967 | /* switch directly to sending task (16 bit thread only) */ |
Alexandre Julliard | 0a860a0 | 1999-06-22 11:43:42 +0000 | [diff] [blame] | 968 | if ( THREAD_IsWin16( NtCurrentTeb() ) && THREAD_IsWin16( senderQ->teb ) ) |
| 969 | DirectedYield16( senderQ->teb->htask16 ); |
Ulrich Weigand | c68c4b1 | 1999-03-17 15:14:31 +0000 | [diff] [blame] | 970 | |
| 971 | ret = TRUE; |
| 972 | } |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 973 | |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 974 | if (smsg->flags & SMSG_SENDING_REPLY) |
| 975 | { |
Andreas Mohr | 260f1a1 | 2000-09-22 20:59:29 +0000 | [diff] [blame] | 976 | /* remove msg from the waiting list, since this is the last |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 977 | ReplyMessage */ |
| 978 | QUEUE_RemoveSMSG( queue, SM_WAITING_LIST, smsg ); |
| 979 | |
Ove Kaaven | bea0560 | 2000-11-25 21:39:36 +0000 | [diff] [blame] | 980 | if (senderQ) EnterCriticalSection(&senderQ->cSection); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 981 | |
| 982 | /* tell the sender we're all done with smsg structure */ |
| 983 | smsg->flags |= SMSG_RECEIVED; |
| 984 | |
| 985 | /* sender will set SMSG_RECEIVER_CLEANS_UP if it wants the |
Andreas Mohr | 260f1a1 | 2000-09-22 20:59:29 +0000 | [diff] [blame] | 986 | receiver to clean up smsg, it could only happen when there is |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 987 | an early reply or a timeout */ |
| 988 | if ( smsg->flags & SMSG_RECEIVER_CLEANS ) |
| 989 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 990 | TRACE_(sendmsg)("Receiver cleans up!\n" ); |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 991 | HeapFree( GetProcessHeap(), 0, smsg ); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 992 | } |
Ove Kaaven | bea0560 | 2000-11-25 21:39:36 +0000 | [diff] [blame] | 993 | |
| 994 | if (senderQ) LeaveCriticalSection(&senderQ->cSection); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | ReplyMessageEnd: |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 998 | if ( senderQ ) |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 999 | QUEUE_Unlock( senderQ ); |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 1000 | if ( queue ) |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 1001 | QUEUE_Unlock( queue ); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1002 | |
Stephane Lussier | 2c86dab | 1999-02-18 17:34:09 +0000 | [diff] [blame] | 1003 | return ret; |
| 1004 | } |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1005 | |
| 1006 | /*********************************************************************** |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1007 | * MSG_ConvertMsg |
| 1008 | */ |
| 1009 | static BOOL MSG_ConvertMsg( MSG *msg, int srcType, int dstType ) |
| 1010 | { |
| 1011 | UINT16 msg16; |
| 1012 | MSGPARAM16 mp16; |
| 1013 | |
| 1014 | switch ( MAKELONG( srcType, dstType ) ) |
| 1015 | { |
| 1016 | case MAKELONG( QMSG_WIN16, QMSG_WIN16 ): |
| 1017 | case MAKELONG( QMSG_WIN32A, QMSG_WIN32A ): |
| 1018 | case MAKELONG( QMSG_WIN32W, QMSG_WIN32W ): |
| 1019 | return TRUE; |
| 1020 | |
| 1021 | case MAKELONG( QMSG_WIN16, QMSG_WIN32A ): |
| 1022 | switch ( WINPROC_MapMsg16To32A( msg->message, msg->wParam, |
| 1023 | &msg->message, &msg->wParam, &msg->lParam ) ) |
| 1024 | { |
| 1025 | case 0: |
| 1026 | return TRUE; |
| 1027 | case 1: |
| 1028 | /* Pointer messages were mapped --> need to free allocated memory and fail */ |
| 1029 | WINPROC_UnmapMsg16To32A( msg->hwnd, msg->message, msg->wParam, msg->lParam, 0 ); |
| 1030 | default: |
| 1031 | return FALSE; |
| 1032 | } |
| 1033 | |
| 1034 | case MAKELONG( QMSG_WIN16, QMSG_WIN32W ): |
| 1035 | switch ( WINPROC_MapMsg16To32W( msg->hwnd, msg->message, msg->wParam, |
| 1036 | &msg->message, &msg->wParam, &msg->lParam ) ) |
| 1037 | { |
| 1038 | case 0: |
| 1039 | return TRUE; |
| 1040 | case 1: |
| 1041 | /* Pointer messages were mapped --> need to free allocated memory and fail */ |
| 1042 | WINPROC_UnmapMsg16To32W( msg->hwnd, msg->message, msg->wParam, msg->lParam, 0 ); |
| 1043 | default: |
| 1044 | return FALSE; |
| 1045 | } |
| 1046 | |
| 1047 | case MAKELONG( QMSG_WIN32A, QMSG_WIN16 ): |
| 1048 | mp16.lParam = msg->lParam; |
| 1049 | switch ( WINPROC_MapMsg32ATo16( msg->hwnd, msg->message, msg->wParam, |
| 1050 | &msg16, &mp16.wParam, &mp16.lParam ) ) |
| 1051 | { |
| 1052 | case 0: |
| 1053 | msg->message = msg16; |
| 1054 | msg->wParam = mp16.wParam; |
| 1055 | msg->lParam = mp16.lParam; |
| 1056 | return TRUE; |
| 1057 | case 1: |
| 1058 | /* Pointer messages were mapped --> need to free allocated memory and fail */ |
| 1059 | WINPROC_UnmapMsg32ATo16( msg->hwnd, msg->message, msg->wParam, msg->lParam, &mp16 ); |
| 1060 | default: |
| 1061 | return FALSE; |
| 1062 | } |
| 1063 | |
| 1064 | case MAKELONG( QMSG_WIN32W, QMSG_WIN16 ): |
| 1065 | mp16.lParam = msg->lParam; |
| 1066 | switch ( WINPROC_MapMsg32WTo16( msg->hwnd, msg->message, msg->wParam, |
| 1067 | &msg16, &mp16.wParam, &mp16.lParam ) ) |
| 1068 | { |
| 1069 | case 0: |
| 1070 | msg->message = msg16; |
| 1071 | msg->wParam = mp16.wParam; |
| 1072 | msg->lParam = mp16.lParam; |
| 1073 | return TRUE; |
| 1074 | case 1: |
| 1075 | /* Pointer messages were mapped --> need to free allocated memory and fail */ |
| 1076 | WINPROC_UnmapMsg32WTo16( msg->hwnd, msg->message, msg->wParam, msg->lParam, &mp16 ); |
| 1077 | default: |
| 1078 | return FALSE; |
| 1079 | } |
| 1080 | |
| 1081 | case MAKELONG( QMSG_WIN32A, QMSG_WIN32W ): |
Dmitry Timoshkov | 3606dc5 | 2000-11-15 23:13:17 +0000 | [diff] [blame] | 1082 | switch ( WINPROC_MapMsg32ATo32W( msg->hwnd, msg->message, &msg->wParam, &msg->lParam ) ) |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1083 | { |
| 1084 | case 0: |
| 1085 | return TRUE; |
| 1086 | case 1: |
| 1087 | /* Pointer messages were mapped --> need to free allocated memory and fail */ |
| 1088 | WINPROC_UnmapMsg32ATo32W( msg->hwnd, msg->message, msg->wParam, msg->lParam ); |
| 1089 | default: |
| 1090 | return FALSE; |
| 1091 | } |
| 1092 | |
| 1093 | case MAKELONG( QMSG_WIN32W, QMSG_WIN32A ): |
Dmitry Timoshkov | 3606dc5 | 2000-11-15 23:13:17 +0000 | [diff] [blame] | 1094 | switch ( WINPROC_MapMsg32WTo32A( msg->hwnd, msg->message, &msg->wParam, &msg->lParam ) ) |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1095 | { |
| 1096 | case 0: |
| 1097 | return TRUE; |
| 1098 | case 1: |
| 1099 | /* Pointer messages were mapped --> need to free allocated memory and fail */ |
| 1100 | WINPROC_UnmapMsg32WTo32A( msg->hwnd, msg->message, msg->wParam, msg->lParam ); |
| 1101 | default: |
| 1102 | return FALSE; |
| 1103 | } |
| 1104 | |
| 1105 | default: |
| 1106 | FIXME( "Invalid message type(s): %d / %d\n", srcType, dstType ); |
| 1107 | return FALSE; |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | /*********************************************************************** |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1112 | * MSG_PeekMessage |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1113 | */ |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1114 | static BOOL MSG_PeekMessage( int type, LPMSG msg_out, HWND hwnd, |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1115 | DWORD first, DWORD last, WORD flags, BOOL peek ) |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1116 | { |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1117 | int changeBits, mask; |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 1118 | MESSAGEQUEUE *msgQueue; |
Alexandre Julliard | 8cc3a5e | 1996-08-11 15:49:51 +0000 | [diff] [blame] | 1119 | HQUEUE16 hQueue; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1120 | int iWndsLocks; |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1121 | MSG msg; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1122 | |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1123 | mask = QS_POSTMESSAGE | QS_SENDMESSAGE; /* Always selected */ |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1124 | if (first || last) |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1125 | { |
Alexandre Julliard | ac9c9b0 | 1996-07-28 18:50:11 +0000 | [diff] [blame] | 1126 | if ((first <= WM_KEYLAST) && (last >= WM_KEYFIRST)) mask |= QS_KEY; |
| 1127 | if ( ((first <= WM_MOUSELAST) && (last >= WM_MOUSEFIRST)) || |
| 1128 | ((first <= WM_NCMOUSELAST) && (last >= WM_NCMOUSEFIRST)) ) mask |= QS_MOUSE; |
| 1129 | if ((first <= WM_TIMER) && (last >= WM_TIMER)) mask |= QS_TIMER; |
| 1130 | if ((first <= WM_SYSTIMER) && (last >= WM_SYSTIMER)) mask |= QS_TIMER; |
| 1131 | if ((first <= WM_PAINT) && (last >= WM_PAINT)) mask |= QS_PAINT; |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1132 | } |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1133 | else mask |= QS_MOUSE | QS_KEY | QS_TIMER | QS_PAINT; |
| 1134 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1135 | if (IsTaskLocked16()) flags |= PM_NOYIELD; |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1136 | |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 1137 | /* Never yield on Win32 threads */ |
Alexandre Julliard | 0a860a0 | 1999-06-22 11:43:42 +0000 | [diff] [blame] | 1138 | if (!THREAD_IsWin16(NtCurrentTeb())) flags |= PM_NOYIELD; |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 1139 | |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1140 | iWndsLocks = WIN_SuspendWndsLock(); |
| 1141 | |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1142 | while(1) |
| 1143 | { |
Stephane Lussier | a4c8445 | 1999-01-26 09:30:05 +0000 | [diff] [blame] | 1144 | QMSG *qmsg; |
| 1145 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1146 | hQueue = GetFastQueue16(); |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1147 | msgQueue = QUEUE_Lock( hQueue ); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1148 | if (!msgQueue) |
| 1149 | { |
| 1150 | WIN_RestoreWndsLock(iWndsLocks); |
| 1151 | return FALSE; |
| 1152 | } |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1153 | |
| 1154 | EnterCriticalSection( &msgQueue->cSection ); |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1155 | msgQueue->changeBits = 0; |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1156 | LeaveCriticalSection( &msgQueue->cSection ); |
Alexandre Julliard | 594997c | 1995-04-30 10:05:20 +0000 | [diff] [blame] | 1157 | |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1158 | /* First handle a message put by SendMessage() */ |
| 1159 | |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1160 | while ( QUEUE_ReceiveMessage( msgQueue ) ) |
| 1161 | ; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1162 | |
Alexandre Julliard | df2673b | 1997-03-29 17:20:20 +0000 | [diff] [blame] | 1163 | /* Now handle a WM_QUIT message */ |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1164 | |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1165 | EnterCriticalSection( &msgQueue->cSection ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1166 | if (msgQueue->wPostQMsg && |
| 1167 | (!first || WM_QUIT >= first) && |
| 1168 | (!last || WM_QUIT <= last) ) |
| 1169 | { |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1170 | msg.hwnd = hwnd; |
| 1171 | msg.message = WM_QUIT; |
| 1172 | msg.wParam = msgQueue->wExitCode; |
| 1173 | msg.lParam = 0; |
Alexandre Julliard | b1bac32 | 1996-12-15 19:45:59 +0000 | [diff] [blame] | 1174 | if (flags & PM_REMOVE) msgQueue->wPostQMsg = 0; |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1175 | LeaveCriticalSection( &msgQueue->cSection ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 1176 | break; |
| 1177 | } |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1178 | LeaveCriticalSection( &msgQueue->cSection ); |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1179 | |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1180 | /* Now find a normal message */ |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1181 | |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1182 | retry: |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1183 | if ((QUEUE_TestWakeBit(msgQueue, mask & QS_POSTMESSAGE)) && |
Stephane Lussier | a4c8445 | 1999-01-26 09:30:05 +0000 | [diff] [blame] | 1184 | ((qmsg = QUEUE_FindMsg( msgQueue, hwnd, first, last )) != 0)) |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1185 | { |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1186 | /* Try to convert message to requested type */ |
| 1187 | MSG tmpMsg = qmsg->msg; |
| 1188 | if ( !MSG_ConvertMsg( &tmpMsg, qmsg->type, type ) ) |
| 1189 | { |
Dmitry Timoshkov | 3606dc5 | 2000-11-15 23:13:17 +0000 | [diff] [blame] | 1190 | ERR( "Message %s of wrong type contains pointer parameters. Skipped!\n", |
| 1191 | SPY_GetMsgName(tmpMsg.message)); |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1192 | QUEUE_RemoveMsg( msgQueue, qmsg ); |
| 1193 | goto retry; |
| 1194 | } |
| 1195 | |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1196 | msg = tmpMsg; |
| 1197 | msgQueue->GetMessageTimeVal = msg.time; |
| 1198 | msgQueue->GetMessagePosVal = MAKELONG( (INT16)msg.pt.x, (INT16)msg.pt.y ); |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1199 | msgQueue->GetMessageExtraInfoVal = qmsg->extraInfo; |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1200 | |
Stephane Lussier | a4c8445 | 1999-01-26 09:30:05 +0000 | [diff] [blame] | 1201 | if (flags & PM_REMOVE) QUEUE_RemoveMsg( msgQueue, qmsg ); |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1202 | break; |
| 1203 | } |
| 1204 | |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1205 | changeBits = MSG_JournalPlayBackMsg(); |
| 1206 | EnterCriticalSection( &msgQueue->cSection ); |
| 1207 | msgQueue->changeBits |= changeBits; |
| 1208 | LeaveCriticalSection( &msgQueue->cSection ); |
Alexandre Julliard | d1ce8b2 | 1996-09-02 16:46:30 +0000 | [diff] [blame] | 1209 | |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1210 | /* Now find a hardware event */ |
| 1211 | |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1212 | if (MSG_PeekHardwareMsg( &msg, hwnd, first, last, flags & PM_REMOVE )) |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1213 | { |
| 1214 | /* Got one */ |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1215 | msgQueue->GetMessageTimeVal = msg.time; |
| 1216 | msgQueue->GetMessagePosVal = MAKELONG( (INT16)msg.pt.x, (INT16)msg.pt.y ); |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1217 | msgQueue->GetMessageExtraInfoVal = 0; /* Always 0 for now */ |
| 1218 | break; |
| 1219 | } |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1220 | |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1221 | /* Check again for SendMessage */ |
| 1222 | |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1223 | while ( QUEUE_ReceiveMessage( msgQueue ) ) |
| 1224 | ; |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1225 | |
| 1226 | /* Now find a WM_PAINT message */ |
| 1227 | |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1228 | if (QUEUE_TestWakeBit(msgQueue, mask & QS_PAINT)) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1229 | { |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1230 | WND* wndPtr; |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1231 | msg.hwnd = WIN_FindWinToRepaint( hwnd , hQueue ); |
| 1232 | msg.message = WM_PAINT; |
| 1233 | msg.wParam = 0; |
| 1234 | msg.lParam = 0; |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 1235 | |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1236 | if ((wndPtr = WIN_FindWndPtr(msg.hwnd))) |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1237 | { |
| 1238 | if( wndPtr->dwStyle & WS_MINIMIZE && |
Patrik Stridvall | 4bf3354 | 1999-06-12 14:52:15 +0000 | [diff] [blame] | 1239 | (HICON) GetClassLongA(wndPtr->hwndSelf, GCL_HICON) ) |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1240 | { |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1241 | msg.message = WM_PAINTICON; |
| 1242 | msg.wParam = 1; |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1243 | } |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 1244 | |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1245 | if( !hwnd || msg.hwnd == hwnd || IsChild16(hwnd,msg.hwnd) ) |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1246 | { |
| 1247 | if( wndPtr->flags & WIN_INTERNAL_PAINT && !wndPtr->hrgnUpdate) |
| 1248 | { |
| 1249 | wndPtr->flags &= ~WIN_INTERNAL_PAINT; |
| 1250 | QUEUE_DecPaintCount( hQueue ); |
| 1251 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1252 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1253 | break; |
| 1254 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1255 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1256 | } |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1257 | } |
| 1258 | |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1259 | /* Check for timer messages, but yield first */ |
| 1260 | |
| 1261 | if (!(flags & PM_NOYIELD)) |
| 1262 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1263 | UserYield16(); |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1264 | while ( QUEUE_ReceiveMessage( msgQueue ) ) |
| 1265 | ; |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1266 | } |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1267 | |
| 1268 | if (QUEUE_TestWakeBit(msgQueue, mask & QS_TIMER)) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1269 | { |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1270 | if (TIMER_GetTimerMsg(&msg, hwnd, hQueue, flags & PM_REMOVE)) break; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1271 | } |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1272 | |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1273 | if (peek) |
| 1274 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1275 | if (!(flags & PM_NOYIELD)) UserYield16(); |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 1276 | |
| 1277 | QUEUE_Unlock( msgQueue ); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1278 | WIN_RestoreWndsLock(iWndsLocks); |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1279 | return FALSE; |
Alexandre Julliard | aca0578 | 1994-10-17 18:12:41 +0000 | [diff] [blame] | 1280 | } |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 1281 | |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1282 | QUEUE_WaitBits( mask, INFINITE ); |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 1283 | QUEUE_Unlock( msgQueue ); |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1284 | } |
| 1285 | |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1286 | WIN_RestoreWndsLock(iWndsLocks); |
| 1287 | |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 1288 | /* instead of unlocking queue for every break condition, all break |
| 1289 | condition will fall here */ |
| 1290 | QUEUE_Unlock( msgQueue ); |
| 1291 | |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 1292 | /* We got a message */ |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1293 | if (flags & PM_REMOVE) |
| 1294 | { |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1295 | WORD message = msg.message; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1296 | |
| 1297 | if (message == WM_KEYDOWN || message == WM_SYSKEYDOWN) |
| 1298 | { |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1299 | BYTE *p = &QueueKeyStateTable[msg.wParam & 0xff]; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1300 | |
| 1301 | if (!(*p & 0x80)) |
| 1302 | *p ^= 0x01; |
| 1303 | *p |= 0x80; |
| 1304 | } |
| 1305 | else if (message == WM_KEYUP || message == WM_SYSKEYUP) |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1306 | QueueKeyStateTable[msg.wParam & 0xff] &= ~0x80; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 1307 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1308 | |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1309 | /* copy back our internal safe copy of message data to msg_out. |
| 1310 | * msg_out is a variable from the *program*, so it can't be used |
| 1311 | * internally as it can get "corrupted" by our use of SendMessage() |
| 1312 | * (back to the program) inside the message handling itself. */ |
| 1313 | *msg_out = msg; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1314 | if (peek) |
| 1315 | return TRUE; |
| 1316 | |
| 1317 | else |
Andreas Mohr | cd5f28b | 2001-02-12 19:15:06 +0000 | [diff] [blame] | 1318 | return (msg.message != WM_QUIT); |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1319 | } |
| 1320 | |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1321 | /*********************************************************************** |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1322 | * MSG_InternalGetMessage |
| 1323 | * |
| 1324 | * GetMessage() function for internal use. Behave like GetMessage(), |
| 1325 | * but also call message filters and optionally send WM_ENTERIDLE messages. |
| 1326 | * 'hwnd' must be the handle of the dialog or menu window. |
| 1327 | * 'code' is the message filter value (MSGF_??? codes). |
| 1328 | */ |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1329 | BOOL MSG_InternalGetMessage( int type, MSG *msg, HWND hwnd, HWND hwndOwner, |
| 1330 | WPARAM code, WORD flags, BOOL sendIdle, BOOL* idleSent ) |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1331 | { |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 1332 | for (;;) |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1333 | { |
| 1334 | if (sendIdle) |
| 1335 | { |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1336 | if (!MSG_PeekMessage( type, msg, 0, 0, 0, flags, TRUE )) |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 1337 | { |
| 1338 | /* No message present -> send ENTERIDLE and wait */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1339 | if (IsWindow(hwndOwner)) |
Francis Beaudet | 7ed1af3 | 1999-08-15 16:58:03 +0000 | [diff] [blame] | 1340 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1341 | SendMessageA( hwndOwner, WM_ENTERIDLE, |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 1342 | code, (LPARAM)hwnd ); |
Francis Beaudet | 7ed1af3 | 1999-08-15 16:58:03 +0000 | [diff] [blame] | 1343 | |
| 1344 | if (idleSent!=NULL) |
| 1345 | *idleSent=TRUE; |
| 1346 | } |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1347 | MSG_PeekMessage( type, msg, 0, 0, 0, flags, FALSE ); |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 1348 | } |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1349 | } |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 1350 | else /* Always wait for a message */ |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1351 | MSG_PeekMessage( type, msg, 0, 0, 0, flags, FALSE ); |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 1352 | |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1353 | /* Call message filters */ |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 1354 | |
Alexandre Julliard | 7e6ae4b | 1996-12-08 19:25:27 +0000 | [diff] [blame] | 1355 | if (HOOK_IsHooked( WH_SYSMSGFILTER ) || HOOK_IsHooked( WH_MSGFILTER )) |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1356 | { |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 1357 | MSG *pmsg = HeapAlloc( GetProcessHeap(), 0, sizeof(MSG) ); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1358 | if (pmsg) |
| 1359 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1360 | BOOL ret; |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1361 | *pmsg = *msg; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1362 | ret = (HOOK_CallHooksA( WH_SYSMSGFILTER, code, 0, |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 1363 | (LPARAM) pmsg ) || |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1364 | HOOK_CallHooksA( WH_MSGFILTER, code, 0, |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 1365 | (LPARAM) pmsg )); |
| 1366 | |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame^] | 1367 | HeapFree( GetProcessHeap(), 0, pmsg ); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1368 | if (ret) |
| 1369 | { |
| 1370 | /* Message filtered -> remove it from the queue */ |
| 1371 | /* if it's still there. */ |
| 1372 | if (!(flags & PM_REMOVE)) |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1373 | MSG_PeekMessage( type, msg, 0, 0, 0, PM_REMOVE, TRUE ); |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 1374 | continue; |
| 1375 | } |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | return (msg->message != WM_QUIT); |
Alexandre Julliard | 3f2abfa | 1994-08-16 15:43:11 +0000 | [diff] [blame] | 1380 | } |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1381 | } |
| 1382 | |
| 1383 | |
| 1384 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1385 | * PeekMessage32 (USER.819) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1386 | */ |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 1387 | BOOL16 WINAPI PeekMessage32_16( SEGPTR msg16_32, HWND16 hwnd, |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1388 | UINT16 first, UINT16 last, UINT16 flags, |
| 1389 | BOOL16 wHaveParamHigh ) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1390 | { |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1391 | BOOL ret; |
Alexandre Julliard | 982a223 | 2000-12-13 20:20:09 +0000 | [diff] [blame] | 1392 | MSG32_16 *lpmsg16_32 = MapSL(msg16_32); |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1393 | MSG msg; |
| 1394 | |
| 1395 | ret = MSG_PeekMessage( QMSG_WIN16, &msg, hwnd, first, last, flags, TRUE ); |
| 1396 | |
| 1397 | lpmsg16_32->msg.hwnd = msg.hwnd; |
| 1398 | lpmsg16_32->msg.message = msg.message; |
| 1399 | lpmsg16_32->msg.wParam = LOWORD(msg.wParam); |
| 1400 | lpmsg16_32->msg.lParam = msg.lParam; |
| 1401 | lpmsg16_32->msg.time = msg.time; |
| 1402 | lpmsg16_32->msg.pt.x = (INT16)msg.pt.x; |
| 1403 | lpmsg16_32->msg.pt.y = (INT16)msg.pt.y; |
| 1404 | |
| 1405 | if ( wHaveParamHigh ) |
| 1406 | lpmsg16_32->wParamHigh = HIWORD(msg.wParam); |
| 1407 | |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 1408 | HOOK_CallHooks16( WH_GETMESSAGE, HC_ACTION, flags & PM_REMOVE, (LPARAM)msg16_32 ); |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 1409 | return ret; |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1410 | } |
| 1411 | |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 1412 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1413 | * PeekMessage (USER.109) |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 1414 | */ |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 1415 | BOOL16 WINAPI PeekMessage16( SEGPTR msg, HWND16 hwnd, |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1416 | UINT16 first, UINT16 last, UINT16 flags ) |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 1417 | { |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 1418 | return PeekMessage32_16( msg, hwnd, first, last, flags, FALSE ); |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 1419 | } |
| 1420 | |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 1421 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1422 | * PeekMessageA (USER32.@) |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 1423 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1424 | BOOL WINAPI PeekMessageA( LPMSG lpmsg, HWND hwnd, |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1425 | UINT min, UINT max, UINT wRemoveMsg) |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 1426 | { |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 1427 | BOOL ret = MSG_PeekMessage( QMSG_WIN32A, lpmsg, hwnd, min, max, wRemoveMsg, TRUE ); |
| 1428 | |
| 1429 | TRACE( "peekmessage %04x, hwnd %04x, filter(%04x - %04x)\n", |
| 1430 | lpmsg->message, hwnd, min, max ); |
| 1431 | |
| 1432 | if (ret) HOOK_CallHooksA( WH_GETMESSAGE, HC_ACTION, |
| 1433 | wRemoveMsg & PM_REMOVE, (LPARAM)lpmsg ); |
| 1434 | return ret; |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 1435 | } |
| 1436 | |
| 1437 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1438 | * PeekMessageW (USER32.@) Check queue for messages |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1439 | * |
| 1440 | * Checks for a message in the thread's queue, filtered as for |
| 1441 | * GetMessage(). Returns immediately whether a message is available |
| 1442 | * or not. |
| 1443 | * |
| 1444 | * Whether a retrieved message is removed from the queue is set by the |
| 1445 | * _wRemoveMsg_ flags, which should be one of the following values: |
| 1446 | * |
| 1447 | * PM_NOREMOVE Do not remove the message from the queue. |
| 1448 | * |
| 1449 | * PM_REMOVE Remove the message from the queue. |
| 1450 | * |
| 1451 | * In addition, PM_NOYIELD may be combined into _wRemoveMsg_ to |
| 1452 | * request that the system not yield control during PeekMessage(); |
| 1453 | * however applications may not rely on scheduling behavior. |
| 1454 | * |
| 1455 | * RETURNS |
| 1456 | * |
| 1457 | * Nonzero if a message is available and is retrieved, zero otherwise. |
| 1458 | * |
| 1459 | * CONFORMANCE |
| 1460 | * |
| 1461 | * ECMA-234, Win32 |
| 1462 | * |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 1463 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1464 | BOOL WINAPI PeekMessageW( |
Patrik Stridvall | 2b3aa61 | 2000-12-01 23:58:28 +0000 | [diff] [blame] | 1465 | LPMSG lpmsg, /* [out] buffer to receive message */ |
| 1466 | HWND hwnd, /* [in] restrict to messages for hwnd */ |
| 1467 | UINT min, /* [in] minimum message to receive */ |
| 1468 | UINT max, /* [in] maximum message to receive */ |
| 1469 | UINT wRemoveMsg /* [in] removal flags */ |
Juergen Schmied | 13f1b12 | 1999-05-02 09:17:48 +0000 | [diff] [blame] | 1470 | ) |
| 1471 | { |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 1472 | BOOL ret = MSG_PeekMessage( QMSG_WIN32W, lpmsg, hwnd, min, max, wRemoveMsg, TRUE ); |
| 1473 | if (ret) HOOK_CallHooksW( WH_GETMESSAGE, HC_ACTION, |
| 1474 | wRemoveMsg & PM_REMOVE, (LPARAM)lpmsg ); |
| 1475 | return ret; |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1476 | } |
| 1477 | |
| 1478 | |
| 1479 | /*********************************************************************** |
Patrik Stridvall | 0c61028 | 2001-01-25 22:22:21 +0000 | [diff] [blame] | 1480 | * GetMessage32 (USER.820) |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1481 | */ |
| 1482 | BOOL16 WINAPI GetMessage32_16( SEGPTR msg16_32, HWND16 hWnd, UINT16 first, |
| 1483 | UINT16 last, BOOL16 wHaveParamHigh ) |
| 1484 | { |
Alexandre Julliard | 982a223 | 2000-12-13 20:20:09 +0000 | [diff] [blame] | 1485 | MSG32_16 *lpmsg16_32 = MapSL(msg16_32); |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1486 | MSG msg; |
| 1487 | |
| 1488 | MSG_PeekMessage( QMSG_WIN16, &msg, hWnd, first, last, PM_REMOVE, FALSE ); |
| 1489 | |
| 1490 | lpmsg16_32->msg.hwnd = msg.hwnd; |
| 1491 | lpmsg16_32->msg.message = msg.message; |
| 1492 | lpmsg16_32->msg.wParam = LOWORD(msg.wParam); |
| 1493 | lpmsg16_32->msg.lParam = msg.lParam; |
| 1494 | lpmsg16_32->msg.time = msg.time; |
| 1495 | lpmsg16_32->msg.pt.x = (INT16)msg.pt.x; |
| 1496 | lpmsg16_32->msg.pt.y = (INT16)msg.pt.y; |
| 1497 | |
| 1498 | if ( wHaveParamHigh ) |
| 1499 | lpmsg16_32->wParamHigh = HIWORD(msg.wParam); |
| 1500 | |
| 1501 | TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n", |
| 1502 | lpmsg16_32->msg.message, hWnd, first, last ); |
| 1503 | |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 1504 | HOOK_CallHooks16( WH_GETMESSAGE, HC_ACTION, PM_REMOVE, (LPARAM)msg16_32 ); |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1505 | return lpmsg16_32->msg.message != WM_QUIT; |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 1506 | } |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1507 | |
| 1508 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1509 | * GetMessage (USER.108) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1510 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1511 | BOOL16 WINAPI GetMessage16( SEGPTR msg, HWND16 hwnd, UINT16 first, UINT16 last) |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1512 | { |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1513 | return GetMessage32_16( msg, hwnd, first, last, FALSE ); |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1514 | } |
| 1515 | |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 1516 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1517 | * GetMessageA (USER32.@) |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 1518 | */ |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1519 | BOOL WINAPI GetMessageA( MSG *lpmsg, HWND hwnd, UINT min, UINT max ) |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 1520 | { |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1521 | MSG_PeekMessage( QMSG_WIN32A, lpmsg, hwnd, min, max, PM_REMOVE, FALSE ); |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 1522 | |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1523 | TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n", |
| 1524 | lpmsg->message, hwnd, min, max ); |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 1525 | |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 1526 | HOOK_CallHooksA( WH_GETMESSAGE, HC_ACTION, PM_REMOVE, (LPARAM)lpmsg ); |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1527 | return lpmsg->message != WM_QUIT; |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 1528 | } |
| 1529 | |
| 1530 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1531 | * GetMessageW (USER32.@) Retrieve next message |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 1532 | * |
| 1533 | * GetMessage retrieves the next event from the calling thread's |
| 1534 | * queue and deposits it in *lpmsg. |
| 1535 | * |
| 1536 | * If _hwnd_ is not NULL, only messages for window _hwnd_ and its |
| 1537 | * children as specified by IsChild() are retrieved. If _hwnd_ is NULL |
| 1538 | * all application messages are retrieved. |
| 1539 | * |
| 1540 | * _min_ and _max_ specify the range of messages of interest. If |
| 1541 | * min==max==0, no filtering is performed. Useful examples are |
| 1542 | * WM_KEYFIRST and WM_KEYLAST to retrieve keyboard input, and |
| 1543 | * WM_MOUSEFIRST and WM_MOUSELAST to retrieve mouse input. |
| 1544 | * |
| 1545 | * WM_PAINT messages are not removed from the queue; they remain until |
| 1546 | * processed. Other messages are removed from the queue. |
| 1547 | * |
| 1548 | * RETURNS |
| 1549 | * |
| 1550 | * -1 on error, 0 if message is WM_QUIT, nonzero otherwise. |
| 1551 | * |
| 1552 | * CONFORMANCE |
| 1553 | * |
| 1554 | * ECMA-234, Win32 |
| 1555 | * |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 1556 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1557 | BOOL WINAPI GetMessageW( |
Patrik Stridvall | 2b3aa61 | 2000-12-01 23:58:28 +0000 | [diff] [blame] | 1558 | MSG* lpmsg, /* [out] buffer to receive message */ |
| 1559 | HWND hwnd, /* [in] restrict to messages for hwnd */ |
| 1560 | UINT min, /* [in] minimum message to receive */ |
| 1561 | UINT max /* [in] maximum message to receive */ |
Juergen Schmied | 13f1b12 | 1999-05-02 09:17:48 +0000 | [diff] [blame] | 1562 | ) |
| 1563 | { |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1564 | MSG_PeekMessage( QMSG_WIN32W, lpmsg, hwnd, min, max, PM_REMOVE, FALSE ); |
| 1565 | |
| 1566 | TRACE( "message %04x, hwnd %04x, filter(%04x - %04x)\n", |
| 1567 | lpmsg->message, hwnd, min, max ); |
| 1568 | |
Alexandre Julliard | 0ff083b | 2000-09-24 19:51:15 +0000 | [diff] [blame] | 1569 | HOOK_CallHooksW( WH_GETMESSAGE, HC_ACTION, PM_REMOVE, (LPARAM)lpmsg ); |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1570 | return lpmsg->message != WM_QUIT; |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 1571 | } |
| 1572 | |
Alexandre Julliard | 401710d | 1993-09-04 10:09:32 +0000 | [diff] [blame] | 1573 | /*********************************************************************** |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1574 | * MSG_PostToQueue |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1575 | */ |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1576 | static BOOL MSG_PostToQueue( HQUEUE16 hQueue, int type, HWND hwnd, |
| 1577 | UINT message, WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1578 | { |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1579 | MSG msg; |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 1580 | |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1581 | if ( !hQueue ) return FALSE; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1582 | |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 1583 | msg.hwnd = hwnd; |
| 1584 | msg.message = message; |
| 1585 | msg.wParam = wParam; |
| 1586 | msg.lParam = lParam; |
| 1587 | msg.time = GetTickCount(); |
Sheri Steeves | bd59d23 | 2000-06-15 00:09:04 +0000 | [diff] [blame] | 1588 | GetCursorPos(&msg.pt); |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 1589 | |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1590 | return QUEUE_AddMsg( hQueue, type, &msg, 0 ); |
| 1591 | } |
| 1592 | |
| 1593 | /*********************************************************************** |
Marcus Meissner | 5bcef61 | 2001-02-13 01:48:39 +0000 | [diff] [blame] | 1594 | * MSG_IsPointerMessage |
| 1595 | * |
| 1596 | * Check whether this message (may) contain pointers. |
| 1597 | * Those messages may not be PostMessage()d or GetMessage()d, but are dropped. |
| 1598 | * |
| 1599 | * FIXME: list of pointer messages might be incomplete. |
| 1600 | * |
| 1601 | * (We could do a generic !IsBadWritePtr() check, but this would cause too |
| 1602 | * much slow down I think. MM20010206) |
| 1603 | */ |
| 1604 | static BOOL MSG_IsPointerMessage(UINT message, WPARAM wParam, LPARAM lParam) { |
| 1605 | switch (message) { |
| 1606 | case WM_CREATE: |
| 1607 | case WM_NCCREATE: |
| 1608 | case WM_COMPAREITEM: |
| 1609 | case WM_DELETEITEM: |
| 1610 | case WM_MEASUREITEM: |
| 1611 | case WM_DRAWITEM: |
| 1612 | case WM_GETMINMAXINFO: |
| 1613 | case WM_GETTEXT: |
| 1614 | case WM_SETTEXT: |
| 1615 | case WM_MDICREATE: |
| 1616 | case WM_MDIGETACTIVE: |
| 1617 | case WM_NCCALCSIZE: |
| 1618 | case WM_WINDOWPOSCHANGING: |
| 1619 | case WM_WINDOWPOSCHANGED: |
| 1620 | case WM_NOTIFY: |
| 1621 | case WM_GETDLGCODE: |
| 1622 | case WM_WININICHANGE: |
| 1623 | case WM_HELP: |
| 1624 | case WM_COPYDATA: |
| 1625 | case WM_STYLECHANGING: |
| 1626 | case WM_STYLECHANGED: |
| 1627 | case WM_DROPOBJECT: |
| 1628 | case WM_DRAGMOVE: |
| 1629 | case WM_DRAGSELECT: |
| 1630 | case WM_QUERYDROPOBJECT: |
| 1631 | |
| 1632 | case CB_DIR: |
| 1633 | case CB_ADDSTRING: |
| 1634 | case CB_INSERTSTRING: |
| 1635 | case CB_FINDSTRING: |
| 1636 | case CB_FINDSTRINGEXACT: |
| 1637 | case CB_SELECTSTRING: |
| 1638 | case CB_GETLBTEXT: |
| 1639 | case CB_GETDROPPEDCONTROLRECT: |
| 1640 | |
| 1641 | case LB_DIR: |
| 1642 | case LB_ADDFILE: |
| 1643 | case LB_ADDSTRING: |
| 1644 | case LB_INSERTSTRING: |
| 1645 | case LB_GETTEXT: |
| 1646 | case LB_GETITEMRECT: |
| 1647 | case LB_FINDSTRING: |
| 1648 | case LB_FINDSTRINGEXACT: |
| 1649 | case LB_SELECTSTRING: |
| 1650 | case LB_GETSELITEMS: |
| 1651 | case LB_SETTABSTOPS: |
| 1652 | |
| 1653 | case EM_REPLACESEL: |
| 1654 | case EM_GETSEL: |
| 1655 | case EM_GETRECT: |
| 1656 | case EM_SETRECT: |
| 1657 | case EM_SETRECTNP: |
| 1658 | case EM_GETLINE: |
| 1659 | case EM_SETTABSTOPS: |
| 1660 | return TRUE; |
| 1661 | default: |
| 1662 | return FALSE; |
| 1663 | } |
| 1664 | } |
| 1665 | |
| 1666 | /*********************************************************************** |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1667 | * MSG_PostMessage |
| 1668 | */ |
| 1669 | static BOOL MSG_PostMessage( int type, HWND hwnd, UINT message, |
| 1670 | WPARAM wParam, LPARAM lParam ) |
| 1671 | { |
| 1672 | HQUEUE16 hQueue; |
| 1673 | WND *wndPtr; |
| 1674 | |
Marcus Meissner | 5bcef61 | 2001-02-13 01:48:39 +0000 | [diff] [blame] | 1675 | /* See thread on wine-devel around 6.2.2001. Basically posted messages |
| 1676 | * that are known to contain pointers are dropped by the Windows 32bit |
| 1677 | * PostMessage() with return FALSE; and invalid parameter last error. |
| 1678 | * (tested against NT4 by Gerard Patel) |
| 1679 | * 16 bit does not care, so we don't either. |
| 1680 | */ |
| 1681 | if ( (type!=QMSG_WIN16) && MSG_IsPointerMessage(message,wParam,lParam)) { |
| 1682 | FIXME("Ignoring posted pointer message 0x%04x to hwnd 0x%04x.\n", |
| 1683 | message,hwnd |
| 1684 | ); |
| 1685 | SetLastError(ERROR_INVALID_PARAMETER); |
| 1686 | return FALSE; |
| 1687 | } |
| 1688 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1689 | if (hwnd == HWND_BROADCAST) |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 1690 | { |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1691 | WND *pDesktop = WIN_GetDesktop(); |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1692 | TRACE("HWND_BROADCAST !\n"); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1693 | |
| 1694 | for (wndPtr=WIN_LockWndPtr(pDesktop->child); wndPtr; WIN_UpdateWndPtr(&wndPtr,wndPtr->next)) |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 1695 | { |
| 1696 | if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION) |
| 1697 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1698 | TRACE("BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n", |
| 1699 | wndPtr->hwndSelf, message, wParam, lParam); |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1700 | MSG_PostToQueue( wndPtr->hmemTaskQ, type, |
| 1701 | wndPtr->hwndSelf, message, wParam, lParam ); |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 1702 | } |
| 1703 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1704 | WIN_ReleaseDesktop(); |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1705 | TRACE("End of HWND_BROADCAST !\n"); |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 1706 | return TRUE; |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 1707 | } |
Alexandre Julliard | 7e50df3 | 1994-08-06 11:22:41 +0000 | [diff] [blame] | 1708 | |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 1709 | wndPtr = WIN_FindWndPtr( hwnd ); |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1710 | hQueue = wndPtr? wndPtr->hmemTaskQ : 0; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1711 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1712 | |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1713 | return MSG_PostToQueue( hQueue, type, hwnd, message, wParam, lParam ); |
| 1714 | } |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1715 | |
| 1716 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1717 | * PostMessage (USER.110) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1718 | */ |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1719 | BOOL16 WINAPI PostMessage16( HWND16 hwnd, UINT16 message, WPARAM16 wParam, |
| 1720 | LPARAM lParam ) |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1721 | { |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1722 | return (BOOL16) MSG_PostMessage( QMSG_WIN16, hwnd, message, wParam, lParam ); |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1723 | } |
| 1724 | |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1725 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1726 | * PostMessageA (USER32.@) |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1727 | */ |
| 1728 | BOOL WINAPI PostMessageA( HWND hwnd, UINT message, WPARAM wParam, |
| 1729 | LPARAM lParam ) |
| 1730 | { |
| 1731 | return MSG_PostMessage( QMSG_WIN32A, hwnd, message, wParam, lParam ); |
| 1732 | } |
| 1733 | |
| 1734 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1735 | * PostMessageW (USER32.@) |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1736 | */ |
| 1737 | BOOL WINAPI PostMessageW( HWND hwnd, UINT message, WPARAM wParam, |
| 1738 | LPARAM lParam ) |
| 1739 | { |
| 1740 | return MSG_PostMessage( QMSG_WIN32W, hwnd, message, wParam, lParam ); |
| 1741 | } |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 1742 | |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 1743 | /*********************************************************************** |
Patrik Stridvall | 0c61028 | 2001-01-25 22:22:21 +0000 | [diff] [blame] | 1744 | * PostAppMessage (USER.116) |
| 1745 | * PostAppMessage16 (USER32.@) |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 1746 | */ |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1747 | BOOL16 WINAPI PostAppMessage16( HTASK16 hTask, UINT16 message, |
| 1748 | WPARAM16 wParam, LPARAM lParam ) |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 1749 | { |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1750 | return MSG_PostToQueue( GetTaskQueue16(hTask), QMSG_WIN16, |
| 1751 | 0, message, wParam, lParam ); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 1752 | } |
| 1753 | |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1754 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1755 | * PostThreadMessageA (USER32.@) |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1756 | */ |
| 1757 | BOOL WINAPI PostThreadMessageA( DWORD idThread, UINT message, |
| 1758 | WPARAM wParam, LPARAM lParam ) |
| 1759 | { |
| 1760 | return MSG_PostToQueue( GetThreadQueue16(idThread), QMSG_WIN32A, |
| 1761 | 0, message, wParam, lParam ); |
| 1762 | } |
| 1763 | |
| 1764 | /********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1765 | * PostThreadMessageW (USER32.@) |
Ulrich Weigand | 2faf2cf | 1999-12-10 03:47:13 +0000 | [diff] [blame] | 1766 | */ |
| 1767 | BOOL WINAPI PostThreadMessageW( DWORD idThread, UINT message, |
| 1768 | WPARAM wParam, LPARAM lParam ) |
| 1769 | { |
| 1770 | return MSG_PostToQueue( GetThreadQueue16(idThread), QMSG_WIN32W, |
| 1771 | 0, message, wParam, lParam ); |
| 1772 | } |
| 1773 | |
| 1774 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1775 | /************************************************************************ |
| 1776 | * MSG_CallWndProcHook32 |
| 1777 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1778 | static void MSG_CallWndProcHook( LPMSG pmsg, BOOL bUnicode ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1779 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1780 | CWPSTRUCT cwp; |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1781 | |
| 1782 | cwp.lParam = pmsg->lParam; |
| 1783 | cwp.wParam = pmsg->wParam; |
| 1784 | cwp.message = pmsg->message; |
| 1785 | cwp.hwnd = pmsg->hwnd; |
| 1786 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1787 | if (bUnicode) HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp); |
| 1788 | else HOOK_CallHooksA( WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1789 | |
| 1790 | pmsg->lParam = cwp.lParam; |
| 1791 | pmsg->wParam = cwp.wParam; |
| 1792 | pmsg->message = cwp.message; |
| 1793 | pmsg->hwnd = cwp.hwnd; |
| 1794 | } |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1795 | |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1796 | |
| 1797 | /*********************************************************************** |
| 1798 | * MSG_SendMessage |
| 1799 | * |
| 1800 | * return values: 0 if timeout occurs |
| 1801 | * 1 otherwise |
| 1802 | */ |
Patrik Stridvall | 1ed4ecf | 1999-06-26 14:58:24 +0000 | [diff] [blame] | 1803 | static LRESULT MSG_SendMessage( HWND hwnd, UINT msg, WPARAM wParam, |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1804 | LPARAM lParam, DWORD timeout, WORD flags, |
| 1805 | LRESULT *pRes) |
| 1806 | { |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1807 | WND * wndPtr = 0; |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1808 | WND **list, **ppWnd; |
| 1809 | LRESULT ret = 1; |
| 1810 | |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 1811 | if (pRes) *pRes = 0; |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1812 | |
Uwe Bonnes | 991fc35 | 1999-06-05 15:16:57 +0000 | [diff] [blame] | 1813 | if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST) |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1814 | { |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 1815 | if (pRes) *pRes = 1; |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1816 | |
| 1817 | if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL ))) |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1818 | { |
| 1819 | WIN_ReleaseDesktop(); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1820 | return 1; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1821 | } |
| 1822 | WIN_ReleaseDesktop(); |
| 1823 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1824 | TRACE("HWND_BROADCAST !\n"); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1825 | for (ppWnd = list; *ppWnd; ppWnd++) |
| 1826 | { |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1827 | WIN_UpdateWndPtr(&wndPtr,*ppWnd); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1828 | if (!IsWindow(wndPtr->hwndSelf)) continue; |
| 1829 | if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION) |
| 1830 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1831 | TRACE("BROADCAST Message to hWnd=%04x m=%04X w=%04lX l=%08lX !\n", |
| 1832 | wndPtr->hwndSelf, msg, (DWORD)wParam, lParam); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1833 | MSG_SendMessage( wndPtr->hwndSelf, msg, wParam, lParam, |
| 1834 | timeout, flags, pRes); |
| 1835 | } |
| 1836 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1837 | WIN_ReleaseWndPtr(wndPtr); |
| 1838 | WIN_ReleaseWinArray(list); |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1839 | TRACE("End of HWND_BROADCAST !\n"); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1840 | return 1; |
| 1841 | } |
| 1842 | |
| 1843 | if (HOOK_IsHooked( WH_CALLWNDPROC )) |
| 1844 | { |
| 1845 | if (flags & SMSG_UNICODE) |
| 1846 | MSG_CallWndProcHook( (LPMSG)&hwnd, TRUE); |
| 1847 | else if (flags & SMSG_WIN32) |
| 1848 | MSG_CallWndProcHook( (LPMSG)&hwnd, FALSE); |
| 1849 | else |
| 1850 | { |
| 1851 | LPCWPSTRUCT16 pmsg; |
| 1852 | |
| 1853 | if ((pmsg = SEGPTR_NEW(CWPSTRUCT16))) |
| 1854 | { |
| 1855 | pmsg->hwnd = hwnd & 0xffff; |
| 1856 | pmsg->message= msg & 0xffff; |
| 1857 | pmsg->wParam = wParam & 0xffff; |
| 1858 | pmsg->lParam = lParam; |
| 1859 | HOOK_CallHooks16( WH_CALLWNDPROC, HC_ACTION, 1, |
| 1860 | (LPARAM)SEGPTR_GET(pmsg) ); |
| 1861 | hwnd = pmsg->hwnd; |
| 1862 | msg = pmsg->message; |
| 1863 | wParam = pmsg->wParam; |
| 1864 | lParam = pmsg->lParam; |
| 1865 | SEGPTR_FREE( pmsg ); |
| 1866 | } |
| 1867 | } |
| 1868 | } |
| 1869 | |
| 1870 | if (!(wndPtr = WIN_FindWndPtr( hwnd ))) |
| 1871 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 1872 | WARN("invalid hwnd %04x\n", hwnd ); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1873 | return 0; |
| 1874 | } |
| 1875 | if (QUEUE_IsExitingQueue(wndPtr->hmemTaskQ)) |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1876 | { |
| 1877 | ret = 0; /* Don't send anything if the task is dying */ |
| 1878 | goto END; |
| 1879 | } |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1880 | if (flags & SMSG_WIN32) |
| 1881 | SPY_EnterMessage( SPY_SENDMESSAGE, hwnd, msg, wParam, lParam ); |
| 1882 | else |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 1883 | SPY_EnterMessage( SPY_SENDMESSAGE16, hwnd, msg, wParam, lParam ); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1884 | |
| 1885 | if (wndPtr->hmemTaskQ != GetFastQueue16()) |
| 1886 | ret = MSG_SendMessageInterThread( wndPtr->hmemTaskQ, hwnd, msg, |
| 1887 | wParam, lParam, timeout, flags, pRes ); |
| 1888 | else |
| 1889 | { |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 1890 | LRESULT res; |
| 1891 | |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1892 | /* Call the right CallWindowProc flavor */ |
| 1893 | if (flags & SMSG_UNICODE) |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 1894 | res = CallWindowProcW( (WNDPROC)wndPtr->winproc, |
| 1895 | hwnd, msg, wParam, lParam ); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1896 | else if (flags & SMSG_WIN32) |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 1897 | res = CallWindowProcA( (WNDPROC)wndPtr->winproc, |
| 1898 | hwnd, msg, wParam, lParam ); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1899 | else |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 1900 | res = CallWindowProc16( (WNDPROC16)wndPtr->winproc, |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1901 | (HWND16) hwnd, (UINT16) msg, |
| 1902 | (WPARAM16) wParam, lParam ); |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 1903 | if (pRes) *pRes = res; |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1904 | } |
| 1905 | |
| 1906 | if (flags & SMSG_WIN32) |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 1907 | SPY_ExitMessage( SPY_RESULT_OK, hwnd, msg, pRes?*pRes:0, wParam, lParam ); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1908 | else |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 1909 | SPY_ExitMessage( SPY_RESULT_OK16, hwnd, msg, pRes?*pRes:0, wParam, lParam ); |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1910 | END: |
| 1911 | WIN_ReleaseWndPtr(wndPtr); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1912 | return ret; |
| 1913 | } |
| 1914 | |
| 1915 | |
| 1916 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1917 | * SendMessage (USER.111) |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1918 | */ |
| 1919 | LRESULT WINAPI SendMessage16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, |
| 1920 | LPARAM lParam) |
| 1921 | { |
| 1922 | LRESULT res; |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1923 | MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE, 0, &res); |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1924 | return res; |
| 1925 | } |
| 1926 | |
| 1927 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1928 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1929 | * SendMessageA (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1930 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1931 | LRESULT WINAPI SendMessageA( HWND hwnd, UINT msg, WPARAM wParam, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1932 | LPARAM lParam ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1933 | { |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1934 | LRESULT res; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1935 | |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1936 | MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE, |
| 1937 | SMSG_WIN32, &res); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1938 | |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1939 | return res; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1940 | } |
| 1941 | |
| 1942 | |
| 1943 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1944 | * SendMessageW (USER32.@) Send Window Message |
Douglas Ridgway | efaa573 | 1998-10-25 09:20:30 +0000 | [diff] [blame] | 1945 | * |
| 1946 | * Sends a message to the window procedure of the specified window. |
| 1947 | * SendMessage() will not return until the called window procedure |
| 1948 | * either returns or calls ReplyMessage(). |
| 1949 | * |
| 1950 | * Use PostMessage() to send message and return immediately. A window |
| 1951 | * procedure may use InSendMessage() to detect |
| 1952 | * SendMessage()-originated messages. |
| 1953 | * |
| 1954 | * Applications which communicate via HWND_BROADCAST may use |
| 1955 | * RegisterWindowMessage() to obtain a unique message to avoid conflicts |
| 1956 | * with other applications. |
| 1957 | * |
| 1958 | * CONFORMANCE |
| 1959 | * |
| 1960 | * ECMA-234, Win32 |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1961 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1962 | LRESULT WINAPI SendMessageW( |
Patrik Stridvall | 2b3aa61 | 2000-12-01 23:58:28 +0000 | [diff] [blame] | 1963 | HWND hwnd, /* [in] Window to send message to. If HWND_BROADCAST, |
| 1964 | the message will be sent to all top-level windows. */ |
Douglas Ridgway | efaa573 | 1998-10-25 09:20:30 +0000 | [diff] [blame] | 1965 | |
Patrik Stridvall | 2b3aa61 | 2000-12-01 23:58:28 +0000 | [diff] [blame] | 1966 | UINT msg, /* [in] message */ |
| 1967 | WPARAM wParam, /* [in] message parameter */ |
| 1968 | LPARAM lParam /* [in] additional message parameter */ |
Douglas Ridgway | efaa573 | 1998-10-25 09:20:30 +0000 | [diff] [blame] | 1969 | ) { |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1970 | LRESULT res; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1971 | |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1972 | MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE, |
| 1973 | SMSG_WIN32 | SMSG_UNICODE, &res); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1974 | |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1975 | return res; |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 1976 | } |
| 1977 | |
| 1978 | |
| 1979 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1980 | * SendMessageTimeout (not a WINAPI) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1981 | */ |
| 1982 | LRESULT WINAPI SendMessageTimeout16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, |
| 1983 | LPARAM lParam, UINT16 flags, |
| 1984 | UINT16 timeout, LPWORD resultp) |
| 1985 | { |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1986 | LRESULT ret; |
| 1987 | LRESULT msgRet; |
| 1988 | |
| 1989 | /* FIXME: need support for SMTO_BLOCK */ |
| 1990 | |
| 1991 | ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout, 0, &msgRet); |
Andreas Mohr | 98c5cd6 | 2000-01-04 00:23:32 +0000 | [diff] [blame] | 1992 | if (resultp) *resultp = (WORD) msgRet; |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 1993 | return ret; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1994 | } |
| 1995 | |
| 1996 | |
| 1997 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1998 | * SendMessageTimeoutA (USER32.@) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 1999 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2000 | LRESULT WINAPI SendMessageTimeoutA( HWND hwnd, UINT msg, WPARAM wParam, |
| 2001 | LPARAM lParam, UINT flags, |
| 2002 | UINT timeout, LPDWORD resultp) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 2003 | { |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 2004 | LRESULT ret; |
| 2005 | LRESULT msgRet; |
| 2006 | |
| 2007 | /* FIXME: need support for SMTO_BLOCK */ |
| 2008 | |
| 2009 | ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout, SMSG_WIN32, |
| 2010 | &msgRet); |
| 2011 | |
Andreas Mohr | 98c5cd6 | 2000-01-04 00:23:32 +0000 | [diff] [blame] | 2012 | if (resultp) *resultp = (DWORD) msgRet; |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 2013 | return ret; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 2014 | } |
| 2015 | |
| 2016 | |
| 2017 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2018 | * SendMessageTimeoutW (USER32.@) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 2019 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2020 | LRESULT WINAPI SendMessageTimeoutW( HWND hwnd, UINT msg, WPARAM wParam, |
| 2021 | LPARAM lParam, UINT flags, |
| 2022 | UINT timeout, LPDWORD resultp) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 2023 | { |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 2024 | LRESULT ret; |
| 2025 | LRESULT msgRet; |
| 2026 | |
| 2027 | /* FIXME: need support for SMTO_BLOCK */ |
| 2028 | |
| 2029 | ret = MSG_SendMessage(hwnd, msg, wParam, lParam, timeout, |
| 2030 | SMSG_WIN32 | SMSG_UNICODE, &msgRet); |
| 2031 | |
Andreas Mohr | 98c5cd6 | 2000-01-04 00:23:32 +0000 | [diff] [blame] | 2032 | if (resultp) *resultp = (DWORD) msgRet; |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 2033 | return ret; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 2034 | } |
| 2035 | |
| 2036 | |
| 2037 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2038 | * WaitMessage (USER.112) (USER32.@) Suspend thread pending messages |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2039 | * |
| 2040 | * WaitMessage() suspends a thread until events appear in the thread's |
| 2041 | * queue. |
| 2042 | * |
| 2043 | * BUGS |
| 2044 | * |
| 2045 | * Is supposed to return BOOL under Win32. |
| 2046 | * |
Douglas Ridgway | efaa573 | 1998-10-25 09:20:30 +0000 | [diff] [blame] | 2047 | * Thread-local message queues are not supported. |
| 2048 | * |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2049 | * CONFORMANCE |
| 2050 | * |
| 2051 | * ECMA-234, Win32 |
| 2052 | * |
Alexandre Julliard | 7e50df3 | 1994-08-06 11:22:41 +0000 | [diff] [blame] | 2053 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2054 | void WINAPI WaitMessage( void ) |
Alexandre Julliard | 7e50df3 | 1994-08-06 11:22:41 +0000 | [diff] [blame] | 2055 | { |
Stephane Lussier | bae5552 | 1999-03-10 16:21:12 +0000 | [diff] [blame] | 2056 | QUEUE_WaitBits( QS_ALLINPUT, INFINITE ); |
Alexandre Julliard | 7e50df3 | 1994-08-06 11:22:41 +0000 | [diff] [blame] | 2057 | } |
| 2058 | |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2059 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2060 | * MsgWaitForMultipleObjects (USER32.@) |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2061 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2062 | DWORD WINAPI MsgWaitForMultipleObjects( DWORD nCount, HANDLE *pHandles, |
| 2063 | BOOL fWaitAll, DWORD dwMilliseconds, |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2064 | DWORD dwWakeMask ) |
| 2065 | { |
Alexandre Julliard | dbf2bf0 | 1999-01-01 17:05:53 +0000 | [diff] [blame] | 2066 | DWORD i; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2067 | HANDLE handles[MAXIMUM_WAIT_OBJECTS]; |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 2068 | DWORD ret; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2069 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2070 | HQUEUE16 hQueue = GetFastQueue16(); |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 2071 | MESSAGEQUEUE *msgQueue = QUEUE_Lock( hQueue ); |
Alexandre Julliard | dbf2bf0 | 1999-01-01 17:05:53 +0000 | [diff] [blame] | 2072 | if (!msgQueue) return WAIT_FAILED; |
| 2073 | |
| 2074 | if (nCount > MAXIMUM_WAIT_OBJECTS-1) |
| 2075 | { |
| 2076 | SetLastError( ERROR_INVALID_PARAMETER ); |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 2077 | QUEUE_Unlock( msgQueue ); |
Alexandre Julliard | dbf2bf0 | 1999-01-01 17:05:53 +0000 | [diff] [blame] | 2078 | return WAIT_FAILED; |
| 2079 | } |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2080 | |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 2081 | EnterCriticalSection( &msgQueue->cSection ); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2082 | msgQueue->changeBits = 0; |
| 2083 | msgQueue->wakeMask = dwWakeMask; |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 2084 | LeaveCriticalSection( &msgQueue->cSection ); |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2085 | |
Alexandre Julliard | 0a860a0 | 1999-06-22 11:43:42 +0000 | [diff] [blame] | 2086 | if (THREAD_IsWin16(NtCurrentTeb())) |
Francis Beaudet | 6a6f6e2 | 1999-02-19 15:34:40 +0000 | [diff] [blame] | 2087 | { |
| 2088 | /* |
| 2089 | * This is a temporary solution to a big problem. |
| 2090 | * You see, the main thread of all Win32 programs is created as a 16 bit |
Andreas Mohr | 2e011a5 | 2000-06-01 23:28:25 +0000 | [diff] [blame] | 2091 | * task. This means that if you wait on an event using Win32 synchronization |
Francis Beaudet | 6a6f6e2 | 1999-02-19 15:34:40 +0000 | [diff] [blame] | 2092 | * methods, the 16 bit scheduler is stopped and things might just stop happening. |
| 2093 | * This implements a semi-busy loop that checks the handles to wait on and |
| 2094 | * also the message queue. When either one is ready, the wait function returns. |
| 2095 | * |
| 2096 | * This will all go away when the real Win32 threads are implemented for all |
| 2097 | * the threads of an applications. Including the main thread. |
| 2098 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2099 | DWORD curTime = GetCurrentTime(); |
Francis Beaudet | 6a6f6e2 | 1999-02-19 15:34:40 +0000 | [diff] [blame] | 2100 | |
| 2101 | do |
| 2102 | { |
| 2103 | /* |
| 2104 | * Check the handles in the list. |
| 2105 | */ |
| 2106 | ret = WaitForMultipleObjects(nCount, pHandles, fWaitAll, 5L); |
| 2107 | |
| 2108 | /* |
| 2109 | * If the handles have been triggered, return. |
| 2110 | */ |
| 2111 | if (ret != WAIT_TIMEOUT) |
| 2112 | break; |
| 2113 | |
| 2114 | /* |
| 2115 | * Then, let the 16 bit scheduler do it's thing. |
| 2116 | */ |
Eric Pouech | 4d24e0f | 2000-12-22 23:25:47 +0000 | [diff] [blame] | 2117 | K32WOWYield16(); |
Francis Beaudet | 6a6f6e2 | 1999-02-19 15:34:40 +0000 | [diff] [blame] | 2118 | |
| 2119 | /* |
| 2120 | * If a message matching the wait mask has arrived, return. |
| 2121 | */ |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 2122 | EnterCriticalSection( &msgQueue->cSection ); |
Francis Beaudet | 6a6f6e2 | 1999-02-19 15:34:40 +0000 | [diff] [blame] | 2123 | if (msgQueue->changeBits & dwWakeMask) |
| 2124 | { |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 2125 | LeaveCriticalSection( &msgQueue->cSection ); |
Francis Beaudet | 6a6f6e2 | 1999-02-19 15:34:40 +0000 | [diff] [blame] | 2126 | ret = nCount; |
| 2127 | break; |
| 2128 | } |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 2129 | LeaveCriticalSection( &msgQueue->cSection ); |
Francis Beaudet | 6a6f6e2 | 1999-02-19 15:34:40 +0000 | [diff] [blame] | 2130 | |
| 2131 | /* |
| 2132 | * And continue doing this until we hit the timeout. |
| 2133 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2134 | } while ((dwMilliseconds == INFINITE) || (GetCurrentTime()-curTime < dwMilliseconds) ); |
Francis Beaudet | 6a6f6e2 | 1999-02-19 15:34:40 +0000 | [diff] [blame] | 2135 | } |
| 2136 | else |
| 2137 | { |
Alexandre Julliard | dbf2bf0 | 1999-01-01 17:05:53 +0000 | [diff] [blame] | 2138 | /* Add the thread event to the handle list */ |
Francis Beaudet | 6a6f6e2 | 1999-02-19 15:34:40 +0000 | [diff] [blame] | 2139 | for (i = 0; i < nCount; i++) |
Alexandre Julliard | c5e433a | 2000-05-30 19:48:18 +0000 | [diff] [blame] | 2140 | handles[i] = pHandles[i]; |
| 2141 | handles[nCount] = msgQueue->server_queue; |
Peter Ganten | 6619f5a | 2000-01-01 22:38:20 +0000 | [diff] [blame] | 2142 | ret = WaitForMultipleObjects( nCount+1, handles, fWaitAll, dwMilliseconds ); |
Francis Beaudet | 6a6f6e2 | 1999-02-19 15:34:40 +0000 | [diff] [blame] | 2143 | } |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 2144 | QUEUE_Unlock( msgQueue ); |
Stephane Lussier | b3a99de | 1999-02-09 15:35:12 +0000 | [diff] [blame] | 2145 | return ret; |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2146 | } |
| 2147 | |
Eric Pouech | 982e0ce | 2001-01-28 23:44:56 +0000 | [diff] [blame] | 2148 | /*********************************************************************** |
Patrik Stridvall | df75e89 | 2001-02-12 03:49:07 +0000 | [diff] [blame] | 2149 | * MsgWaitForMultipleObjects (USER.640) |
Eric Pouech | 982e0ce | 2001-01-28 23:44:56 +0000 | [diff] [blame] | 2150 | */ |
| 2151 | DWORD WINAPI MsgWaitForMultipleObjects16( DWORD nCount, HANDLE *pHandles, |
| 2152 | BOOL fWaitAll, DWORD dwMilliseconds, |
| 2153 | DWORD dwWakeMask ) |
| 2154 | { |
| 2155 | TRACE("(%lu,%p,%u,%lu,0x%lx)\n", |
| 2156 | nCount, pHandles, fWaitAll, dwMilliseconds, dwWakeMask); |
| 2157 | return MsgWaitForMultipleObjects(nCount, pHandles, fWaitAll, dwMilliseconds, dwWakeMask); |
| 2158 | } |
Alexandre Julliard | 7e50df3 | 1994-08-06 11:22:41 +0000 | [diff] [blame] | 2159 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2160 | struct accent_char |
| 2161 | { |
| 2162 | BYTE ac_accent; |
| 2163 | BYTE ac_char; |
| 2164 | BYTE ac_result; |
| 2165 | }; |
| 2166 | |
| 2167 | static const struct accent_char accent_chars[] = |
| 2168 | { |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 2169 | /* A good idea should be to read /usr/X11/lib/X11/locale/iso8859-x/Compose */ |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2170 | {'`', 'A', '\300'}, {'`', 'a', '\340'}, |
| 2171 | {'\'', 'A', '\301'}, {'\'', 'a', '\341'}, |
| 2172 | {'^', 'A', '\302'}, {'^', 'a', '\342'}, |
| 2173 | {'~', 'A', '\303'}, {'~', 'a', '\343'}, |
| 2174 | {'"', 'A', '\304'}, {'"', 'a', '\344'}, |
| 2175 | {'O', 'A', '\305'}, {'o', 'a', '\345'}, |
| 2176 | {'0', 'A', '\305'}, {'0', 'a', '\345'}, |
| 2177 | {'A', 'A', '\305'}, {'a', 'a', '\345'}, |
| 2178 | {'A', 'E', '\306'}, {'a', 'e', '\346'}, |
| 2179 | {',', 'C', '\307'}, {',', 'c', '\347'}, |
| 2180 | {'`', 'E', '\310'}, {'`', 'e', '\350'}, |
| 2181 | {'\'', 'E', '\311'}, {'\'', 'e', '\351'}, |
| 2182 | {'^', 'E', '\312'}, {'^', 'e', '\352'}, |
| 2183 | {'"', 'E', '\313'}, {'"', 'e', '\353'}, |
| 2184 | {'`', 'I', '\314'}, {'`', 'i', '\354'}, |
| 2185 | {'\'', 'I', '\315'}, {'\'', 'i', '\355'}, |
| 2186 | {'^', 'I', '\316'}, {'^', 'i', '\356'}, |
| 2187 | {'"', 'I', '\317'}, {'"', 'i', '\357'}, |
| 2188 | {'-', 'D', '\320'}, {'-', 'd', '\360'}, |
| 2189 | {'~', 'N', '\321'}, {'~', 'n', '\361'}, |
| 2190 | {'`', 'O', '\322'}, {'`', 'o', '\362'}, |
| 2191 | {'\'', 'O', '\323'}, {'\'', 'o', '\363'}, |
| 2192 | {'^', 'O', '\324'}, {'^', 'o', '\364'}, |
| 2193 | {'~', 'O', '\325'}, {'~', 'o', '\365'}, |
| 2194 | {'"', 'O', '\326'}, {'"', 'o', '\366'}, |
| 2195 | {'/', 'O', '\330'}, {'/', 'o', '\370'}, |
| 2196 | {'`', 'U', '\331'}, {'`', 'u', '\371'}, |
| 2197 | {'\'', 'U', '\332'}, {'\'', 'u', '\372'}, |
| 2198 | {'^', 'U', '\333'}, {'^', 'u', '\373'}, |
| 2199 | {'"', 'U', '\334'}, {'"', 'u', '\374'}, |
| 2200 | {'\'', 'Y', '\335'}, {'\'', 'y', '\375'}, |
| 2201 | {'T', 'H', '\336'}, {'t', 'h', '\376'}, |
| 2202 | {'s', 's', '\337'}, {'"', 'y', '\377'}, |
| 2203 | {'s', 'z', '\337'}, {'i', 'j', '\377'}, |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 2204 | /* iso-8859-2 uses this */ |
| 2205 | {'<', 'L', '\245'}, {'<', 'l', '\265'}, /* caron */ |
| 2206 | {'<', 'S', '\251'}, {'<', 's', '\271'}, |
| 2207 | {'<', 'T', '\253'}, {'<', 't', '\273'}, |
| 2208 | {'<', 'Z', '\256'}, {'<', 'z', '\276'}, |
| 2209 | {'<', 'C', '\310'}, {'<', 'c', '\350'}, |
| 2210 | {'<', 'E', '\314'}, {'<', 'e', '\354'}, |
| 2211 | {'<', 'D', '\317'}, {'<', 'd', '\357'}, |
| 2212 | {'<', 'N', '\322'}, {'<', 'n', '\362'}, |
| 2213 | {'<', 'R', '\330'}, {'<', 'r', '\370'}, |
| 2214 | {';', 'A', '\241'}, {';', 'a', '\261'}, /* ogonek */ |
| 2215 | {';', 'E', '\312'}, {';', 'e', '\332'}, |
| 2216 | {'\'', 'Z', '\254'}, {'\'', 'z', '\274'}, /* acute */ |
| 2217 | {'\'', 'R', '\300'}, {'\'', 'r', '\340'}, |
| 2218 | {'\'', 'L', '\305'}, {'\'', 'l', '\345'}, |
| 2219 | {'\'', 'C', '\306'}, {'\'', 'c', '\346'}, |
| 2220 | {'\'', 'N', '\321'}, {'\'', 'n', '\361'}, |
| 2221 | /* collision whith S, from iso-8859-9 !!! */ |
| 2222 | {',', 'S', '\252'}, {',', 's', '\272'}, /* cedilla */ |
| 2223 | {',', 'T', '\336'}, {',', 't', '\376'}, |
| 2224 | {'.', 'Z', '\257'}, {'.', 'z', '\277'}, /* dot above */ |
| 2225 | {'/', 'L', '\243'}, {'/', 'l', '\263'}, /* slash */ |
| 2226 | {'/', 'D', '\320'}, {'/', 'd', '\360'}, |
| 2227 | {'(', 'A', '\303'}, {'(', 'a', '\343'}, /* breve */ |
| 2228 | {'\275', 'O', '\325'}, {'\275', 'o', '\365'}, /* double acute */ |
| 2229 | {'\275', 'U', '\334'}, {'\275', 'u', '\374'}, |
| 2230 | {'0', 'U', '\332'}, {'0', 'u', '\372'}, /* ring above */ |
| 2231 | /* iso-8859-3 uses this */ |
| 2232 | {'/', 'H', '\241'}, {'/', 'h', '\261'}, /* slash */ |
| 2233 | {'>', 'H', '\246'}, {'>', 'h', '\266'}, /* circumflex */ |
| 2234 | {'>', 'J', '\254'}, {'>', 'j', '\274'}, |
| 2235 | {'>', 'C', '\306'}, {'>', 'c', '\346'}, |
| 2236 | {'>', 'G', '\330'}, {'>', 'g', '\370'}, |
| 2237 | {'>', 'S', '\336'}, {'>', 's', '\376'}, |
| 2238 | /* collision whith G( from iso-8859-9 !!! */ |
| 2239 | {'(', 'G', '\253'}, {'(', 'g', '\273'}, /* breve */ |
| 2240 | {'(', 'U', '\335'}, {'(', 'u', '\375'}, |
| 2241 | /* collision whith I. from iso-8859-3 !!! */ |
| 2242 | {'.', 'I', '\251'}, {'.', 'i', '\271'}, /* dot above */ |
| 2243 | {'.', 'C', '\305'}, {'.', 'c', '\345'}, |
| 2244 | {'.', 'G', '\325'}, {'.', 'g', '\365'}, |
| 2245 | /* iso-8859-4 uses this */ |
| 2246 | {',', 'R', '\243'}, {',', 'r', '\263'}, /* cedilla */ |
| 2247 | {',', 'L', '\246'}, {',', 'l', '\266'}, |
| 2248 | {',', 'G', '\253'}, {',', 'g', '\273'}, |
| 2249 | {',', 'N', '\321'}, {',', 'n', '\361'}, |
| 2250 | {',', 'K', '\323'}, {',', 'k', '\363'}, |
| 2251 | {'~', 'I', '\245'}, {'~', 'i', '\265'}, /* tilde */ |
| 2252 | {'-', 'E', '\252'}, {'-', 'e', '\272'}, /* macron */ |
| 2253 | {'-', 'A', '\300'}, {'-', 'a', '\340'}, |
| 2254 | {'-', 'I', '\317'}, {'-', 'i', '\357'}, |
| 2255 | {'-', 'O', '\322'}, {'-', 'o', '\362'}, |
| 2256 | {'-', 'U', '\336'}, {'-', 'u', '\376'}, |
| 2257 | {'/', 'T', '\254'}, {'/', 't', '\274'}, /* slash */ |
| 2258 | {'.', 'E', '\314'}, {'.', 'e', '\344'}, /* dot above */ |
| 2259 | {';', 'I', '\307'}, {';', 'i', '\347'}, /* ogonek */ |
| 2260 | {';', 'U', '\331'}, {';', 'u', '\371'}, |
| 2261 | /* iso-8859-9 uses this */ |
| 2262 | /* iso-8859-9 has really bad choosen G( S, and I. as they collide |
| 2263 | * whith the same letters on other iso-8859-x (that is they are on |
| 2264 | * different places :-( ), if you use turkish uncomment these and |
| 2265 | * comment out the lines in iso-8859-2 and iso-8859-3 sections |
| 2266 | * FIXME: should be dynamic according to chosen language |
| 2267 | * if/when Wine has turkish support. |
| 2268 | */ |
| 2269 | /* collision whith G( from iso-8859-3 !!! */ |
| 2270 | /* {'(', 'G', '\320'}, {'(', 'g', '\360'}, */ /* breve */ |
| 2271 | /* collision whith S, from iso-8859-2 !!! */ |
| 2272 | /* {',', 'S', '\336'}, {',', 's', '\376'}, */ /* cedilla */ |
| 2273 | /* collision whith I. from iso-8859-3 !!! */ |
| 2274 | /* {'.', 'I', '\335'}, {'.', 'i', '\375'}, */ /* dot above */ |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2275 | }; |
| 2276 | |
| 2277 | |
Alexandre Julliard | 7e50df3 | 1994-08-06 11:22:41 +0000 | [diff] [blame] | 2278 | /*********************************************************************** |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2279 | * MSG_DoTranslateMessage |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 2280 | * |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2281 | * Implementation of TranslateMessage. |
| 2282 | * |
| 2283 | * TranslateMessage translates virtual-key messages into character-messages, |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 2284 | * as follows : |
| 2285 | * WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message. |
| 2286 | * ditto replacing WM_* with WM_SYS* |
| 2287 | * This produces WM_CHAR messages only for keys mapped to ASCII characters |
| 2288 | * by the keyboard driver. |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 2289 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2290 | static BOOL MSG_DoTranslateMessage( UINT message, HWND hwnd, |
| 2291 | WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 2292 | { |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2293 | static int dead_char; |
Dmitry Timoshkov | 2fa0c66 | 2000-11-25 02:09:45 +0000 | [diff] [blame] | 2294 | WCHAR wp[2]; |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 2295 | |
Alexandre Julliard | a11d7b1 | 1998-03-01 20:05:02 +0000 | [diff] [blame] | 2296 | if (message != WM_MOUSEMOVE && message != WM_TIMER) |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2297 | TRACE("(%s, %04X, %08lX)\n", |
Alexandre Julliard | a11d7b1 | 1998-03-01 20:05:02 +0000 | [diff] [blame] | 2298 | SPY_GetMsgName(message), wParam, lParam ); |
| 2299 | if(message >= WM_KEYFIRST && message <= WM_KEYLAST) |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 2300 | TRACE_(key)("(%s, %04X, %08lX)\n", |
Alexandre Julliard | a11d7b1 | 1998-03-01 20:05:02 +0000 | [diff] [blame] | 2301 | SPY_GetMsgName(message), wParam, lParam ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2302 | |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 2303 | if ((message != WM_KEYDOWN) && (message != WM_SYSKEYDOWN)) return FALSE; |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2304 | |
Dmitry Timoshkov | 740bb92 | 2000-11-05 20:07:59 +0000 | [diff] [blame] | 2305 | TRACE_(key)("Translating key %s (%04x), scancode %02x\n", |
| 2306 | SPY_GetVKeyName(wParam), wParam, LOBYTE(HIWORD(lParam))); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2307 | |
Dmitry Timoshkov | 2fa0c66 | 2000-11-25 02:09:45 +0000 | [diff] [blame] | 2308 | /* FIXME : should handle ToUnicode yielding 2 */ |
| 2309 | switch (ToUnicode(wParam, HIWORD(lParam), QueueKeyStateTable, wp, 2, 0)) |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 2310 | { |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 2311 | case 1: |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2312 | message = (message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR; |
| 2313 | /* Should dead chars handling go in ToAscii ? */ |
| 2314 | if (dead_char) |
| 2315 | { |
| 2316 | int i; |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 2317 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2318 | if (wp[0] == ' ') wp[0] = dead_char; |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 2319 | if (dead_char == 0xa2) dead_char = '('; |
| 2320 | else if (dead_char == 0xa8) dead_char = '"'; |
| 2321 | else if (dead_char == 0xb2) dead_char = ';'; |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2322 | else if (dead_char == 0xb4) dead_char = '\''; |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 2323 | else if (dead_char == 0xb7) dead_char = '<'; |
| 2324 | else if (dead_char == 0xb8) dead_char = ','; |
| 2325 | else if (dead_char == 0xff) dead_char = '.'; |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2326 | for (i = 0; i < sizeof(accent_chars)/sizeof(accent_chars[0]); i++) |
| 2327 | if ((accent_chars[i].ac_accent == dead_char) && |
| 2328 | (accent_chars[i].ac_char == wp[0])) |
| 2329 | { |
| 2330 | wp[0] = accent_chars[i].ac_result; |
| 2331 | break; |
| 2332 | } |
| 2333 | dead_char = 0; |
| 2334 | } |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 2335 | TRACE_(key)("1 -> PostMessage(%s)\n", SPY_GetMsgName(message)); |
Dmitry Timoshkov | 2fa0c66 | 2000-11-25 02:09:45 +0000 | [diff] [blame] | 2336 | PostMessageW( hwnd, message, wp[0], lParam ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2337 | return TRUE; |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 2338 | |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 2339 | case -1: |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2340 | message = (message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR; |
| 2341 | dead_char = wp[0]; |
Dmitry Timoshkov | 2fa0c66 | 2000-11-25 02:09:45 +0000 | [diff] [blame] | 2342 | TRACE_(key)("-1 -> PostMessage(%s)\n", SPY_GetMsgName(message)); |
| 2343 | PostMessageW( hwnd, message, wp[0], lParam ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2344 | return TRUE; |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 2345 | } |
| 2346 | return FALSE; |
| 2347 | } |
| 2348 | |
| 2349 | |
| 2350 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2351 | * TranslateMessage (USER.113) |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 2352 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2353 | BOOL16 WINAPI TranslateMessage16( const MSG16 *msg ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2354 | { |
| 2355 | return MSG_DoTranslateMessage( msg->message, msg->hwnd, |
| 2356 | msg->wParam, msg->lParam ); |
| 2357 | } |
| 2358 | |
| 2359 | |
| 2360 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2361 | * TranslateMessage32 (USER.821) |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 2362 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2363 | BOOL16 WINAPI TranslateMessage32_16( const MSG32_16 *msg, BOOL16 wHaveParamHigh ) |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 2364 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2365 | WPARAM wParam; |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 2366 | |
| 2367 | if (wHaveParamHigh) |
| 2368 | wParam = MAKELONG(msg->msg.wParam, msg->wParamHigh); |
| 2369 | else |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2370 | wParam = (WPARAM)msg->msg.wParam; |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 2371 | |
| 2372 | return MSG_DoTranslateMessage( msg->msg.message, msg->msg.hwnd, |
| 2373 | wParam, msg->msg.lParam ); |
| 2374 | } |
| 2375 | |
| 2376 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2377 | * TranslateMessage (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2378 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2379 | BOOL WINAPI TranslateMessage( const MSG *msg ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2380 | { |
| 2381 | return MSG_DoTranslateMessage( msg->message, msg->hwnd, |
| 2382 | msg->wParam, msg->lParam ); |
| 2383 | } |
| 2384 | |
| 2385 | |
| 2386 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2387 | * DispatchMessage (USER.114) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2388 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2389 | LONG WINAPI DispatchMessage16( const MSG16* msg ) |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 2390 | { |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 2391 | WND * wndPtr; |
| 2392 | LONG retval; |
| 2393 | int painting; |
| 2394 | |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 2395 | /* Process timer messages */ |
| 2396 | if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER)) |
| 2397 | { |
| 2398 | if (msg->lParam) |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2399 | { |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 2400 | /* before calling window proc, verify whether timer is still valid; |
| 2401 | there's a slim chance that the application kills the timer |
| 2402 | between GetMessage and DispatchMessage API calls */ |
Stephane Lussier | 6bac4f2 | 2000-09-29 00:56:05 +0000 | [diff] [blame] | 2403 | if (!TIMER_IsTimerValid(msg->hwnd, (UINT) msg->wParam, (HWINDOWPROC) msg->lParam)) |
| 2404 | return 0; /* invalid winproc */ |
| 2405 | |
Alexandre Julliard | d90840e | 1996-06-11 16:02:08 +0000 | [diff] [blame] | 2406 | return CallWindowProc16( (WNDPROC16)msg->lParam, msg->hwnd, |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2407 | msg->message, msg->wParam, GetTickCount() ); |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 2408 | } |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 2409 | } |
| 2410 | |
| 2411 | if (!msg->hwnd) return 0; |
| 2412 | if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 2413 | if (!wndPtr->winproc) |
| 2414 | { |
| 2415 | retval = 0; |
| 2416 | goto END; |
| 2417 | } |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 2418 | painting = (msg->message == WM_PAINT); |
| 2419 | if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2420 | |
| 2421 | SPY_EnterMessage( SPY_DISPATCHMESSAGE16, msg->hwnd, msg->message, |
| 2422 | msg->wParam, msg->lParam ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 2423 | retval = CallWindowProc16( (WNDPROC16)wndPtr->winproc, |
| 2424 | msg->hwnd, msg->message, |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2425 | msg->wParam, msg->lParam ); |
Guy L. Albertelli | 936c6c4 | 2000-10-22 23:52:47 +0000 | [diff] [blame] | 2426 | SPY_ExitMessage( SPY_RESULT_OK16, msg->hwnd, msg->message, retval, |
| 2427 | msg->wParam, msg->lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 2428 | |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 2429 | WIN_ReleaseWndPtr(wndPtr); |
| 2430 | wndPtr = WIN_FindWndPtr(msg->hwnd); |
| 2431 | if (painting && wndPtr && |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 2432 | (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate) |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 2433 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2434 | ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n", |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2435 | msg->hwnd); |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 2436 | wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT; |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 2437 | /* Validate the update region to avoid infinite WM_PAINT loop */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2438 | ValidateRect( msg->hwnd, NULL ); |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 2439 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 2440 | END: |
| 2441 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | 5f721f8 | 1994-01-04 20:14:34 +0000 | [diff] [blame] | 2442 | return retval; |
Alexandre Julliard | 75a839a | 1993-07-15 11:13:45 +0000 | [diff] [blame] | 2443 | } |
| 2444 | |
| 2445 | |
| 2446 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2447 | * DispatchMessage32 (USER.822) |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 2448 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2449 | LONG WINAPI DispatchMessage32_16( const MSG32_16* lpmsg16_32, BOOL16 wHaveParamHigh ) |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 2450 | { |
| 2451 | if (wHaveParamHigh == FALSE) |
| 2452 | return DispatchMessage16(&(lpmsg16_32->msg)); |
| 2453 | else |
| 2454 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2455 | MSG msg; |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 2456 | |
| 2457 | msg.hwnd = lpmsg16_32->msg.hwnd; |
| 2458 | msg.message = lpmsg16_32->msg.message; |
| 2459 | msg.wParam = MAKELONG(lpmsg16_32->msg.wParam, lpmsg16_32->wParamHigh); |
| 2460 | msg.lParam = lpmsg16_32->msg.lParam; |
| 2461 | msg.time = lpmsg16_32->msg.time; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2462 | msg.pt.x = (INT)lpmsg16_32->msg.pt.x; |
| 2463 | msg.pt.y = (INT)lpmsg16_32->msg.pt.y; |
| 2464 | return DispatchMessageA(&msg); |
Andreas Mohr | 94e4485 | 1999-01-23 14:15:17 +0000 | [diff] [blame] | 2465 | } |
| 2466 | } |
| 2467 | |
| 2468 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2469 | * DispatchMessageA (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2470 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2471 | LONG WINAPI DispatchMessageA( const MSG* msg ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2472 | { |
| 2473 | WND * wndPtr; |
| 2474 | LONG retval; |
| 2475 | int painting; |
| 2476 | |
| 2477 | /* Process timer messages */ |
| 2478 | if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER)) |
| 2479 | { |
| 2480 | if (msg->lParam) |
| 2481 | { |
| 2482 | /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */ |
Stephane Lussier | 6bac4f2 | 2000-09-29 00:56:05 +0000 | [diff] [blame] | 2483 | |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 2484 | /* before calling window proc, verify whether timer is still valid; |
| 2485 | there's a slim chance that the application kills the timer |
| 2486 | between GetMessage and DispatchMessage API calls */ |
Stephane Lussier | 6bac4f2 | 2000-09-29 00:56:05 +0000 | [diff] [blame] | 2487 | if (!TIMER_IsTimerValid(msg->hwnd, (UINT) msg->wParam, (HWINDOWPROC) msg->lParam)) |
| 2488 | return 0; /* invalid winproc */ |
| 2489 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2490 | return CallWindowProcA( (WNDPROC)msg->lParam, msg->hwnd, |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2491 | msg->message, msg->wParam, GetTickCount() ); |
| 2492 | } |
| 2493 | } |
| 2494 | |
| 2495 | if (!msg->hwnd) return 0; |
| 2496 | if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 2497 | if (!wndPtr->winproc) |
| 2498 | { |
| 2499 | retval = 0; |
| 2500 | goto END; |
| 2501 | } |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2502 | painting = (msg->message == WM_PAINT); |
| 2503 | if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT; |
| 2504 | /* HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */ |
| 2505 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2506 | SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message, |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2507 | msg->wParam, msg->lParam ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2508 | retval = CallWindowProcA( (WNDPROC)wndPtr->winproc, |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2509 | msg->hwnd, msg->message, |
| 2510 | msg->wParam, msg->lParam ); |
Guy L. Albertelli | 936c6c4 | 2000-10-22 23:52:47 +0000 | [diff] [blame] | 2511 | SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval, |
| 2512 | msg->wParam, msg->lParam ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2513 | |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 2514 | WIN_ReleaseWndPtr(wndPtr); |
| 2515 | wndPtr = WIN_FindWndPtr(msg->hwnd); |
| 2516 | |
| 2517 | if (painting && wndPtr && |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2518 | (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate) |
| 2519 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2520 | ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n", |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2521 | msg->hwnd); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2522 | wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT; |
| 2523 | /* Validate the update region to avoid infinite WM_PAINT loop */ |
John R . Sheets | 278b3bc | 2000-07-15 21:31:01 +0000 | [diff] [blame] | 2524 | PAINT_RedrawWindow( wndPtr->hwndSelf, NULL, 0, |
| 2525 | RDW_FRAME | RDW_VALIDATE | RDW_NOCHILDREN | RDW_NOINTERNALPAINT, 0 ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2526 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 2527 | END: |
| 2528 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2529 | return retval; |
| 2530 | } |
| 2531 | |
| 2532 | |
| 2533 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2534 | * DispatchMessageW (USER32.@) Process Message |
Alexandre Julliard | 767e6f6 | 1998-08-09 12:47:43 +0000 | [diff] [blame] | 2535 | * |
| 2536 | * Process the message specified in the structure *_msg_. |
| 2537 | * |
| 2538 | * If the lpMsg parameter points to a WM_TIMER message and the |
| 2539 | * parameter of the WM_TIMER message is not NULL, the lParam parameter |
| 2540 | * points to the function that is called instead of the window |
| 2541 | * procedure. |
| 2542 | * |
| 2543 | * The message must be valid. |
| 2544 | * |
| 2545 | * RETURNS |
| 2546 | * |
| 2547 | * DispatchMessage() returns the result of the window procedure invoked. |
| 2548 | * |
| 2549 | * CONFORMANCE |
| 2550 | * |
| 2551 | * ECMA-234, Win32 |
| 2552 | * |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2553 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2554 | LONG WINAPI DispatchMessageW( const MSG* msg ) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2555 | { |
| 2556 | WND * wndPtr; |
| 2557 | LONG retval; |
| 2558 | int painting; |
| 2559 | |
| 2560 | /* Process timer messages */ |
| 2561 | if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER)) |
| 2562 | { |
| 2563 | if (msg->lParam) |
| 2564 | { |
| 2565 | /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */ |
Stephane Lussier | 6bac4f2 | 2000-09-29 00:56:05 +0000 | [diff] [blame] | 2566 | |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 2567 | /* before calling window proc, verify whether timer is still valid; |
| 2568 | there's a slim chance that the application kills the timer |
| 2569 | between GetMessage and DispatchMessage API calls */ |
Stephane Lussier | 6bac4f2 | 2000-09-29 00:56:05 +0000 | [diff] [blame] | 2570 | if (!TIMER_IsTimerValid(msg->hwnd, (UINT) msg->wParam, (HWINDOWPROC) msg->lParam)) |
| 2571 | return 0; /* invalid winproc */ |
| 2572 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2573 | return CallWindowProcW( (WNDPROC)msg->lParam, msg->hwnd, |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2574 | msg->message, msg->wParam, GetTickCount() ); |
| 2575 | } |
| 2576 | } |
| 2577 | |
| 2578 | if (!msg->hwnd) return 0; |
| 2579 | if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 2580 | if (!wndPtr->winproc) |
| 2581 | { |
| 2582 | retval = 0; |
| 2583 | goto END; |
| 2584 | } |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2585 | painting = (msg->message == WM_PAINT); |
| 2586 | if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT; |
| 2587 | /* HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */ |
| 2588 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2589 | SPY_EnterMessage( SPY_DISPATCHMESSAGE, msg->hwnd, msg->message, |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2590 | msg->wParam, msg->lParam ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2591 | retval = CallWindowProcW( (WNDPROC)wndPtr->winproc, |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2592 | msg->hwnd, msg->message, |
| 2593 | msg->wParam, msg->lParam ); |
Guy L. Albertelli | 936c6c4 | 2000-10-22 23:52:47 +0000 | [diff] [blame] | 2594 | SPY_ExitMessage( SPY_RESULT_OK, msg->hwnd, msg->message, retval, |
| 2595 | msg->wParam, msg->lParam ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2596 | |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 2597 | WIN_ReleaseWndPtr(wndPtr); |
| 2598 | wndPtr = WIN_FindWndPtr(msg->hwnd); |
| 2599 | |
| 2600 | if (painting && wndPtr && |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2601 | (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate) |
| 2602 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2603 | ERR("BeginPaint not called on WM_PAINT for hwnd %04x!\n", |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2604 | msg->hwnd); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2605 | wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT; |
| 2606 | /* Validate the update region to avoid infinite WM_PAINT loop */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2607 | ValidateRect( msg->hwnd, NULL ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2608 | } |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 2609 | END: |
| 2610 | WIN_ReleaseWndPtr(wndPtr); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2611 | return retval; |
| 2612 | } |
| 2613 | |
| 2614 | |
| 2615 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2616 | * RegisterWindowMessage (USER.118) |
| 2617 | * RegisterWindowMessageA (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2618 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2619 | WORD WINAPI RegisterWindowMessageA( LPCSTR str ) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 2620 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2621 | TRACE("%s\n", str ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2622 | return GlobalAddAtomA( str ); |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 2623 | } |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2624 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2625 | |
| 2626 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2627 | * RegisterWindowMessageW (USER32.@) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2628 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2629 | WORD WINAPI RegisterWindowMessageW( LPCWSTR str ) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2630 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2631 | TRACE("%p\n", str ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2632 | return GlobalAddAtomW( str ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 2633 | } |
| 2634 | |
| 2635 | |
Alexandre Julliard | 86a8d0f | 1994-01-18 23:04:40 +0000 | [diff] [blame] | 2636 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2637 | * GetCurrentTime (USER.15) |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 2638 | * |
| 2639 | * (effectively identical to GetTickCount) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 2640 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2641 | DWORD WINAPI GetCurrentTime16(void) |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 2642 | { |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 2643 | return GetTickCount(); |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 2644 | } |
| 2645 | |
Alexandre Julliard | b817f4f | 1996-03-14 18:08:34 +0000 | [diff] [blame] | 2646 | |
Alexandre Julliard | ade697e | 1995-11-26 13:59:11 +0000 | [diff] [blame] | 2647 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2648 | * InSendMessage (USER.192) |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 2649 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2650 | BOOL16 WINAPI InSendMessage16(void) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2651 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2652 | return InSendMessage(); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2653 | } |
| 2654 | |
| 2655 | |
| 2656 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2657 | * InSendMessage (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 2658 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2659 | BOOL WINAPI InSendMessage(void) |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 2660 | { |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 2661 | MESSAGEQUEUE *queue; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2662 | BOOL ret; |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 2663 | |
Ulrich Weigand | 52e891d | 2001-01-29 00:33:35 +0000 | [diff] [blame] | 2664 | if (!(queue = QUEUE_Lock( GetFastQueue16() ))) |
Alexandre Julliard | ef702d8 | 1996-05-28 18:54:58 +0000 | [diff] [blame] | 2665 | return 0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2666 | ret = (BOOL)queue->smWaiting; |
Stephane Lussier | 1c4786f | 1999-01-28 10:54:11 +0000 | [diff] [blame] | 2667 | |
| 2668 | QUEUE_Unlock( queue ); |
| 2669 | return ret; |
Alexandre Julliard | e2abbb1 | 1995-03-19 17:39:39 +0000 | [diff] [blame] | 2670 | } |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 2671 | |
| 2672 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2673 | * BroadcastSystemMessage (USER32.@) |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 2674 | */ |
| 2675 | LONG WINAPI BroadcastSystemMessage( |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2676 | DWORD dwFlags,LPDWORD recipients,UINT uMessage,WPARAM wParam, |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 2677 | LPARAM lParam |
| 2678 | ) { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 2679 | FIXME_(sendmsg)("(%08lx,%08lx,%08x,%08x,%08lx): stub!\n", |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2680 | dwFlags,*recipients,uMessage,wParam,lParam |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 2681 | ); |
| 2682 | return 0; |
| 2683 | } |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 2684 | |
| 2685 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2686 | * SendNotifyMessageA (USER32.@) |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 2687 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2688 | BOOL WINAPI SendNotifyMessageA(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 2689 | { |
| 2690 | return MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE, |
| 2691 | SMSG_WIN32, NULL); |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 2692 | } |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 2693 | |
| 2694 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2695 | * SendNotifyMessageW (USER32.@) |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 2696 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2697 | BOOL WINAPI SendNotifyMessageW(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) |
Ove Kaaven | 9811129 | 2000-11-25 01:23:50 +0000 | [diff] [blame] | 2698 | { |
| 2699 | return MSG_SendMessage(hwnd, msg, wParam, lParam, INFINITE, |
| 2700 | SMSG_WIN32 | SMSG_UNICODE, NULL); |
Alexandre Julliard | 0c0e3be | 1998-12-10 15:49:22 +0000 | [diff] [blame] | 2701 | } |
| 2702 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2703 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2704 | * SendMessageCallbackA (USER32.@) |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2705 | * FIXME: It's like PostMessage. The callback gets called when the message |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 2706 | * is processed. We have to modify the message processing for an exact |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2707 | * implementation... |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 2708 | * The callback is only called when the thread that called us calls one of |
| 2709 | * Get/Peek/WaitMessage. |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2710 | */ |
Juergen Schmied | 13f1b12 | 1999-05-02 09:17:48 +0000 | [diff] [blame] | 2711 | BOOL WINAPI SendMessageCallbackA( |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2712 | HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam, |
| 2713 | FARPROC lpResultCallBack,DWORD dwData) |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2714 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2715 | FIXME("(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n", |
| 2716 | hWnd,Msg,wParam,lParam,lpResultCallBack,dwData); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2717 | if ( hWnd == HWND_BROADCAST) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2718 | { PostMessageA( hWnd, Msg, wParam, lParam); |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2719 | FIXME("Broadcast: Callback will not be called!\n"); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2720 | return TRUE; |
| 2721 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2722 | (lpResultCallBack)( hWnd, Msg, dwData, SendMessageA ( hWnd, Msg, wParam, lParam )); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2723 | return TRUE; |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2724 | } |
Juergen Schmied | 13f1b12 | 1999-05-02 09:17:48 +0000 | [diff] [blame] | 2725 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2726 | * SendMessageCallbackW (USER32.@) |
Andreas Mohr | 1af53cb | 2000-12-09 03:15:32 +0000 | [diff] [blame] | 2727 | * FIXME: see SendMessageCallbackA. |
Juergen Schmied | 13f1b12 | 1999-05-02 09:17:48 +0000 | [diff] [blame] | 2728 | */ |
| 2729 | BOOL WINAPI SendMessageCallbackW( |
| 2730 | HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam, |
| 2731 | FARPROC lpResultCallBack,DWORD dwData) |
| 2732 | { |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2733 | FIXME("(0x%04x,0x%04x,0x%08x,0x%08lx,%p,0x%08lx),stub!\n", |
| 2734 | hWnd,Msg,wParam,lParam,lpResultCallBack,dwData); |
Juergen Schmied | 13f1b12 | 1999-05-02 09:17:48 +0000 | [diff] [blame] | 2735 | if ( hWnd == HWND_BROADCAST) |
| 2736 | { PostMessageW( hWnd, Msg, wParam, lParam); |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 2737 | FIXME("Broadcast: Callback will not be called!\n"); |
Juergen Schmied | 13f1b12 | 1999-05-02 09:17:48 +0000 | [diff] [blame] | 2738 | return TRUE; |
| 2739 | } |
| 2740 | (lpResultCallBack)( hWnd, Msg, dwData, SendMessageA ( hWnd, Msg, wParam, lParam )); |
| 2741 | return TRUE; |
| 2742 | } |