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

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

menu, resize/move fixes + ported Wine messagebox code

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