source: trunk/src/user32/new/oslibmsgtranslate.cpp@ 2335

Last change on this file since 2335 was 2335, checked in by cbratschi, 26 years ago

single frame works now

File size: 24.6 KB
Line 
1/* $Id: oslibmsgtranslate.cpp,v 1.5 2000-01-05 21:25:04 cbratschi 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 fMsgRemoved)
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) win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(os2Msg->hwnd);
115 //PostThreadMessage posts WIN32APP_POSTMSG msg without window handle
116 if((win32wnd == 0) && (os2Msg->msg != WM_CREATE) && (os2Msg->msg != WIN32APP_POSTMSG))
117 {
118 goto dummymessage; //not a win32 client window
119 }
120 winMsg->time = os2Msg->time;
121 winMsg->pt.x = os2Msg->ptl.x;
122 winMsg->pt.y = mapScreenY(os2Msg->ptl.y);
123
124 if(win32wnd) //==0 for WM_CREATE
125 winMsg->hwnd = win32wnd->getWindowHandle();
126
127 if (win32wnd && (os2Msg->hwnd == win32wnd->getOS2FrameWindowHandle()))
128 {
129 //special frame messages
130
131 switch (os2Msg->msg)
132 {
133 case WM_BUTTON1DOWN:
134 case WM_BUTTON1UP:
135 case WM_BUTTON1DBLCLK:
136 case WM_BUTTON2DOWN:
137 case WM_BUTTON2UP:
138 case WM_BUTTON2DBLCLK:
139 case WM_BUTTON3DOWN:
140 case WM_BUTTON3UP:
141 case WM_BUTTON3DBLCLK:
142 //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
143 if((win32wnd->lastHitTestVal != HTCLIENT_W) && (WinQueryCapture(HWND_DESKTOP) != win32wnd->getOS2WindowHandle())) {
144 winMsg->message = WINWM_NCLBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
145 winMsg->wParam = win32wnd->lastHitTestVal;
146 winMsg->lParam = MAKELONG(winMsg->pt.x, winMsg->pt.y); //screen coordinates
147 }
148 else {
149 point.x = (*(POINTS *)&os2Msg->mp1).x;
150 point.y = (*(POINTS *)&os2Msg->mp1).y;
151 ClientPoint.x = point.x;
152 ClientPoint.y = mapOS2ToWin32Y(os2Msg->hwnd,win32wnd->getOS2WindowHandle(),point.y);
153
154 winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
155 winMsg->lParam = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
156 }
157
158 return TRUE;
159
160 case WM_BUTTON2MOTIONSTART:
161 case WM_BUTTON2MOTIONEND:
162 case WM_BUTTON2CLICK:
163 case WM_BUTTON1MOTIONSTART:
164 case WM_BUTTON1MOTIONEND:
165 case WM_BUTTON1CLICK:
166 case WM_BUTTON3MOTIONSTART:
167 case WM_BUTTON3MOTIONEND:
168 case WM_BUTTON3CLICK:
169 goto dummymessage;
170
171 case WM_MOUSEMOVE:
172 {
173 ULONG keystate = 0, setcursormsg = WINWM_MOUSEMOVE;
174
175 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000)
176 keystate |= MK_LBUTTON_W;
177 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000)
178 keystate |= MK_RBUTTON_W;
179 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000)
180 keystate |= MK_MBUTTON_W;
181 if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
182 keystate |= MK_SHIFT_W;
183 if(WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
184 keystate |= MK_CONTROL_W;
185
186 //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
187 if((win32wnd->lastHitTestVal != HTCLIENT_W) && (WinQueryCapture(HWND_DESKTOP) != win32wnd->getOS2WindowHandle()))
188 {
189 setcursormsg = WINWM_NCMOUSEMOVE;
190 winMsg->wParam = (WPARAM)win32wnd->lastHitTestVal;
191 winMsg->lParam = MAKELONG(winMsg->pt.x,winMsg->pt.y);
192 } else
193 {
194 winMsg->wParam = (WPARAM)keystate;
195 winMsg->lParam = MAKELONG(SHORT1FROMMP(os2Msg->mp1),mapOS2ToWin32Y(win32wnd->getOS2FrameWindowHandle(),win32wnd->getOS2WindowHandle(),SHORT2FROMMP(os2Msg->mp1)));
196 }
197 //OS/2 Window coordinates -> Win32 Window coordinates
198 winMsg->message = setcursormsg;
199 return TRUE;
200 }
201
202 case WM_PAINT:
203 {
204 winMsg->message = WINWM_NCPAINT;
205 return TRUE;
206 }
207
208 case WM_HITTEST:
209 {
210 winMsg->message = WINWM_NCHITTEST;
211 winMsg->wParam = 0;
212 winMsg->lParam = MAKELONG(winMsg->pt.x,winMsg->pt.y);
213 return TRUE;
214 }
215 }
216 //do normal translation for all other messages
217 }
218
219 switch(os2Msg->msg)
220 {
221 case WIN32APP_POSTMSG:
222 {
223 packet = (POSTMSG_PACKET *)os2Msg->mp2;
224 if(packet && ((ULONG)os2Msg->mp1 == WIN32MSG_MAGICA || (ULONG)os2Msg->mp1 == WIN32MSG_MAGICW)) {
225 winMsg->message = packet->Msg;
226 winMsg->wParam = packet->wParam;
227 winMsg->lParam = packet->lParam;
228 if(fMsgRemoved == MSG_REMOVE) free(packet); //free the shared memory here
229 break;
230 }
231 goto dummymessage;
232 }
233
234 //OS/2 msgs
235 case WM_CREATE:
236 {
237 if(thdb->newWindow == 0) {
238 DebugInt3();
239 goto dummymessage;
240 }
241
242 win32wnd = (Win32BaseWindow *)thdb->newWindow;
243
244 winMsg->message = WINWM_CREATE;
245 winMsg->hwnd = win32wnd->getWindowHandle();
246 winMsg->wParam = 0;
247 winMsg->lParam = (LPARAM)win32wnd->tmpcs;
248 break;
249 }
250
251 case WM_QUIT:
252 winMsg->message = WINWM_QUIT;
253 break;
254
255 case WM_CLOSE:
256 winMsg->message = WINWM_CLOSE;
257 break;
258
259 case WM_DESTROY:
260 winMsg->message = WINWM_DESTROY;
261 break;
262
263 case WM_ENABLE:
264 winMsg->message = WINWM_ENABLE;
265 winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
266 break;
267
268 case WM_SHOW:
269 winMsg->message = WINWM_SHOWWINDOW;
270 winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
271 break;
272
273 case WM_WINDOWPOSCHANGED:
274 goto dummymessage;
275
276 case WM_ACTIVATE:
277 {
278 HWND hwndActivate = (HWND)os2Msg->mp2;
279 BOOL fMinimized = FALSE;
280
281 if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
282 //another (non-win32) application's window
283 //set to NULL (allowed according to win32 SDK) to avoid problems
284 hwndActivate = NULL;
285 }
286 else hwndActivate = Win32BaseWindow::OS2ToWin32Handle(hwndActivate);
287
288 if(WinQueryWindowULong(os2Msg->hwnd, QWL_STYLE) & WS_MINIMIZED)
289 {
290 fMinimized = TRUE;
291 }
292
293 winMsg->message = WINWM_ACTIVATE;
294 winMsg->wParam = MAKELONG((SHORT1FROMMP(os2Msg->mp1)) ? WA_ACTIVE_W : WA_INACTIVE_W, fMinimized);
295 winMsg->lParam = (LPARAM)hwndActivate;
296 break;
297 }
298
299 case WM_SETFOCUS:
300 {
301 HWND hwndFocus = (HWND)os2Msg->mp1;
302
303 if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
304 //another (non-win32) application's window
305 //set to NULL (allowed according to win32 SDK) to avoid problems
306 hwndFocus = NULL;
307 }
308 else hwndFocus = Win32BaseWindow::OS2ToWin32Handle(hwndFocus);
309
310 if((ULONG)os2Msg->mp2 == TRUE) {
311 winMsg->message = WINWM_SETFOCUS;
312 winMsg->wParam = (WPARAM)hwndFocus;
313 }
314 else {
315 winMsg->message = WINWM_KILLFOCUS;
316 winMsg->wParam = (WPARAM)hwndFocus;
317 }
318 break;
319 }
320
321 //**************************************************************************
322 //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
323 //**************************************************************************
324 case WM_BUTTON1DOWN:
325 case WM_BUTTON1UP:
326 case WM_BUTTON1DBLCLK:
327 case WM_BUTTON2DOWN:
328 case WM_BUTTON2UP:
329 case WM_BUTTON2DBLCLK:
330 case WM_BUTTON3DOWN:
331 case WM_BUTTON3UP:
332 case WM_BUTTON3DBLCLK:
333 //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
334 if((win32wnd->lastHitTestVal != HTCLIENT_W) && (WinQueryCapture(HWND_DESKTOP) != win32wnd->getOS2WindowHandle())) {
335 winMsg->message = WINWM_NCLBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
336 winMsg->wParam = win32wnd->lastHitTestVal;
337 winMsg->lParam = MAKELONG(winMsg->pt.x, winMsg->pt.y); //screen coordinates
338 }
339 else {
340 point.x = (*(POINTS *)&os2Msg->mp1).x;
341 point.y = (*(POINTS *)&os2Msg->mp1).y;
342 ClientPoint.x = point.x;
343 ClientPoint.y = mapY(os2Msg->hwnd,point.y);
344
345 winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
346 winMsg->lParam = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
347 }
348
349 break;
350
351 case WM_BUTTON2MOTIONSTART:
352 case WM_BUTTON2MOTIONEND:
353 case WM_BUTTON2CLICK:
354 case WM_BUTTON1MOTIONSTART:
355 case WM_BUTTON1MOTIONEND:
356 case WM_BUTTON1CLICK:
357 case WM_BUTTON3MOTIONSTART:
358 case WM_BUTTON3MOTIONEND:
359 case WM_BUTTON3CLICK:
360 goto dummymessage;
361
362 case WM_MOUSEMOVE:
363 {
364 ULONG keystate = 0, setcursormsg = WINWM_MOUSEMOVE;
365
366 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000)
367 keystate |= MK_LBUTTON_W;
368 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000)
369 keystate |= MK_RBUTTON_W;
370 if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000)
371 keystate |= MK_MBUTTON_W;
372 if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
373 keystate |= MK_SHIFT_W;
374 if(WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
375 keystate |= MK_CONTROL_W;
376
377 //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
378 if((win32wnd->lastHitTestVal != HTCLIENT_W) && (WinQueryCapture(HWND_DESKTOP) != win32wnd->getOS2WindowHandle()))
379 {
380 setcursormsg = WINWM_NCMOUSEMOVE;
381 winMsg->wParam = (WPARAM)win32wnd->lastHitTestVal;
382 winMsg->lParam = MAKELONG(winMsg->pt.x,winMsg->pt.y);
383 } else
384 {
385 winMsg->wParam = (WPARAM)keystate;
386 winMsg->lParam = MAKELONG(SHORT1FROMMP(os2Msg->mp1),mapY(win32wnd,SHORT2FROMMP(os2Msg->mp1)));
387 }
388 //OS/2 Window coordinates -> Win32 Window coordinates
389 winMsg->message = setcursormsg;
390 break;
391 }
392
393 case WM_CONTROL:
394 goto dummymessage;
395
396 case WM_COMMAND:
397 if(SHORT1FROMMP(os2Msg->mp2) == CMDSRC_MENU) {
398 winMsg->message = WINWM_COMMAND;
399 winMsg->wParam = (WPARAM)SHORT1FROMMP(os2Msg->mp1); //id
400 break;
401 }
402 //todo controls
403 goto dummymessage;
404
405 case WM_SYSCOMMAND:
406 {
407 ULONG x = 0, y = 0;
408 ULONG win32sc;
409
410 if(SHORT2FROMMP(os2Msg->mp2) == TRUE) {//syscommand caused by mouse action
411 POINTL pointl;
412 WinQueryPointerPos(HWND_DESKTOP, &pointl);
413 x = pointl.x;
414 y = mapScreenY(y);
415 }
416 switch(SHORT1FROMMP(os2Msg->mp1)) {
417 case SC_MOVE:
418 win32sc = SC_MOVE_W;
419 break;
420 case SC_CLOSE:
421 win32sc = SC_CLOSE_W;
422 break;
423 case SC_MAXIMIZE:
424 win32sc = SC_MAXIMIZE_W;
425 break;
426 case SC_MINIMIZE:
427 win32sc = SC_MINIMIZE_W;
428 break;
429 case SC_NEXTFRAME:
430 case SC_NEXTWINDOW:
431 win32sc = SC_NEXTWINDOW_W;
432 break;
433 case SC_RESTORE:
434 win32sc = SC_RESTORE_W;
435 break;
436 case SC_TASKMANAGER:
437 win32sc = SC_TASKLIST_W;
438 break;
439 default:
440 goto dummymessage;
441 }
442 winMsg->message = WINWM_SYSCOMMAND;
443 winMsg->wParam = (WPARAM)win32sc;
444 winMsg->lParam = MAKELONG((USHORT)x, (USHORT)y);
445 break;
446 }
447 case WM_CHAR:
448 {
449 ULONG repeatCount=0, virtualKey=0, keyFlags=0, scanCode=0;
450 ULONG flags = SHORT1FROMMP(os2Msg->mp1);
451 BOOL keyWasPressed;
452 char c;
453
454 thdb->fTranslated = FALSE;
455 repeatCount = CHAR3FROMMP(os2Msg->mp1);
456 scanCode = CHAR4FROMMP(os2Msg->mp1);
457 keyWasPressed = ((SHORT1FROMMP (os2Msg->mp1) & KC_PREVDOWN) == KC_PREVDOWN);
458
459 dprintf(("PM: WM_CHAR: %x %x %d %x", SHORT1FROMMP(os2Msg->mp2), SHORT2FROMMP(os2Msg->mp2), repeatCount, scanCode));
460 dprintf(("PM: WM_CHAR: %x", flags));
461
462 // vitali add begin
463 if ( ( SHORT1FROMMP(os2Msg->mp2) & 0x0FF ) == 0x0E0 )
464 {
465 // an extended key ( arrows, ins, del and so on )
466 // get "virtual" scancode from character code cause
467 // for "regular" keys they are equal
468 scanCode = ( SHORT1FROMMP(os2Msg->mp2) >> 8) & 0x0FF;
469 }
470 // vitali add end
471
472 // both WM_KEYUP & WM_KEYDOWN want a virtual key, find the right Win32 virtual key
473 // given the OS/2 virtual key and OS/2 character
474
475 //if (((SHORT1FROMMP (mp1) & KC_CHAR) == KC_CHAR) ||
476 // ((SHORT1FROMMP (mp1) & KC_LONEKEY) == KC_LONEKEY))
477 c = 0;
478 if ((SHORT1FROMMP (os2Msg->mp1) & 0xFF) != 0)
479 {
480 c = SHORT1FROMMP (os2Msg->mp2);
481 if ((c >= 'A') && (c <= 'Z')) {
482 virtualKey = c;
483 goto VirtualKeyFound;
484 }
485 if ((c >='a') && (c <= 'z')) {
486 virtualKey = c - 32; // make it uppercase
487 goto VirtualKeyFound;
488 }
489 if ((c >= '0') && (c <= '9')) {
490 virtualKey = c;
491 goto VirtualKeyFound;
492 }
493 }
494
495 // convert OS/2 virtual keys to Win32 virtual key
496 if (SHORT2FROMMP (os2Msg->mp2) <= VK_BLK2)
497 virtualKey = virtualKeyTable [SHORT2FROMMP (os2Msg->mp2)];
498
499VirtualKeyFound:
500 dprintf (("VIRTUALKEYFOUND:(%x)", virtualKey));
501
502 winMsg->wParam = virtualKey;
503 winMsg->lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount
504 winMsg->lParam |= (scanCode & 0x0FF) << 16; // bit 16-23, scancode
505 win32wnd->setExtendedKey(virtualKey, (ULONG *)&winMsg->lParam);
506
507 if(!(SHORT1FROMMP(os2Msg->mp1) & KC_ALT))
508 {
509 //
510 // the Alt key is not pressed
511 //
512 if ((flags & KC_KEYUP) == KC_KEYUP) {
513 // send WM_KEYUP message
514
515 winMsg->message = WINWM_KEYUP;
516 winMsg->lParam |= 1 << 30; // bit 30, previous state, always 1 for a WM_KEYUP message
517 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
518 }
519 else {
520 // send WM_KEYDOWN message
521 winMsg->message = WINWM_KEYDOWN;
522 if (keyWasPressed)
523 winMsg->lParam |= 1 << 30; // bit 30, previous state, 1 means key was pressed
524 }
525 }
526 else {
527 //
528 // the Alt key is pressed
529 //
530 if ((flags & KC_KEYUP) == KC_KEYUP) {
531 // send WM_SYSKEYUP message
532
533 winMsg->message = WINWM_SYSKEYUP;
534 winMsg->lParam |= 1 << 30; // bit 30, previous state, always 1 for a WM_KEYUP message
535 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
536 }
537 else {
538 // send WM_SYSKEYDOWN message
539 winMsg->message = WINWM_SYSKEYDOWN;
540 if (keyWasPressed)
541 winMsg->lParam |= 1 << 30; // bit 30, previous state, 1 means key was pressed
542 }
543 }
544
545 break;
546 }
547
548 case WM_INITMENU:
549 winMsg->message = WINWM_INITMENU;
550 winMsg->wParam = (WPARAM)os2Msg->mp2; //hMenu
551 break;
552
553 case WM_MENUSELECT:
554 case WM_MENUEND:
555 case WM_NEXTMENU:
556 goto dummymessage;
557
558 case WM_TIMER:
559 if (os2Msg->mp2)
560 {
561 BOOL sys;
562 ULONG id;
563
564 if (TIMER_GetTimerInfo(os2Msg->hwnd,(ULONG)os2Msg->mp1,&sys,&id))
565 {
566 winMsg->wParam = (WPARAM)id;
567 winMsg->message= (sys) ? WINWM_SYSTIMER : WINWM_TIMER;
568 break;
569 }
570 }
571 goto dummymessage; //for caret blinking
572
573 case WM_SETWINDOWPARAMS:
574 {
575 WNDPARAMS *wndParams = (WNDPARAMS *)os2Msg->mp1;
576
577 if(wndParams->fsStatus & WPM_TEXT) {
578 win32wnd->MsgSetText(wndParams->pszText, wndParams->cchText);
579 break;
580 }
581 goto dummymessage;
582 }
583
584#if 0
585 case WM_QUERYWINDOWPARAMS:
586 {
587 PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
588 ULONG textlen;
589 PSZ wintext;
590
591 if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
592 {
593 if(wndpars->fsStatus & WPM_CCHTEXT)
594 wndpars->cchText = win32wnd->MsgGetTextLength();
595 if(wndpars->fsStatus & WPM_TEXT)
596 wndpars->pszText = win32wnd->MsgGetText();
597
598 wndpars->fsStatus = 0;
599 wndpars->cbCtlData = 0;
600 wndpars->cbPresParams = 0;
601 goto dummymessage;
602 }
603 }
604#endif
605
606 case WM_PAINT:
607 {
608 if(win32wnd->IsIconic()) {
609 winMsg->message = WINWM_PAINTICON;
610 }
611 else winMsg->message = WINWM_PAINT;
612 break;
613 }
614
615 case WM_HITTEST:
616 {
617 winMsg->message = WINWM_NCHITTEST;
618 winMsg->wParam = 0;
619 winMsg->lParam = MAKELONG(winMsg->pt.x,winMsg->pt.y);
620 break;
621 }
622
623 case WM_CONTEXTMENU:
624 {
625 OSLIBPOINT pt;
626
627 pt.x = (*(POINTS *)&os2Msg->mp1).x;
628 pt.y = (*(POINTS *)&os2Msg->mp1).y;
629 mapOS2ToWin32Point(os2Msg->hwnd,OSLIB_HWND_DESKTOP,&pt);
630 winMsg->message = WINWM_CONTEXTMENU;
631 winMsg->wParam = (WPARAM)win32wnd->getWindowHandle();
632 winMsg->lParam = MAKELONG((USHORT)pt.x, (USHORT)pt.y);
633 break;
634 }
635
636 case WM_SYSCOLORCHANGE:
637 case WM_SYSVALUECHANGED:
638 case WM_SETSELECTION:
639 case WM_PPAINT:
640 case WM_PSETFOCUS:
641 case WM_PSYSCOLORCHANGE:
642 case WM_PSIZE:
643 case WM_PACTIVATE:
644 case WM_PCONTROL:
645 case WM_HELP:
646 case WM_APPTERMINATENOTIFY:
647 case WM_PRESPARAMCHANGED:
648 case WM_DRAWITEM:
649 case WM_MEASUREITEM:
650 case WM_CONTROLPOINTER:
651 case WM_QUERYDLGCODE:
652 case WM_SUBSTITUTESTRING:
653 case WM_MATCHMNEMONIC:
654 case WM_SAVEAPPLICATION:
655 case WM_SEMANTICEVENT:
656 default:
657dummymessage:
658 return FALSE;
659 }
660 return TRUE;
661}
662//******************************************************************************
663//******************************************************************************
664BOOL OSLibWinTranslateMessage(MSG *msg)
665{
666 THDB *thdb;
667
668 thdb = GetThreadTHDB();
669 if(!thdb) {
670 return FALSE;
671 }
672 //NOTE: These actually need to be posted so that the next message retrieved by GetMessage contains
673 // the newly generated WM_CHAR message.
674 if(!thdb->fTranslated && MsgThreadPtr->msg == WM_CHAR && !((SHORT1FROMMP(MsgThreadPtr->mp1) & KC_KEYUP) == KC_KEYUP))
675 {//TranslatedMessage was called before DispatchMessage, so queue WM_CHAR message
676 ULONG fl = SHORT1FROMMP(MsgThreadPtr->mp1);
677 MSG extramsg;
678
679 memcpy(&extramsg, msg, sizeof(MSG));
680 extramsg.wParam = SHORT1FROMMP(MsgThreadPtr->mp2);
681 extramsg.lParam = 0;
682
683 if(!(fl & KC_CHAR)) {
684 return FALSE;
685 }
686
687 if(fl & KC_VIRTUALKEY) {
688 if(msg->wParam)
689 extramsg.wParam = msg->wParam;
690 else extramsg.wParam = SHORT2FROMMP(MsgThreadPtr->mp2);
691 }
692
693 if(msg->message >= WINWM_SYSKEYDOWN) {
694 extramsg.message = WINWM_SYSCHAR;
695 }
696 else extramsg.message = WINWM_CHAR;
697
698 if(fl & KC_DEADKEY) {
699 extramsg.message++; //WM_DEADCHAR/WM_SYSDEADCHAR
700 }
701
702 extramsg.lParam = msg->lParam & 0x00FFFFFF;
703 if(fl & KC_ALT)
704 extramsg.lParam |= (1<<29);
705 if(fl & KC_PREVDOWN)
706 extramsg.lParam |= (1<<30);
707 if(fl & KC_KEYUP)
708 extramsg.lParam |= (1<<31);
709
710 thdb->fTranslated = TRUE;
711 memcpy(&thdb->msgWCHAR, &extramsg, sizeof(MSG));
712 return TRUE;
713 }
714 return FALSE;
715}
716//******************************************************************************
717//******************************************************************************
718
Note: See TracBrowser for help on using the repository browser.