Changeset 7155 for trunk/src


Ignore:
Timestamp:
Oct 23, 2001, 1:17:18 AM (24 years ago)
Author:
phaller
Message:

added PM hook

Location:
trunk/src
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/HOOK.CPP

    r7154 r7155  
    1 /* $Id: HOOK.CPP,v 1.26 2001-10-22 17:00:58 phaller Exp $ */
     1/* $Id: HOOK.CPP,v 1.27 2001-10-22 23:14:32 phaller Exp $ */
    22
    33/*
     
    825825 
    826826  // check if alt is currently pressed
    827   BOOL fAltDown = GetKeyState(VK_LMENU);
     827  // Note: ALT seems to stick sometimes
     828  // BOOL fAltDown = GetKeyState(VK_LMENU);
     829  BOOL fAltDown = GetAsyncKeyState(VK_LMENU);
    828830 
    829831  kbhs.vkCode      = msg->wParam;
  • trunk/src/user32/inituser32.cpp

    r6650 r7155  
    1 /* $Id: inituser32.cpp,v 1.5 2001-09-05 13:53:50 bird Exp $ */
     1/* $Id: inituser32.cpp,v 1.6 2001-10-22 23:13:58 phaller Exp $ */
    22/*
    33 * USER32 DLL entry point
     
    2828#define  INCL_DOSSEMAPHORES
    2929#define  INCL_DOSMISC
     30#define  INCL_DOSERRORS
    3031#include <os2wrap.h>    //Odin32 OS/2 api wrappers
    3132#include <stdlib.h>
     
    6465DWORD hInstanceUser32 = 0;
    6566
     67
     68/**************************************************************/
     69/* Try to load the Presentation Manager Keyboard Hook module. */
     70/* If this fails, some hotkeys may not arrive properly at the */
     71/* targetted window, but no more harmful things will happen.  */
     72/**************************************************************/
     73#define PMKBDHK_MODULE "PMKBDHK"
     74#define PMKBDHK_HOOK_INIT "hookInit"
     75#define PMKBDHK_HOOK_TERM "hookKill"
     76
     77static BOOL pmkbdhk_installed = FALSE;
     78static HMODULE hmodPMKBDHK;
     79
     80static PVOID (*APIENTRY pfnHookInit)(HAB);
     81static BOOL  (*APIENTRY pfnHookTerm)(void);
     82
     83// defined initialized in pmwindow.cpp: InitPM()
     84extern HAB hab;
     85
     86void pmkbdhk_initialize(HAB _hab)
     87{
     88  APIRET rc;
     89 
     90  if (pmkbdhk_installed == FALSE)
     91  {
     92    CHAR szBuf[260];
     93   
     94    // load the DLL
     95    rc = DosLoadModule(szBuf,
     96                       sizeof(szBuf),
     97                       PMKBDHK_MODULE,
     98                       &hmodPMKBDHK);
     99    if (NO_ERROR != rc)
     100    {
     101      dprintf(("USER32: pmkbdhk_initalize(%08xh) failed rc=%d\n",
     102               _hab,
     103               rc));
     104     
     105      return;
     106    }
     107   
     108    // get the entry points
     109    rc = DosQueryProcAddr(hmodPMKBDHK,
     110                          0,
     111                          PMKBDHK_HOOK_INIT,
     112                          (PFN*)&pfnHookInit);
     113    if (NO_ERROR == rc)
     114      rc = DosQueryProcAddr(hmodPMKBDHK,
     115                            0,
     116                            PMKBDHK_HOOK_TERM,
     117                            (PFN*)&pfnHookTerm);
     118   
     119    if (NO_ERROR != rc)
     120    {
     121      dprintf(("USER32: pmkbdhk_initalize(%08xh) failed importing functions, rc=%d\n",
     122               _hab,
     123               rc));
     124     
     125      // free the DLL again
     126      DosFreeModule(hmodPMKBDHK);
     127      hmodPMKBDHK = NULLHANDLE;
     128     
     129      return;
     130    }
     131   
     132    // now finally call the initializer function
     133    pfnHookInit(_hab);
     134   
     135    // OK, hook is armed
     136    pmkbdhk_installed = TRUE;
     137  }
     138}
     139
     140void pmkbdhk_terminate(void)
     141{
     142  if (pmkbdhk_installed == TRUE)
     143  {
     144    // call the terminator function
     145    pfnHookTerm();
     146   
     147    // OK, hook is disarmed
     148    pmkbdhk_installed = TRUE;
     149  }
     150 
     151  // unload the dll
     152  if (NULLHANDLE != hmodPMKBDHK)
     153  {
     154    APIRET rc = DosFreeModule(hmodPMKBDHK);
     155    if (NO_ERROR != rc)
     156    {
     157      dprintf(("USER32: pmkbdhk_terminate() failed rc=%d\n",
     158               rc));
     159   
     160      hmodPMKBDHK = NULLHANDLE;
     161    }
     162  }
     163}
     164
     165
    66166/****************************************************************************/
    67167/* _DLL_InitTerm is the function that gets called by the operating system   */
     
    103203
    104204         //SvL: Init win32 PM classes
    105          if(InitPM() == FALSE) {
    106                 return 0UL;
    107          }
     205         //PH:  initializes HAB!
     206         if (FALSE == InitPM())
     207           return 0UL;
     208     
     209         // try to install the keyboard hook
     210         pmkbdhk_initialize(hab);
    108211
    109212         //SvL: 18-7-'98, Register system window classes (button, listbox etc etc)
     
    114217         MONITOR_Initialize(&MONITOR_PrimaryMonitor);
    115218
    116          break;
    117       case 1 :
     219       break;
     220     
     221     
     222       case 1 :
    118223         if(hInstanceUser32) {
    119224            UnregisterLxDll(hInstanceUser32);
     
    132237void APIENTRY cleanupUser32(ULONG ulReason)
    133238{
    134    dprintf(("user32 exit\n"));
     239  dprintf(("user32 exit\n"));
     240 
     241  // try to unistall the keyboard hook
     242  pmkbdhk_terminate();
     243
    135244//SvL: Causes PM hangs on some (a lot?) machines. Reason unknown.
    136245////   RestoreCursor();
  • trunk/src/user32/oslibmsgtranslate.cpp

    r6745 r7155  
    1 /* $Id: oslibmsgtranslate.cpp,v 1.60 2001-09-17 13:31:29 sandervl Exp $ */
     1/* $Id: oslibmsgtranslate.cpp,v 1.61 2001-10-22 23:14:32 phaller Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    3333#include "oslibwin.h"
    3434#include "winmouse.h"
     35#include <pmkbdhk.h>
    3536
    3637#define DBG_LOCALLOG    DBG_oslibmsgtranslate
     
    600601        break;
    601602    }
     603     
     604    case WM_CHAR_SPECIAL:
     605        // @@@PH
     606        // special char message from the keyboard hook
     607        dprintf(("PM: WM_CHAR_SPECIAL\n"));
     608        // NO BREAK! FALLTHRU CASE!
     609     
    602610    case WM_CHAR:
    603611    {
Note: See TracChangeset for help on using the changeset viewer.