| 1 | /* $Id: oslibmsgtranslate.cpp,v 1.83 2002-02-13 15:10: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 <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 |
|
|---|
| 40 | #define DBG_LOCALLOG DBG_oslibmsgtranslate
|
|---|
| 41 | #include "dbglocal.h"
|
|---|
| 42 |
|
|---|
| 43 | static BOOL fGenerateDoubleClick = FALSE;
|
|---|
| 44 | static MSG doubleClickMsg = {0};
|
|---|
| 45 |
|
|---|
| 46 | //******************************************************************************
|
|---|
| 47 | //******************************************************************************
|
|---|
| 48 | BOOL setThreadQueueExtraCharMessage(TEB* teb, MSG* pExtraMsg)
|
|---|
| 49 | {
|
|---|
| 50 | // check if the single slot is occupied already
|
|---|
| 51 | if (teb->o.odin.fTranslated == TRUE)
|
|---|
| 52 | // there's still an already translated message to be processed
|
|---|
| 53 | return FALSE;
|
|---|
| 54 | teb->o.odin.fTranslated = TRUE;
|
|---|
| 55 | memcpy(&teb->o.odin.msgWCHAR, pExtraMsg, sizeof(MSG));
|
|---|
| 56 | return TRUE;
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | //******************************************************************************
|
|---|
| 60 | //******************************************************************************
|
|---|
| 61 | ULONG GetMouseKeyState()
|
|---|
| 62 | {
|
|---|
| 63 | ULONG keystate = 0;
|
|---|
| 64 |
|
|---|
| 65 | if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000)
|
|---|
| 66 | keystate |= MK_LBUTTON_W;
|
|---|
| 67 | if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000)
|
|---|
| 68 | keystate |= MK_RBUTTON_W;
|
|---|
| 69 | if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000)
|
|---|
| 70 | keystate |= MK_MBUTTON_W;
|
|---|
| 71 | if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
|
|---|
| 72 | keystate |= MK_SHIFT_W;
|
|---|
| 73 | if(WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
|
|---|
| 74 | keystate |= MK_CONTROL_W;
|
|---|
| 75 |
|
|---|
| 76 | return keystate;
|
|---|
| 77 | }
|
|---|
| 78 | //******************************************************************************
|
|---|
| 79 | //******************************************************************************
|
|---|
| 80 | LONG IsNCMouseMsg(Win32BaseWindow *win32wnd)
|
|---|
| 81 | {
|
|---|
| 82 | return ((win32wnd->getLastHitTestVal() != HTCLIENT_W) && (WinQueryCapture(HWND_DESKTOP) != win32wnd->getOS2WindowHandle()));
|
|---|
| 83 | }
|
|---|
| 84 | //******************************************************************************
|
|---|
| 85 | //******************************************************************************
|
|---|
| 86 | void SetMenuDoubleClick(BOOL fSet)
|
|---|
| 87 | {
|
|---|
| 88 | fGenerateDoubleClick = fSet;
|
|---|
| 89 | }
|
|---|
| 90 | //******************************************************************************
|
|---|
| 91 | //******************************************************************************
|
|---|
| 92 | BOOL OS2ToWinMsgTranslate(void *pTeb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fMsgRemoved)
|
|---|
| 93 | {
|
|---|
| 94 | Win32BaseWindow *win32wnd = 0;
|
|---|
| 95 | OSLIBPOINT point, ClientPoint;
|
|---|
| 96 | POSTMSG_PACKET *packet;
|
|---|
| 97 | TEB *teb = (TEB *)pTeb;
|
|---|
| 98 | BOOL fWasDisabled = FALSE;
|
|---|
| 99 | BOOL fIsFrame = FALSE;
|
|---|
| 100 | int i;
|
|---|
| 101 |
|
|---|
| 102 | memset(winMsg, 0, sizeof(MSG));
|
|---|
| 103 | win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(os2Msg->hwnd);
|
|---|
| 104 | if(!win32wnd) {
|
|---|
| 105 | win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(os2Msg->hwnd);
|
|---|
| 106 | if(win32wnd) {
|
|---|
| 107 | fIsFrame = TRUE;
|
|---|
| 108 | }
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | //PostThreadMessage posts WIN32APP_POSTMSG msg without window handle
|
|---|
| 112 | //Realplayer starts a timer with hwnd 0 & proc 0; check this here
|
|---|
| 113 | if(win32wnd == 0 && (os2Msg->msg != WM_CREATE && os2Msg->msg != WM_QUIT && os2Msg->msg != WM_TIMER && os2Msg->msg < WIN32APP_POSTMSG))
|
|---|
| 114 | {
|
|---|
| 115 | goto dummymessage; //not a win32 client window
|
|---|
| 116 | }
|
|---|
| 117 | winMsg->time = os2Msg->time;
|
|---|
| 118 | //CB: PM bug or undocumented feature? ptl.x highword is set!
|
|---|
| 119 | winMsg->pt.x = os2Msg->ptl.x & 0xFFFF;
|
|---|
| 120 | winMsg->pt.y = mapScreenY(os2Msg->ptl.y);
|
|---|
| 121 |
|
|---|
| 122 | if(win32wnd) //==0 for WM_CREATE/WM_QUIT
|
|---|
| 123 | winMsg->hwnd = win32wnd->getWindowHandle();
|
|---|
| 124 |
|
|---|
| 125 | if(os2Msg->msg >= WIN32APP_POSTMSG) {
|
|---|
| 126 | packet = (POSTMSG_PACKET *)os2Msg->mp2;
|
|---|
| 127 | if(packet && ((ULONG)os2Msg->mp1 == WIN32MSG_MAGICA || (ULONG)os2Msg->mp1 == WIN32MSG_MAGICW)) {
|
|---|
| 128 | winMsg->message = os2Msg->msg - WIN32APP_POSTMSG;
|
|---|
| 129 | winMsg->wParam = packet->wParam;
|
|---|
| 130 | winMsg->lParam = packet->lParam;
|
|---|
| 131 | if(fMsgRemoved == MSG_REMOVE) free(packet); //free the shared memory here
|
|---|
| 132 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 133 | return TRUE;
|
|---|
| 134 | }
|
|---|
| 135 | else {//broadcasted message (no packet present)
|
|---|
| 136 | winMsg->message = os2Msg->msg - WIN32APP_POSTMSG;
|
|---|
| 137 | winMsg->wParam = (UINT)os2Msg->mp1;
|
|---|
| 138 | winMsg->lParam = (DWORD)os2Msg->mp2;
|
|---|
| 139 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 140 | return TRUE;
|
|---|
| 141 | }
|
|---|
| 142 | goto dummymessage;
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | switch(os2Msg->msg)
|
|---|
| 146 | {
|
|---|
| 147 | //OS/2 msgs
|
|---|
| 148 | case WM_CREATE:
|
|---|
| 149 | {
|
|---|
| 150 | if(teb->o.odin.newWindow == 0) {
|
|---|
| 151 | DebugInt3();
|
|---|
| 152 | goto dummymessage;
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
|
|---|
| 156 | win32wnd->addRef();
|
|---|
| 157 |
|
|---|
| 158 | winMsg->message = WINWM_CREATE;
|
|---|
| 159 | winMsg->hwnd = win32wnd->getWindowHandle();
|
|---|
| 160 | winMsg->wParam = 0;
|
|---|
| 161 | winMsg->lParam = (LPARAM)win32wnd->tmpcs;
|
|---|
| 162 | break;
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | case WM_QUIT:
|
|---|
| 166 | winMsg->message = WINWM_QUIT;
|
|---|
| 167 | break;
|
|---|
| 168 |
|
|---|
| 169 | case WM_CLOSE:
|
|---|
| 170 | winMsg->message = WINWM_CLOSE;
|
|---|
| 171 | break;
|
|---|
| 172 |
|
|---|
| 173 | case WM_DESTROY:
|
|---|
| 174 | winMsg->message = WINWM_DESTROY;
|
|---|
| 175 | break;
|
|---|
| 176 |
|
|---|
| 177 | case WM_ENABLE:
|
|---|
| 178 | winMsg->message = WINWM_ENABLE;
|
|---|
| 179 | winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
|
|---|
| 180 | break;
|
|---|
| 181 |
|
|---|
| 182 | case WM_SHOW:
|
|---|
| 183 | winMsg->message = WINWM_SHOWWINDOW;
|
|---|
| 184 | winMsg->wParam = SHORT1FROMMP(os2Msg->mp1);
|
|---|
| 185 | break;
|
|---|
| 186 |
|
|---|
| 187 | case WM_WINDOWPOSCHANGED:
|
|---|
| 188 | {
|
|---|
| 189 | PSWP pswp = (PSWP)os2Msg->mp1;
|
|---|
| 190 | SWP swpOld = *(pswp + 1);
|
|---|
| 191 | HWND hParent = NULLHANDLE;
|
|---|
| 192 | LONG yDelta = pswp->cy - swpOld.cy;
|
|---|
| 193 | LONG xDelta = pswp->cx - swpOld.cx;
|
|---|
| 194 |
|
|---|
| 195 | if(!fIsFrame) goto dummymessage;
|
|---|
| 196 |
|
|---|
| 197 | if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) goto dummymessage;
|
|---|
| 198 |
|
|---|
| 199 | if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
|
|---|
| 200 | if (win32wnd->isChild()) {
|
|---|
| 201 | if(win32wnd->getParent()) {
|
|---|
| 202 | hParent = win32wnd->getParent()->getOS2WindowHandle();
|
|---|
| 203 | }
|
|---|
| 204 | else goto dummymessage; //parent has just been destroyed
|
|---|
| 205 | }
|
|---|
| 206 | }
|
|---|
| 207 | if(win32wnd->getParent()) {
|
|---|
| 208 | OSLibMapSWPtoWINDOWPOS(pswp, &teb->o.odin.wp, &swpOld, win32wnd->getParent()->getClientHeight(),
|
|---|
| 209 | win32wnd->getOS2WindowHandle());
|
|---|
| 210 | }
|
|---|
| 211 | else OSLibMapSWPtoWINDOWPOS(pswp, &teb->o.odin.wp, &swpOld, OSLibQueryScreenHeight(), win32wnd->getOS2WindowHandle());
|
|---|
| 212 |
|
|---|
| 213 | if (!win32wnd->CanReceiveSizeMsgs()) goto dummymessage;
|
|---|
| 214 |
|
|---|
| 215 | if(pswp->fl & (SWP_MOVE | SWP_SIZE))
|
|---|
| 216 | {
|
|---|
| 217 | teb->o.odin.wp.hwnd = win32wnd->getWindowHandle();
|
|---|
| 218 | if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
|
|---|
| 219 | {
|
|---|
| 220 | Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
|
|---|
| 221 | if(wndAfter) {
|
|---|
| 222 | teb->o.odin.wp.hwndInsertAfter = wndAfter->getWindowHandle();
|
|---|
| 223 | RELEASE_WNDOBJ(wndAfter);
|
|---|
| 224 | }
|
|---|
| 225 | else teb->o.odin.wp.hwndInsertAfter = HWND_TOP_W;
|
|---|
| 226 | }
|
|---|
| 227 | }
|
|---|
| 228 | winMsg->message = WINWM_WINDOWPOSCHANGED;
|
|---|
| 229 | winMsg->lParam = (LPARAM)&teb->o.odin.wp;
|
|---|
| 230 | break;
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | case WM_ACTIVATE:
|
|---|
| 234 | {
|
|---|
| 235 | HWND hwndActivate = (HWND)os2Msg->mp2;
|
|---|
| 236 | BOOL fMinimized = FALSE;
|
|---|
| 237 |
|
|---|
| 238 | hwndActivate = OS2ToWin32Handle(hwndActivate);
|
|---|
| 239 | if(hwndActivate == 0) {
|
|---|
| 240 | //another (non-win32) application's window
|
|---|
| 241 | //set to desktop window handle
|
|---|
| 242 | hwndActivate = windowDesktop->getWindowHandle();
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | if(win32wnd->getStyle() & WS_MINIMIZE_W)
|
|---|
| 246 | {
|
|---|
| 247 | fMinimized = TRUE;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | winMsg->message = WINWM_ACTIVATE;
|
|---|
| 251 | winMsg->wParam = MAKELONG((SHORT1FROMMP(os2Msg->mp1)) ? WA_ACTIVE_W : WA_INACTIVE_W, fMinimized);
|
|---|
| 252 | winMsg->lParam = (LPARAM)hwndActivate;
|
|---|
| 253 | break;
|
|---|
| 254 | }
|
|---|
| 255 |
|
|---|
| 256 | case WM_SETFOCUS:
|
|---|
| 257 | {
|
|---|
| 258 | HWND hwndFocus = (HWND)os2Msg->mp1;
|
|---|
| 259 |
|
|---|
| 260 | if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
|
|---|
| 261 | //another (non-win32) application's window
|
|---|
| 262 | //set to NULL (allowed according to win32 SDK) to avoid problems
|
|---|
| 263 | hwndFocus = NULL;
|
|---|
| 264 | }
|
|---|
| 265 | else hwndFocus = OS2ToWin32Handle(hwndFocus);
|
|---|
| 266 |
|
|---|
| 267 | if((ULONG)os2Msg->mp2 == TRUE) {
|
|---|
| 268 | winMsg->message = WINWM_SETFOCUS;
|
|---|
| 269 | winMsg->wParam = (WPARAM)hwndFocus;
|
|---|
| 270 | }
|
|---|
| 271 | else {
|
|---|
| 272 | winMsg->message = WINWM_KILLFOCUS;
|
|---|
| 273 | winMsg->wParam = (WPARAM)hwndFocus;
|
|---|
| 274 | }
|
|---|
| 275 | break;
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | //**************************************************************************
|
|---|
| 279 | //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
|
|---|
| 280 | //**************************************************************************
|
|---|
| 281 | case WM_BUTTON1DOWN:
|
|---|
| 282 | case WM_BUTTON1UP:
|
|---|
| 283 | case WM_BUTTON1DBLCLK:
|
|---|
| 284 | case WM_BUTTON2DOWN:
|
|---|
| 285 | case WM_BUTTON2UP:
|
|---|
| 286 | case WM_BUTTON2DBLCLK:
|
|---|
| 287 | case WM_BUTTON3DOWN:
|
|---|
| 288 | case WM_BUTTON3UP:
|
|---|
| 289 | case WM_BUTTON3DBLCLK:
|
|---|
| 290 | {
|
|---|
| 291 | //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
|
|---|
| 292 |
|
|---|
| 293 | 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));
|
|---|
| 294 |
|
|---|
| 295 | HWND hwnd;
|
|---|
| 296 |
|
|---|
| 297 | DisableLogging();
|
|---|
| 298 | if(GetCapture() != winMsg->hwnd)
|
|---|
| 299 | {
|
|---|
| 300 | hwnd = WindowFromPoint(winMsg->pt);
|
|---|
| 301 | if(win32wnd->getWindowHandle() != hwnd) {
|
|---|
| 302 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 303 | win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 304 | if(win32wnd == NULL) {
|
|---|
| 305 | DebugInt3();
|
|---|
| 306 | EnableLogging();
|
|---|
| 307 | goto dummymessage;
|
|---|
| 308 | }
|
|---|
| 309 | winMsg->hwnd = hwnd;
|
|---|
| 310 | }
|
|---|
| 311 | }
|
|---|
| 312 |
|
|---|
| 313 | //if a window is disabled, it's parent receives the mouse messages
|
|---|
| 314 | if(!IsWindowEnabled(win32wnd->getWindowHandle())) {
|
|---|
| 315 | if(win32wnd->getParent()) {
|
|---|
| 316 | Win32BaseWindow *parent = win32wnd->getParent();;
|
|---|
| 317 | if(parent) parent->addRef();
|
|---|
| 318 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 319 | win32wnd = parent;
|
|---|
| 320 | }
|
|---|
| 321 | fWasDisabled = TRUE;
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | if(IsNCMouseMsg(win32wnd)) {
|
|---|
| 325 | winMsg->message = WINWM_NCLBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
|
|---|
| 326 | winMsg->wParam = win32wnd->getLastHitTestVal();
|
|---|
| 327 | winMsg->lParam = MAKELONG(winMsg->pt.x, winMsg->pt.y); //screen coordinates
|
|---|
| 328 | }
|
|---|
| 329 | else {
|
|---|
| 330 | ClientPoint.x = winMsg->pt.x;
|
|---|
| 331 | ClientPoint.y = winMsg->pt.y;
|
|---|
| 332 | MapWindowPoints(0, win32wnd->getWindowHandle(), (LPPOINT)&ClientPoint, 1);
|
|---|
| 333 | winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
|
|---|
| 334 | winMsg->wParam = GetMouseKeyState();
|
|---|
| 335 | winMsg->lParam = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
|
|---|
| 336 | }
|
|---|
| 337 | EnableLogging();
|
|---|
| 338 | if((fMsgRemoved == MSG_REMOVE) && ISMOUSE_CAPTURED())
|
|---|
| 339 | {
|
|---|
| 340 | if(DInputMouseHandler(win32wnd->getWindowHandle(), winMsg->message, winMsg->pt.x, winMsg->pt.y)) {
|
|---|
| 341 | goto dummymessage; //dinput swallowed message
|
|---|
| 342 | }
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 | if(fWasDisabled) {
|
|---|
| 346 | if(win32wnd) {
|
|---|
| 347 | winMsg->hwnd = win32wnd->getWindowHandle();
|
|---|
| 348 | }
|
|---|
| 349 | else goto dummymessage; //don't send mouse messages to disabled windows
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | DisableLogging();
|
|---|
| 353 | if ((winMsg->message == WINWM_LBUTTONDOWN) ||
|
|---|
| 354 | (winMsg->message == WINWM_RBUTTONDOWN) ||
|
|---|
| 355 | (winMsg->message == WINWM_MBUTTONDOWN) ||
|
|---|
| 356 | (winMsg->message == WINWM_NCLBUTTONDOWN) ||
|
|---|
| 357 | (winMsg->message == WINWM_NCRBUTTONDOWN) ||
|
|---|
| 358 | (winMsg->message == WINWM_NCMBUTTONDOWN))
|
|---|
| 359 | {
|
|---|
| 360 | if(fGenerateDoubleClick && doubleClickMsg.message == winMsg->message &&
|
|---|
| 361 | winMsg->time - doubleClickMsg.time < GetDoubleClickTime() &&
|
|---|
| 362 | (abs(winMsg->pt.x - doubleClickMsg.pt.x) < GetSystemMetrics(SM_CXDOUBLECLK_W)/2) &&
|
|---|
| 363 | (abs(winMsg->pt.y - doubleClickMsg.pt.y) < GetSystemMetrics(SM_CYDOUBLECLK_W)/2))
|
|---|
| 364 | {
|
|---|
| 365 | dprintf(("single -> double click"));
|
|---|
| 366 | if(winMsg->message >= WINWM_LBUTTONDOWN) {
|
|---|
| 367 | winMsg->message += (WINWM_LBUTTONDBLCLK - WINWM_LBUTTONDOWN);
|
|---|
| 368 | }
|
|---|
| 369 | else winMsg->message += (WINWM_LBUTTONDBLCLK - WINWM_NCLBUTTONDOWN);
|
|---|
| 370 | doubleClickMsg.message = 0;
|
|---|
| 371 | }
|
|---|
| 372 | else {
|
|---|
| 373 | dprintf(("save for double click"));
|
|---|
| 374 | doubleClickMsg = *winMsg;
|
|---|
| 375 | if(doubleClickMsg.message >= WINWM_NCLBUTTONDOWN && doubleClickMsg.message <= WINWM_NCMBUTTONDOWN) {
|
|---|
| 376 | doubleClickMsg.message += (WINWM_LBUTTONDOWN - WINWM_NCLBUTTONDOWN);
|
|---|
| 377 | }
|
|---|
| 378 | }
|
|---|
| 379 | }
|
|---|
| 380 | EnableLogging();
|
|---|
| 381 |
|
|---|
| 382 | break;
|
|---|
| 383 | }
|
|---|
| 384 |
|
|---|
| 385 | case WM_BUTTON2CLICK:
|
|---|
| 386 | case WM_BUTTON1CLICK:
|
|---|
| 387 | case WM_BUTTON3CLICK:
|
|---|
| 388 | goto dummymessage;
|
|---|
| 389 |
|
|---|
| 390 | case WM_BUTTON2MOTIONSTART:
|
|---|
| 391 | case WM_BUTTON2MOTIONEND:
|
|---|
| 392 | case WM_BUTTON1MOTIONSTART:
|
|---|
| 393 | case WM_BUTTON1MOTIONEND:
|
|---|
| 394 | case WM_BUTTON3MOTIONSTART:
|
|---|
| 395 | case WM_BUTTON3MOTIONEND:
|
|---|
| 396 | //no break; translate to WM_MOUSEMOVE
|
|---|
| 397 | //Some applications (e.g. Unreal) retrieve all mouse messages
|
|---|
| 398 | //when a mouse button is pressed and don't expect WM_NULL
|
|---|
| 399 |
|
|---|
| 400 | case WM_MOUSEMOVE:
|
|---|
| 401 | {
|
|---|
| 402 | //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
|
|---|
| 403 |
|
|---|
| 404 | HWND hwnd;
|
|---|
| 405 |
|
|---|
| 406 | dprintf2(("WM_NCMOUSEMOVE (%d,%d)", winMsg->pt.x, winMsg->pt.y));
|
|---|
| 407 | DisableLogging();
|
|---|
| 408 | if(GetCapture() != winMsg->hwnd)
|
|---|
| 409 | {
|
|---|
| 410 | hwnd = WindowFromPoint(winMsg->pt);
|
|---|
| 411 | if(win32wnd->getWindowHandle() != hwnd) {
|
|---|
| 412 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 413 | win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 414 | if(win32wnd == NULL) {
|
|---|
| 415 | DebugInt3();
|
|---|
| 416 | EnableLogging();
|
|---|
| 417 | goto dummymessage;
|
|---|
| 418 | }
|
|---|
| 419 | winMsg->hwnd = hwnd;
|
|---|
| 420 | }
|
|---|
| 421 | }
|
|---|
| 422 |
|
|---|
| 423 | //if a window is disabled, it's parent receives the mouse messages
|
|---|
| 424 | if(!IsWindowEnabled(win32wnd->getWindowHandle())) {
|
|---|
| 425 | if(win32wnd->getParent()) {
|
|---|
| 426 | Win32BaseWindow *parent = win32wnd->getParent();;
|
|---|
| 427 | if(parent) parent->addRef();
|
|---|
| 428 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 429 | win32wnd = parent;
|
|---|
| 430 | }
|
|---|
| 431 | fWasDisabled = TRUE;
|
|---|
| 432 | }
|
|---|
| 433 | if(IsNCMouseMsg(win32wnd))
|
|---|
| 434 | {
|
|---|
| 435 | winMsg->message = WINWM_NCMOUSEMOVE;
|
|---|
| 436 | winMsg->wParam = (WPARAM)win32wnd->getLastHitTestVal();
|
|---|
| 437 | winMsg->lParam = MAKELONG(winMsg->pt.x,winMsg->pt.y);
|
|---|
| 438 | }
|
|---|
| 439 | else
|
|---|
| 440 | {
|
|---|
| 441 | ClientPoint.x = winMsg->pt.x;
|
|---|
| 442 | ClientPoint.y = winMsg->pt.y;
|
|---|
| 443 | MapWindowPoints(0, win32wnd->getWindowHandle(), (LPPOINT)&ClientPoint, 1);
|
|---|
| 444 |
|
|---|
| 445 | winMsg->message = WINWM_MOUSEMOVE;
|
|---|
| 446 | winMsg->wParam = GetMouseKeyState();
|
|---|
| 447 | winMsg->lParam = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
|
|---|
| 448 | }
|
|---|
| 449 | EnableLogging();
|
|---|
| 450 | if((fMsgRemoved == MSG_REMOVE) && ISMOUSE_CAPTURED())
|
|---|
| 451 | {
|
|---|
| 452 | if(DInputMouseHandler(win32wnd->getWindowHandle(), winMsg->message, winMsg->pt.x, winMsg->pt.y)) {
|
|---|
| 453 | goto dummymessage; //dinput swallowed message
|
|---|
| 454 | }
|
|---|
| 455 | }
|
|---|
| 456 | if(fWasDisabled) {
|
|---|
| 457 | if(win32wnd) {
|
|---|
| 458 | winMsg->hwnd = win32wnd->getWindowHandle();
|
|---|
| 459 | }
|
|---|
| 460 | else {
|
|---|
| 461 | goto dummymessage; //don't send mouse messages to disabled windows
|
|---|
| 462 | }
|
|---|
| 463 | }
|
|---|
| 464 | //OS/2 Window coordinates -> Win32 Window coordinates
|
|---|
| 465 | break;
|
|---|
| 466 | }
|
|---|
| 467 |
|
|---|
| 468 | case WM_CONTROL:
|
|---|
| 469 | goto dummymessage;
|
|---|
| 470 |
|
|---|
| 471 | case WM_COMMAND:
|
|---|
| 472 | if(SHORT1FROMMP(os2Msg->mp2) == CMDSRC_MENU) {
|
|---|
| 473 | winMsg->message = WINWM_COMMAND;
|
|---|
| 474 | winMsg->wParam = (WPARAM)SHORT1FROMMP(os2Msg->mp1); //id
|
|---|
| 475 | break;
|
|---|
| 476 | }
|
|---|
| 477 | //todo controls
|
|---|
| 478 | goto dummymessage;
|
|---|
| 479 |
|
|---|
| 480 | case WM_SYSCOMMAND:
|
|---|
| 481 | {
|
|---|
| 482 | ULONG x = 0, y = 0;
|
|---|
| 483 | ULONG win32sc;
|
|---|
| 484 |
|
|---|
| 485 | if(SHORT2FROMMP(os2Msg->mp2) == TRUE) {//syscommand caused by mouse action
|
|---|
| 486 | POINTL pointl;
|
|---|
| 487 | WinQueryPointerPos(HWND_DESKTOP, &pointl);
|
|---|
| 488 | x = pointl.x;
|
|---|
| 489 | y = mapScreenY(y);
|
|---|
| 490 | }
|
|---|
| 491 | switch(SHORT1FROMMP(os2Msg->mp1)) {
|
|---|
| 492 | case SC_MOVE:
|
|---|
| 493 | win32sc = SC_MOVE_W;
|
|---|
| 494 | break;
|
|---|
| 495 | case SC_CLOSE:
|
|---|
| 496 | {
|
|---|
| 497 | //FALSE -> keyboard operation = user pressed Alt-F4 -> close app
|
|---|
| 498 | //TRUE -> user clicked on close button -> close window
|
|---|
| 499 | if(SHORT2FROMMP(os2Msg->mp2) == FALSE)
|
|---|
| 500 | {
|
|---|
| 501 | HWND hwnd = win32wnd->GetTopParent();
|
|---|
| 502 | if(win32wnd->getWindowHandle() != hwnd) {
|
|---|
| 503 | RELEASE_WNDOBJ(win32wnd);
|
|---|
| 504 | win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 505 | if(win32wnd == NULL) {
|
|---|
| 506 | DebugInt3();
|
|---|
| 507 | goto dummymessage;
|
|---|
| 508 | }
|
|---|
| 509 | winMsg->hwnd = hwnd;
|
|---|
| 510 | }
|
|---|
| 511 | }
|
|---|
| 512 | win32sc = SC_CLOSE_W;
|
|---|
| 513 | break;
|
|---|
| 514 | }
|
|---|
| 515 | case SC_MAXIMIZE:
|
|---|
| 516 | win32sc = SC_MAXIMIZE_W;
|
|---|
| 517 | break;
|
|---|
| 518 | case SC_MINIMIZE:
|
|---|
| 519 | win32sc = SC_MINIMIZE_W;
|
|---|
| 520 | break;
|
|---|
| 521 | case SC_NEXTFRAME:
|
|---|
| 522 | case SC_NEXTWINDOW:
|
|---|
| 523 | win32sc = SC_NEXTWINDOW_W;
|
|---|
| 524 | break;
|
|---|
| 525 | case SC_RESTORE:
|
|---|
| 526 | win32sc = SC_RESTORE_W;
|
|---|
| 527 | break;
|
|---|
| 528 | case SC_TASKMANAGER:
|
|---|
| 529 | win32sc = SC_TASKLIST_W;
|
|---|
| 530 | break;
|
|---|
| 531 | default:
|
|---|
| 532 | dprintf(("Unknown/unsupported SC command %d", SHORT1FROMMP(os2Msg->mp1)));
|
|---|
| 533 | goto dummymessage;
|
|---|
| 534 | }
|
|---|
| 535 | winMsg->message= WINWM_SYSCOMMAND;
|
|---|
| 536 | winMsg->wParam = (WPARAM)win32sc;
|
|---|
| 537 | winMsg->lParam = MAKELONG((USHORT)x, (USHORT)y);
|
|---|
| 538 | break;
|
|---|
| 539 | }
|
|---|
| 540 |
|
|---|
| 541 | case WM_CHAR_SPECIAL:
|
|---|
| 542 | {
|
|---|
| 543 | // @@@PH
|
|---|
| 544 | // special char message from the keyboard hook
|
|---|
| 545 | dprintf(("PM: WM_CHAR_SPECIAL\n"));
|
|---|
| 546 |
|
|---|
| 547 | // NO BREAK! FALLTHRU CASE!
|
|---|
| 548 | }
|
|---|
| 549 |
|
|---|
| 550 | case WM_CHAR:
|
|---|
| 551 | {
|
|---|
| 552 | ULONG repeatCount=0;
|
|---|
| 553 | ULONG virtualKey=0;
|
|---|
| 554 | ULONG keyFlags=0;
|
|---|
| 555 | USHORT scanCode=0;
|
|---|
| 556 | ULONG flags = SHORT1FROMMP(os2Msg->mp1);
|
|---|
| 557 | BOOL keyWasPressed;
|
|---|
| 558 | char c;
|
|---|
| 559 | USHORT usPMScanCode = CHAR4FROMMP(os2Msg->mp1);
|
|---|
| 560 |
|
|---|
| 561 | teb->o.odin.fTranslated = FALSE;
|
|---|
| 562 | repeatCount = CHAR3FROMMP(os2Msg->mp1);
|
|---|
| 563 | scanCode = CHAR4FROMMP(os2Msg->mp1);
|
|---|
| 564 | keyWasPressed = ((SHORT1FROMMP (os2Msg->mp1) & KC_PREVDOWN) == KC_PREVDOWN);
|
|---|
| 565 |
|
|---|
| 566 | dprintf(("PM: WM_CHAR: %x %x rep=%d scancode=%x", SHORT1FROMMP(os2Msg->mp2), SHORT2FROMMP(os2Msg->mp2), repeatCount, scanCode));
|
|---|
| 567 | dprintf(("PM: WM_CHAR: hwnd %x flags %x mp1 %x, mp2 %x, time=%08xh", win32wnd->getWindowHandle(), flags, os2Msg->mp1, os2Msg->mp2, os2Msg->time));
|
|---|
| 568 |
|
|---|
| 569 | BOOL fWinExtended;
|
|---|
| 570 | BYTE bWinVKey;
|
|---|
| 571 | WORD wWinScan;
|
|---|
| 572 |
|
|---|
| 573 | if (scanCode==0) goto dummymessage;
|
|---|
| 574 |
|
|---|
| 575 | // Note: Numlock-state currently ignored, see below
|
|---|
| 576 | KeyTranslatePMScanToWinVKey(usPMScanCode,
|
|---|
| 577 | FALSE,
|
|---|
| 578 | &bWinVKey,
|
|---|
| 579 | &wWinScan,
|
|---|
| 580 | &fWinExtended);
|
|---|
| 581 | winMsg->wParam = bWinVKey;
|
|---|
| 582 | winMsg->lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount
|
|---|
| 583 | winMsg->lParam |= (wWinScan & 0x1FF) << 16; // bit 16-23, scancode + bit 15 extended
|
|---|
| 584 |
|
|---|
| 585 | // Set the extended bit when appropriate
|
|---|
| 586 | if (fWinExtended)
|
|---|
| 587 | winMsg->lParam = winMsg->lParam | WIN_KEY_EXTENDED;
|
|---|
| 588 |
|
|---|
| 589 | #if 0
|
|---|
| 590 | //TODO
|
|---|
| 591 | // Adjust VKEY value for pad digits if NumLock is on
|
|---|
| 592 | if ((scanCode >= 0x47) && (scanCode <= 0x53) &&
|
|---|
| 593 | (virtualKey >= 0x30) && (virtualKey >= 39))
|
|---|
| 594 | winMsg->wParam = virtualKey + 0x30;
|
|---|
| 595 | #endif
|
|---|
| 596 |
|
|---|
| 597 | #ifdef ALTGR_HACK
|
|---|
| 598 |
|
|---|
| 599 | if (usPMScanCode == PMSCAN_ALTRIGHT)
|
|---|
| 600 | {
|
|---|
| 601 | // Turn message into CTRL-event
|
|---|
| 602 | // The original PM message is still saved inside
|
|---|
| 603 | // the TEB, the next call to TranslateMessage()
|
|---|
| 604 | // will then generate the required additional message
|
|---|
| 605 | // for the ALTGR-event.
|
|---|
| 606 | winMsg->wParam = VK_LCONTROL_W;
|
|---|
| 607 | winMsg->lParam = repeatCount & 0x0FFFF;
|
|---|
| 608 | winMsg->lParam |= WINSCAN_CTRLLEFT << 16
|
|---|
| 609 | | WIN_KEY_DONTCARE;
|
|---|
| 610 |
|
|---|
| 611 | if (flags & KC_KEYUP)
|
|---|
| 612 | {
|
|---|
| 613 | winMsg->message = WINWM_SYSKEYUP;
|
|---|
| 614 | winMsg->lParam |= WIN_KEY_ALTHELD; // bit 29, alt was pressed
|
|---|
| 615 | winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, always 1 for a WM_KEYUP message
|
|---|
| 616 | winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
|
|---|
| 617 |
|
|---|
| 618 | // Note: altgr affects the alt-key state in windows!
|
|---|
| 619 | // The overlay causes GetKeyState/GetAsyncKeyState to return
|
|---|
| 620 | // the correct states
|
|---|
| 621 | KeySetOverlayKeyState(VK_LCONTROL_W, KEYOVERLAYSTATE_DONTCARE);
|
|---|
| 622 | KeySetOverlayKeyState(VK_CONTROL_W, KEYOVERLAYSTATE_DONTCARE);
|
|---|
| 623 | }
|
|---|
| 624 | else
|
|---|
| 625 | {
|
|---|
| 626 | winMsg->lParam |= WIN_KEY_ALTHELD;
|
|---|
| 627 | if (keyWasPressed)
|
|---|
| 628 | winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, 1 means key was pressed
|
|---|
| 629 | winMsg->message = WINWM_KEYDOWN;
|
|---|
| 630 |
|
|---|
| 631 | // Note: altgr affects the alt-key state in windows!
|
|---|
| 632 | // The overlay causes GetKeyState/GetAsyncKeyState to return
|
|---|
| 633 | // the correct states
|
|---|
| 634 | KeySetOverlayKeyState(VK_LCONTROL_W, KEYOVERLAYSTATE_DOWN);
|
|---|
| 635 | KeySetOverlayKeyState(VK_CONTROL_W, KEYOVERLAYSTATE_DOWN);
|
|---|
| 636 | KeySetOverlayKeyState(VK_RMENU_W, KEYOVERLAYSTATE_DOWN);
|
|---|
| 637 | KeySetOverlayKeyState(VK_MENU_W, KEYOVERLAYSTATE_DOWN);
|
|---|
| 638 |
|
|---|
| 639 | // Note: when CTRL comes up, windows keeps ALTGR still down!
|
|---|
| 640 | // KeySetOverlayKeyState(VK_RMENU_W, KEYOVERLAYSTATE_DOWN);
|
|---|
| 641 | }
|
|---|
| 642 | }
|
|---|
| 643 | #endif
|
|---|
| 644 |
|
|---|
| 645 | if (!(flags & KC_ALT))
|
|---|
| 646 | {
|
|---|
| 647 | //
|
|---|
| 648 | // the Alt key is not pressed
|
|---|
| 649 | // or no more pressed
|
|---|
| 650 | //
|
|---|
| 651 | if (flags & KC_KEYUP)
|
|---|
| 652 | {
|
|---|
| 653 | // check for a lonesome ALT key ...
|
|---|
| 654 | if ( (flags & KC_LONEKEY) &&
|
|---|
| 655 | (winMsg->wParam == VK_LMENU_W) )
|
|---|
| 656 | {
|
|---|
| 657 | winMsg->message = WINWM_SYSKEYUP;
|
|---|
| 658 | // held ALT-key when current key is released
|
|---|
| 659 | // generates additional flag 0x2000000
|
|---|
| 660 | // Note: PM seems to do this differently,
|
|---|
| 661 | // KC_ALT is already reset
|
|---|
| 662 | }
|
|---|
| 663 | else
|
|---|
| 664 | {
|
|---|
| 665 | // send WM_KEYUP message
|
|---|
| 666 | winMsg->message = WINWM_KEYUP;
|
|---|
| 667 | }
|
|---|
| 668 | winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, always 1 for a WM_KEYUP message
|
|---|
| 669 | winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
|
|---|
| 670 | }
|
|---|
| 671 | else
|
|---|
| 672 | { // send WM_KEYDOWN message
|
|---|
| 673 | winMsg->message = WINWM_KEYDOWN;
|
|---|
| 674 | if (keyWasPressed)
|
|---|
| 675 | winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, 1 means key was pressed
|
|---|
| 676 |
|
|---|
| 677 | //Shift-Enter and possibly others need to have special handling
|
|---|
| 678 | if (flags & KC_SHIFT)
|
|---|
| 679 | {
|
|---|
| 680 | if(fMsgRemoved && !(teb->o.odin.fTranslated))
|
|---|
| 681 | {
|
|---|
| 682 | dprintf(("PM: KC_SHIFT: %x",winMsg->wParam));
|
|---|
| 683 | if (winMsg->wParam == VK_RETURN_W)
|
|---|
| 684 | {
|
|---|
| 685 | MSG extramsg;
|
|---|
| 686 | memcpy(&extramsg, winMsg, sizeof(MSG));
|
|---|
| 687 |
|
|---|
| 688 | extramsg.message = WINWM_CHAR;
|
|---|
| 689 |
|
|---|
| 690 | // insert message into the queue
|
|---|
| 691 | setThreadQueueExtraCharMessage(teb, &extramsg);
|
|---|
| 692 | winMsg->lParam &= 0x3FFFFFFF;
|
|---|
| 693 | }
|
|---|
| 694 | } // else ???
|
|---|
| 695 | } // KC_SHIFT
|
|---|
| 696 | else
|
|---|
| 697 | {
|
|---|
| 698 | // in case we handle Enter directly through PMKBDHOOK
|
|---|
| 699 | if ((os2Msg->msg == WM_CHAR_SPECIAL) && (winMsg->wParam == VK_RETURN_W)
|
|---|
| 700 | && (fMsgRemoved && !(teb->o.odin.fTranslated)))
|
|---|
| 701 | {
|
|---|
| 702 | MSG extramsg;
|
|---|
| 703 | memcpy(&extramsg, winMsg, sizeof(MSG));
|
|---|
| 704 |
|
|---|
| 705 | extramsg.message = WINWM_CHAR;
|
|---|
| 706 |
|
|---|
| 707 | // insert message into the queue
|
|---|
| 708 | setThreadQueueExtraCharMessage(teb, &extramsg);
|
|---|
| 709 | }
|
|---|
| 710 | }
|
|---|
| 711 | }
|
|---|
| 712 | }
|
|---|
| 713 | else
|
|---|
| 714 | {
|
|---|
| 715 | //
|
|---|
| 716 | // the Alt key is pressed
|
|---|
| 717 | //
|
|---|
| 718 | if (flags & KC_KEYUP)
|
|---|
| 719 | {
|
|---|
| 720 | //@@PF Note that without pmkbdhook there will not be correct message for Alt-Enter
|
|---|
| 721 | winMsg->message = WINWM_SYSKEYUP;
|
|---|
| 722 | winMsg->lParam |= WIN_KEY_PREVSTATE;
|
|---|
| 723 | winMsg->lParam |= WIN_KEY_ALTHELD;
|
|---|
| 724 | winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP
|
|---|
| 725 | }
|
|---|
| 726 | else
|
|---|
| 727 | {
|
|---|
| 728 | // send WM_SYSKEYDOWN message
|
|---|
| 729 | winMsg->message = WINWM_SYSKEYDOWN;
|
|---|
| 730 | if (keyWasPressed)
|
|---|
| 731 | winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, 1 means key was pressed
|
|---|
| 732 |
|
|---|
| 733 | // pressed ALT-key generates additional flag 0x2000000
|
|---|
| 734 | // if the current window has keyboard focus
|
|---|
| 735 | winMsg->lParam |= WIN_KEY_ALTHELD;
|
|---|
| 736 | }
|
|---|
| 737 | }
|
|---|
| 738 |
|
|---|
| 739 | if (ISKDB_CAPTURED())
|
|---|
| 740 | {
|
|---|
| 741 | if (DInputKeyBoardHandler(winMsg)) {
|
|---|
| 742 | goto dummymessage; //dinput swallowed message
|
|---|
| 743 | }
|
|---|
| 744 | }
|
|---|
| 745 |
|
|---|
| 746 | #ifdef ALTGR_HACK
|
|---|
| 747 | // it's a PMSCAN_ALTRIGHT WM_CHAR message?
|
|---|
| 748 | // and not previously translated?
|
|---|
| 749 | if(fMsgRemoved && usPMScanCode == PMSCAN_ALTRIGHT && !(teb->o.odin.fTranslated))
|
|---|
| 750 | {
|
|---|
| 751 | dprintf(("Queue ALTRIGHT message"));
|
|---|
| 752 | // special ALTRIGHT treatment:
|
|---|
| 753 | // we try to insert another WM_KEYDOWN or WM_KEYUP instead of
|
|---|
| 754 | // the usual WM_CHAR which is expected here.
|
|---|
| 755 | // -> experimental
|
|---|
| 756 | // it's really an OS/2-style WM_CHAR message?
|
|---|
| 757 | MSG extramsg;
|
|---|
| 758 | memcpy(&extramsg, winMsg, sizeof(MSG));
|
|---|
| 759 |
|
|---|
| 760 | // AltGr is not released with WINWM_SYSKEYUP, but WINWM_KEYUP
|
|---|
| 761 | if(flags & KC_KEYUP)
|
|---|
| 762 | {
|
|---|
| 763 | extramsg.message = WINWM_KEYUP;
|
|---|
| 764 | }
|
|---|
| 765 | extramsg.wParam = VK_RMENU_W;
|
|---|
| 766 |
|
|---|
| 767 | // mask out message bits and scan code
|
|---|
| 768 | extramsg.lParam &= (0xDC00FFFF);
|
|---|
| 769 | extramsg.lParam |= (WINSCAN_ALTRIGHT & 0x1FF) << 16;
|
|---|
| 770 | //// extramsg.lParam |= WIN_KEY_EXTENDED;
|
|---|
| 771 | if (!(flags & KC_KEYUP))
|
|---|
| 772 | extramsg.lParam |= WIN_KEY_ALTHELD;
|
|---|
| 773 |
|
|---|
| 774 | // insert message into the queue
|
|---|
| 775 | setThreadQueueExtraCharMessage(teb, &extramsg);
|
|---|
| 776 | }
|
|---|
| 777 | #endif
|
|---|
| 778 | break;
|
|---|
| 779 | }
|
|---|
| 780 |
|
|---|
| 781 | case WM_TIMER:
|
|---|
| 782 | //Why was this check here????
|
|---|
| 783 | // if (os2Msg->mp2)
|
|---|
| 784 | // {
|
|---|
| 785 | BOOL sys;
|
|---|
| 786 | ULONG id;
|
|---|
| 787 |
|
|---|
| 788 | if (TIMER_GetTimerInfo(os2Msg->hwnd,(ULONG)os2Msg->mp1,&sys,&id))
|
|---|
| 789 | {
|
|---|
| 790 | winMsg->wParam = (WPARAM)id;
|
|---|
| 791 | winMsg->message= (sys) ? WINWM_SYSTIMER : WINWM_TIMER;
|
|---|
| 792 | break;
|
|---|
| 793 | }
|
|---|
| 794 | // }
|
|---|
| 795 | goto dummymessage; //for caret blinking
|
|---|
| 796 |
|
|---|
| 797 | case WM_SETWINDOWPARAMS:
|
|---|
| 798 | {
|
|---|
| 799 | WNDPARAMS *wndParams = (WNDPARAMS *)os2Msg->mp1;
|
|---|
| 800 |
|
|---|
| 801 | if(wndParams->fsStatus & WPM_TEXT) {
|
|---|
| 802 | winMsg->message = WINWM_SETTEXT;
|
|---|
| 803 | winMsg->lParam = (LPARAM)wndParams->pszText;
|
|---|
| 804 | break;
|
|---|
| 805 | }
|
|---|
| 806 | goto dummymessage;
|
|---|
| 807 | }
|
|---|
| 808 |
|
|---|
| 809 | #if 0
|
|---|
| 810 | case WM_QUERYWINDOWPARAMS:
|
|---|
| 811 | {
|
|---|
| 812 | PWNDPARAMS wndpars = (PWNDPARAMS)mp1;
|
|---|
| 813 | ULONG textlen;
|
|---|
| 814 | PSZ wintext;
|
|---|
| 815 |
|
|---|
| 816 | if(wndpars->fsStatus & (WPM_CCHTEXT | WPM_TEXT))
|
|---|
| 817 | {
|
|---|
| 818 | if(wndpars->fsStatus & WPM_CCHTEXT)
|
|---|
| 819 | wndpars->cchText = win32wnd->MsgGetTextLength();
|
|---|
| 820 | if(wndpars->fsStatus & WPM_TEXT)
|
|---|
| 821 | wndpars->pszText = win32wnd->MsgGetText();
|
|---|
| 822 |
|
|---|
| 823 | wndpars->fsStatus = 0;
|
|---|
| 824 | wndpars->cbCtlData = 0;
|
|---|
| 825 | wndpars->cbPresParams = 0;
|
|---|
| 826 | goto dummymessage;
|
|---|
| 827 | }
|
|---|
| 828 | }
|
|---|
| 829 | #endif
|
|---|
| 830 |
|
|---|
| 831 | case WM_PAINT:
|
|---|
| 832 | {
|
|---|
| 833 | if(win32wnd->IsWindowIconic()) {
|
|---|
| 834 | winMsg->message = WINWM_PAINTICON;
|
|---|
| 835 | }
|
|---|
| 836 | else winMsg->message = WINWM_PAINT;
|
|---|
| 837 | break;
|
|---|
| 838 | }
|
|---|
| 839 |
|
|---|
| 840 | case WM_CONTEXTMENU:
|
|---|
| 841 | winMsg->message = WINWM_CONTEXTMENU;
|
|---|
| 842 | winMsg->wParam = win32wnd->getWindowHandle();
|
|---|
| 843 | winMsg->lParam = MAKELONG(winMsg->pt.x,winMsg->pt.y);
|
|---|
| 844 | break;
|
|---|
| 845 |
|
|---|
| 846 | case WM_RENDERFMT:
|
|---|
| 847 | winMsg->message = WINWM_RENDERFORMAT;
|
|---|
| 848 | winMsg->wParam = (UINT) os2Msg->mp1;
|
|---|
| 849 | break;
|
|---|
| 850 |
|
|---|
| 851 | case WM_RENDERALLFMTS:
|
|---|
| 852 | winMsg->message = WINWM_RENDERALLFORMATS;
|
|---|
| 853 | break;
|
|---|
| 854 |
|
|---|
| 855 | case WM_DESTROYCLIPBOARD:
|
|---|
| 856 | winMsg->message = WINWM_DESTROYCLIPBOARD;
|
|---|
| 857 | break;
|
|---|
| 858 |
|
|---|
| 859 | case WM_HSCROLL:
|
|---|
| 860 | case WM_VSCROLL:
|
|---|
| 861 | winMsg->message = (os2Msg->msg == WM_HSCROLL) ? WINWM_HSCROLL : WINWM_VSCROLL;
|
|---|
| 862 | winMsg->lParam = 0;
|
|---|
| 863 | winMsg->wParam = 0;
|
|---|
| 864 | switch(SHORT2FROMMP(os2Msg->mp2)) {
|
|---|
| 865 | case SB_LINERIGHT:
|
|---|
| 866 | winMsg->wParam = SB_LINERIGHT_W;
|
|---|
| 867 | break;
|
|---|
| 868 | case SB_LINELEFT:
|
|---|
| 869 | winMsg->wParam = SB_LINELEFT_W;
|
|---|
| 870 | break;
|
|---|
| 871 | case SB_PAGELEFT:
|
|---|
| 872 | winMsg->wParam = SB_PAGELEFT_W;
|
|---|
| 873 | break;
|
|---|
| 874 | case SB_PAGERIGHT:
|
|---|
| 875 | winMsg->wParam = SB_PAGERIGHT_W;
|
|---|
| 876 | break;
|
|---|
| 877 | default:
|
|---|
| 878 | dprintf(("Unsupported WM_H/VSCROLL message %x!!", SHORT2FROMMP(os2Msg->mp2)));
|
|---|
| 879 | goto dummymessage;
|
|---|
| 880 | }
|
|---|
| 881 | break;
|
|---|
| 882 |
|
|---|
| 883 | case WM_INITMENU:
|
|---|
| 884 | case WM_MENUSELECT:
|
|---|
| 885 | case WM_MENUEND:
|
|---|
| 886 | case WM_NEXTMENU:
|
|---|
| 887 | case WM_SYSCOLORCHANGE:
|
|---|
| 888 | case WM_SYSVALUECHANGED:
|
|---|
| 889 | case WM_SETSELECTION:
|
|---|
| 890 | case WM_PPAINT:
|
|---|
| 891 | case WM_PSETFOCUS:
|
|---|
| 892 | case WM_PSYSCOLORCHANGE:
|
|---|
| 893 | case WM_PSIZE:
|
|---|
| 894 | case WM_PACTIVATE:
|
|---|
| 895 | case WM_PCONTROL:
|
|---|
| 896 | case WM_HELP:
|
|---|
| 897 | case WM_APPTERMINATENOTIFY:
|
|---|
| 898 | case WM_PRESPARAMCHANGED:
|
|---|
| 899 | case WM_DRAWITEM:
|
|---|
| 900 | case WM_MEASUREITEM:
|
|---|
| 901 | case WM_CONTROLPOINTER:
|
|---|
| 902 | case WM_QUERYDLGCODE:
|
|---|
| 903 | case WM_SUBSTITUTESTRING:
|
|---|
| 904 | case WM_MATCHMNEMONIC:
|
|---|
| 905 | case WM_SAVEAPPLICATION:
|
|---|
| 906 | case WM_SEMANTICEVENT:
|
|---|
| 907 | default:
|
|---|
| 908 | dummymessage:
|
|---|
| 909 | dprintf2(("dummy message %x %x %x %x", os2Msg->hwnd, os2Msg->msg, os2Msg->mp1, os2Msg->mp2));
|
|---|
| 910 | winMsg->message = 0;
|
|---|
| 911 | winMsg->wParam = 0;
|
|---|
| 912 | winMsg->lParam = 0;
|
|---|
| 913 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 914 | return FALSE;
|
|---|
| 915 | }
|
|---|
| 916 | if(win32wnd) RELEASE_WNDOBJ(win32wnd);
|
|---|
| 917 | return TRUE;
|
|---|
| 918 | }
|
|---|
| 919 | //******************************************************************************
|
|---|
| 920 | //******************************************************************************
|
|---|
| 921 | BOOL OSLibWinTranslateMessage(MSG *msg)
|
|---|
| 922 | {
|
|---|
| 923 | TEB *teb;
|
|---|
| 924 | MSG extramsg;
|
|---|
| 925 |
|
|---|
| 926 | teb = GetThreadTEB();
|
|---|
| 927 | if(!teb)
|
|---|
| 928 | return FALSE;
|
|---|
| 929 |
|
|---|
| 930 | UCHAR ucPMScanCode = CHAR4FROMMP(teb->o.odin.os2msg.mp1);
|
|---|
| 931 | ULONG fl = SHORT1FROMMP(teb->o.odin.os2msg.mp1);
|
|---|
| 932 |
|
|---|
| 933 |
|
|---|
| 934 | //NOTE: These actually need to be posted so that the next message retrieved by GetMessage contains
|
|---|
| 935 | // the newly generated WM_CHAR message.
|
|---|
| 936 | if(!teb->o.odin.fTranslated &&
|
|---|
| 937 | teb->o.odin.os2msg.msg == WM_CHAR &&
|
|---|
| 938 | !((SHORT1FROMMP(teb->o.odin.os2msg.mp1) & KC_KEYUP) == KC_KEYUP))
|
|---|
| 939 | {
|
|---|
| 940 | //TranslatedMessage was called before DispatchMessage, so queue WM_CHAR message
|
|---|
| 941 | memcpy(&extramsg, msg, sizeof(MSG));
|
|---|
| 942 | extramsg.wParam = SHORT1FROMMP(teb->o.odin.os2msg.mp2);
|
|---|
| 943 | extramsg.lParam = 0;
|
|---|
| 944 |
|
|---|
| 945 | // ESCAPE generates a WM_CHAR under windows, so take
|
|---|
| 946 | // special care for this here.
|
|---|
| 947 | switch (ucPMScanCode)
|
|---|
| 948 | {
|
|---|
| 949 | case PMSCAN_ESC:
|
|---|
| 950 | extramsg.wParam = VK_ESCAPE_W;
|
|---|
| 951 | fl |= KC_CHAR;
|
|---|
| 952 | break;
|
|---|
| 953 | }
|
|---|
| 954 |
|
|---|
| 955 | if(!(fl & KC_CHAR) && msg->message < WINWM_SYSKEYDOWN)
|
|---|
| 956 | {
|
|---|
| 957 | return FALSE;
|
|---|
| 958 | }
|
|---|
| 959 |
|
|---|
| 960 | if(fl & KC_VIRTUALKEY)
|
|---|
| 961 | {
|
|---|
| 962 | if(msg->wParam)
|
|---|
| 963 | {
|
|---|
| 964 | if ((msg->wParam >= VK_NUMPAD0_W) &&
|
|---|
| 965 | (msg->wParam <= VK_NUMPAD9_W))
|
|---|
| 966 | extramsg.wParam = msg->wParam - 0x30;
|
|---|
| 967 | else
|
|---|
| 968 | extramsg.wParam = msg->wParam;
|
|---|
| 969 | }
|
|---|
| 970 | else
|
|---|
| 971 | extramsg.wParam = SHORT2FROMMP(teb->o.odin.os2msg.mp2);
|
|---|
| 972 | }
|
|---|
| 973 |
|
|---|
| 974 |
|
|---|
| 975 | if(msg->message >= WINWM_SYSKEYDOWN)
|
|---|
| 976 | extramsg.message = WINWM_SYSCHAR;
|
|---|
| 977 | else
|
|---|
| 978 | extramsg.message = WINWM_CHAR;
|
|---|
| 979 |
|
|---|
| 980 | if(fl & KC_DEADKEY)
|
|---|
| 981 | extramsg.message++; //WM_DEADCHAR/WM_SYSDEADCHAR
|
|---|
| 982 |
|
|---|
| 983 |
|
|---|
| 984 | extramsg.lParam = msg->lParam & 0x00FFFFFF;
|
|---|
| 985 | if(fl & KC_ALT)
|
|---|
| 986 | extramsg.lParam |= WIN_KEY_ALTHELD;
|
|---|
| 987 | if(fl & KC_PREVDOWN)
|
|---|
| 988 | extramsg.lParam |= WIN_KEY_PREVSTATE;
|
|---|
| 989 | if(fl & KC_KEYUP)
|
|---|
| 990 | extramsg.lParam |= (1<<31);
|
|---|
| 991 |
|
|---|
| 992 | // insert message into the queue
|
|---|
| 993 | setThreadQueueExtraCharMessage(teb, &extramsg);
|
|---|
| 994 | return TRUE;
|
|---|
| 995 | }
|
|---|
| 996 | return FALSE;
|
|---|
| 997 | }
|
|---|
| 998 | //******************************************************************************
|
|---|
| 999 | //******************************************************************************
|
|---|
| 1000 |
|
|---|