From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/cursoricon.c | 7 ++++--- dlls/win32u/dce.c | 8 ++++---- dlls/win32u/imm.c | 3 +-- dlls/win32u/menu.c | 22 +++++++++++----------- dlls/win32u/ntuser_private.h | 10 ++-------- dlls/win32u/window.c | 30 +++++++++++++----------------- 6 files changed, 35 insertions(+), 45 deletions(-)
diff --git a/dlls/win32u/cursoricon.c b/dlls/win32u/cursoricon.c index 1ce34ab3a54..dff7f646d6b 100644 --- a/dlls/win32u/cursoricon.c +++ b/dlls/win32u/cursoricon.c @@ -39,7 +39,7 @@ WINE_DECLARE_DEBUG_CHANNEL(icon);
struct cursoricon_object { - struct user_object obj; /* object header */ + HICON handle; /* cursor full handle */ struct list entry; /* entry in shared icons list */ struct free_icon_params params; /* opaque params used by 16-bit code */ UNICODE_STRING module; /* module for icons loaded from resources */ @@ -152,7 +152,8 @@ HICON alloc_cursoricon_handle( BOOL is_icon )
if (!(obj = calloc( 1, sizeof(*obj) ))) return NULL; obj->is_icon = is_icon; - if (!(handle = alloc_user_handle( &obj->obj, NTUSER_OBJ_ICON ))) free( obj ); + if (!(handle = alloc_user_handle( obj, NTUSER_OBJ_ICON ))) free( obj ); + else obj->handle = handle; return handle; }
@@ -358,7 +359,7 @@ HICON WINAPI NtUserFindExistingCursorIcon( UNICODE_STRING *module, UNICODE_STRIN if (memcmp( ptr->module.Buffer, module->Buffer, module->Length )) continue; /* We pass rsrc as desc argument, this is not compatible with Windows */ if (ptr->rsrc != desc) continue; - ret = ptr->obj.handle; + ret = ptr->handle; break; } user_unlock(); diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index c54e555fad5..19443c05373 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -1153,9 +1153,9 @@ void invalidate_dce( WND *win, const RECT *old_rect )
if (!win->parent) return;
- context = set_thread_dpi_awareness_context( get_window_dpi_awareness_context( win->obj.handle )); + context = set_thread_dpi_awareness_context( get_window_dpi_awareness_context( win->handle ) );
- TRACE("%p parent %p, old_rect %s\n", win->obj.handle, win->parent, wine_dbgstr_rect(old_rect) ); + TRACE( "%p parent %p, old_rect %s\n", win->handle, win->parent, wine_dbgstr_rect( old_rect ) );
/* walk all DCEs and fixup non-empty entries */
@@ -1170,7 +1170,7 @@ void invalidate_dce( WND *win, const RECT *old_rect ) continue; /* child window positions don't bother us */
/* if DCE window is a child of hwnd, it has to be invalidated */ - if (dce->hwnd == win->obj.handle || is_child( win->obj.handle, dce->hwnd )) + if (dce->hwnd == win->handle || is_child( win->handle, dce->hwnd )) { make_dc_dirty( dce ); continue; @@ -1183,7 +1183,7 @@ void invalidate_dce( WND *win, const RECT *old_rect ) struct window_rects rects;
/* get the parent client-relative old/new window rects */ - get_window_rects( win->obj.handle, COORDS_PARENT, &rects, get_thread_dpi() ); + get_window_rects( win->handle, COORDS_PARENT, &rects, get_thread_dpi() ); old_window_rect = old_rect ? *old_rect : rects.window; new_window_rect = rects.window;
diff --git a/dlls/win32u/imm.c b/dlls/win32u/imm.c index 8fd5d1e4923..986074194df 100644 --- a/dlls/win32u/imm.c +++ b/dlls/win32u/imm.c @@ -48,7 +48,6 @@ struct ime_update
struct imc { - struct user_object obj; DWORD thread_id; UINT_PTR client_ptr; }; @@ -95,7 +94,7 @@ HIMC WINAPI NtUserCreateInputContext( UINT_PTR client_ptr ) if (!(imc = malloc( sizeof(*imc) ))) return 0; imc->client_ptr = client_ptr; imc->thread_id = GetCurrentThreadId(); - if (!(handle = alloc_user_handle( &imc->obj, NTUSER_OBJ_IMC ))) + if (!(handle = alloc_user_handle( imc, NTUSER_OBJ_IMC ))) { free( imc ); return 0; diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c index e506e22124c..f98b45e4992 100644 --- a/dlls/win32u/menu.c +++ b/dlls/win32u/menu.c @@ -54,7 +54,7 @@ struct menu_item /* menu user object */ struct menu { - struct user_object obj; + HMENU handle; /* menu full handle */ struct menu_item *items; /* array of menu items */ WORD wFlags; /* menu flags (MF_POPUP, MF_SYSMENU) */ WORD Width; /* width of the whole menu */ @@ -80,7 +80,6 @@ struct menu /* the accelerator user object */ struct accelerator { - struct user_object obj; unsigned int count; ACCEL table[1]; }; @@ -208,7 +207,7 @@ HACCEL WINAPI NtUserCreateAcceleratorTable( ACCEL *table, INT count ) accel->count = count; memcpy( accel->table, table, count * sizeof(*table) );
- if (!(handle = alloc_user_handle( &accel->obj, NTUSER_OBJ_ACCEL ))) free( accel ); + if (!(handle = alloc_user_handle( accel, NTUSER_OBJ_ACCEL ))) free( accel ); TRACE_(accel)("returning %p\n", handle ); return handle; } @@ -606,7 +605,8 @@ static HMENU create_menu( BOOL is_popup ) menu->refcount = 1; if (is_popup) menu->wFlags |= MF_POPUP;
- if (!(handle = alloc_user_handle( &menu->obj, NTUSER_OBJ_MENU ))) free( menu ); + if (!(handle = alloc_user_handle( menu, NTUSER_OBJ_MENU ))) free( menu ); + else menu->handle = handle;
TRACE( "return %p\n", handle ); return handle; @@ -1184,7 +1184,7 @@ static BOOL check_menu_radio_item( HMENU handle, UINT first, UINT last, UINT che struct menu_item *item;
if (!(check_menu = find_menu_item( handle, i, flags, &check_pos ))) continue; - if (!first_menu) first_menu = grab_menu_ptr( check_menu->obj.handle ); + if (!first_menu) first_menu = grab_menu_ptr( check_menu->handle );
if (first_menu != check_menu) { @@ -1422,7 +1422,7 @@ BOOL WINAPI NtUserDeleteMenu( HMENU handle, UINT id, UINT flags ) if (menu->items[pos].fType & MF_POPUP) NtUserDestroyMenu( menu->items[pos].hSubMenu );
- NtUserRemoveMenu( menu->obj.handle, pos, flags | MF_BYPOSITION ); + NtUserRemoveMenu( menu->handle, pos, flags | MF_BYPOSITION ); release_menu_ptr( menu ); return TRUE; } @@ -1760,7 +1760,7 @@ found: /* 1. in the system menu */ if ((menu = find_menu_item( sys_menu, cmd, MF_BYCOMMAND, NULL ))) { - submenu = menu->obj.handle; + submenu = menu->handle; release_menu_ptr( menu );
if (get_capture()) @@ -1784,7 +1784,7 @@ found: { if ((menu = find_menu_item( menu_handle, cmd, MF_BYCOMMAND, NULL ))) { - submenu = menu->obj.handle; + submenu = menu->handle; release_menu_ptr( menu );
if (get_capture()) @@ -2313,7 +2313,7 @@ static void draw_bitmap_item( HWND hwnd, HDC hdc, struct menu_item *item, const if (item->fState & MF_DISABLED) drawItem.itemState |= ODS_DISABLED; if (item->fState & MF_GRAYED) drawItem.itemState |= ODS_GRAYED|ODS_DISABLED; if (item->fState & MF_HILITE) drawItem.itemState |= ODS_SELECTED; - drawItem.hwndItem = (HWND)menu->obj.handle; + drawItem.hwndItem = (HWND)menu->handle; drawItem.hDC = hdc; drawItem.itemData = item->dwItemData; drawItem.rcItem = *rect; @@ -2475,7 +2475,7 @@ static void draw_menu_item( HWND hwnd, struct menu *menu, HWND owner, HDC hdc, if (item->fState & MF_GRAYED) dis.itemState |= ODS_GRAYED|ODS_DISABLED; if (item->fState & MF_HILITE) dis.itemState |= ODS_SELECTED; dis.itemAction = odaction; /* ODA_DRAWENTIRE | ODA_SELECT | ODA_FOCUS; */ - dis.hwndItem = (HWND)menu->obj.handle; + dis.hwndItem = (HWND)menu->handle; dis.hDC = hdc; dis.rcItem = rect; TRACE( "Ownerdraw: owner=%p itemID=%d, itemState=%d, itemAction=%d, " @@ -4561,7 +4561,7 @@ BOOL WINAPI NtUserHiliteMenuItem( HWND hwnd, HMENU handle, UINT item, UINT hilit TRACE( "(%p, %p, %04x, %04x);\n", hwnd, handle, item, hilite );
if (!(menu = find_menu_item(handle, item, hilite, &pos))) return FALSE; - handle_menu = menu->obj.handle; + handle_menu = menu->handle; focused_item = menu->FocusedItem; release_menu_ptr(menu);
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index dfa9545d2e0..66899957be8 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -38,17 +38,11 @@ enum system_timer_id SYSTEM_TIMER_CARET = 0xffff, };
-struct user_object -{ - HANDLE handle; - unsigned int type; -}; - #define OBJ_OTHER_PROCESS ((void *)1) /* returned by get_user_handle_ptr on unknown handles */
typedef struct tagWND { - struct user_object obj; /* object header */ + HWND handle; /* window full handle */ HWND parent; /* Window parent */ HWND owner; /* Window owner */ struct tagCLASS *class; /* Window class */ @@ -230,7 +224,7 @@ extern BOOL vulkan_init(void); extern void vulkan_detach_surfaces( struct list *surfaces );
/* window.c */ -HANDLE alloc_user_handle( struct user_object *ptr, unsigned short type ); +HANDLE alloc_user_handle( void *ptr, unsigned short type ); void *free_user_handle( HANDLE handle, unsigned short type ); void *get_user_handle_ptr( HANDLE handle, unsigned short type ); void release_user_handle_ptr( void *ptr ); diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 170dfedc415..1abc5c90945 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -55,7 +55,7 @@ static void *client_objects[MAX_USER_HANDLES]; /*********************************************************************** * alloc_user_handle */ -HANDLE alloc_user_handle( struct user_object *ptr, unsigned short type ) +HANDLE alloc_user_handle( void *ptr, unsigned short type ) { HANDLE handle = 0;
@@ -71,8 +71,6 @@ HANDLE alloc_user_handle( struct user_object *ptr, unsigned short type ) UINT index = USER_HANDLE_TO_INDEX( handle );
assert( index < MAX_USER_HANDLES ); - ptr->handle = handle; - ptr->type = type; InterlockedExchangePointer( &client_objects[index], ptr ); } return handle; @@ -128,7 +126,7 @@ static BOOL get_user_entry_at( WORD index, unsigned short type, struct user_entr static void *get_thread_user_object( HANDLE handle, unsigned short type, UINT tid ) { WORD index = USER_HANDLE_TO_INDEX( handle ); - struct user_object *ptr = NULL; + void *ptr = NULL; struct user_entry entry;
if (index >= MAX_USER_HANDLES) return NULL; @@ -177,7 +175,7 @@ void *next_thread_user_object( UINT tid, HANDLE *handle, unsigned short type ) /*********************************************************************** * set_user_handle_ptr */ -static void set_user_handle_ptr( HANDLE handle, struct user_object *ptr ) +static void set_user_handle_ptr( HANDLE handle, void *ptr ) { WORD index = USER_HANDLE_TO_INDEX(handle); assert( index < MAX_USER_HANDLES ); @@ -198,7 +196,7 @@ void release_user_handle_ptr( void *ptr ) */ void *free_user_handle( HANDLE handle, unsigned short type ) { - struct user_object *ptr; + void *ptr; WORD index = USER_HANDLE_TO_INDEX( handle );
if ((ptr = get_user_handle_ptr( handle, type )) && ptr != OBJ_OTHER_PROCESS) @@ -2686,7 +2684,7 @@ static void update_maximized_pos( WND *wnd ) { if (!(wnd->dwStyle & WS_MINIMIZE)) { - mon_info = monitor_info_from_window( wnd->obj.handle, MONITOR_DEFAULTTOPRIMARY ); + mon_info = monitor_info_from_window( wnd->handle, MONITOR_DEFAULTTOPRIMARY ); work_rect = mon_info.rcWork; }
@@ -3536,7 +3534,7 @@ static BOOL fixup_swp_flags( WINDOWPOS *winpos, const RECT *old_window_rect, int RtlSetLastWin32Error( ERROR_INVALID_WINDOW_HANDLE ); return FALSE; } - winpos->hwnd = win->obj.handle; /* make it a full handle */ + winpos->hwnd = win->handle; /* make it a full handle */
/* Finally make sure that all coordinates are valid */ if (winpos->x < -32768) winpos->x = -32768; @@ -3879,7 +3877,6 @@ BOOL WINAPI NtUserSetWindowPos( HWND hwnd, HWND after, INT x, INT y, INT cx, INT
typedef struct { - struct user_object obj; INT count; INT suggested_count; HWND parent; @@ -3911,7 +3908,7 @@ HDWP WINAPI NtUserBeginDeferWindowPos( INT count ) dwp->suggested_count = count;
if (!(dwp->winpos = malloc( count * sizeof(WINDOWPOS) )) || - !(handle = alloc_user_handle( &dwp->obj, NTUSER_OBJ_WINPOS ))) + !(handle = alloc_user_handle( dwp, NTUSER_OBJ_WINPOS ))) { free( dwp->winpos ); free( dwp ); @@ -4880,7 +4877,7 @@ BOOL WINAPI NtUserFlashWindowEx( FLASHWINFO *info )
win = get_win_ptr( hwnd, -1 ); if (!win || win == WND_OTHER_PROCESS || win == WND_DESKTOP) return FALSE; - hwnd = win->obj.handle; /* make it a full handle */ + hwnd = win->handle; /* make it a full handle */
if (info->dwFlags) wparam = !(win->flags & WIN_NCACTIVATED); else wparam = (hwnd == NtUserGetForegroundWindow()); @@ -5218,7 +5215,7 @@ void destroy_thread_windows(void) user_lock(); while ((win = next_thread_user_object( GetCurrentThreadId(), &handle, NTUSER_OBJ_WINDOW ))) { - free_dce( win->dce, win->obj.handle ); + free_dce( win->dce, win->handle ); set_user_handle_ptr( handle, NULL ); win->userdata = (UINT_PTR)free_list; free_list = win; @@ -5239,7 +5236,7 @@ void destroy_thread_windows(void) free_list = (WND *)win->userdata; TRACE( "destroying %p\n", win );
- user_driver->pDestroyWindow( win->obj.handle ); + user_driver->pDestroyWindow( win->handle ); vulkan_detach_surfaces( &win->vulkan_surfaces );
if ((win->dwStyle & (WS_CHILD | WS_POPUP)) != WS_CHILD && win->wIDmenu) @@ -5332,8 +5329,7 @@ static WND *create_window_handle( HWND parent, HWND owner, UNICODE_STRING *name,
user_lock();
- win->obj.handle = handle; - win->obj.type = NTUSER_OBJ_WINDOW; + win->handle = handle; win->parent = full_parent; win->owner = full_owner; win->class = class; @@ -5341,7 +5337,7 @@ static WND *create_window_handle( HWND parent, HWND owner, UNICODE_STRING *name, win->cbWndExtra = extra_bytes; win->dpi_context = dpi_context; list_init( &win->vulkan_surfaces ); - set_user_handle_ptr( handle, &win->obj ); + set_user_handle_ptr( handle, win ); if (is_winproc_unicode( win->winproc, !ansi )) win->flags |= WIN_ISUNICODE; return win; } @@ -5508,7 +5504,7 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name, ex_style = cs.dwExStyle & ~WS_EX_LAYERED; if (!(win = create_window_handle( parent, owner, class_name, instance, ansi, style, ex_style ))) return 0; - hwnd = win->obj.handle; + hwnd = win->handle;
/* Fill the window structure */