1 | /* $Id: oslibmsgtranslate.cpp,v 1.89 2002-06-18 09:32:26 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Window message translation functions for OS/2
|
---|
4 | *
|
---|
5 | *
|
---|
6 | * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
7 | * Copyright 1999 Daniela Engert (dani@ngrt.de)
|
---|
8 | * Copyright 1999 Rene Pronk (R.Pronk@twi.tudelft.nl)
|
---|
9 | *
|
---|
10 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
11 | *
|
---|
12 | * TODO: Extra msgs: which messages must be put into the queue and which can be sent directly?
|
---|
13 | * (According to the docs TranslateMessage really inserts a msg in the queue)
|
---|
14 | * TODO: Filter translation isn't correct for posted messages
|
---|
15 | *
|
---|
16 | */
|
---|
17 | #define INCL_WIN
|
---|
18 | #define INCL_PM
|
---|
19 | #define INCL_DOSPROCESS
|
---|
20 | #include <os2wrap.h>
|
---|
21 | #include <string.h>
|
---|
22 | #include <misc.h>
|
---|
23 | #include <winconst.h>
|
---|
24 | #include <win32api.h>
|
---|
25 | #include "oslibmsg.h"
|
---|
26 | #include <winuser32.h>
|
---|
27 | #include "win32wdesktop.h"
|
---|
28 | #include "oslibutil.h"
|
---|
29 | #include "timer.h"
|
---|
30 | #include <thread.h>
|
---|
31 | #include <wprocess.h>
|
---|
32 | #include "pmwindow.h"
|
---|
33 | #include "oslibwin.h"
|
---|
34 | #include "winmouse.h"
|
---|
35 | #include <pmkbdhk.h>
|
---|
36 | #include <pmscan.h>
|
---|
37 | #include <winscan.h>
|
---|
38 | #include <winkeyboard.h>
|
---|
39 | #include "hook.h"
|
---|
40 |
|
---|
41 | #define DBG_LOCALLOG DBG_oslibmsgtranslate
|
---|
42 | #include "dbglocal.h"
|
---|
43 |
|
---|
44 | static BOOL fGenerateDoubleClick = FALSE;
|
---|
45 | static MSG doubleClickMsg = {0};
|
---|
46 |
|
---|
47 | //******************************************************************************
|
---|
48 | //******************************************************************************
|
---|
49 | BOOL setThreadQueueExtraCharMessage(TEB* teb, MSG* pExtraMsg)
|
---|
50 | {
|
---|
51 | // check if the single slot is occupied already
|
---|
52 | if (teb->o.odin.fTranslated == TRUE)
|
---|
53 | // there's still an already translated message to be processed
|
---|
54 | return FALSE;
|
---|
55 | teb->o.odin.fTranslated = TRUE;
|
---|
56 | memcpy(&teb->o.odin.msgWCHAR, pExtraMsg, sizeof(MSG));
|
---|
57 | return TRUE;
|
---|
58 | }
|
---|
59 |
|
---|
60 | //******************************************************************************
|
---|
61 | //******************************************************************************
|
---|
62 | ULONG GetMouseKeyState()
|
---|
63 | {
|
---|
64 | ULONG keystate = 0;
|
---|
65 |
|
---|
66 | if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000)
|
---|
67 | keystate |= MK_LBUTTON_W;
|
---|
68 | if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000)
|
---|
69 | keystate |= MK_RBUTTON_W;
|
---|
70 | if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000)
|
---|
71 | keystate |= MK_MBUTTON_W;
|
---|
72 | if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
|
---|
73 | keystate |= MK_SHIFT_W;
|
---|
74 | if(WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
|
---|
75 | keystate |= MK_CONTROL_W;
|
---|
76 |
|
---|
77 | return keystate;
|
---|
78 | }
|
---|
79 | //******************************************************************************
|
---|
80 | //******************************************************************************
|
---|
81 | LONG IsNCMouseMsg(Win32BaseWindow *win32wnd)
|
---|
82 | {
|
---|
83 | return ((win32wnd->getLastHitTestVal() != HTCLIENT_W) && (WinQueryCapture(HWND_DESKTOP) != win32wnd->getOS2WindowHandle()));
|
---|
84 | }
|
---|
85 | //******************************************************************************
|
---|
86 | //******************************************************************************
|
---|
87 | void SetMenuDoubleClick(BOOL fSet)
|
---|
88 | {
|
---|
89 | fGenerateDoubleClick = fSet;
|
---|
90 | }
|
---|
91 | //******************************************************************************
|
---|
92 | //******************************************************************************
|
---|
93 | BOOL OS2ToWinMsgTranslate(void *pTeb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fMsgRemoved)
|
---|
94 | {
|
---|
95 | Win32BaseWindow *win32wnd = 0;
|
---|
96 | OSLIBPOINT point, ClientPoint;
|
---|
97 | POSTMSG_PACKET *packet;
|
---|
98 | TEB *teb = (TEB *)pTeb;
|
---|
99 | BOOL fWasDisabled = FALSE;
|
---|
100 | BOOL fIsFrame = FALSE;
|
---|
101 | int i;
|
---|
102 |
|
---|
103 | memset(winMsg, 0, sizeof(MSG));
|
---|
104 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(os2Msg->hwnd);
|
---|
105 | if(!win32wnd) {
|
---|
106 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(os2Msg->hwnd);
|
---|
107 | if(win32wnd) {
|
---|
108 | fIsFrame = TRUE;
|
---|
109 | }
|
---|
110 | }
|
---|
111 |
|
---|
112 | //PostThreadMessage posts WIN32APP_POSTMSG msg without window handle
|
---|
113 | //Realplayer starts a timer with hwnd 0 & proc 0; check this here
|
---|
114 | if(win32wnd == 0 && (os2Msg->msg != WM_CREATE && os2Msg->msg != WM_QUIT && os2Msg->msg != WM_TIMER && os2Msg->msg < WIN32APP_POSTMSG))
|
---|
115 | {
|
---|
116 | goto dummymessage; //not a win32 client window
|
---|
117 | }
|
---|
118 | winMsg->time = os2Msg->time;
|
---|
119 | //CB: PM bug or undocumented feature? ptl.x highword is set!
|
---|
120 | winMsg->pt.x = os2Msg->ptl.x & 0xFFFF;
|
---|
121 | winMsg->pt.y = mapScreenY(os2Msg->ptl.y);
|
---|
122 |
|
---|
123 | if(win32wnd) //==0 for WM_CREATE/WM_QUIT
|
---|
124 | winMsg->hwnd = win32wnd->getWindowHandle();
|
---|
125 |
|
---|
126 | if(os2Msg->msg >= WIN32APP_POSTMSG) {
|
---|
127 | packet = (POSTMSG_PACKET *)os2Msg->mp2;
|
---|
128 | if(packet && ((ULONG)os2Msg->mp1 == WIN32MSG_MAGICA || (ULONG)os2Msg->mp1 == WIN32MSG_MAGICW)) {
|
---|
129 | winMsg->message = os2Msg->msg - WIN32APP_POSTMSG;
|
---|
130 | winMsg->wParam = packet->wParam;
|
---|
131 | winMsg->lParam = packet->lParam;
|
---|
132 | if(fMsgRemoved == MSG_REMOVE) free(packet); //free the shared memory here
|
---|
133 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
134 | return TRUE;
|
---|
135 | }
|
---|
136 | else {//broadcasted message (no packet present)
|
---|
137 | winMsg->message = os2Msg->msg - WIN32APP_POSTMSG;
|
---|
138 | winMsg->wParam = (UINT)os2Msg->mp1;
|
---|
139 | winMsg->lParam = (DWORD)os2Msg->mp2;
|
---|
140 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
141 | return TRUE;
|
---|
142 | }
|
---|
143 | goto dummymessage;
|
---|
144 | }
|
---|
145 |
|
---|
146 | switch(os2Msg->msg)
|
---|
147 | {
|
---|
148 | //OS/2 msgs
|
---|
149 | case WM_CREATE:
|
---|
150 | {
|
---|
151 | if(teb->o.odin.newWindow == 0) {
|
---|
152 | DebugInt3();
|
---|
153 | goto dummymessage;
|
---|
154 | }
|
---|
155 |
|
---|
156 | win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
|
---|
157 | win32wnd->addRef();
|
---|
158 |
|
---|
159 | winMsg->message = WINWM_CREATE;
|
---|
160 | winMsg->hwnd = win32wnd->getWindowHandle();
|
---|
161 | winMsg->wParam = 0;
|
---|
162 | winMsg->lParam = (LPARAM)win32wnd->tmpcs;
|
---|
163 | break;
|
---|
164 | }
|
---|
165 |
|
---|
166 | case WM_QUIT:
|
---|
167 | winMsg->message = WINWM_QUIT;
|
---|
168 | if (fMsgRemoved && win32wnd && (ULONG)os2Msg->mp2 != 0) {
|
---|
169 | // mp2 != 0 -> sent by window list; be nice and close
|
---|
170 | // the window first
|
---|
171 | win32wnd->MsgClose();
|
---|
172 | }
|
---|
173 | break;
|
---|
174 |
|
---|
175 | case WM_CLOSE:
|
---|
176 | winMsg->message = WINWM_CLOSE;
|
---|
177 | break;
|
---|
178 |
|
---|
179 | case WM_DESTROY:
|
---|
180 | winMsg->message = WINWM_DESTROY;
|
---|
181 | break;
|
---|
182 |
|
---|
183 | case WM_ENABLE:
|
---|
184 | winMsg->message = WINWM_ENABLE;
|
---|
185 | winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
|
---|
186 | break;
|
---|
187 |
|
---|
188 | case WM_SHOW:
|
---|
189 | winMsg->message = WINWM_SHOWWINDOW;
|
---|
190 | winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
|
---|
191 | break;
|
---|
192 |
|
---|
193 | case WM_WINDOWPOSCHANGED:
|
---|
194 | {
|
---|
195 | PSWP pswp = (PSWP)os2Msg->mp1;
|
---|
196 | SWP swpOld = *(pswp + 1);
|
---|
197 | HWND hParent = NULLHANDLE;
|
---|
198 | LONG yDelta = pswp->cy - swpOld.cy;
|
---|
199 | LONG xDelta = pswp->cx - swpOld.cx;
|
---|
200 |
|
---|
201 | if(!fIsFrame) goto dummymessage;
|
---|
202 |
|
---|
203 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) goto dummymessage;
|
---|
204 |
|
---|
205 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
---|
206 | if (win32wnd->isChild()) {
|
---|
207 | if(win32wnd->getParent()) {
|
---|
208 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
---|
209 | }
|
---|
210 | else goto dummymessage; //parent has just been destroyed
|
---|
211 | }
|
---|
212 | }
|
---|
213 | if(win32wnd->getParent()) {
|
---|
214 | OSLibMapSWPtoWINDOWPOS(pswp, &teb->o.odin.wp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
---|
215 | win32wnd->getOS2WindowHandle());
|
---|
216 | }
|
---|
217 | else OSLibMapSWPtoWINDOWPOS(pswp, &teb->o.odin.wp, &swpOld, OSLibQueryScreenHeight(), win32wnd->getOS2WindowHandle());
|
---|
218 |
|
---|
219 | if (!win32wnd->CanReceiveSizeMsgs()) goto dummymessage;
|
---|
220 |
|
---|
221 | if(pswp->fl & (SWP_MOVE | SWP_SIZE))
|
---|
222 | {
|
---|
223 | teb->o.odin.wp.hwnd = win32wnd->getWindowHandle();
|
---|
224 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
---|
225 | {
|
---|
226 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
---|
227 | if(wndAfter) {
|
---|
228 | teb->o.odin.wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
---|
229 | RELEASE_WNDOBJ(wndAfter);
|
---|
230 | }
|
---|
231 | else teb->o.odin.wp.hwndInsertAfter = HWND_TOP_W;
|
---|
232 | }
|
---|
233 | }
|
---|
234 | winMsg->message = WINWM_WINDOWPOSCHANGED;
|
---|
235 | winMsg->lParam = (LPARAM)&teb->o.odin.wp;
|
---|
236 | break;
|
---|
237 | }
|
---|
238 |
|
---|
239 | case WM_ACTIVATE:
|
---|
240 | {
|
---|
241 | HWND hwndActivate = (HWND)os2Msg->mp2;
|
---|
242 | BOOL fMinimized = FALSE;
|
---|
243 |
|
---|
244 | hwndActivate = OS2ToWin32Handle(hwndActivate);
|
---|
245 | if(hwndActivate == 0) {
|
---|
246 | //another (non-win32) application's window
|
---|
247 | //set to desktop window handle
|
---|
248 | hwndActivate = windowDesktop->getWindowHandle();
|
---|
249 | }
|
---|
250 |
|
---|
251 | if(win32wnd->getStyle() & WS_MINIMIZE_W)
|
---|
252 | {
|
---|
253 | fMinimized = TRUE;
|
---|
254 | }
|
---|
255 |
|
---|
256 | winMsg->message = WINWM_ACTIVATE;
|
---|
257 | winMsg->wParam = MAKELONG((SHORT1FROMMP(os2Msg->mp1)) ? WA_ACTIVE_W : WA_INACTIVE_W, fMinimized);
|
---|
258 | winMsg->lParam = (LPARAM)hwndActivate;
|
---|
259 | break;
|
---|
260 | }
|
---|
261 |
|
---|
262 | case WM_SETFOCUS:
|
---|
263 | {
|
---|
264 | HWND hwndFocus = (HWND)os2Msg->mp1;
|
---|
265 |
|
---|
266 | if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
|
---|
267 | //another (non-win32) application's window
|
---|
268 | //set to NULL (allowed according to win32 SDK) to avoid problems
|
---|
269 | hwndFocus = NULL;
|
---|
270 | }
|
---|
271 | else hwndFocus = OS2ToWin32Handle(hwndFocus);
|
---|
272 |
|
---|
273 | if((ULONG)os2Msg->mp2 == TRUE) {
|
---|
274 | winMsg->message = WINWM_SETFOCUS;
|
---|
275 | winMsg->wParam = (WPARAM)hwndFocus;
|
---|
276 | }
|
---|
277 | else {
|
---|
278 | winMsg->message = WINWM_KILLFOCUS;
|
---|
279 | winMsg->wParam = (WPARAM)hwndFocus;
|
---|
280 | }
|
---|
281 | break;
|
---|
282 | }
|
---|
283 |
|
---|
284 | //**************************************************************************
|
---|
285 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
---|
286 | //**************************************************************************
|
---|
287 | case WM_BUTTON1DOWN:
|
---|
288 | case WM_BUTTON1UP:
|
---|
289 | case WM_BUTTON1DBLCLK:
|
---|
290 | case WM_BUTTON2DOWN:
|
---|
291 | case WM_BUTTON2UP:
|
---|
292 | case WM_BUTTON2DBLCLK:
|
---|
293 | case WM_BUTTON3DOWN:
|
---|
294 | case WM_BUTTON3UP:
|
---|
295 | case WM_BUTTON3DBLCLK:
|
---|
296 | {
|
---|
297 | //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
|
---|
298 |
|
---|
299 | dprintf(("MsgButton %x (%x) %d at (%d,%d) time %x", winMsg->hwnd, os2Msg->hwnd, WINWM_NCLBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN), winMsg->pt.x, winMsg->pt.y, winMsg->time));
|
---|
300 |
|
---|
301 | HWND hwnd;
|
---|
302 |
|
---|
303 | DisableLogging();
|
---|
304 | if(GetCapture() != winMsg->hwnd)
|
---|
305 | {
|
---|
306 | hwnd = WindowFromPoint(winMsg->pt);
|
---|
307 | if(win32wnd->getWindowHandle() != hwnd) {
|
---|
308 | RELEASE_WNDOBJ(win32wnd);
|
---|
309 | win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
310 | if(win32wnd == NULL) {
|
---|
311 | DebugInt3();
|
---|
312 | EnableLogging();
|
---|
313 | goto dummymessage;
|
---|
314 | }
|
---|
315 | winMsg->hwnd = hwnd;
|
---|
316 | }
|
---|
317 | }
|
---|
318 |
|
---|
319 | //if a window is disabled, it's parent receives the mouse messages
|
---|
320 | if(!IsWindowEnabled(win32wnd->getWindowHandle())) {
|
---|
321 | if(win32wnd->getParent()) {
|
---|
322 | Win32BaseWindow *parent = win32wnd->getParent();;
|
---|
323 | if(parent) parent->addRef();
|
---|
324 | RELEASE_WNDOBJ(win32wnd);
|
---|
325 | win32wnd = parent;
|
---|
326 | }
|
---|
327 | fWasDisabled = TRUE;
|
---|
328 | }
|
---|
329 |
|
---|
330 | if(IsNCMouseMsg(win32wnd)) {
|
---|
331 | winMsg->message = WINWM_NCLBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
|
---|
332 | winMsg->wParam = win32wnd->getLastHitTestVal();
|
---|
333 | winMsg->lParam = MAKELONG(winMsg->pt.x, winMsg->pt.y); //screen coordinates
|
---|
334 | }
|
---|
335 | else {
|
---|
336 | ClientPoint.x = winMsg->pt.x;
|
---|
337 | ClientPoint.y = winMsg->pt.y;
|
---|
338 | MapWindowPoints(0, win32wnd->getWindowHandle(), (LPPOINT)&ClientPoint, 1);
|
---|
339 | winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
|
---|
340 | winMsg->wParam = GetMouseKeyState();
|
---|
341 | winMsg->lParam = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
|
---|
342 | }
|
---|
343 | EnableLogging();
|
---|
344 |
|
---|
345 | if(fWasDisabled) {
|
---|
346 | if(win32wnd) {
|
---|
347 | winMsg->hwnd = win32wnd->getWindowHandle();
|
---|
348 | }
|
---|
349 | else goto dummymessage; //don't send mouse messages to disabled windows
|
---|
350 | }
|
---|
351 |
|
---|
352 | DisableLogging();
|
---|
353 | if ((winMsg->message == WINWM_LBUTTONDOWN) ||
|
---|
354 | (winMsg->message == WINWM_RBUTTONDOWN) ||
|
---|
355 | (winMsg->message == WINWM_MBUTTONDOWN) ||
|
---|
356 | (winMsg->message == WINWM_NCLBUTTONDOWN) ||
|
---|
357 | (winMsg->message == WINWM_NCRBUTTONDOWN) ||
|
---|
358 | (winMsg->message == WINWM_NCMBUTTONDOWN))
|
---|
359 | {
|
---|
360 | if(fGenerateDoubleClick && doubleClickMsg.message == winMsg->message &&
|
---|
361 | winMsg->time - doubleClickMsg.time < GetDoubleClickTime() &&
|
---|
362 | (abs(winMsg->pt.x - doubleClickMsg.pt.x) < GetSystemMetrics(SM_CXDOUBLECLK_W)/2) &&
|
---|
363 | (abs(winMsg->pt.y - doubleClickMsg.pt.y) < GetSystemMetrics(SM_CYDOUBLECLK_W)/2))
|
---|
364 | {
|
---|
365 | dprintf(("single -> double click"));
|
---|
366 | if(winMsg->message >= WINWM_LBUTTONDOWN) {
|
---|
367 | winMsg->message += (WINWM_LBUTTONDBLCLK - WINWM_LBUTTONDOWN);
|
---|
368 | }
|
---|
369 | else winMsg->message += (WINWM_LBUTTONDBLCLK - WINWM_NCLBUTTONDOWN);
|
---|
370 | doubleClickMsg.message = 0;
|
---|
371 | }
|
---|
372 | else {
|
---|
373 | dprintf(("save for double click"));
|
---|
374 | doubleClickMsg = *winMsg;
|
---|
375 | if(doubleClickMsg.message >= WINWM_NCLBUTTONDOWN && doubleClickMsg.message <= WINWM_NCMBUTTONDOWN) {
|
---|
376 | doubleClickMsg.message += (WINWM_LBUTTONDOWN - WINWM_NCLBUTTONDOWN);
|
---|
377 | }
|
---|
378 | }
|
---|
379 | }
|
---|
380 | EnableLogging();
|
---|
381 |
|
---|
382 | if(fMsgRemoved == MSG_REMOVE)
|
---|
383 | {
|
---|
384 | MSLLHOOKSTRUCT hook;
|
---|
385 | ULONG msg;
|
---|
386 |
|
---|
387 | if(winMsg->message >= WINWM_NCLBUTTONDOWN && winMsg->message <= WINWM_NCMBUTTONDBLCLK) {
|
---|
388 | msg = winMsg->message - WINWM_NCLBUTTONDOWN + WINWM_LBUTTONDOWN;
|
---|
389 | }
|
---|
390 | else msg = winMsg->message;
|
---|
391 |
|
---|
392 | if(msg == WINWM_LBUTTONDBLCLK) {
|
---|
393 | msg = WINWM_LBUTTONDOWN;
|
---|
394 | }
|
---|
395 | else
|
---|
396 | if(msg == WINWM_RBUTTONDBLCLK) {
|
---|
397 | msg = WINWM_RBUTTONDOWN;
|
---|
398 | }
|
---|
399 | else
|
---|
400 | if(msg == WINWM_MBUTTONDBLCLK) {
|
---|
401 | msg = WINWM_MBUTTONDOWN;
|
---|
402 | }
|
---|
403 |
|
---|
404 | hook.pt.x = os2Msg->ptl.x & 0xFFFF;
|
---|
405 | hook.pt.y = mapScreenY(os2Msg->ptl.y);
|
---|
406 | hook.mouseData = 0; //todo: XBUTTON1/2 (XP feature) or wheel data
|
---|
407 | hook.flags = 0; //todo: injected (LLMHF_INJECTED)
|
---|
408 | hook.time = winMsg->time;
|
---|
409 | hook.dwExtraInfo = 0;
|
---|
410 |
|
---|
411 | if(HOOK_CallHooksW( WH_MOUSE_LL, HC_ACTION, msg, (LPARAM)&hook)) {
|
---|
412 | goto dummymessage; //hook swallowed message
|
---|
413 | }
|
---|
414 | }
|
---|
415 | break;
|
---|
416 | }
|
---|
417 |
|
---|
418 | case WM_BUTTON2CLICK:
|
---|
419 | case WM_BUTTON1CLICK:
|
---|
420 | case WM_BUTTON3CLICK:
|
---|
421 | goto dummymessage;
|
---|
422 |
|
---|
423 | case WM_BUTTON2MOTIONSTART:
|
---|
424 | case WM_BUTTON2MOTIONEND:
|
---|
425 | case WM_BUTTON1MOTIONSTART:
|
---|
426 | case WM_BUTTON1MOTIONEND:
|
---|
427 | case WM_BUTTON3MOTIONSTART:
|
---|
428 | case WM_BUTTON3MOTIONEND:
|
---|
429 | //no break; translate to WM_MOUSEMOVE
|
---|
430 | //Some applications (e.g. Unreal) retrieve all mouse messages
|
---|
431 | //when a mouse button is pressed and don't expect WM_NULL
|
---|
432 |
|
---|
433 | case WM_MOUSEMOVE:
|
---|
434 | {
|
---|
435 | //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
|
---|
436 |
|
---|
437 | HWND hwnd;
|
---|
438 |
|
---|
439 | dprintf2(("WM_MOUSEMOVE (%d,%d)", winMsg->pt.x, winMsg->pt.y));
|
---|
440 | DisableLogging();
|
---|
441 | if(GetCapture() != winMsg->hwnd)
|
---|
442 | {
|
---|
443 | hwnd = WindowFromPoint(winMsg->pt);
|
---|
444 | if(win32wnd->getWindowHandle() != hwnd) {
|
---|
445 | RELEASE_WNDOBJ(win32wnd);
|
---|
446 | win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
447 | if(win32wnd == NULL) {
|
---|
448 | DebugInt3();
|
---|
449 | EnableLogging();
|
---|
450 | goto dummymessage;
|
---|
451 | }
|
---|
452 | winMsg->hwnd = hwnd;
|
---|
453 | }
|
---|
454 | }
|
---|
455 |
|
---|
456 | //if a window is disabled, it's parent receives the mouse messages
|
---|
457 | if(!IsWindowEnabled(win32wnd->getWindowHandle())) {
|
---|
458 | if(win32wnd->getParent()) {
|
---|
459 | Win32BaseWindow *parent = win32wnd->getParent();;
|
---|
460 | if(parent) parent->addRef();
|
---|
461 | RELEASE_WNDOBJ(win32wnd);
|
---|
462 | win32wnd = parent;
|
---|
463 | }
|
---|
464 | fWasDisabled = TRUE;
|
---|
465 | }
|
---|
466 | if(IsNCMouseMsg(win32wnd))
|
---|
467 | {
|
---|
468 | winMsg->message = WINWM_NCMOUSEMOVE;
|
---|
469 | winMsg->wParam = (WPARAM)win32wnd->getLastHitTestVal();
|
---|
470 | winMsg->lParam = MAKELONG(winMsg->pt.x,winMsg->pt.y);
|
---|
471 | }
|
---|
472 | else
|
---|
473 | {
|
---|
474 | ClientPoint.x = winMsg->pt.x;
|
---|
475 | ClientPoint.y = winMsg->pt.y;
|
---|
476 | MapWindowPoints(0, win32wnd->getWindowHandle(), (LPPOINT)&ClientPoint, 1);
|
---|
477 |
|
---|
478 | winMsg->message = WINWM_MOUSEMOVE;
|
---|
479 | winMsg->wParam = GetMouseKeyState();
|
---|
480 | winMsg->lParam = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
|
---|
481 | }
|
---|
482 | EnableLogging();
|
---|
483 | if(fWasDisabled) {
|
---|
484 | if(win32wnd) {
|
---|
485 | winMsg->hwnd = win32wnd->getWindowHandle();
|
---|
486 | }
|
---|
487 | else {
|
---|
488 | goto dummymessage; //don't send mouse messages to disabled windows
|
---|
489 | }
|
---|
490 | }
|
---|
491 | if(fMsgRemoved == MSG_REMOVE)
|
---|
492 | {
|
---|
493 | MSLLHOOKSTRUCT hook;
|
---|
494 |
|
---|
495 | hook.pt.x = os2Msg->ptl.x & 0xFFFF;
|
---|
496 | hook.pt.y = mapScreenY(os2Msg->ptl.y);
|
---|
497 | hook.mouseData = 0;
|
---|
498 | hook.flags = 0; //todo: injected (LLMHF_INJECTED)
|
---|
499 | hook.time = winMsg->time;
|
---|
500 | hook.dwExtraInfo = 0;
|
---|
501 |
|
---|
502 | if(HOOK_CallHooksW( WH_MOUSE_LL, HC_ACTION, winMsg->message, (LPARAM)&hook)) {
|
---|
503 | goto dummymessage; //hook swallowed message
|
---|
504 | }
|
---|
505 | }
|
---|
506 | break;
|
---|
507 | }
|
---|
508 |
|
---|
509 | case WM_CONTROL:
|
---|
510 | goto dummymessage;
|
---|
511 |
|
---|
512 | case WM_COMMAND:
|
---|
513 | if(SHORT1FROMMP(os2Msg->mp2) == CMDSRC_MENU) {
|
---|
514 | winMsg->message = WINWM_COMMAND;
|
---|
515 | winMsg->wParam = (WPARAM)SHORT1FROMMP(os2Msg->mp1); //id
|
---|
516 | break;
|
---|
517 | }
|
---|
518 | //todo controls
|
---|
519 | goto dummymessage;
|
---|
520 |
|
---|
521 | case WM_SYSCOMMAND:
|
---|
522 | {
|
---|
523 | ULONG x = 0, y = 0;
|
---|
524 | ULONG win32sc;
|
---|
525 |
|
---|
526 | if(SHORT2FROMMP(os2Msg->mp2) == TRUE) {//syscommand caused by mouse action
|
---|
527 | POINTL pointl;
|
---|
528 | WinQueryPointerPos(HWND_DESKTOP, &pointl);
|
---|
529 | x = pointl.x;
|
---|
530 | y = mapScreenY(y);
|
---|
531 | }
|
---|
532 | switch(SHORT1FROMMP(os2Msg->mp1)) {
|
---|
533 | case SC_MOVE:
|
---|
534 | win32sc = SC_MOVE_W;
|
---|
535 | break;
|
---|
536 | case SC_CLOSE:
|
---|
537 | {
|
---|
538 | //FALSE -> keyboard operation = user pressed Alt-F4 -> close app
|
---|
539 | //TRUE -> user clicked on close button -> close window
|
---|
540 | if(SHORT2FROMMP(os2Msg->mp2) == FALSE)
|
---|
541 | {
|
---|
542 | HWND hwnd = win32wnd->GetTopParent();
|
---|
543 | if(win32wnd->getWindowHandle() != hwnd) {
|
---|
544 | RELEASE_WNDOBJ(win32wnd);
|
---|
545 | win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
546 | if(win32wnd == NULL) {
|
---|
547 | DebugInt3();
|
---|
548 | goto dummymessage;
|
---|
549 | }
|
---|
550 | winMsg->hwnd = hwnd;
|
---|
551 | }
|
---|
552 | }
|
---|
553 | win32sc = SC_CLOSE_W;
|
---|
554 | break;
|
---|
555 | }
|
---|
556 | case SC_MAXIMIZE:
|
---|
557 | win32sc = SC_MAXIMIZE_W;
|
---|
558 | break;
|
---|
559 | case SC_MINIMIZE:
|
---|
560 | win32sc = SC_MINIMIZE_W;
|
---|
561 | break;
|
---|
562 | case SC_NEXTFRAME:
|
---|
563 | case SC_NEXTWINDOW:
|
---|
564 | win32sc = SC_NEXTWINDOW_W;
|
---|
565 | break;
|
---|
566 | case SC_RESTORE:
|
---|
567 | win32sc = SC_RESTORE_W;
|
---|
568 | break;
|
---|
569 | case SC_TASKMANAGER:
|
---|
570 | win32sc = SC_TASKLIST_W;
|
---|
571 | break;
|
---|
572 | default:
|
---|
573 | dprintf(("Unknown/unsupported SC command %d", SHORT1FROMMP(os2Msg->mp1)));
|
---|
574 | goto dummymessage;
|
---|
575 | }
|
---|
576 | winMsg->message= WINWM_SYSCOMMAND;
|
---|
577 | winMsg->wParam = (WPARAM)win32sc;
|
---|
578 | winMsg->lParam = MAKELONG((USHORT)x, (USHORT)y);
|
---|
579 | break;
|
---|
580 | }
|
---|
581 |
|
---|
582 | case WM_CHAR_SPECIAL:
|
---|
583 | {
|
---|
584 | // @@@PH
|
---|
585 | // special char message from the keyboard hook
|
---|
586 | dprintf(("PM: WM_CHAR_SPECIAL\n"));
|
---|
587 |
|
---|
588 | // NO BREAK! FALLTHRU CASE!
|
---|
589 | }
|
---|
590 |
|
---|
591 | case WM_CHAR:
|
---|
592 | {
|
---|
593 | ULONG repeatCount=0;
|
---|
594 | ULONG virtualKey=0;
|
---|
595 | ULONG keyFlags=0;
|
---|
596 | USHORT scanCode=0;
|
---|
597 | ULONG flags = SHORT1FROMMP(os2Msg->mp1);
|
---|
598 | BOOL keyWasPressed;
|
---|
599 | char c;
|
---|
600 | USHORT usPMScanCode = CHAR4FROMMP(os2Msg->mp1);
|
---|
601 |
|
---|
602 | teb->o.odin.fTranslated = FALSE;
|
---|
603 | repeatCount = CHAR3FROMMP(os2Msg->mp1);
|
---|
604 | scanCode = CHAR4FROMMP(os2Msg->mp1);
|
---|
605 | keyWasPressed = ((SHORT1FROMMP (os2Msg->mp1) & KC_PREVDOWN) == KC_PREVDOWN);
|
---|
606 |
|
---|
607 | dprintf(("PM: WM_CHAR: %x %x rep=%d scancode=%x", SHORT1FROMMP(os2Msg->mp2), SHORT2FROMMP(os2Msg->mp2), repeatCount, scanCode));
|
---|
608 | dprintf(("PM: WM_CHAR: hwnd %x flags %x mp1 %x, mp2 %x, time=%08xh", win32wnd->getWindowHandle(), flags, os2Msg->mp1, os2Msg->mp2, os2Msg->time));
|
---|
609 |
|
---|
610 | BOOL fWinExtended;
|
---|
611 | BYTE bWinVKey;
|
---|
612 | WORD wWinScan;
|
---|
613 |
|
---|
614 | if (scanCode==0) goto dummymessage;
|
---|
615 |
|
---|
616 | // Note: Numlock-state currently ignored, see below
|
---|
617 | KeyTranslatePMScanToWinVKey(usPMScanCode,
|
---|
618 | FALSE,
|
---|
619 | &bWinVKey,
|
---|
620 | &wWinScan,
|
---|
621 | &fWinExtended);
|
---|
622 | winMsg->wParam = bWinVKey;
|
---|
623 | winMsg->lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount
|
---|
624 | winMsg->lParam |= (wWinScan & 0x1FF) << 16; // bit 16-23, scancode + bit 15 extended
|
---|
625 |
|
---|
626 | // Set the extended bit when appropriate
|
---|
627 | if (fWinExtended)
|
---|
628 | winMsg->lParam = winMsg->lParam | WIN_KEY_EXTENDED;
|
---|
629 |
|
---|
630 | #if 0
|
---|
631 | //TODO
|
---|
632 | // Adjust VKEY value for pad digits if NumLock is on
|
---|
633 | if ((scanCode >= 0x47) && (scanCode <= 0x53) &&
|
---|
634 | (virtualKey >= 0x30) && (virtualKey >= 39))
|
---|
635 | winMsg->wParam = virtualKey + 0x30;
|
---|
636 | #endif
|
---|
637 |
|
---|
638 | #ifdef ALTGR_HACK
|
---|
639 |
|
---|
640 | if (usPMScanCode == PMSCAN_ALTRIGHT)
|
---|
641 | {
|
---|
642 | // Turn message into CTRL-event
|
---|
643 | // The original PM message is still saved inside
|
---|
644 | // the TEB, the next call to TranslateMessage()
|
---|
645 | // will then generate the required additional message
|
---|
646 | // for the ALTGR-event.
|
---|
647 | winMsg->wParam = VK_LCONTROL_W;
|
---|
648 | winMsg->lParam = repeatCount & 0x0FFFF;
|
---|
649 | winMsg->lParam |= WINSCAN_CTRLLEFT << 16
|
---|
650 | | WIN_KEY_DONTCARE;
|
---|
651 |
|
---|
652 | if (flags & KC_KEYUP)
|
---|
653 | {
|
---|
654 | winMsg->message = WINWM_SYSKEYUP;
|
---|
655 | winMsg->lParam |= WIN_KEY_ALTHELD; // bit 29, alt was pressed
|
---|
656 | winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, always 1 for a WM_KEYUP message
|
---|
657 | winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
|
---|
658 |
|
---|
659 | // Note: altgr affects the alt-key state in windows!
|
---|
660 | // The overlay causes GetKeyState/GetAsyncKeyState to return
|
---|
661 | // the correct states
|
---|
662 | KeySetOverlayKeyState(VK_LCONTROL_W, KEYOVERLAYSTATE_DONTCARE);
|
---|
663 | KeySetOverlayKeyState(VK_CONTROL_W, KEYOVERLAYSTATE_DONTCARE);
|
---|
664 | }
|
---|
665 | else
|
---|
666 | {
|
---|
667 | winMsg->lParam |= WIN_KEY_ALTHELD;
|
---|
668 | if (keyWasPressed)
|
---|
669 | winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, 1 means key was pressed
|
---|
670 | winMsg->message = WINWM_KEYDOWN;
|
---|
671 |
|
---|
672 | // Note: altgr affects the alt-key state in windows!
|
---|
673 | // The overlay causes GetKeyState/GetAsyncKeyState to return
|
---|
674 | // the correct states
|
---|
675 | KeySetOverlayKeyState(VK_LCONTROL_W, KEYOVERLAYSTATE_DOWN);
|
---|
676 | KeySetOverlayKeyState(VK_CONTROL_W, KEYOVERLAYSTATE_DOWN);
|
---|
677 | KeySetOverlayKeyState(VK_RMENU_W, KEYOVERLAYSTATE_DOWN);
|
---|
678 | KeySetOverlayKeyState(VK_MENU_W, KEYOVERLAYSTATE_DOWN);
|
---|
679 |
|
---|
680 | // Note: when CTRL comes up, windows keeps ALTGR still down!
|
---|
681 | // KeySetOverlayKeyState(VK_RMENU_W, KEYOVERLAYSTATE_DOWN);
|
---|
682 | }
|
---|
683 | }
|
---|
684 | #endif
|
---|
685 |
|
---|
686 | if (!(flags & KC_ALT))
|
---|
687 | {
|
---|
688 | //
|
---|
689 | // the Alt key is not pressed
|
---|
690 | // or no more pressed
|
---|
691 | //
|
---|
692 | if (flags & KC_KEYUP)
|
---|
693 | {
|
---|
694 | // check for a lonesome ALT key ...
|
---|
695 | if ( (flags & KC_LONEKEY) &&
|
---|
696 | ((winMsg->wParam == VK_LMENU_W) || (winMsg->wParam == VK_RMENU_W)) )
|
---|
697 | {
|
---|
698 | winMsg->message = WINWM_SYSKEYUP;
|
---|
699 | // held ALT-key when current key is released
|
---|
700 | // generates additional flag 0x2000000
|
---|
701 | // Note: PM seems to do this differently,
|
---|
702 | // KC_ALT is already reset
|
---|
703 | }
|
---|
704 | else
|
---|
705 | {
|
---|
706 | // send WM_KEYUP message
|
---|
707 | winMsg->message = WINWM_KEYUP;
|
---|
708 | }
|
---|
709 | winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, always 1 for a WM_KEYUP message
|
---|
710 | winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
|
---|
711 | }
|
---|
712 | else
|
---|
713 | { // send WM_KEYDOWN message
|
---|
714 | winMsg->message = WINWM_KEYDOWN;
|
---|
715 |
|
---|
716 | if (keyWasPressed)
|
---|
717 | winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, 1 means key was pressed
|
---|
718 |
|
---|
719 | //Shift-Enter and possibly others need to have special handling
|
---|
720 | if (flags & KC_SHIFT)
|
---|
721 | {
|
---|
722 | if(fMsgRemoved && !(teb->o.odin.fTranslated))
|
---|
723 | {
|
---|
724 | dprintf(("PM: KC_SHIFT: %x",winMsg->wParam));
|
---|
725 | if (winMsg->wParam == VK_RETURN_W)
|
---|
726 | {
|
---|
727 | MSG extramsg;
|
---|
728 | memcpy(&extramsg, winMsg, sizeof(MSG));
|
---|
729 |
|
---|
730 | extramsg.message = WINWM_CHAR;
|
---|
731 |
|
---|
732 | // insert message into the queue
|
---|
733 | setThreadQueueExtraCharMessage(teb, &extramsg);
|
---|
734 | winMsg->lParam &= 0x3FFFFFFF;
|
---|
735 | }
|
---|
736 | } // else ???
|
---|
737 | } // KC_SHIFT
|
---|
738 | else
|
---|
739 | {
|
---|
740 | // in case we handle Enter directly through PMKBDHOOK
|
---|
741 | if ((os2Msg->msg == WM_CHAR_SPECIAL) && (winMsg->wParam == VK_RETURN_W)
|
---|
742 | && (fMsgRemoved && !(teb->o.odin.fTranslated)))
|
---|
743 | {
|
---|
744 | MSG extramsg;
|
---|
745 | memcpy(&extramsg, winMsg, sizeof(MSG));
|
---|
746 |
|
---|
747 | extramsg.message = WINWM_CHAR;
|
---|
748 |
|
---|
749 | // insert message into the queue
|
---|
750 | setThreadQueueExtraCharMessage(teb, &extramsg);
|
---|
751 | }
|
---|
752 | }
|
---|
753 | }
|
---|
754 | // if right alt is down, then we need to set the alt down bit too
|
---|
755 | if (WinGetKeyState(HWND_DESKTOP, VK_ALTGRAF) & 0x8000) {
|
---|
756 | winMsg->lParam |= WIN_KEY_ALTHELD;
|
---|
757 | }
|
---|
758 | }
|
---|
759 | else
|
---|
760 | {
|
---|
761 | //
|
---|
762 | // the Alt key is pressed
|
---|
763 | //
|
---|
764 | if (flags & KC_KEYUP)
|
---|
765 | {
|
---|
766 | //@@PF Note that without pmkbdhook there will not be correct message for Alt-Enter
|
---|
767 | winMsg->message = WINWM_SYSKEYUP;
|
---|
768 | winMsg->lParam |= WIN_KEY_PREVSTATE;
|
---|
769 | // No ALTHELD for Alt itself ;)
|
---|
770 | winMsg->lParam |= WIN_KEY_ALTHELD;
|
---|
771 | winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
|
---|
772 | }
|
---|
773 | else
|
---|
774 | {
|
---|
775 | // send WM_SYSKEYDOWN message
|
---|
776 | winMsg->message = WINWM_SYSKEYDOWN;
|
---|
777 | if (keyWasPressed)
|
---|
778 | winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, 1 means key was pressed
|
---|
779 |
|
---|
780 | // pressed ALT-key generates additional flag 0x2000000
|
---|
781 | // if the current window has keyboard focus
|
---|
782 | winMsg->lParam |= WIN_KEY_ALTHELD;
|
---|
783 | }
|
---|
784 | }
|
---|
785 |
|
---|
786 | #ifdef ALTGR_HACK
|
---|
787 | // it's a PMSCAN_ALTRIGHT WM_CHAR message?
|
---|
788 | // and not previously translated?
|
---|
789 | if(fMsgRemoved && usPMScanCode == PMSCAN_ALTRIGHT && !(teb->o.odin.fTranslated))
|
---|
790 | {
|
---|
791 | dprintf(("Queue ALTRIGHT message"));
|
---|
792 | // special ALTRIGHT treatment:
|
---|
793 | // we try to insert another WM_KEYDOWN or WM_KEYUP instead of
|
---|
794 | // the usual WM_CHAR which is expected here.
|
---|
795 | // -> experimental
|
---|
796 | // it's really an OS/2-style WM_CHAR message?
|
---|
797 | MSG extramsg;
|
---|
798 | memcpy(&extramsg, winMsg, sizeof(MSG));
|
---|
799 |
|
---|
800 | // AltGr is not released with WINWM_SYSKEYUP, but WINWM_KEYUP
|
---|
801 | if(flags & KC_KEYUP)
|
---|
802 | {
|
---|
803 | extramsg.message = WINWM_KEYUP;
|
---|
804 | }
|
---|
805 | extramsg.wParam = VK_RMENU_W;
|
---|
806 |
|
---|
807 | // mask out message bits and scan code
|
---|
808 | extramsg.lParam &= (0xDC00FFFF);
|
---|
809 | extramsg.lParam |= (WINSCAN_ALTRIGHT & 0x1FF) << 16;
|
---|
810 | //// extramsg.lParam |= WIN_KEY_EXTENDED;
|
---|
811 | if (!(flags & KC_KEYUP))
|
---|
812 | extramsg.lParam |= WIN_KEY_ALTHELD;
|
---|
813 |
|
---|
814 | // insert message into the queue
|
---|
815 | setThreadQueueExtraCharMessage(teb, &extramsg);
|
---|
816 | }
|
---|
817 | #endif
|
---|
818 | break;
|
---|
819 | }
|
---|
820 |
|
---|
821 | case WM_TIMER:
|
---|
822 | //Why was this check here????
|
---|
823 | // if (os2Msg->mp2)
|
---|
824 | // {
|
---|
825 | BOOL sys;
|
---|
826 | ULONG id;
|
---|
827 |
|
---|
828 | if (TIMER_GetTimerInfo(os2Msg->hwnd,(ULONG)os2Msg->mp1,&sys,&id))
|
---|
829 | {
|
---|
830 | winMsg->wParam = (WPARAM)id;
|
---|
831 | winMsg->message= (sys) ? WINWM_SYSTIMER : WINWM_TIMER;
|
---|
832 | break;
|
---|
833 | }
|
---|
834 | // }
|
---|
835 | goto dummymessage; //for caret blinking
|
---|
836 |
|
---|
837 | case WM_SETWINDOWPARAMS:
|
---|
838 | {
|
---|
839 | WNDPARAMS *wndParams = (WNDPARAMS *)os2Msg->mp1;
|
---|
840 |
|
---|
841 | if(wndParams->fsStatus & WPM_TEXT) {
|
---|
842 | winMsg->message = WINWM_SETTEXT;
|
---|
843 | winMsg->lParam = (LPARAM)wndParams->pszText;
|
---|
844 | break;
|
---|
845 | }
|
---|
846 | goto dummymessage;
|
---|
847 | }
|
---|
848 |
|
---|
849 | #if 0
|
---|
850 | case WM_QUERYWINDOWPARAMS:
|
---|
851 | {
|
---|
852 | PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
|
---|
853 | ULONG textlen;
|
---|
854 | PSZ wintext;
|
---|
855 |
|
---|
856 | if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
|
---|
857 | {
|
---|
858 | if(wndpars->fsStatus & WPM_CCHTEXT)
|
---|
859 | wndpars->cchText = win32wnd->MsgGetTextLength();
|
---|
860 | if(wndpars->fsStatus & WPM_TEXT)
|
---|
861 | wndpars->pszText = win32wnd->MsgGetText();
|
---|
862 |
|
---|
863 | wndpars->fsStatus = 0;
|
---|
864 | wndpars->cbCtlData = 0;
|
---|
865 | wndpars->cbPresParams = 0;
|
---|
866 | goto dummymessage;
|
---|
867 | }
|
---|
868 | }
|
---|
869 | #endif
|
---|
870 |
|
---|
871 | case WM_PAINT:
|
---|
872 | {
|
---|
873 | if(win32wnd->IsWindowIconic()) {
|
---|
874 | winMsg->message = WINWM_PAINTICON;
|
---|
875 | }
|
---|
876 | else winMsg->message = WINWM_PAINT;
|
---|
877 | break;
|
---|
878 | }
|
---|
879 |
|
---|
880 | case WM_CONTEXTMENU:
|
---|
881 | winMsg->message = WINWM_CONTEXTMENU;
|
---|
882 | winMsg->wParam = win32wnd->getWindowHandle();
|
---|
883 | winMsg->lParam = MAKELONG(winMsg->pt.x,winMsg->pt.y);
|
---|
884 | break;
|
---|
885 |
|
---|
886 | case WM_RENDERFMT:
|
---|
887 | winMsg->message = WINWM_RENDERFORMAT;
|
---|
888 | winMsg->wParam = (UINT) os2Msg->mp1;
|
---|
889 | break;
|
---|
890 |
|
---|
891 | case WM_RENDERALLFMTS:
|
---|
892 | winMsg->message = WINWM_RENDERALLFORMATS;
|
---|
893 | break;
|
---|
894 |
|
---|
895 | case WM_DESTROYCLIPBOARD:
|
---|
896 | winMsg->message = WINWM_DESTROYCLIPBOARD;
|
---|
897 | break;
|
---|
898 |
|
---|
899 | case WM_HSCROLL:
|
---|
900 | case WM_VSCROLL:
|
---|
901 | winMsg->message = (os2Msg->msg == WM_HSCROLL) ? WINWM_HSCROLL : WINWM_VSCROLL;
|
---|
902 | winMsg->lParam = 0;
|
---|
903 | winMsg->wParam = 0;
|
---|
904 | switch(SHORT2FROMMP(os2Msg->mp2)) {
|
---|
905 | case SB_LINERIGHT:
|
---|
906 | winMsg->wParam = SB_LINERIGHT_W;
|
---|
907 | break;
|
---|
908 | case SB_LINELEFT:
|
---|
909 | winMsg->wParam = SB_LINELEFT_W;
|
---|
910 | break;
|
---|
911 | case SB_PAGELEFT:
|
---|
912 | winMsg->wParam = SB_PAGELEFT_W;
|
---|
913 | break;
|
---|
914 | case SB_PAGERIGHT:
|
---|
915 | winMsg->wParam = SB_PAGERIGHT_W;
|
---|
916 | break;
|
---|
917 | default:
|
---|
918 | dprintf(("Unsupported WM_H/VSCROLL message %x!!", SHORT2FROMMP(os2Msg->mp2)));
|
---|
919 | goto dummymessage;
|
---|
920 | }
|
---|
921 | break;
|
---|
922 |
|
---|
923 | case WM_INITMENU:
|
---|
924 | case WM_MENUSELECT:
|
---|
925 | case WM_MENUEND:
|
---|
926 | case WM_NEXTMENU:
|
---|
927 | case WM_SYSCOLORCHANGE:
|
---|
928 | case WM_SYSVALUECHANGED:
|
---|
929 | case WM_SETSELECTION:
|
---|
930 | case WM_PPAINT:
|
---|
931 | case WM_PSETFOCUS:
|
---|
932 | case WM_PSYSCOLORCHANGE:
|
---|
933 | case WM_PSIZE:
|
---|
934 | case WM_PACTIVATE:
|
---|
935 | case WM_PCONTROL:
|
---|
936 | case WM_HELP:
|
---|
937 | case WM_APPTERMINATENOTIFY:
|
---|
938 | case WM_PRESPARAMCHANGED:
|
---|
939 | case WM_DRAWITEM:
|
---|
940 | case WM_MEASUREITEM:
|
---|
941 | case WM_CONTROLPOINTER:
|
---|
942 | case WM_QUERYDLGCODE:
|
---|
943 | case WM_SUBSTITUTESTRING:
|
---|
944 | case WM_MATCHMNEMONIC:
|
---|
945 | case WM_SAVEAPPLICATION:
|
---|
946 | case WM_SEMANTICEVENT:
|
---|
947 | default:
|
---|
948 | dummymessage:
|
---|
949 | dprintf2(("dummy message %x %x %x %x", os2Msg->hwnd, os2Msg->msg, os2Msg->mp1, os2Msg->mp2));
|
---|
950 | winMsg->message = 0;
|
---|
951 | winMsg->wParam = 0;
|
---|
952 | winMsg->lParam = 0;
|
---|
953 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
954 | return FALSE;
|
---|
955 | }
|
---|
956 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
---|
957 | return TRUE;
|
---|
958 | }
|
---|
959 | //******************************************************************************
|
---|
960 | //******************************************************************************
|
---|
961 | BOOL OSLibWinTranslateMessage(MSG *msg)
|
---|
962 | {
|
---|
963 | TEB *teb;
|
---|
964 | MSG extramsg;
|
---|
965 |
|
---|
966 | teb = GetThreadTEB();
|
---|
967 | if(!teb)
|
---|
968 | return FALSE;
|
---|
969 |
|
---|
970 | UCHAR ucPMScanCode = CHAR4FROMMP(teb->o.odin.os2msg.mp1);
|
---|
971 | ULONG fl = SHORT1FROMMP(teb->o.odin.os2msg.mp1);
|
---|
972 |
|
---|
973 |
|
---|
974 | //NOTE: These actually need to be posted so that the next message retrieved by GetMessage contains
|
---|
975 | // the newly generated WM_CHAR message.
|
---|
976 | if(!teb->o.odin.fTranslated &&
|
---|
977 | teb->o.odin.os2msg.msg == WM_CHAR &&
|
---|
978 | !((SHORT1FROMMP(teb->o.odin.os2msg.mp1) & KC_KEYUP) == KC_KEYUP))
|
---|
979 | {
|
---|
980 | //TranslatedMessage was called before DispatchMessage, so queue WM_CHAR message
|
---|
981 | memcpy(&extramsg, msg, sizeof(MSG));
|
---|
982 | extramsg.wParam = SHORT1FROMMP(teb->o.odin.os2msg.mp2);
|
---|
983 | extramsg.lParam = 0;
|
---|
984 |
|
---|
985 | // ESCAPE generates a WM_CHAR under windows, so take
|
---|
986 | // special care for this here.
|
---|
987 | switch (ucPMScanCode)
|
---|
988 | {
|
---|
989 | case PMSCAN_ESC:
|
---|
990 | extramsg.wParam = VK_ESCAPE_W;
|
---|
991 | fl |= KC_CHAR;
|
---|
992 | break;
|
---|
993 | }
|
---|
994 |
|
---|
995 | if(!(fl & KC_CHAR) && msg->message < WINWM_SYSKEYDOWN)
|
---|
996 | {
|
---|
997 | return FALSE;
|
---|
998 | }
|
---|
999 |
|
---|
1000 | if(fl & KC_VIRTUALKEY)
|
---|
1001 | {
|
---|
1002 | if(msg->wParam)
|
---|
1003 | {
|
---|
1004 | if ((msg->wParam >= VK_NUMPAD0_W) &&
|
---|
1005 | (msg->wParam <= VK_NUMPAD9_W))
|
---|
1006 | extramsg.wParam = msg->wParam - 0x30;
|
---|
1007 | else
|
---|
1008 | extramsg.wParam = msg->wParam;
|
---|
1009 | }
|
---|
1010 | else
|
---|
1011 | extramsg.wParam = SHORT2FROMMP(teb->o.odin.os2msg.mp2);
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 |
|
---|
1015 | if(msg->message >= WINWM_SYSKEYDOWN)
|
---|
1016 | extramsg.message = WINWM_SYSCHAR;
|
---|
1017 | else
|
---|
1018 | extramsg.message = WINWM_CHAR;
|
---|
1019 |
|
---|
1020 | if(fl & KC_DEADKEY)
|
---|
1021 | extramsg.message++; //WM_DEADCHAR/WM_SYSDEADCHAR
|
---|
1022 |
|
---|
1023 |
|
---|
1024 | extramsg.lParam = msg->lParam & 0x00FFFFFF;
|
---|
1025 | if ((fl & KC_ALT) || (msg->lParam & WIN_KEY_ALTHELD))
|
---|
1026 | extramsg.lParam |= WIN_KEY_ALTHELD;
|
---|
1027 | if(fl & KC_PREVDOWN)
|
---|
1028 | extramsg.lParam |= WIN_KEY_PREVSTATE;
|
---|
1029 | if(fl & KC_KEYUP)
|
---|
1030 | extramsg.lParam |= (1<<31);
|
---|
1031 |
|
---|
1032 | // insert message into the queue
|
---|
1033 | setThreadQueueExtraCharMessage(teb, &extramsg);
|
---|
1034 | return TRUE;
|
---|
1035 | }
|
---|
1036 | return FALSE;
|
---|
1037 | }
|
---|
1038 | //******************************************************************************
|
---|
1039 | //******************************************************************************
|
---|
1040 |
|
---|