win32u: Move accelerators object implementation from user32.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-03-02 15:06:33 +01:00 committed by Alexandre Julliard
parent e58b561ced
commit 9759ed143a
12 changed files with 154 additions and 100 deletions

View File

@ -5705,12 +5705,12 @@ INT WINAPI TranslateAcceleratorW( HWND hWnd, HACCEL hAccel, LPMSG msg )
TRACE_(accel)("hAccel %p, hWnd %p, msg->hwnd %p, msg->message %04x, wParam %08lx, lParam %08lx\n",
hAccel,hWnd,msg->hwnd,msg->message,msg->wParam,msg->lParam);
if (!(count = CopyAcceleratorTableW( hAccel, NULL, 0 ))) return 0;
if (!(count = NtUserCopyAcceleratorTable( hAccel, NULL, 0 ))) return 0;
if (count > ARRAY_SIZE( data ))
{
if (!(ptr = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*ptr) ))) return 0;
}
count = CopyAcceleratorTableW( hAccel, ptr, count );
count = NtUserCopyAcceleratorTable( hAccel, ptr, count );
for (i = 0; i < count; i++)
{
if (translate_accelerator( hWnd, msg->message, msg->wParam, msg->lParam,

View File

@ -23,11 +23,9 @@
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winternl.h"
#include "winnls.h"
#include "ntuser.h"
#include "wine/debug.h"
#include "user_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(resource);
WINE_DECLARE_DEBUG_CHANNEL(accel);
@ -41,14 +39,6 @@ typedef struct
WORD pad;
} PE_ACCEL;
/* the accelerator user object */
struct accelerator
{
struct user_object obj;
unsigned int count;
ACCEL table[1];
};
/**********************************************************************
* LoadAcceleratorsW (USER32.@)
*/
@ -73,7 +63,7 @@ HACCEL WINAPI LoadAcceleratorsW(HINSTANCE instance, LPCWSTR name)
table[i].key = pe_table[i].key;
table[i].cmd = pe_table[i].cmd;
}
handle = CreateAcceleratorTableW( table, count );
handle = NtUserCreateAcceleratorTable( table, count );
HeapFree( GetProcessHeap(), 0, table );
TRACE_(accel)("%p %s returning %p\n", instance, debugstr_w(name), handle );
return handle;
@ -106,7 +96,7 @@ HACCEL WINAPI LoadAcceleratorsA(HINSTANCE instance,LPCSTR lpTableName)
INT WINAPI CopyAcceleratorTableA(HACCEL src, LPACCEL dst, INT count)
{
char ch;
int i, ret = CopyAcceleratorTableW( src, dst, count );
int i, ret = NtUserCopyAcceleratorTable( src, dst, count );
if (ret && dst)
{
@ -120,35 +110,6 @@ INT WINAPI CopyAcceleratorTableA(HACCEL src, LPACCEL dst, INT count)
return ret;
}
/**********************************************************************
* CopyAcceleratorTableW (USER32.@)
*/
INT WINAPI CopyAcceleratorTableW(HACCEL src, LPACCEL dst, INT count)
{
struct accelerator *accel;
int i;
if (!(accel = get_user_handle_ptr( src, NTUSER_OBJ_ACCEL ))) return 0;
if (accel == OBJ_OTHER_PROCESS)
{
FIXME( "other process handle %p?\n", src );
return 0;
}
if (dst)
{
if (count > accel->count) count = accel->count;
for (i = 0; i < count; i++)
{
dst[i].fVirt = accel->table[i].fVirt & 0x7f;
dst[i].key = accel->table[i].key;
dst[i].cmd = accel->table[i].cmd;
}
}
else count = accel->count;
release_user_handle_ptr( accel );
return count;
}
/*********************************************************************
* CreateAcceleratorTableA (USER32.@)
*/
@ -176,60 +137,12 @@ HACCEL WINAPI CreateAcceleratorTableA( ACCEL *accel, INT count )
}
else table[i].key = accel[i].key;
}
handle = CreateAcceleratorTableW( table, count );
handle = NtUserCreateAcceleratorTable( table, count );
HeapFree( GetProcessHeap(), 0, table );
TRACE_(accel)("returning %p\n", handle );
return handle;
}
/*********************************************************************
* CreateAcceleratorTableW (USER32.@)
*/
HACCEL WINAPI CreateAcceleratorTableW(LPACCEL lpaccel, INT count)
{
struct accelerator *accel;
HACCEL handle;
if (count < 1)
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
accel = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( struct accelerator, table[count] ));
if (!accel) return 0;
accel->count = count;
memcpy( accel->table, lpaccel, count * sizeof(*lpaccel) );
if (!(handle = alloc_user_handle( &accel->obj, NTUSER_OBJ_ACCEL )))
HeapFree( GetProcessHeap(), 0, accel );
TRACE_(accel)("returning %p\n", handle );
return handle;
}
/******************************************************************************
* DestroyAcceleratorTable [USER32.@]
* Destroys an accelerator table
*
* PARAMS
* handle [I] Handle to accelerator table
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOL WINAPI DestroyAcceleratorTable( HACCEL handle )
{
struct accelerator *accel;
if (!(accel = free_user_handle( handle, NTUSER_OBJ_ACCEL ))) return FALSE;
if (accel == OBJ_OTHER_PROCESS)
{
FIXME( "other process handle %p?\n", accel );
return FALSE;
}
return HeapFree( GetProcessHeap(), 0, accel );
}
/**********************************************************************
* LoadStringW (USER32.@)
*/

View File

@ -79,13 +79,13 @@
@ stdcall CloseWindow(long)
@ stdcall CloseWindowStation(long) NtUserCloseWindowStation
@ stdcall CopyAcceleratorTableA(long ptr long)
@ stdcall CopyAcceleratorTableW(long ptr long)
@ stdcall CopyAcceleratorTableW(long ptr long) NtUserCopyAcceleratorTable
@ stdcall CopyIcon(long)
@ stdcall CopyImage(long long long long long)
@ stdcall CopyRect(ptr ptr)
@ stdcall CountClipboardFormats() NtUserCountClipboardFormats
@ stdcall CreateAcceleratorTableA(ptr long)
@ stdcall CreateAcceleratorTableW(ptr long)
@ stdcall CreateAcceleratorTableW(ptr long) NtUserCreateAcceleratorTable
@ stdcall CreateCaret(long long long long)
@ stdcall CreateCursor(long long long long long ptr ptr)
@ stdcall CreateDesktopA(str str ptr long long ptr)
@ -155,7 +155,7 @@
@ stdcall DeferWindowPos(long long long long long long long long)
@ stdcall DeleteMenu(long long long)
@ stdcall DeregisterShellHookWindow (long)
@ stdcall DestroyAcceleratorTable(long)
@ stdcall DestroyAcceleratorTable(long) NtUserDestroyAcceleratorTable
@ stdcall DestroyCaret()
@ stdcall DestroyCursor(long)
@ stdcall DestroyIcon(long)

View File

@ -32,6 +32,7 @@ C_SRCS = \
input.c \
main.c \
mapping.c \
menu.c \
message.c \
opentype.c \
painting.c \

107
dlls/win32u/menu.c Normal file
View File

@ -0,0 +1,107 @@
/*
* Menu functions
*
* Copyright 1993 Robert J. Amstadt
* Copyright 1995, 2009 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "win32u_private.h"
#include "ntuser_private.h"
#include "wine/debug.h"
WINE_DECLARE_DEBUG_CHANNEL(accel);
/* the accelerator user object */
struct accelerator
{
struct user_object obj;
unsigned int count;
ACCEL table[1];
};
/**********************************************************************
* NtUserCopyAcceleratorTable (win32u.@)
*/
INT WINAPI NtUserCopyAcceleratorTable( HACCEL src, ACCEL *dst, INT count )
{
struct accelerator *accel;
int i;
if (!(accel = get_user_handle_ptr( src, NTUSER_OBJ_ACCEL ))) return 0;
if (accel == OBJ_OTHER_PROCESS)
{
FIXME_(accel)( "other process handle %p?\n", src );
return 0;
}
if (dst)
{
if (count > accel->count) count = accel->count;
for (i = 0; i < count; i++)
{
dst[i].fVirt = accel->table[i].fVirt & 0x7f;
dst[i].key = accel->table[i].key;
dst[i].cmd = accel->table[i].cmd;
}
}
else count = accel->count;
release_user_handle_ptr( accel );
return count;
}
/*********************************************************************
* NtUserCreateAcceleratorTable (win32u.@)
*/
HACCEL WINAPI NtUserCreateAcceleratorTable( ACCEL *table, INT count )
{
struct accelerator *accel;
HACCEL handle;
if (count < 1)
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
accel = malloc( FIELD_OFFSET( struct accelerator, table[count] ));
if (!accel) return 0;
accel->count = count;
memcpy( accel->table, table, count * sizeof(*table) );
if (!(handle = alloc_user_handle( &accel->obj, NTUSER_OBJ_ACCEL ))) free( accel );
TRACE_(accel)("returning %p\n", handle );
return handle;
}
/******************************************************************************
* NtUserDestroyAcceleratorTable (win32u.@)
*/
BOOL WINAPI NtUserDestroyAcceleratorTable( HACCEL handle )
{
struct accelerator *accel;
if (!(accel = free_user_handle( handle, NTUSER_OBJ_ACCEL ))) return FALSE;
if (accel == OBJ_OTHER_PROCESS)
{
FIXME_(accel)( "other process handle %p\n", accel );
return FALSE;
}
free( accel );
return TRUE;
}

View File

@ -23,7 +23,6 @@
#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include "win32u_private.h"
/* extra stock object: default 1x1 bitmap for memory DCs */

View File

@ -106,8 +106,11 @@ static void * const syscalls[] =
NtUserBuildHwndList,
NtUserCloseDesktop,
NtUserCloseWindowStation,
NtUserCopyAcceleratorTable,
NtUserCreateAcceleratorTable,
NtUserCreateDesktopEx,
NtUserCreateWindowStation,
NtUserDestroyAcceleratorTable,
NtUserFindExistingCursorIcon,
NtUserGetClipboardFormatName,
NtUserGetClipboardOwner,

View File

@ -802,9 +802,9 @@
@ stub NtUserConfirmResizeCommit
@ stub NtUserConsoleControl
@ stub NtUserConvertMemHandle
@ stub NtUserCopyAcceleratorTable
@ stdcall -syscall NtUserCopyAcceleratorTable(long ptr long)
@ stdcall NtUserCountClipboardFormats()
@ stub NtUserCreateAcceleratorTable
@ stdcall -syscall NtUserCreateAcceleratorTable(ptr long)
@ stub NtUserCreateActivationGroup
@ stub NtUserCreateActivationObject
@ stub NtUserCreateCaret
@ -826,7 +826,7 @@
@ stub NtUserDelegateInput
@ stub NtUserDeleteMenu
@ stub NtUserDeleteWindowGroup
@ stub NtUserDestroyAcceleratorTable
@ stdcall -syscall NtUserDestroyAcceleratorTable(long)
@ stub NtUserDestroyActivationGroup
@ stub NtUserDestroyActivationObject
@ stdcall NtUserDestroyCursor(long long)

View File

@ -22,6 +22,7 @@
#define __WINE_WIN32U_PRIVATE
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "ntgdi.h"

View File

@ -93,8 +93,11 @@
SYSCALL_ENTRY( NtUserBuildHwndList ) \
SYSCALL_ENTRY( NtUserCloseDesktop ) \
SYSCALL_ENTRY( NtUserCloseWindowStation ) \
SYSCALL_ENTRY( NtUserCopyAcceleratorTable ) \
SYSCALL_ENTRY( NtUserCreateAcceleratorTable ) \
SYSCALL_ENTRY( NtUserCreateDesktopEx ) \
SYSCALL_ENTRY( NtUserCreateWindowStation ) \
SYSCALL_ENTRY( NtUserDestroyAcceleratorTable ) \
SYSCALL_ENTRY( NtUserFindExistingCursorIcon ) \
SYSCALL_ENTRY( NtUserGetClipboardFormatName ) \
SYSCALL_ENTRY( NtUserGetClipboardOwner ) \

View File

@ -491,3 +491,27 @@ NTSTATUS WINAPI wow64_NtUserGetGUIThreadInfo( UINT *args )
info32->rcCaret = info.rcCaret;
return TRUE;
}
NTSTATUS WINAPI wow64_NtUserCopyAcceleratorTable( UINT *args )
{
HACCEL src = get_handle( &args );
ACCEL *dst = get_ptr( &args );
INT count = get_ulong( &args );
return NtUserCopyAcceleratorTable( src, dst, count );
}
NTSTATUS WINAPI wow64_NtUserCreateAcceleratorTable( UINT *args )
{
ACCEL *table = get_ptr( &args );
INT count = get_ulong( &args );
return HandleToUlong( NtUserCreateAcceleratorTable( table, count ));
}
NTSTATUS WINAPI wow64_NtUserDestroyAcceleratorTable( UINT *args )
{
HACCEL handle = get_handle( &args );
return NtUserDestroyAcceleratorTable( handle );
}

View File

@ -215,12 +215,15 @@ LONG WINAPI NtUserChangeDisplaySettings( UNICODE_STRING *devname, DEVMODEW *d
BOOL WINAPI NtUserClipCursor( const RECT *rect );
BOOL WINAPI NtUserCloseDesktop( HDESK handle );
BOOL WINAPI NtUserCloseWindowStation( HWINSTA handle );
INT WINAPI NtUserCopyAcceleratorTable( HACCEL src, ACCEL *dst, INT count );
INT WINAPI NtUserCountClipboardFormats(void);
HACCEL WINAPI NtUserCreateAcceleratorTable( ACCEL *table, INT count );
HDESK WINAPI NtUserCreateDesktopEx( OBJECT_ATTRIBUTES *attr, UNICODE_STRING *device,
DEVMODEW *devmode, DWORD flags, ACCESS_MASK access,
ULONG heap_size );
HWINSTA WINAPI NtUserCreateWindowStation( OBJECT_ATTRIBUTES *attr, ACCESS_MASK mask, ULONG arg3,
ULONG arg4, ULONG arg5, ULONG arg6, ULONG arg7 );
BOOL WINAPI NtUserDestroyAcceleratorTable( HACCEL handle );
BOOL WINAPI NtUserDestroyCursor( HCURSOR cursor, ULONG arg );
BOOL WINAPI NtUserDrawIconEx( HDC hdc, INT x0, INT y0, HICON icon, INT width,
INT height, UINT istep, HBRUSH hbr, UINT flags );