Ignore:
Timestamp:
Oct 25, 2001, 5:35:53 PM (24 years ago)
Author:
phaller
Message:

fixed ESC processing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/oslibmsgtranslate.cpp

    r7201 r7205  
    1 /* $Id: oslibmsgtranslate.cpp,v 1.67 2001-10-25 13:16:57 phaller Exp $ */
     1/* $Id: oslibmsgtranslate.cpp,v 1.68 2001-10-25 15:35:53 phaller Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    3535#include <pmkbdhk.h>
    3636#include <pmscan.h>
     37#include <winscan.h>
    3738
    3839#define DBG_LOCALLOG    DBG_oslibmsgtranslate
     
    164165static MSG  doubleClickMsg = {0};
    165166
     167
     168//******************************************************************************
     169//******************************************************************************
     170BOOL setThreadQueueExtraCharMessage(TEB* teb, MSG* pExtraMsg)
     171{
     172  // check if the single slot is occupied already
     173  if (teb->o.odin.fTranslated == TRUE)
     174    // there's still an already translated message to be processed
     175    return FALSE;
     176 
     177  teb->o.odin.fTranslated = TRUE;
     178  memcpy(&teb->o.odin.msgWCHAR, pExtraMsg, sizeof(MSG));
     179  return TRUE;
     180}
     181
    166182//******************************************************************************
    167183//******************************************************************************
     
    652668        dprintf(("PM: WM_CHAR_SPECIAL\n"));
    653669       
    654         // AltGr is a very, very strange key!
    655         UCHAR ucPMScanCode = CHAR4FROMMP(os2Msg->mp1);
    656         switch (ucPMScanCode)
    657         {
    658           case PMSCAN_ESC:
    659             // Note: ESC generates a WM_CHAR under Windows, not under PM
    660             // so we've got to post it to ourself here!
    661             // WM_CHAR(0x0000001bh, 00010001h)
    662             // @@@PH
    663             break;
    664          
    665           case PMSCAN_PRINT:
    666             // Note: PRINT generates a WM_KEYUP under Windows
    667             // also only call the standard kbd hook for the WM_KEYUP msg,
    668             // the low-level hook is called twice
    669             // WM_CHAR(0x0000002ch, c1370001h)
    670             // @@@PH
    671             break;
    672          
    673           case PMSCAN_ALTRIGHT:
    674           {
    675             ULONG flags = SHORT1FROMMP(os2Msg->mp1);
    676            
    677             // we need very special treatment here for the
    678             // poor, crippled AltGr key
    679            
    680             if (flags & KC_KEYUP)
    681             {
    682               // key up
    683               // 1 - generate a virtual LCONTROL-keypress
    684               // 2 - send LMENU-keypress (NT emulates ALtGr w/ Ctrl-Alt!)
    685             }
    686             else
    687             {
    688               // key down:
    689               // 1 - generate a virtual LCONTROL-keypress
    690               // 2 - send LMENU-keypress (NT emulates ALtGr w/ Ctrl-AltGr!)
    691             }
    692           }
    693         } /* switch */
    694     } /* case */
    695         // NO BREAK! FALLTHRU CASE!
     670      // NO BREAK! FALLTHRU CASE!
     671    }
    696672     
    697673    case WM_CHAR:
     
    824800            winMsg->lParam |= 1 << 29;
    825801          }
     802        }
     803     
     804        // ------------------------------------------------
     805        // check if additional messages have to be recorded
     806        // ------------------------------------------------
     807        {
     808          MSG extramsg;
     809          extramsg.hwnd = winMsg->hwnd;
     810          extramsg.time = winMsg->time;
     811          extramsg.pt   = winMsg->pt;
     812         
     813          switch (scanCode)
     814          {
     815            case PMSCAN_ESC:
     816            {
     817              // Note: ESC generates a WM_CHAR for WINWM_KEYDOWN
     818              // under Windows, not under PM
     819              // so we've got to post it to ourself here!
     820              // WM_CHAR(0x0000001bh, 00010001h)
     821              if (winMsg->message == WINWM_KEYDOWN)
     822              {
     823                extramsg.message = WINWM_CHAR;
     824                extramsg.wParam  = VK_ESCAPE_W;
     825                extramsg.lParam  = winMsg->lParam;
     826                setThreadQueueExtraCharMessage(teb, &extramsg);
     827              }
     828            }
     829            break;
     830           
     831#if 0
     832            case PMSCAN_PRINT:
     833              // Note: PRINT generates a WM_KEYUP under Windows
     834              // also only call the standard kbd hook for the WM_KEYUP msg,
     835              // the low-level hook is called twice
     836              // mb->putWinMsg(hwndWin32, WM_CHAR, VK_PRINT_W, ... )
     837              // WM_CHAR(0x0000002ch, c1370001h)
     838              extramsg.message = WINWM_KEYUP;
     839              extramsg.wParam  = VK_PRINT_W;
     840              extramsg.lParam  = winMsg->lParam;
     841              setThreadQueueExtraCharMessage(teb, &extramsg);
     842              break;
     843#endif
     844           
     845            case PMSCAN_ALTRIGHT:
     846            {
     847              // we need very special treatment here for the
     848              // poor, crippled AltGr key
     849              if (keyWasPressed)
     850              {
     851                // 1 - generate a virtual LCONTROL-keypress
     852                // 2 - send LMENU-keypress (NT emulates ALtGr w/ Ctrl-AltGr!)
     853                // 0xfe000000: mask out extended-key, scancode, repeatcount
     854                extramsg.message = WINWM_KEYDOWN;
     855                extramsg.wParam  = VK_RMENU_W;
     856                extramsg.lParam  = (winMsg->lParam & 0xfe000000)
     857                                   | repeatCount
     858                                   | (WINSCAN_ALTRIGHT << 24);
     859                winMsg->message  = WINWM_KEYDOWN;
     860                winMsg->wParam   = VK_LCONTROL_W;
     861                winMsg->lParam   = (winMsg->lParam & 0xfe000000)
     862                                   | repeatCount
     863                                   | (WINSCAN_CTRLLEFT << 24);
     864              }
     865              else
     866              {
     867                // key up
     868                // 1 - generate a virtual LCONTROL-keypress
     869                // 2 - send LMENU-keypress (NT emulates ALtGr w/ Ctrl-Alt!)
     870                extramsg.message = WINWM_KEYDOWN;
     871                extramsg.wParam  = VK_RMENU_W;
     872                extramsg.lParam  = (winMsg->lParam & 0xfe000000)
     873                                   | repeatCount
     874                                   | (WINSCAN_ALTRIGHT << 24);
     875                winMsg->message  = WINWM_SYSKEYUP;
     876                winMsg->wParam   = VK_LCONTROL_W;
     877                winMsg->lParam   = (winMsg->lParam & 0xfe000000)
     878                                   | repeatCount
     879                                   | (WINSCAN_CTRLLEFT << 24);
     880              }
     881             
     882              setThreadQueueExtraCharMessage(teb, &extramsg);
     883            }
     884          } /* switch */
    826885        }
    827886     
     
    10261085            if(fl & KC_KEYUP)
    10271086                extramsg.lParam |= (1<<31);
    1028 
    1029             teb->o.odin.fTranslated = TRUE;
    1030             memcpy(&teb->o.odin.msgWCHAR, &extramsg, sizeof(MSG));
     1087     
     1088            // insert message into the queue
     1089            setThreadQueueExtraCharMessage(teb, &extramsg);
    10311090            return TRUE;
    10321091    }
Note: See TracChangeset for help on using the changeset viewer.