Fixed a bug in the accelerators code

svn path=/trunk/; revision=5176
This commit is contained in:
KJK::Hyperion 2003-07-20 03:45:31 +00:00
parent e1c932cd9e
commit 93baf2c7ad
3 changed files with 45 additions and 28 deletions

View file

@ -0,0 +1,38 @@
/* $Id: accel.h,v 1.1 2003/07/20 03:45:31 hyperion Exp $
*/
#ifndef __USER32_ACCEL_H_INCLUDED__
#define __USER32_ACCEL_H_INCLUDED__
/* RT_ACCELERATOR resources are arrays of RES_ACCEL structures */
typedef struct _RES_ACCEL
{
WORD fVirt;
WORD key;
DWORD cmd;
}
RES_ACCEL;
/* ACCELERATOR TABLES CACHE */
/* Cache entry */
typedef struct _USER_ACCEL_CACHE_ENTRY
{
struct _USER_ACCEL_CACHE_ENTRY * Next;
ULONG_PTR Usage; /* how many times the table has been loaded */
HACCEL Object; /* handle to the NtUser accelerator table object */
HGLOBAL Data; /* base address of the resource data */
}
U32_ACCEL_CACHE_ENTRY;
/* Lock guarding the cache */
extern CRITICAL_SECTION U32AccelCacheLock;
/* Cache */
extern U32_ACCEL_CACHE_ENTRY * U32AccelCache;
extern U32_ACCEL_CACHE_ENTRY ** WINAPI U32AccelCacheFind(HANDLE, HGLOBAL);
extern void WINAPI U32AccelCacheAdd(HACCEL, HGLOBAL);
#endif
/* EOF */

View file

@ -1,6 +1,7 @@
#include <windows.h>
#include <debug.h>
#include <user32/callback.h>
#include <user32/accel.h>
#include <window.h>
#ifdef DBG
@ -43,6 +44,8 @@ Init(VOID)
(PVOID)User32SendSTYLECHANGEDMessageForKernel;
UserSetupInternalPos();
RtlInitializeCriticalSection(&U32AccelCacheLock);
GdiDllInitialize(NULL, DLL_PROCESS_ATTACH, NULL);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: accel.c,v 1.9 2003/07/11 17:08:44 chorns Exp $
/* $Id: accel.c,v 1.10 2003/07/20 03:45:31 hyperion Exp $
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/input.c
@ -28,42 +28,18 @@
*/
/* INCLUDES ******************************************************************/
#include <string.h>
#include <windows.h>
#include <user32.h>
#include <debug.h>
#include <user32/accel.h>
#include <win32k/ntuser.h>
/* FUNCTIONS *****************************************************************/
/* RT_ACCELERATOR resources are arrays of RES_ACCEL structures */
typedef struct _RES_ACCEL
{
WORD fVirt;
WORD key;
DWORD cmd;
}
RES_ACCEL;
/* ACCELERATOR TABLES CACHE */
/* Cache entry */
typedef struct _USER_ACCEL_CACHE_ENTRY
{
struct _USER_ACCEL_CACHE_ENTRY * Next;
ULONG_PTR Usage; /* how many times the table has been loaded */
HACCEL Object; /* handle to the NtUser accelerator table object */
HGLOBAL Data; /* base address of the resource data */
}
U32_ACCEL_CACHE_ENTRY;
/* Lock guarding the cache */
CRITICAL_SECTION U32AccelCacheLock;
/* Cache */
U32_ACCEL_CACHE_ENTRY * U32AccelCache = NULL;
U32_ACCEL_CACHE_ENTRY ** WINAPI U32AccelCacheFind(HANDLE, HGLOBAL);
void WINAPI U32AccelCacheAdd(HACCEL, HGLOBAL);
/* Look up a handle or resource address in the cache */
U32_ACCEL_CACHE_ENTRY ** WINAPI U32AccelCacheFind(HANDLE Object, HGLOBAL Data)
{
@ -220,7 +196,7 @@ BOOL WINAPI DestroyAcceleratorTable(HACCEL hAccel)
U32_ACCEL_CACHE_ENTRY * pEntry = *ppEntry;
/* decrement the reference count */
nUsage = pEntry->Usage= pEntry->Usage - 1;
nUsage = pEntry->Usage = pEntry->Usage - 1;
/* reference count now zero: destroy the cache entry */
if(nUsage == 0)