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

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

KSO: Implemented WM_COPYDATA

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