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

Last change on this file since 2200 was 2200, checked in by sandervl, 26 years ago

Message handling rewrite

File size: 23.1 KB
Line 
1/* $Id: oslibmsgtranslate.cpp,v 1.1 1999-12-24 18:42:46 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 <os2.h>
21#include <os2wrap.h>
22#include <string.h>
23#include <misc.h>
24#include "oslibmsg.h"
25#include <win32wnd.h>
26#include "oslibutil.h"
27#include "timer.h"
28#include <thread.h>
29#include <wprocess.h>
30#include "pmwindow.h"
31#include "oslibwin.h"
32
33//Used for key translation while processing WM_CHAR message
34USHORT virtualKeyTable [66] = {
35 0x00, // OS/2 VK Win32 VK, Entry 0 is not used
36 0x01, // VK_BUTTON1 VK_LBUTTON
37 0x02, // VK_BUTTON2 VK_RBUTTON
38 0x04, // VK_BUTTON3 VK_MBUTTON
39 0x03, // VK_BREAK VK_CANCEL
40 0x08, // VK_BACKSPACE VK_BACK
41 0x09, // VK_TAB VK_TAB
42 0x00, // VK_BACKTAB No equivalent!
43 0x0A, // VK_NEWLINE 0x0A (no VK_* def)
44 0x10, // VK_SHIFT VK_SHIFT
45 0x11, // VK_CTRL VK_CONTROL
46 0x12, // VK_ALT VK_MENU, best match I guess
47 0x12, // VK_ALTGRAF VK_MENU, best match I guess
48 0x13, // VK_PAUSE VK_PAUSE
49 0x14, // VK_CAPSLOCK VK_CAPITAL
50 0x1B, // VK_ESC VK_ESCAPE
51 0x20, // VK_SPACE VK_SPACE
52 0x21, // VK_PAGEUP VK_PRIOR
53 0x22, // VK_PAGEDOWN VK_NEXT
54 0x23, // VK_END VK_END
55 0x24, // VK_HOME VK_HOME
56 0x25, // VK_LEFT VK_LEFT
57 0x26, // VK_UP VK_UP
58 0x27, // VK_RIGHT VK_RIGHT
59 0x28, // VK_DOWN VK_DOWN
60 0x2C, // VK_PRINTSCRN VK_SNAPSHOT
61 0x2D, // VK_INSERT VK_INSERT
62 0x2E, // VK_DELETE VK_DELETE
63 0x91, // VK_SCRLLOCK VK_SCROLL
64 0x90, // VK_NUMLOCK VK_NUMLOCK
65 0x0D, // VK_ENTER VK_RETURN
66 0x00, // VK_SYSRQ No equivalent!
67 0x70, // VK_F1 VK_F1
68 0x71, // VK_F2 VK_F2
69 0x72, // VK_F3 VK_F3
70 0x73, // VK_F4 VK_F4
71 0x74, // VK_F5 VK_F5
72 0x75, // VK_F6 VK_F6
73 0x76, // VK_F7 VK_F7
74 0x77, // VK_F8 VK_F8
75 0x78, // VK_F9 VK_F9
76 0x79, // VK_F10 VK_F10
77 0x7A, // VK_F11 VK_F11
78 0x7B, // VK_F12 VK_F12
79 0x7C, // VK_F13 VK_F13
80 0x7D, // VK_F14 VK_F14
81 0x7E, // VK_F15 VK_F15
82 0x7F, // VK_F16 VK_F16
83 0x80, // VK_F17 VK_F17
84 0x81, // VK_F18 VK_F18
85 0x82, // VK_F19 VK_F19
86 0x83, // VK_F20 VK_F20
87 0x84, // VK_F21 VK_F21
88 0x85, // VK_F22 VK_F22
89 0x86, // VK_F23 VK_F23
90 0x87, // VK_F24 VK_F24
91 0x00, // VK_ENDDRAG No equivalent!
92 0x0C, // VK_CLEAR VK_CLEAR
93 0xF9, // VK_EREOF VK_EREOF
94 0xFD, // VK_PA1 VK_PA1
95 0xF6, // VK_ATTN VK_ATTN
96 0xF7, // VK_CRSEL VK_CRSEL
97 0xF8, // VK_EXSEL VK_EXSEL
98 0x00, // VK_COPY No equivalent!
99 0x00, // VK_BLK1 No equivalent!
100 0x00}; // VK_BLK2 No equivalent!
101
102//******************************************************************************
103//******************************************************************************
104BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs)
105{
106 Win32BaseWindow *win32wnd = 0;
107 OSLIBPOINT point, ClientPoint;
108 POSTMSG_PACKET *packet;
109 THDB *thdb = (THDB *)pThdb;
110 int i;
111
112 memset(winMsg, 0, sizeof(MSG));
113 win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(os2Msg->hwnd);
114 if((win32wnd == 0 && os2Msg->msg != WM_CREATE))
115 {
116 goto dummymessage; //not a win32 client window
117 }
118 winMsg->time = os2Msg->time;
119 winMsg->pt.x = os2Msg->ptl.x;
120 winMsg->pt.y = ScreenHeight - os2Msg->ptl.y - 1;
121 if(win32wnd) //==0 for WM_CREATE
122 winMsg->hwnd = win32wnd->getWindowHandle();
123
124 switch(os2Msg->msg)
125 {
126 case WIN32APP_POSTMSG:
127 {
128 packet = (POSTMSG_PACKET *)os2Msg->mp2;
129 if(packet && (ULONG)os2Msg->mp1 == WIN32PM_MAGIC) {
130 winMsg->message = packet->Msg;
131 winMsg->wParam = packet->wParam;
132 winMsg->lParam = packet->lParam;
133 break;
134 }
135 goto dummymessage;
136 }
137
138 //OS/2 msgs
139 case WM_CREATE:
140 {
141 if(thdb->newWindow == 0) {
142 DebugInt3();
143 goto dummymessage;
144 }
145
146 win32wnd = (Win32BaseWindow *)thdb->newWindow;
147
148 winMsg->message = WINWM_CREATE;
149 winMsg->hwnd = win32wnd->getWindowHandle();
150 winMsg->wParam = 0;
151 winMsg->lParam = (LPARAM)win32wnd->tmpcs;
152 break;
153 }
154
155 case WM_QUIT:
156 winMsg->message = WINWM_QUIT;
157 break;
158
159 case WM_CLOSE:
160 winMsg->message = WINWM_CLOSE;
161 break;
162
163 case WM_DESTROY:
164 winMsg->message = WINWM_DESTROY;
165 break;
166
167 case WM_ENABLE:
168 winMsg->message = WINWM_ENABLE;
169 winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
170 break;
171
172 case WM_SHOW:
173 winMsg->message = WINWM_SHOWWINDOW;
174 winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
175 break;
176
177 case WM_WINDOWPOSCHANGED:
178 {
179 PSWP pswp = (PSWP)os2Msg->mp1;
180 SWP swpOld = *(pswp + 1);
181 HWND hParent = NULLHANDLE;
182 LONG yDelta = pswp->cy - swpOld.cy;
183 LONG xDelta = pswp->cx - swpOld.cx;
184
185 dprintf(("OS2: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
186
187 if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) goto dummymessage;
188
189 if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
190 if (win32wnd->isChild()) {
191 if(win32wnd->getParent()) {
192 hParent = win32wnd->getParent()->getOS2WindowHandle();
193 }
194 else goto dummymessage; //parent has just been destroyed
195 }
196 }
197 OSLibMapSWPtoWINDOWPOS(pswp, &thdb->wp, &swpOld, hParent, win32wnd->getOS2FrameWindowHandle());
198
199 if (!win32wnd->CanReceiveSizeMsgs()) goto dummymessage;
200
201 dprintf(("Set client rectangle to (%d,%d)(%d,%d)", swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy));
202 win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
203
204 thdb->wp.hwnd = win32wnd->getWindowHandle();
205 if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
206 {
207 Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
208 thdb->wp.hwndInsertAfter = wndAfter->getWindowHandle();
209 }
210
211 PRECT lpRect = win32wnd->getWindowRect();
212 //SvL: Only send it when the client has changed & the frame hasn't
213 // If the frame size/position has changed, pmframe.cpp will send
214 // this message
215 if(lpRect->right == thdb->wp.x+thdb->wp.cx && lpRect->bottom == thdb->wp.y+thdb->wp.cy) {
216 winMsg->message = WINWM_WINDOWPOSCHANGED;
217 winMsg->lParam = (LPARAM)&thdb->wp;
218 }
219 else {
220 win32wnd->setWindowRect(thdb->wp.x, thdb->wp.y, thdb->wp.x+thdb->wp.cx, thdb->wp.y+thdb->wp.cy);
221 goto dummymessage;
222 }
223 }
224
225 case WM_ACTIVATE:
226 {
227 HWND hwndActivate = (HWND)os2Msg->mp2;
228 BOOL fMinimized = FALSE;
229
230 if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
231 //another (non-win32) application's window
232 //set to NULL (allowed according to win32 SDK) to avoid problems
233 hwndActivate = NULL;
234 }
235 else hwndActivate = Win32BaseWindow::OS2ToWin32Handle(hwndActivate);
236
237 if(WinQueryWindowULong(os2Msg->hwnd, QWL_STYLE) & WS_MINIMIZED)
238 {
239 fMinimized = TRUE;
240 }
241
242 winMsg->message = WINWM_ACTIVATE;
243 winMsg->wParam = MAKELONG((SHORT1FROMMP(os2Msg->mp1)) ? WA_ACTIVE_W : WA_INACTIVE_W, fMinimized);
244 winMsg->lParam = (LPARAM)hwndActivate;
245 break;
246 }
247
248 case WM_SETFOCUS:
249 {
250 HWND hwndFocus = (HWND)os2Msg->mp1;
251
252 if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
253 //another (non-win32) application's window
254 //set to NULL (allowed according to win32 SDK) to avoid problems
255 hwndFocus = NULL;
256 }
257 else hwndFocus = Win32BaseWindow::OS2ToWin32Handle(hwndFocus);
258
259 if((ULONG)os2Msg->mp2 == TRUE) {
260 winMsg->message = WINWM_SETFOCUS;
261 winMsg->wParam = (WPARAM)hwndFocus;
262 }
263 else {
264 winMsg->message = WINWM_KILLFOCUS;
265 winMsg->wParam = (WPARAM)hwndFocus;
266 }
267 break;
268 }
269
270 //**************************************************************************
271 //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
272 //**************************************************************************
273 case WM_BUTTON1DOWN:
274 case WM_BUTTON1UP:
275 case WM_BUTTON1DBLCLK:
276 case WM_BUTTON2DOWN:
277 case WM_BUTTON2UP:
278 case WM_BUTTON2DBLCLK:
279 case WM_BUTTON3DOWN:
280 case WM_BUTTON3UP:
281 case WM_BUTTON3DBLCLK:
282 //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
283 if(win32wnd->lastHitTestVal != HTCLIENT_W) {
284 winMsg->message = WINWM_NCLBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
285 winMsg->lParam = MAKELONG(winMsg->pt.x, winMsg->pt.y); //screen coordinates
286 }
287 else {
288 point.x = (*(POINTS *)&os2Msg->mp1).x;
289 point.y = (*(POINTS *)&os2Msg->mp1).y;
290 ClientPoint.x = point.x;
291 ClientPoint.y = MapOS2ToWin32Y(os2Msg->hwnd, 1, point.y);
292
293 winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
294 winMsg->lParam = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
295 }
296
297 break;
298
299 case WM_BUTTON2MOTIONSTART:
300 case WM_BUTTON2MOTIONEND:
301 case WM_BUTTON2CLICK:
302 case WM_BUTTON1MOTIONSTART:
303 case WM_BUTTON1MOTIONEND:
304 case WM_BUTTON1CLICK:
305 case WM_BUTTON3MOTIONSTART:
306 case WM_BUTTON3MOTIONEND:
307 case WM_BUTTON3CLICK:
308 goto dummymessage;
309
310 case WM_MOUSEMOVE:
311 {
312 ULONG keystate = 0, setcursormsg = WINWM_MOUSEMOVE;
313
314 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000)
315 keystate |= MK_LBUTTON_W;
316 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000)
317 keystate |= MK_RBUTTON_W;
318 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000)
319 keystate |= MK_MBUTTON_W;
320 if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
321 keystate |= MK_SHIFT_W;
322 if(WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
323 keystate |= MK_CONTROL_W;
324
325 //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
326 if(win32wnd->lastHitTestVal != HTCLIENT_W) {
327 setcursormsg = WINWM_NCMOUSEMOVE;
328 winMsg->wParam = (WPARAM)win32wnd->lastHitTestVal;
329 }
330 else winMsg->wParam = (WPARAM)keystate;
331 //OS/2 Window coordinates -> Win32 Window coordinates
332 winMsg->message = setcursormsg;
333 winMsg->lParam = MAKELONG(SHORT1FROMMP(os2Msg->mp1), MapOS2ToWin32Y(win32wnd, SHORT2FROMMP(os2Msg->mp1)));
334 break;
335 }
336
337 case WM_CONTROL:
338 case WM_COMMAND:
339 if(SHORT1FROMMP(os2Msg->mp2) == CMDSRC_MENU) {
340 winMsg->message = WINWM_COMMAND;
341 winMsg->wParam = (WPARAM)SHORT1FROMMP(os2Msg->mp1); //id
342 break;
343 }
344 //todo controls
345 goto dummymessage;
346
347 case WM_SYSCOMMAND:
348 {
349 ULONG x = 0, y = 0;
350 ULONG win32sc;
351
352 if(SHORT2FROMMP(os2Msg->mp2) == TRUE) {//syscommand caused by mouse action
353 POINTL pointl;
354 WinQueryPointerPos(HWND_DESKTOP, &pointl);
355 x = pointl.x;
356 y = ScreenHeight - y;
357 }
358 switch(SHORT1FROMMP(os2Msg->mp1)) {
359 case SC_MOVE:
360 win32sc = SC_MOVE_W;
361 break;
362 case SC_CLOSE:
363 win32sc = SC_CLOSE_W;
364 break;
365 case SC_MAXIMIZE:
366 win32sc = SC_MAXIMIZE_W;
367 break;
368 case SC_MINIMIZE:
369 win32sc = SC_MINIMIZE_W;
370 break;
371 case SC_NEXTFRAME:
372 case SC_NEXTWINDOW:
373 win32sc = SC_NEXTWINDOW_W;
374 break;
375 case SC_RESTORE:
376 win32sc = SC_RESTORE_W;
377 break;
378 case SC_TASKMANAGER:
379 win32sc = SC_TASKLIST_W;
380 break;
381 default:
382 goto dummymessage;
383 }
384 winMsg->message = WINWM_SYSCOMMAND;
385 winMsg->wParam = (WPARAM)win32sc;
386 winMsg->lParam = MAKELONG((USHORT)x, (USHORT)y);
387 break;
388 }
389 case WM_CHAR:
390 {
391 ULONG repeatCount=0, virtualKey=0, keyFlags=0, scanCode=0;
392 ULONG flags = SHORT1FROMMP(os2Msg->mp1);
393 BOOL keyWasPressed;
394 char c;
395
396 thdb->fTranslated = FALSE;
397 repeatCount = CHAR3FROMMP(os2Msg->mp1);
398 scanCode = CHAR4FROMMP(os2Msg->mp1);
399 keyWasPressed = ((SHORT1FROMMP (os2Msg->mp1) & KC_PREVDOWN) == KC_PREVDOWN);
400
401 dprintf(("PM: WM_CHAR: %x %x %d %x", SHORT1FROMMP(os2Msg->mp2), SHORT2FROMMP(os2Msg->mp2), repeatCount, scanCode));
402 dprintf(("PM: WM_CHAR: %x", flags));
403
404 // vitali add begin
405 if ( ( SHORT1FROMMP(os2Msg->mp2) & 0x0FF ) == 0x0E0 )
406 {
407 // an extended key ( arrows, ins, del and so on )
408 // get "virtual" scancode from character code cause
409 // for "regular" keys they are equal
410 scanCode = ( SHORT1FROMMP(os2Msg->mp2) >> 8) & 0x0FF;
411 }
412 // vitali add end
413
414 // both WM_KEYUP & WM_KEYDOWN want a virtual key, find the right Win32 virtual key
415 // given the OS/2 virtual key and OS/2 character
416
417 //if (((SHORT1FROMMP (mp1) & KC_CHAR) == KC_CHAR) ||
418 // ((SHORT1FROMMP (mp1) & KC_LONEKEY) == KC_LONEKEY))
419 c = 0;
420 if ((SHORT1FROMMP (os2Msg->mp1) & 0xFF) != 0)
421 {
422 c = SHORT1FROMMP (os2Msg->mp2);
423 if ((c >= 'A') && (c <= 'Z')) {
424 virtualKey = c;
425 goto VirtualKeyFound;
426 }
427 if ((c >='a') && (c <= 'z')) {
428 virtualKey = c - 32; // make it uppercase
429 goto VirtualKeyFound;
430 }
431 if ((c >= '0') && (c <= '9')) {
432 virtualKey = c;
433 goto VirtualKeyFound;
434 }
435 }
436
437 // convert OS/2 virtual keys to Win32 virtual key
438 if (SHORT2FROMMP (os2Msg->mp2) <= VK_BLK2)
439 virtualKey = virtualKeyTable [SHORT2FROMMP (os2Msg->mp2)];
440
441VirtualKeyFound:
442 dprintf (("VIRTUALKEYFOUND:(%x)", virtualKey));
443
444 winMsg->wParam = virtualKey;
445 winMsg->lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount
446 winMsg->lParam |= (scanCode & 0x0FF) << 16; // bit 16-23, scancode
447 win32wnd->setExtendedKey(virtualKey, (ULONG *)&winMsg->lParam);
448
449 if(!(SHORT1FROMMP(os2Msg->mp1) & KC_ALT))
450 {
451 //
452 // the Alt key is not pressed
453 //
454 if ((flags & KC_KEYUP) == KC_KEYUP) {
455 // send WM_KEYUP message
456
457 winMsg->message = WINWM_KEYUP;
458 winMsg->lParam |= 1 << 30; // bit 30, previous state, always 1 for a WM_KEYUP message
459 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
460 }
461 else {
462 // send WM_KEYDOWN message
463 winMsg->message = WINWM_KEYDOWN;
464 if (keyWasPressed)
465 winMsg->lParam |= 1 << 30; // bit 30, previous state, 1 means key was pressed
466 }
467 }
468 else {
469 //
470 // the Alt key is pressed
471 //
472 if ((flags & KC_KEYUP) == KC_KEYUP) {
473 // send WM_SYSKEYUP message
474
475 winMsg->message = WINWM_SYSKEYUP;
476 winMsg->lParam |= 1 << 30; // bit 30, previous state, always 1 for a WM_KEYUP message
477 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
478 }
479 else {
480 // send WM_SYSKEYDOWN message
481 winMsg->message = WINWM_SYSKEYDOWN;
482 if (keyWasPressed)
483 winMsg->lParam |= 1 << 30; // bit 30, previous state, 1 means key was pressed
484 }
485 }
486
487 break;
488 }
489
490 case WM_INITMENU:
491 winMsg->message = WINWM_INITMENU;
492 winMsg->wParam = (WPARAM)os2Msg->mp2; //hMenu
493 break;
494
495 case WM_MENUSELECT:
496 case WM_MENUEND:
497 case WM_NEXTMENU:
498 goto dummymessage;
499
500 case WM_TIMER:
501 if (os2Msg->mp2)
502 {
503 BOOL sys;
504 ULONG id;
505
506 if (TIMER_GetTimerInfo(os2Msg->hwnd,(ULONG)os2Msg->mp1,&sys,&id))
507 {
508 winMsg->wParam = (WPARAM)id;
509 winMsg->message= (sys) ? WINWM_SYSTIMER : WINWM_TIMER;
510 break;
511 }
512 }
513 goto dummymessage;
514
515 case WM_SETWINDOWPARAMS:
516 {
517 WNDPARAMS *wndParams = (WNDPARAMS *)os2Msg->mp1;
518
519 if(wndParams->fsStatus & WPM_TEXT) {
520 win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText);
521 break;
522 }
523 goto dummymessage;
524 }
525
526#if 0
527 case WM_QUERYWINDOWPARAMS:
528 {
529 PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
530 ULONG textlen;
531 PSZ wintext;
532
533 if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
534 {
535 if(wndpars->fsStatus & WPM_CCHTEXT)
536 wndpars->cchText = win32wnd->MsgGetTextLength();
537 if(wndpars->fsStatus & WPM_TEXT)
538 wndpars->pszText = win32wnd->MsgGetText();
539
540 wndpars->fsStatus = 0;
541 wndpars->cbCtlData = 0;
542 wndpars->cbPresParams = 0;
543 goto dummymessage;
544 }
545 }
546#endif
547
548 case WM_PAINT:
549 {
550 if(win32wnd->IsIconic()) {
551 winMsg->message = WINWM_PAINTICON;
552 }
553 else winMsg->message = WINWM_PAINT;
554 break;
555 }
556
557 case WM_HITTEST:
558 // Only send this message if the window is enabled
559 if (WinIsWindowEnabled(os2Msg->hwnd))
560 {
561 OSLIBPOINT pt;
562 pt.x = (*(POINTS *)&os2Msg->mp1).x;
563 pt.y = (*(POINTS *)&os2Msg->mp1).y;
564 MapOS2ToWin32Point( OSLIB_HWND_DESKTOP, os2Msg->hwnd, &pt);
565 winMsg->message = WINWM_NCHITTEST;
566 winMsg->lParam = MAKELONG((USHORT)pt.x, (USHORT)pt.y);
567 break;
568 }
569 goto dummymessage;
570
571 case WM_CONTEXTMENU:
572 {
573 POINTL pt;
574
575 pt.x = (*(POINTS *)&os2Msg->mp1).x;
576 pt.y = (*(POINTS *)&os2Msg->mp1).y;
577 WinMapWindowPoints(os2Msg->hwnd,HWND_DESKTOP,&pt,1);
578 pt.y = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN) - pt.y -1;
579 winMsg->message = WINWM_CONTEXTMENU;
580 winMsg->wParam = (WPARAM)win32wnd->getWindowHandle();
581 winMsg->lParam = MAKELONG((USHORT)pt.x, (USHORT)pt.y);
582 break;
583 }
584
585 case WM_SYSCOLORCHANGE:
586 case WM_SYSVALUECHANGED:
587 case WM_SETSELECTION:
588 case WM_PPAINT:
589 case WM_PSETFOCUS:
590 case WM_PSYSCOLORCHANGE:
591 case WM_PSIZE:
592 case WM_PACTIVATE:
593 case WM_PCONTROL:
594 case WM_HELP:
595 case WM_APPTERMINATENOTIFY:
596 case WM_PRESPARAMCHANGED:
597 case WM_DRAWITEM:
598 case WM_MEASUREITEM:
599 case WM_CONTROLPOINTER:
600 case WM_QUERYDLGCODE:
601 case WM_SUBSTITUTESTRING:
602 case WM_MATCHMNEMONIC:
603 case WM_SAVEAPPLICATION:
604 case WM_SEMANTICEVENT:
605 default:
606dummymessage:
607 return FALSE;
608 }
609 return TRUE;
610}
611//******************************************************************************
612//******************************************************************************
613BOOL OSLibWinTranslateMessage(MSG *msg)
614{
615 THDB *thdb;
616
617 thdb = GetThreadTHDB();
618 if(!thdb) {
619 return FALSE;
620 }
621 //NOTE: These actually need to be posted so that the next message retrieved by GetMessage contains
622 // the newly generated WM_CHAR message.
623 if(!thdb->fTranslated && MsgThreadPtr->msg == WM_CHAR && !((SHORT1FROMMP(MsgThreadPtr->mp1) & KC_KEYUP) == KC_KEYUP))
624 {//TranslatedMessage was called before DispatchMessage, so queue WM_CHAR message
625 ULONG fl = SHORT1FROMMP(MsgThreadPtr->mp1);
626 MSG extramsg;
627
628 memcpy(&extramsg, msg, sizeof(MSG));
629 extramsg.wParam = SHORT1FROMMP(MsgThreadPtr->mp2);
630 extramsg.lParam = 0;
631
632 if(!(fl & KC_CHAR)) {
633 return FALSE;
634 }
635
636 if(fl & KC_VIRTUALKEY) {
637 if(msg->wParam)
638 extramsg.wParam = msg->wParam;
639 else extramsg.wParam = SHORT2FROMMP(MsgThreadPtr->mp2);
640 }
641
642 if(msg->message >= WINWM_SYSKEYDOWN) {
643 extramsg.message = WINWM_SYSCHAR;
644 }
645 else extramsg.message = WINWM_CHAR;
646
647 if(fl & KC_DEADKEY) {
648 extramsg.message++; //WM_DEADCHAR/WM_SYSDEADCHAR
649 }
650
651 extramsg.lParam = msg->lParam & 0x00FFFFFF;
652 if(fl & KC_ALT)
653 extramsg.lParam |= (1<<29);
654 if(fl & KC_PREVDOWN)
655 extramsg.lParam |= (1<<30);
656 if(fl & KC_KEYUP)
657 extramsg.lParam |= (1<<31);
658
659 thdb->fTranslated = TRUE;
660 memcpy(&thdb->msgWCHAR, &extramsg, sizeof(MSG));
661 return TRUE;
662 }
663 return FALSE;
664}
665//******************************************************************************
666//******************************************************************************
667
Note: See TracBrowser for help on using the repository browser.