source: trunk/src/user32/oslibmsgtranslate.cpp@ 10212

Last change on this file since 10212 was 10212, checked in by sandervl, 22 years ago

cleaned up Get/PeekMessage; do proper WM_CHAR conversion in those 4 functions

File size: 42.2 KB
Line 
1/* $Id: oslibmsgtranslate.cpp,v 1.114 2003-08-06 11:00:45 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 <winnls.h>
40#include <heapstring.h>
41#include "hook.h"
42#include "user32api.h"
43
44
45#define DBG_LOCALLOG DBG_oslibmsgtranslate
46#include "dbglocal.h"
47
48static BOOL fGenerateDoubleClick = FALSE;
49static MSG doubleClickMsg = {0};
50
51//For wheel mouse translation
52#define WHEEL_DELTA 120
53#define OS2_WHEEL_CORRECTION 1
54//PF Correction is different for different mouse drivers. For now no correction
55//is ok because lots of Odin controls rely on minimum delta. However in future
56//we will possibly detect mouse driver and use correction if speed will be
57//too high or too low.
58
59//******************************************************************************
60//
61// setThreadQueueExtraCharMessage: queues WM_CHAR message so it is retrieved
62// by GetMessage & PeekMessage
63//
64// NOTE: WM_CHAR message always in ascii format
65//
66//******************************************************************************
67BOOL setThreadQueueExtraCharMessage(TEB* teb, MSG* pExtraMsg)
68{
69 // check if the single slot is occupied already
70 if (teb->o.odin.fTranslated == TRUE)
71 // there's still an already translated message to be processed
72 return FALSE;
73
74 teb->o.odin.fTranslated = TRUE;
75 memcpy(&teb->o.odin.msgWCHAR, pExtraMsg, sizeof(MSG));
76 return TRUE;
77}
78
79//******************************************************************************
80//******************************************************************************
81ULONG ConvertNumPadKey(ULONG pmScan)
82{
83 ULONG ret;
84 BYTE winKey;
85
86 switch (pmScan)
87 {
88 case PMSCAN_PAD7: ret = PMSCAN_HOME; break;
89 case PMSCAN_PAD8: ret = PMSCAN_UP; break;
90 case PMSCAN_PAD9: ret = PMSCAN_PAGEUP; break;
91 case PMSCAN_PAD4: ret = PMSCAN_LEFT; break;
92 case PMSCAN_PAD6: ret = PMSCAN_RIGHT; break;
93 case PMSCAN_PAD1: ret = PMSCAN_END; break;
94 case PMSCAN_PAD2: ret = PMSCAN_DOWN; break;
95 case PMSCAN_PAD3: ret = PMSCAN_PAGEDOWN; break;
96 case PMSCAN_PAD0: ret = PMSCAN_INSERT; break;
97 case PMSCAN_PADPERIOD: ret = PMSCAN_DELETE; break;
98 default:
99 ret = pmScan;
100 }
101
102 KeyTranslatePMScanToWinVKey(ret, FALSE, (PBYTE)&winKey, NULL, NULL);
103 return winKey;
104
105}
106//******************************************************************************
107//******************************************************************************
108LONG IsNCMouseMsg(Win32BaseWindow *win32wnd)
109{
110 return ((win32wnd->getLastHitTestVal() != HTCLIENT_W) && (WinQueryCapture(HWND_DESKTOP) != win32wnd->getOS2WindowHandle()));
111}
112//******************************************************************************
113//******************************************************************************
114void OSLibSetMenuDoubleClick(BOOL fSet)
115{
116 fGenerateDoubleClick = fSet;
117}
118//******************************************************************************
119
120
121/**
122 * Inter process/thread packet cleanup.
123 * See OSLibPackMessage() for details on the packing.
124 *
125 * @param pTeb Pointer to the thread environment block for the current thread.
126 * @param pPacket Pointer to the packet in question.
127 * @param pWinMsg Pointer to the window message corresponding to the packet.
128 */
129inline void OSLibCleanupPacket(TEB *pTeb, POSTMSG_PACKET *pPacket, MSG *pWinMsg)
130{
131 switch (pWinMsg->message)
132 {
133 /*
134 * Place this in the TEB freeing any previous WM_COPYDATA packet.
135 * Note! Nested WM_COPYDATA isn't working.
136 */
137 case WINWM_COPYDATA:
138 {
139 dprintf(("OSLibCleanupPacket: WM_COPYDATA: old %#p new %#p", pTeb->o.odin.pWM_COPYDATA, pPacket));
140 if (pTeb->o.odin.pWM_COPYDATA)
141 _sfree(pTeb->o.odin.pWM_COPYDATA);
142 pTeb->o.odin.pWM_COPYDATA = pPacket;
143 break;
144 }
145
146 /*
147 * Default packing - free the shared memory here.
148 */
149 default:
150 _sfree(pPacket);
151 break;
152 }
153}
154
155//******************************************************************************
156BOOL OS2ToWinMsgTranslate(void *pTeb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fMsgRemoved)
157{
158 Win32BaseWindow *win32wnd = 0;
159 OSLIBPOINT point, ClientPoint;
160 POSTMSG_PACKET *packet;
161 TEB *teb = (TEB *)pTeb;
162 BOOL fWasDisabled = FALSE;
163 BOOL fIsFrame = FALSE;
164 int i;
165
166 memset(winMsg, 0, sizeof(MSG));
167 win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(os2Msg->hwnd);
168 if(!win32wnd) {
169 win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(os2Msg->hwnd);
170 if(win32wnd) {
171 fIsFrame = TRUE;
172 }
173 }
174
175 //PostThreadMessage posts WIN32APP_POSTMSG msg without window handle
176 //Realplayer starts a timer with hwnd 0 & proc 0; check this here
177 if(win32wnd == 0 && (os2Msg->msg != WM_CREATE && os2Msg->msg != WM_QUIT && os2Msg->msg != WM_TIMER && os2Msg->msg < WIN32APP_POSTMSG))
178 {
179 goto dummymessage; //not a win32 client window
180 }
181 winMsg->time = os2Msg->time;
182 //CB: PM bug or undocumented feature? ptl.x highword is set!
183 winMsg->pt.x = os2Msg->ptl.x & 0xFFFF;
184 winMsg->pt.y = mapScreenY(os2Msg->ptl.y);
185
186 if(win32wnd) //==0 for WM_CREATE/WM_QUIT
187 winMsg->hwnd = win32wnd->getWindowHandle();
188
189 if(os2Msg->msg >= WIN32APP_POSTMSG) {
190 packet = (POSTMSG_PACKET *)os2Msg->mp2;
191 if(packet && ((ULONG)os2Msg->mp1 == WIN32MSG_MAGICA || (ULONG)os2Msg->mp1 == WIN32MSG_MAGICW)) {
192 winMsg->message = os2Msg->msg - WIN32APP_POSTMSG;
193 winMsg->wParam = packet->wParam;
194 winMsg->lParam = packet->lParam;
195 if (fMsgRemoved == MSG_REMOVE)
196 OSLibCleanupPacket(teb, packet, winMsg);
197 if(win32wnd) RELEASE_WNDOBJ(win32wnd);
198 return TRUE;
199 }
200 else {//broadcasted message (no packet present)
201 winMsg->message = os2Msg->msg - WIN32APP_POSTMSG;
202 winMsg->wParam = (UINT)os2Msg->mp1;
203 winMsg->lParam = (DWORD)os2Msg->mp2;
204 if(win32wnd) RELEASE_WNDOBJ(win32wnd);
205 return TRUE;
206 }
207 goto dummymessage;
208 }
209
210 switch(os2Msg->msg)
211 {
212 //OS/2 msgs
213 case WM_CREATE:
214 {
215 if(teb->o.odin.newWindow == 0) {
216 DebugInt3();
217 goto dummymessage;
218 }
219
220 win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
221 win32wnd->addRef();
222
223 winMsg->message = WINWM_CREATE;
224 winMsg->hwnd = win32wnd->getWindowHandle();
225 winMsg->wParam = 0;
226 winMsg->lParam = (LPARAM)win32wnd->tmpcs;
227 break;
228 }
229
230 case WM_QUIT:
231 winMsg->message = WINWM_QUIT;
232 if (fMsgRemoved && win32wnd && (ULONG)os2Msg->mp2 != 0) {
233 // mp2 != 0 -> sent by window list; be nice and close
234 // the window first
235 win32wnd->MsgClose();
236 }
237 break;
238
239 case WM_CLOSE:
240 winMsg->message = WINWM_CLOSE;
241 break;
242
243 case WM_DESTROY:
244 winMsg->message = WINWM_DESTROY;
245 break;
246
247 case WM_ENABLE:
248 winMsg->message = WINWM_ENABLE;
249 winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
250 break;
251
252 case WM_SHOW:
253 winMsg->message = WINWM_SHOWWINDOW;
254 winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
255 break;
256
257 case WM_REALIZEPALETTE:
258 winMsg->message = WINWM_PALETTECHANGED;
259 break;
260
261 case WM_WINDOWPOSCHANGED:
262 {
263 PSWP pswp = (PSWP)os2Msg->mp1;
264 SWP swpOld = *(pswp + 1);
265 HWND hParent = NULLHANDLE;
266 LONG yDelta = pswp->cy - swpOld.cy;
267 LONG xDelta = pswp->cx - swpOld.cx;
268
269 if(!fIsFrame) goto dummymessage;
270
271 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) goto dummymessage;
272
273 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
274 if (win32wnd->isChild()) {
275 if(win32wnd->getParent()) {
276 hParent = win32wnd->getParent()->getOS2WindowHandle();
277 }
278 else goto dummymessage; //parent has just been destroyed
279 }
280 }
281 if(win32wnd->getParent()) {
282 OSLibMapSWPtoWINDOWPOS(pswp, &teb->o.odin.wp, &swpOld, win32wnd->getParent()->getClientHeight(),
283 win32wnd->getOS2WindowHandle());
284 }
285 else OSLibMapSWPtoWINDOWPOS(pswp, &teb->o.odin.wp, &swpOld, OSLibQueryScreenHeight(), win32wnd->getOS2WindowHandle());
286
287 if (!win32wnd->CanReceiveSizeMsgs()) goto dummymessage;
288
289 if(pswp->fl & (SWP_MOVE | SWP_SIZE))
290 {
291 teb->o.odin.wp.hwnd = win32wnd->getWindowHandle();
292 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
293 {
294 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
295 if(wndAfter) {
296 teb->o.odin.wp.hwndInsertAfter = wndAfter->getWindowHandle();
297 RELEASE_WNDOBJ(wndAfter);
298 }
299 else teb->o.odin.wp.hwndInsertAfter = HWND_TOP_W;
300 }
301 }
302 winMsg->message = WINWM_WINDOWPOSCHANGED;
303 winMsg->lParam = (LPARAM)&teb->o.odin.wp;
304 break;
305 }
306
307 case WM_ACTIVATE:
308 {
309 HWND hwndActivate = (HWND)os2Msg->mp2;
310 BOOL fMinimized = FALSE;
311
312 hwndActivate = OS2ToWin32Handle(hwndActivate);
313 if(hwndActivate == 0) {
314 //another (non-win32) application's window
315 //set to desktop window handle
316 hwndActivate = windowDesktop->getWindowHandle();
317 }
318
319 if(win32wnd->getStyle() & WS_MINIMIZE_W)
320 {
321 fMinimized = TRUE;
322 }
323
324 winMsg->message = WINWM_ACTIVATE;
325 winMsg->wParam = MAKELONG((SHORT1FROMMP(os2Msg->mp1)) ? WA_ACTIVE_W : WA_INACTIVE_W, fMinimized);
326 winMsg->lParam = (LPARAM)hwndActivate;
327 break;
328 }
329
330 case WM_SETFOCUS:
331 {
332 HWND hwndFocus = (HWND)os2Msg->mp1;
333
334 if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
335 //another (non-win32) application's window
336 //set to NULL (allowed according to win32 SDK) to avoid problems
337 hwndFocus = NULL;
338 }
339 else hwndFocus = OS2ToWin32Handle(hwndFocus);
340
341 if((ULONG)os2Msg->mp2 == TRUE) {
342 winMsg->message = WINWM_SETFOCUS;
343 winMsg->wParam = (WPARAM)hwndFocus;
344 }
345 else {
346 //If SetFocus(0) was called, then the window has already received
347 //a WM_KILLFOCUS; don't send another one
348 if(!fIgnoreKeystrokes) {
349 winMsg->message = WINWM_KILLFOCUS;
350 winMsg->wParam = (WPARAM)hwndFocus;
351 }
352 else {
353 dprintf(("Window has already received a WM_KILLFOCUS (SetFocus(0)); ignore"));
354 goto dummymessage;
355 }
356 }
357 break;
358 }
359
360 //**************************************************************************
361 //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
362 //**************************************************************************
363 case WM_BUTTON1DOWN:
364 case WM_BUTTON1UP:
365 case WM_BUTTON1DBLCLK:
366 case WM_BUTTON2DOWN:
367 case WM_BUTTON2UP:
368 case WM_BUTTON2DBLCLK:
369 case WM_BUTTON3DOWN:
370 case WM_BUTTON3UP:
371 case WM_BUTTON3DBLCLK:
372 {
373 //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
374
375 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));
376
377 HWND hwnd;
378
379 DisableLogging();
380 if(GetCapture() != winMsg->hwnd)
381 {
382 hwnd = WindowFromPoint(winMsg->pt);
383 if(win32wnd->getWindowHandle() != hwnd) {
384 RELEASE_WNDOBJ(win32wnd);
385 win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
386 if(win32wnd == NULL) {
387 DebugInt3();
388 EnableLogging();
389 goto dummymessage;
390 }
391 winMsg->hwnd = hwnd;
392 }
393 }
394
395 //if a window is disabled, its parent receives the mouse messages
396 if(!IsWindowEnabled(win32wnd->getWindowHandle())) {
397 if(win32wnd->getParent()) {
398 Win32BaseWindow *parent = win32wnd->getParent();;
399 if(parent) parent->addRef();
400 RELEASE_WNDOBJ(win32wnd);
401 win32wnd = parent;
402 }
403 fWasDisabled = TRUE;
404 }
405
406 if(IsNCMouseMsg(win32wnd)) {
407 winMsg->message = WINWM_NCLBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
408 winMsg->wParam = win32wnd->getLastHitTestVal();
409 winMsg->lParam = MAKELONG(winMsg->pt.x, winMsg->pt.y); //screen coordinates
410 }
411 else {
412 ClientPoint.x = winMsg->pt.x;
413 ClientPoint.y = winMsg->pt.y;
414 MapWindowPoints(0, win32wnd->getWindowHandle(), (LPPOINT)&ClientPoint, 1);
415 winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
416 winMsg->wParam = GetMouseKeyState();
417 winMsg->lParam = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
418 }
419 EnableLogging();
420
421 if(fWasDisabled) {
422 if(win32wnd) {
423 winMsg->hwnd = win32wnd->getWindowHandle();
424 }
425 else goto dummymessage; //don't send mouse messages to disabled windows
426 }
427
428 DisableLogging();
429 if ((winMsg->message == WINWM_LBUTTONDOWN) ||
430 (winMsg->message == WINWM_RBUTTONDOWN) ||
431 (winMsg->message == WINWM_MBUTTONDOWN) ||
432 (winMsg->message == WINWM_NCLBUTTONDOWN) ||
433 (winMsg->message == WINWM_NCRBUTTONDOWN) ||
434 (winMsg->message == WINWM_NCMBUTTONDOWN))
435 {
436 if(fGenerateDoubleClick && doubleClickMsg.message == winMsg->message &&
437 winMsg->time - doubleClickMsg.time < GetDoubleClickTime() &&
438 (abs(winMsg->pt.x - doubleClickMsg.pt.x) < GetSystemMetrics(SM_CXDOUBLECLK_W)/2) &&
439 (abs(winMsg->pt.y - doubleClickMsg.pt.y) < GetSystemMetrics(SM_CYDOUBLECLK_W)/2))
440 {
441 dprintf(("single -> double click"));
442 if(winMsg->message >= WINWM_LBUTTONDOWN) {
443 winMsg->message += (WINWM_LBUTTONDBLCLK - WINWM_LBUTTONDOWN);
444 }
445 else winMsg->message += (WINWM_LBUTTONDBLCLK - WINWM_NCLBUTTONDOWN);
446 if(fMsgRemoved) doubleClickMsg.message = 0;
447 }
448 else {
449 dprintf(("save for double click"));
450 if(fMsgRemoved) {
451 doubleClickMsg = *winMsg;
452 if(doubleClickMsg.message >= WINWM_NCLBUTTONDOWN && doubleClickMsg.message <= WINWM_NCMBUTTONDOWN) {
453 doubleClickMsg.message += (WINWM_LBUTTONDOWN - WINWM_NCLBUTTONDOWN);
454 }
455 }
456 }
457 }
458 EnableLogging();
459
460 if(fMsgRemoved == MSG_REMOVE)
461 {
462 MSLLHOOKSTRUCT hook;
463 ULONG msg;
464
465 if(winMsg->message >= WINWM_NCLBUTTONDOWN && winMsg->message <= WINWM_NCMBUTTONDBLCLK) {
466 msg = winMsg->message - WINWM_NCLBUTTONDOWN + WINWM_LBUTTONDOWN;
467 }
468 else msg = winMsg->message;
469
470 if(msg == WINWM_LBUTTONDBLCLK) {
471 msg = WINWM_LBUTTONDOWN;
472 }
473 else
474 if(msg == WINWM_RBUTTONDBLCLK) {
475 msg = WINWM_RBUTTONDOWN;
476 }
477 else
478 if(msg == WINWM_MBUTTONDBLCLK) {
479 msg = WINWM_MBUTTONDOWN;
480 }
481
482 hook.pt.x = os2Msg->ptl.x & 0xFFFF;
483 hook.pt.y = mapScreenY(os2Msg->ptl.y);
484 hook.mouseData = 0; //todo: XBUTTON1/2 (XP feature) or wheel data
485 hook.flags = 0; //todo: injected (LLMHF_INJECTED)
486 hook.time = winMsg->time;
487 hook.dwExtraInfo = 0;
488
489 if(HOOK_CallHooksW( WH_MOUSE_LL, HC_ACTION, msg, (LPARAM)&hook)) {
490 goto dummymessage; //hook swallowed message
491 }
492 }
493 break;
494 }
495
496 case WM_BUTTON2CLICK:
497 case WM_BUTTON1CLICK:
498 case WM_BUTTON3CLICK:
499 goto dummymessage;
500
501 case WM_BUTTON2MOTIONSTART:
502 case WM_BUTTON2MOTIONEND:
503 case WM_BUTTON1MOTIONSTART:
504 case WM_BUTTON1MOTIONEND:
505 case WM_BUTTON3MOTIONSTART:
506 case WM_BUTTON3MOTIONEND:
507 //no break; translate to WM_MOUSEMOVE
508 //Some applications (e.g. Unreal) retrieve all mouse messages
509 //when a mouse button is pressed and don't expect WM_NULL
510
511 case WM_MOUSEMOVE:
512 {
513 //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
514
515 HWND hwnd;
516
517 dprintf2(("WM_MOUSEMOVE (%d,%d)", winMsg->pt.x, winMsg->pt.y));
518 DisableLogging();
519 if(GetCapture() != winMsg->hwnd)
520 {
521 hwnd = WindowFromPoint(winMsg->pt);
522 if(win32wnd->getWindowHandle() != hwnd) {
523 RELEASE_WNDOBJ(win32wnd);
524 win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
525 if(win32wnd == NULL) {
526 DebugInt3();
527 EnableLogging();
528 goto dummymessage;
529 }
530 winMsg->hwnd = hwnd;
531 }
532 }
533
534 //if a window is disabled, its parent receives the mouse messages
535 if(!IsWindowEnabled(win32wnd->getWindowHandle())) {
536 if(win32wnd->getParent()) {
537 Win32BaseWindow *parent = win32wnd->getParent();;
538 if(parent) parent->addRef();
539 RELEASE_WNDOBJ(win32wnd);
540 win32wnd = parent;
541 }
542 fWasDisabled = TRUE;
543 }
544 if(IsNCMouseMsg(win32wnd))
545 {
546 winMsg->message = WINWM_NCMOUSEMOVE;
547 winMsg->wParam = (WPARAM)win32wnd->getLastHitTestVal();
548 winMsg->lParam = MAKELONG(winMsg->pt.x,winMsg->pt.y);
549 }
550 else
551 {
552 ClientPoint.x = winMsg->pt.x;
553 ClientPoint.y = winMsg->pt.y;
554 MapWindowPoints(0, win32wnd->getWindowHandle(), (LPPOINT)&ClientPoint, 1);
555
556 winMsg->message = WINWM_MOUSEMOVE;
557 winMsg->wParam = GetMouseKeyState();
558 winMsg->lParam = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
559 }
560 EnableLogging();
561 if(fWasDisabled) {
562 if(win32wnd) {
563 winMsg->hwnd = win32wnd->getWindowHandle();
564 }
565 else {
566 goto dummymessage; //don't send mouse messages to disabled windows
567 }
568 }
569 if(fMsgRemoved == MSG_REMOVE)
570 {
571 MSLLHOOKSTRUCT hook;
572
573 hook.pt.x = os2Msg->ptl.x & 0xFFFF;
574 hook.pt.y = mapScreenY(os2Msg->ptl.y);
575 hook.mouseData = 0;
576 hook.flags = 0; //todo: injected (LLMHF_INJECTED)
577 hook.time = winMsg->time;
578 hook.dwExtraInfo = 0;
579
580 if(HOOK_CallHooksW( WH_MOUSE_LL, HC_ACTION, winMsg->message, (LPARAM)&hook)) {
581 goto dummymessage; //hook swallowed message
582 }
583 }
584 break;
585 }
586
587 case WM_CONTROL:
588 goto dummymessage;
589
590 case WM_COMMAND:
591 if(SHORT1FROMMP(os2Msg->mp2) == CMDSRC_MENU) {
592 winMsg->message = WINWM_COMMAND;
593 winMsg->wParam = (WPARAM)SHORT1FROMMP(os2Msg->mp1); //id
594 break;
595 }
596 //todo controls
597 goto dummymessage;
598
599 case WM_SYSCOMMAND:
600 {
601 ULONG x = 0, y = 0;
602 ULONG win32sc;
603
604 if(SHORT2FROMMP(os2Msg->mp2) == TRUE) {//syscommand caused by mouse action
605 POINTL pointl;
606 WinQueryPointerPos(HWND_DESKTOP, &pointl);
607 x = pointl.x;
608 y = mapScreenY(y);
609 }
610 switch(SHORT1FROMMP(os2Msg->mp1)) {
611 case SC_MOVE:
612 win32sc = SC_MOVE_W;
613 break;
614 case SC_CLOSE:
615 {
616 //FALSE -> keyboard operation = user pressed Alt-F4 -> close app
617 //TRUE -> user clicked on close button -> close window
618 if(SHORT2FROMMP(os2Msg->mp2) == FALSE)
619 {
620 HWND hwnd = win32wnd->GetTopParent();
621 if(win32wnd->getWindowHandle() != hwnd) {
622 RELEASE_WNDOBJ(win32wnd);
623 win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
624 if(win32wnd == NULL) {
625 DebugInt3();
626 goto dummymessage;
627 }
628 winMsg->hwnd = hwnd;
629 }
630 }
631 win32sc = SC_CLOSE_W;
632 break;
633 }
634 case SC_MAXIMIZE:
635 win32sc = SC_MAXIMIZE_W;
636 break;
637 case SC_MINIMIZE:
638 win32sc = SC_MINIMIZE_W;
639 break;
640 case SC_NEXTFRAME:
641 case SC_NEXTWINDOW:
642 win32sc = SC_NEXTWINDOW_W;
643 break;
644 case SC_RESTORE:
645 win32sc = SC_RESTORE_W;
646 break;
647 case SC_TASKMANAGER:
648 win32sc = SC_TASKLIST_W;
649 break;
650 case SC_SYSMENU:
651 win32sc = SC_KEYMENU_W; //??
652 break;
653 default:
654 dprintf(("Unknown/unsupported SC command %d", SHORT1FROMMP(os2Msg->mp1)));
655 goto dummymessage;
656 }
657 winMsg->message= WINWM_SYSCOMMAND;
658 winMsg->wParam = (WPARAM)win32sc;
659 winMsg->lParam = MAKELONG((USHORT)x, (USHORT)y);
660 break;
661 }
662
663 case WM_CHAR_SPECIAL_CONSOLE_BREAK:
664 {
665 dprintf(("PM: WM_CHAR_SPECIAL_CONSOLE_BREAK for %x", winMsg->hwnd));
666 if(fMsgRemoved)
667 {
668 GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT_W,0);
669 // It is our internal message, do not work with it more, its function
670 // is over, otherwise it will return FALSE and will be dispatched,
671 // and retranslated once again.
672
673 winMsg->message = 0;
674 winMsg->wParam = 0;
675 winMsg->lParam = 0;
676 goto msgdone;
677 }
678 goto dummymessage;
679 }
680
681 case WM_CHAR_SPECIAL_ALTGRCONTROL:
682 {
683 // special char message from the keyboard hook
684 dprintf(("PM: WM_CHAR_SPECIAL_ALTGRCONTROL"));
685 // NO BREAK! FALLTHRU CASE!
686 }
687
688 case WM_CHAR_SPECIAL:
689 {
690 // @@@PH
691 // special char message from the keyboard hook
692 if(os2Msg->msg == WM_CHAR_SPECIAL) {
693 dprintf(("PM: WM_CHAR_SPECIAL"));
694 }
695 // NO BREAK! FALLTHRU CASE!
696 }
697
698 case WM_CHAR:
699 {
700 ULONG repeatCount=0;
701 ULONG virtualKey=0;
702 ULONG keyFlags=0;
703 USHORT scanCode=0;
704 ULONG flags = SHORT1FROMMP(os2Msg->mp1);
705 BOOL keyWasPressed;
706 BOOL numPressed = (BOOL)(WinGetKeyState(HWND_DESKTOP,VK_NUMLOCK) & 1);
707 char c;
708 USHORT usPMScanCode = CHAR4FROMMP(os2Msg->mp1);
709
710 teb->o.odin.fTranslated = FALSE;
711 repeatCount = CHAR3FROMMP(os2Msg->mp1);
712 scanCode = CHAR4FROMMP(os2Msg->mp1);
713 keyWasPressed = ((SHORT1FROMMP (os2Msg->mp1) & KC_PREVDOWN) == KC_PREVDOWN);
714
715 dprintf(("PM: WM_CHAR: %x %x rep=%d scancode=%x num=%d", SHORT1FROMMP(os2Msg->mp2), SHORT2FROMMP(os2Msg->mp2), repeatCount, scanCode, numPressed));
716 dprintf(("PM: WM_CHAR: hwnd %x flags %x mp1 %x, mp2 %x, time=%08xh", win32wnd->getWindowHandle(), flags, os2Msg->mp1, os2Msg->mp2, os2Msg->time));
717
718 BOOL fWinExtended;
719 BYTE bWinVKey;
720 WORD wWinScan;
721
722 if ( (!IsDBCSEnv() && scanCode == 0) ||
723 (scanCode==0 ) && !( flags & KC_CHAR ) )
724 {
725 goto dummymessage;
726 }
727
728 if( scanCode != 0 )
729 {
730 KeyTranslatePMScanToWinVKey(usPMScanCode,
731 FALSE,
732 &bWinVKey,
733 &wWinScan,
734 &fWinExtended);
735 winMsg->wParam = bWinVKey;
736 }
737 else
738 {
739 dprintf(("PM: WM_CHAR: DBCS processing "));
740
741 winMsg->wParam = CHAR1FROMMP( os2Msg->mp2 );
742
743 wWinScan = 0;
744 fWinExtended = 0;
745
746 if( CHAR2FROMMP( os2Msg->mp2 )) // DBCS character
747 {
748 if( isUnicode )
749 {
750 char dbcsCh[] = { CHAR1FROMMP( os2Msg->mp2 ), CHAR2FROMMP( os2Msg->mp2 ), 0 };
751 WCHAR uniChar[ 2 ];
752
753 lstrcpynAtoW(( LPWSTR )&uniChar, ( LPCSTR )&dbcsCh, 2 );
754 winMsg->wParam = ( WPARAM )uniChar[ 0 ];
755 }
756 // insert DBCS trail byte for Non-Unicode window
757 else if(fMsgRemoved && !(teb->o.odin.fTranslated))
758 {
759 MSG extramsg;
760 memcpy(&extramsg, winMsg, sizeof(MSG));
761
762 //After SetFocus(0), all keystrokes are converted in WM_SYS*
763 extramsg.message = (fIgnoreKeystrokes) ? WINWM_SYSCHAR : WINWM_CHAR;
764
765 extramsg.wParam = CHAR2FROMMP( os2Msg->mp2 );
766 extramsg.lParam = 0;
767
768 setThreadQueueExtraCharMessage(teb, &extramsg);
769 }
770 }
771 }
772 winMsg->lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount
773 winMsg->lParam |= (wWinScan & 0x1FF) << 16; // bit 16-23, scancode + bit 15 extended
774
775 // Set the extended bit when appropriate
776 if (fWinExtended)
777 winMsg->lParam = winMsg->lParam | WIN_KEY_EXTENDED;
778
779 //PF When we press shift we enable non-numeric functions of Numpad
780 if ((!numPressed || (flags & KC_SHIFT)) && (scanCode >= PMSCAN_PAD7) && (scanCode <= PMSCAN_PADPERIOD))
781 winMsg->wParam = ConvertNumPadKey(scanCode);
782
783 //@PF This looks ugly but this is just what we have in win32 both in win98/win2k
784 //what happens is that lParam is tweaked in win32 to contain some illegal codes
785 //I simply reproduce here all situation. Absolute values can be kept because
786 //Break scancode can be acheived only by pressing Ctrl-Break combination
787 if ((usPMScanCode == PMSCAN_BREAK) && !(flags & KC_KEYUP) && (flags & KC_CTRL)
788 && (fMsgRemoved && !(teb->o.odin.fTranslated)))
789 {
790 MSG extramsg;
791 memcpy(&extramsg, winMsg, sizeof(MSG));
792 // adjust our WM_CHAR code
793 extramsg.lParam = 0x01460001;
794
795 //After SetFocus(0), all keystrokes are converted in WM_SYS*
796 extramsg.message = (fIgnoreKeystrokes) ? WINWM_SYSCHAR : WINWM_CHAR;
797
798 setThreadQueueExtraCharMessage(teb, &extramsg);
799 // and finally adjust our WM_KEYDOWN code
800 winMsg->lParam = 0x01460001;
801 }
802
803 if (!(flags & KC_ALT))
804 {
805 //
806 // the Alt key is not pressed
807 // or no more pressed
808 //
809 if (flags & KC_KEYUP)
810 {
811 // check for a lonesome ALT key ...
812 // SvL: Only Left Alt; AltGr generates a WM_KEYUP when released
813 if ( (flags & KC_LONEKEY) &&
814 (winMsg->wParam == VK_LMENU_W) )
815 {
816 winMsg->message = WINWM_SYSKEYUP;
817 // held ALT-key when current key is released
818 // generates additional flag 0x2000000
819 // Note: PM seems to do this differently,
820 // KC_ALT is already reset
821 }
822 else
823 {
824 // send WM_KEYUP message
825 winMsg->message = WINWM_KEYUP;
826 }
827 winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, always 1 for a WM_KEYUP message
828 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
829 }
830 else if( scanCode == 0 )
831 {
832 //After SetFocus(0), all keystrokes are converted in WM_SYS*
833 winMsg->message = (fIgnoreKeystrokes) ? WINWM_SYSCHAR : WINWM_CHAR;
834 }
835 else
836 { // send WM_KEYDOWN message
837 winMsg->message = WINWM_KEYDOWN;
838
839 if (keyWasPressed)
840 winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, 1 means key was pressed
841
842 //Shift-Enter and possibly others need to have special handling
843 if (flags & KC_SHIFT)
844 {
845 if(fMsgRemoved && !(teb->o.odin.fTranslated))
846 {
847 dprintf(("PM: KC_SHIFT: %x",winMsg->wParam));
848 if (winMsg->wParam == VK_RETURN_W)
849 {
850 MSG extramsg;
851 memcpy(&extramsg, winMsg, sizeof(MSG));
852
853 //After SetFocus(0), all keystrokes are converted in WM_SYS*
854 extramsg.message = (fIgnoreKeystrokes) ? WINWM_SYSCHAR : WINWM_CHAR;
855
856 // insert message into the queue
857 setThreadQueueExtraCharMessage(teb, &extramsg);
858 winMsg->lParam &= 0x3FFFFFFF;
859 }
860 } // else ???
861 } // KC_SHIFT
862 else
863 {
864 // in case we handle Enter directly through PMKBDHOOK
865 if ((os2Msg->msg == WM_CHAR_SPECIAL) && (winMsg->wParam == VK_RETURN_W)
866 && (fMsgRemoved && !(teb->o.odin.fTranslated)))
867 {
868 MSG extramsg;
869 memcpy(&extramsg, winMsg, sizeof(MSG));
870
871 //After SetFocus(0), all keystrokes are converted in WM_SYS*
872 extramsg.message = (fIgnoreKeystrokes) ? WINWM_SYSCHAR : WINWM_CHAR;
873
874 // insert message into the queue
875 setThreadQueueExtraCharMessage(teb, &extramsg);
876 }
877 }
878 }
879 // if right alt is down, then we need to set the alt down bit too
880 // except for the fake Ctrl WM_CHAR sent for AltGr emulation
881 if (os2Msg->msg != WM_CHAR_SPECIAL_ALTGRCONTROL &&
882 (WinGetKeyState(HWND_DESKTOP, VK_ALTGRAF) & 0x8000))
883 {
884 winMsg->lParam |= WIN_KEY_ALTHELD;
885 }
886 }
887 else
888 {
889 //
890 // the Alt key is pressed
891 //
892 if (flags & KC_KEYUP)
893 {
894 //@@PF Note that without pmkbdhook there will not be correct message for Alt-Enter
895 winMsg->message = WINWM_SYSKEYUP;
896 winMsg->lParam |= WIN_KEY_PREVSTATE;
897 // No ALTHELD for Alt itself ;)
898 winMsg->lParam |= WIN_KEY_ALTHELD;
899 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
900 }
901 else
902 {
903 // send WM_SYSKEYDOWN message
904 winMsg->message = WINWM_SYSKEYDOWN;
905 if (keyWasPressed)
906 winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, 1 means key was pressed
907
908 // pressed ALT-key generates additional flag 0x2000000
909 // if the current window has keyboard focus
910 winMsg->lParam |= WIN_KEY_ALTHELD;
911 }
912 }
913#if 0
914 //
915 // AltGr needs special handling
916 //
917 // AltGr -> WM_KEYDOWN (VK_CONTROL), WM_KEYDOWN (VK_MENU)
918 // WM_SYSKEYUP (VK_CONTROL)
919 // WM_KEYUP (VK_MENU)
920 //
921 // Ctrl+AltGr -> WM_KEYDOWN (VK_CONTROL), WM_KEYUP (VK_CONTROL)
922 // WM_KEYDOWN (VK_MENU)
923 // WM_KEYUP (VK_MENU)
924 // WM_KEYUP (VK_CONTROL)
925 //
926 // AltGr+Ctrl -> WM_KEYDOWN (VK_CONTROL), WM_KEYDOWN (VK_MENU)
927 // WM_KEYDOWN (VK_CONTROL)
928 // WM_SYSKEYUP (VK_CONTROL)
929 // WM_SYSKEYUP (VK_CONTROL)
930 // WM_KEYUP (VK_MENU)
931 //
932 // AltGr down -> if Ctrl down, send WM_KEYUP (VK_CONTROL)
933 // endif
934 // Send WM_KEYDOWN (VK_CONTROL)
935 // Send WM_KEYDOWN (VK_MENU)
936 // AltGr up -> if !(Ctrl down before AltGr was pressed || Ctrl up)
937 // Send WM_SYSKEYUP (VK_CONTROL)
938 // endif
939 // Send WM_KEYDOWN (VK_MENU)
940 //
941 if(winMsg->wParam == VK_MENU_W && (winMsg->lParam & WIN_KEY_EXTENDED))
942 {//AltGr
943 if(GetKeyState(VK_CONTROL_W) & 0x8000)
944 {//Ctrl key pressed, send WM_KEYUP
945
946 }
947 }
948#endif
949
950 //After SetFocus(0), all keystrokes are converted in WM_SYS*
951 if(fIgnoreKeystrokes) {
952 if(winMsg->message == WINWM_KEYDOWN) {
953 winMsg->message = WINWM_SYSKEYDOWN;
954 }
955 else
956 if(winMsg->message == WINWM_KEYUP) {
957 winMsg->message = WINWM_SYSKEYUP;
958 }
959 }
960 break;
961 }
962
963 case WM_TIMER:
964//Why was this check here????
965// if (os2Msg->mp2)
966// {
967 BOOL sys;
968 ULONG id, proc;
969
970 if (TIMER_GetTimerInfo(os2Msg->hwnd,(ULONG)os2Msg->mp1,&sys,&id, &proc))
971 {
972 winMsg->wParam = (WPARAM)id;
973 winMsg->lParam = (LPARAM)proc;
974 winMsg->message= (sys) ? WINWM_SYSTIMER : WINWM_TIMER;
975 break;
976 }
977// }
978 goto dummymessage; //for caret blinking
979
980 case WM_SETWINDOWPARAMS:
981 {
982 WNDPARAMS *wndParams = (WNDPARAMS *)os2Msg->mp1;
983
984 if(wndParams->fsStatus & WPM_TEXT) {
985 winMsg->message = WINWM_SETTEXT;
986 winMsg->lParam = (LPARAM)wndParams->pszText;
987 break;
988 }
989 goto dummymessage;
990 }
991
992#if 0
993 case WM_QUERYWINDOWPARAMS:
994 {
995 PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
996 ULONG textlen;
997 PSZ wintext;
998
999 if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
1000 {
1001 if(wndpars->fsStatus & WPM_CCHTEXT)
1002 wndpars->cchText = win32wnd->MsgGetTextLength();
1003 if(wndpars->fsStatus & WPM_TEXT)
1004 wndpars->pszText = win32wnd->MsgGetText();
1005
1006 wndpars->fsStatus = 0;
1007 wndpars->cbCtlData = 0;
1008 wndpars->cbPresParams = 0;
1009 goto dummymessage;
1010 }
1011 }
1012#endif
1013
1014 case WM_PAINT:
1015 {
1016 if(win32wnd->IsWindowIconic()) {
1017 winMsg->message = WINWM_PAINTICON;
1018 }
1019 else winMsg->message = WINWM_PAINT;
1020 break;
1021 }
1022
1023 case WM_CONTEXTMENU:
1024 winMsg->message = WINWM_CONTEXTMENU;
1025 winMsg->wParam = win32wnd->getWindowHandle();
1026 winMsg->lParam = MAKELONG(winMsg->pt.x,winMsg->pt.y);
1027 break;
1028
1029 case WM_RENDERFMT:
1030 winMsg->message = WINWM_RENDERFORMAT;
1031 winMsg->wParam = (UINT) os2Msg->mp1;
1032 break;
1033
1034 case WM_RENDERALLFMTS:
1035 winMsg->message = WINWM_RENDERALLFORMATS;
1036 break;
1037
1038 case WM_DESTROYCLIPBOARD:
1039 winMsg->message = WINWM_DESTROYCLIPBOARD;
1040 break;
1041
1042 case WM_DRAWCLIPBOARD:
1043 winMsg->message = WINWM_DRAWCLIPBOARD;
1044 break;
1045
1046 case WM_HSCROLL:
1047 case WM_VSCROLL:
1048 //PF For win32 we support only vertical scrolling for WM_MOUSEWHEEL
1049 if (os2Msg->msg == WM_VSCROLL)
1050 {
1051 POINT CursorPoint;
1052 winMsg->message = WINWM_MOUSEWHEEL;
1053 if (OSLibWinQueryPointerPos(&CursorPoint))
1054 mapScreenPoint((OSLIBPOINT*)&CursorPoint);
1055
1056 if (SHORT2FROMMP(os2Msg->mp2) == SB_LINEDOWN)
1057 winMsg->wParam = MAKELONG(GetMouseKeyState(), -WHEEL_DELTA/OS2_WHEEL_CORRECTION);
1058 else
1059 if (SHORT2FROMMP(os2Msg->mp2) == SB_LINEUP)
1060 winMsg->wParam = MAKELONG(GetMouseKeyState(), WHEEL_DELTA/OS2_WHEEL_CORRECTION);
1061 else
1062 winMsg->wParam = MAKELONG(GetMouseKeyState(), 0);
1063
1064 winMsg->lParam = MAKELONG(CursorPoint.x, CursorPoint.y);
1065
1066 dprintf(("WM_MOUSEWHEEL message delta %d at (%d,%d)",HIWORD(winMsg->wParam),CursorPoint.x, CursorPoint.y));
1067 if (fMsgRemoved == MSG_REMOVE)
1068 {
1069 MSLLHOOKSTRUCT hook;
1070
1071 hook.pt.x = os2Msg->ptl.x & 0xFFFF;
1072 hook.pt.y = mapScreenY(os2Msg->ptl.y);
1073 if (SHORT2FROMMP(os2Msg->mp2) == SB_LINEDOWN)
1074 hook.mouseData = MAKELONG(GetMouseKeyState(), -WHEEL_DELTA/OS2_WHEEL_CORRECTION);
1075 else
1076 if (SHORT2FROMMP(os2Msg->mp2) == SB_LINEUP)
1077 hook.mouseData = MAKELONG(GetMouseKeyState(), WHEEL_DELTA/OS2_WHEEL_CORRECTION);
1078 else goto dummymessage; // IBM driver produces other messages as well sometimes
1079
1080 hook.flags = LLMHF_INJECTED;
1081 hook.time = winMsg->time;
1082 hook.dwExtraInfo = 0;
1083 if(HOOK_CallHooksW( WH_MOUSE_LL, HC_ACTION, WINWM_MOUSEWHEEL, (LPARAM)&hook))
1084 goto dummymessage; //hook swallowed message
1085 }
1086 break;
1087 }
1088 goto dummymessage; //eat this message
1089 break;
1090
1091 case WM_INITMENU:
1092 case WM_MENUSELECT:
1093 case WM_MENUEND:
1094 case WM_NEXTMENU:
1095 case WM_SYSCOLORCHANGE:
1096 case WM_SYSVALUECHANGED:
1097 case WM_SETSELECTION:
1098 case WM_PPAINT:
1099 case WM_PSETFOCUS:
1100 case WM_PSYSCOLORCHANGE:
1101 case WM_PSIZE:
1102 case WM_PACTIVATE:
1103 case WM_PCONTROL:
1104 case WM_HELP:
1105 case WM_APPTERMINATENOTIFY:
1106 case WM_PRESPARAMCHANGED:
1107 case WM_DRAWITEM:
1108 case WM_MEASUREITEM:
1109 case WM_CONTROLPOINTER:
1110 case WM_QUERYDLGCODE:
1111 case WM_SUBSTITUTESTRING:
1112 case WM_MATCHMNEMONIC:
1113 case WM_SAVEAPPLICATION:
1114 case WM_SEMANTICEVENT:
1115 default:
1116dummymessage:
1117 dprintf2(("dummy message %x %x %x %x", os2Msg->hwnd, os2Msg->msg, os2Msg->mp1, os2Msg->mp2));
1118 winMsg->message = 0;
1119 winMsg->wParam = 0;
1120 winMsg->lParam = 0;
1121 if(win32wnd) RELEASE_WNDOBJ(win32wnd);
1122 return FALSE;
1123 }
1124msgdone:
1125 if(win32wnd) RELEASE_WNDOBJ(win32wnd);
1126 return TRUE;
1127}
1128//******************************************************************************
1129//******************************************************************************
1130BOOL OSLibWinTranslateMessage(MSG *msg)
1131{
1132 TEB *teb;
1133 MSG extramsg;
1134 BOOL numPressed = (BOOL)(WinGetKeyState(HWND_DESKTOP,VK_NUMLOCK) & 1);
1135 teb = GetThreadTEB();
1136 if(!teb)
1137 return FALSE;
1138
1139 UCHAR ucPMScanCode = CHAR4FROMMP(teb->o.odin.os2msg.mp1);
1140 ULONG fl = SHORT1FROMMP(teb->o.odin.os2msg.mp1);
1141
1142
1143 //NOTE: These actually need to be posted so that the next message retrieved by GetMessage contains
1144 // the newly generated WM_CHAR message.
1145 if(!teb->o.odin.fTranslated &&
1146 teb->o.odin.os2msg.msg == WM_CHAR &&
1147 !((SHORT1FROMMP(teb->o.odin.os2msg.mp1) & KC_KEYUP) == KC_KEYUP))
1148 {
1149 //TranslatedMessage was called before DispatchMessage, so queue WM_CHAR message
1150 memcpy(&extramsg, msg, sizeof(MSG));
1151 extramsg.wParam = SHORT1FROMMP(teb->o.odin.os2msg.mp2);
1152 extramsg.lParam = 0;
1153
1154 // ESCAPE generates a WM_CHAR under windows, so take
1155 // special care for this here.
1156 switch (ucPMScanCode)
1157 {
1158 case PMSCAN_ESC:
1159 extramsg.wParam = VK_ESCAPE_W;
1160 fl |= KC_CHAR;
1161 break;
1162 }
1163
1164 // PF With NumLock off do not generate any WM_CHAR messages at all
1165 // PADMINUS,PADPLUS fall in range of PAD7..PADPERIOD but they should generate WM_CHAR
1166 // other PAD(X) buttons miss that range at all and thus generate WM_CHAR
1167 if (!numPressed && (ucPMScanCode != PMSCAN_PADMINUS) && (ucPMScanCode != PMSCAN_PADPLUS) &&
1168 (ucPMScanCode >= PMSCAN_PAD7) && (ucPMScanCode <= PMSCAN_PADPERIOD))
1169 return FALSE;
1170
1171 if(!(fl & KC_CHAR) && msg->message < WINWM_SYSKEYDOWN)
1172 {
1173 return FALSE;
1174 }
1175
1176 //the KC_COMPOSITE flag might be set; in that case this key will
1177 //be combined with the previous dead key, so we must use the scancode
1178 //(e.g. ^ on german keyboards)
1179 if((fl & (KC_VIRTUALKEY|KC_COMPOSITE)) == KC_VIRTUALKEY)
1180 {
1181 if(msg->wParam)
1182 {
1183 if ((msg->wParam >= VK_NUMPAD0_W) &&
1184 (msg->wParam <= VK_NUMPAD9_W))
1185 extramsg.wParam = msg->wParam - 0x30;
1186 else
1187 if (msg->wParam == VK_DECIMAL_W)
1188 extramsg.wParam = VK_DELETE_W;
1189 else
1190 /* PM Sends Bogus Things when pressing Shift+NUMAsterisk */
1191 if (msg->wParam != VK_MULTIPLY_W)
1192 extramsg.wParam = msg->wParam;
1193 }
1194 else
1195 extramsg.wParam = SHORT2FROMMP(teb->o.odin.os2msg.mp2);
1196 }
1197
1198
1199 //After SetFocus(0), all keystrokes are converted in WM_SYS*
1200 if(msg->message >= WINWM_SYSKEYDOWN || fIgnoreKeystrokes)
1201 extramsg.message = WINWM_SYSCHAR;
1202 else
1203 extramsg.message = WINWM_CHAR;
1204
1205 if(fl & KC_DEADKEY)
1206 extramsg.message++; //WM_DEADCHAR/WM_SYSDEADCHAR
1207
1208
1209 extramsg.lParam = msg->lParam & 0x00FFFFFF;
1210 if ((fl & KC_ALT) || (msg->lParam & WIN_KEY_ALTHELD))
1211 extramsg.lParam |= WIN_KEY_ALTHELD;
1212 if(fl & KC_PREVDOWN)
1213 extramsg.lParam |= WIN_KEY_PREVSTATE;
1214 if(fl & KC_KEYUP)
1215 extramsg.lParam |= (1<<31);
1216
1217 // insert message into the queue
1218 setThreadQueueExtraCharMessage(teb, &extramsg);
1219
1220 return TRUE;
1221 }
1222 return FALSE;
1223}
1224//******************************************************************************
1225//******************************************************************************
1226
Note: See TracBrowser for help on using the repository browser.