Jacek Caban : win32u: Move NtUserSetSystemMenu implementation from user32.

Alexandre Julliard julliard at winehq.org
Mon May 2 16:02:11 CDT 2022


Module: wine
Branch: master
Commit: d2d715b2016f3f10f0918938594b4ed6a4dbb068
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d2d715b2016f3f10f0918938594b4ed6a4dbb068

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Sun May  1 02:06:31 2022 +0200

win32u: Move NtUserSetSystemMenu implementation from user32.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/menu.c           | 18 ------------------
 dlls/user32/user32.spec      |  2 +-
 dlls/user32/user_main.c      |  1 -
 dlls/win32u/gdiobj.c         |  1 +
 dlls/win32u/menu.c           | 23 +++++++++++++++--------
 dlls/win32u/ntuser_private.h |  1 -
 dlls/win32u/win32u.spec      |  2 +-
 dlls/win32u/win32u_private.h |  1 +
 dlls/win32u/wrappers.c       |  6 ++++++
 9 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 2e9121598fa..64e5d35ba39 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -3925,24 +3925,6 @@ HMENU WINAPI CreateMenu(void)
 }
 
 
-/*******************************************************************
- *         SetSystemMenu    (USER32.@)
- */
-BOOL WINAPI SetSystemMenu( HWND hwnd, HMENU hMenu )
-{
-    WND *wndPtr = WIN_GetPtr( hwnd );
-
-    if (wndPtr && wndPtr != WND_OTHER_PROCESS && wndPtr != WND_DESKTOP)
-    {
-	if (wndPtr->hSysMenu) NtUserDestroyMenu( wndPtr->hSysMenu );
-	wndPtr->hSysMenu = MENU_GetSysMenu( hwnd, hMenu );
-        WIN_ReleasePtr( wndPtr );
-	return TRUE;
-    }
-    return FALSE;
-}
-
-
 /**********************************************************************
  *         GetMenu    (USER32.@)
  */
diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec
index 8bccdab69c6..1ae27b2482f 100644
--- a/dlls/user32/user32.spec
+++ b/dlls/user32/user32.spec
@@ -707,7 +707,7 @@
 @ stdcall SetSysColors(long ptr ptr) NtUserSetSysColors
 @ stdcall SetSysColorsTemp(ptr ptr long)
 @ stdcall SetSystemCursor(long long)
-@ stdcall SetSystemMenu(long long)
+@ stdcall SetSystemMenu(long long) NtUserSetSystemMenu
 @ stdcall SetSystemTimer(long long long ptr)
 @ stdcall SetTaskmanWindow (long)
 @ stdcall SetThreadDesktop(long) NtUserSetThreadDesktop
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c
index 358177d33d2..fa849e9cf2d 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -164,7 +164,6 @@ static const struct user_callbacks user_funcs =
     EndMenu,
     ImmProcessKey,
     ImmTranslateMessage,
-    SetSystemMenu,
     free_win_ptr,
     MENU_GetSysMenu,
     MENU_IsMenuActive,
diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c
index 6cc63800201..f6790690188 100644
--- a/dlls/win32u/gdiobj.c
+++ b/dlls/win32u/gdiobj.c
@@ -1212,6 +1212,7 @@ static struct unix_funcs unix_funcs =
     NtUserSetMenu,
     NtUserSetParent,
     NtUserSetSysColors,
+    NtUserSetSystemMenu,
     NtUserSetWindowLong,
     NtUserSetWindowLongPtr,
     NtUserSetWindowPos,
diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c
index 0da21675e68..a6aeae045e2 100644
--- a/dlls/win32u/menu.c
+++ b/dlls/win32u/menu.c
@@ -465,14 +465,6 @@ BOOL WINAPI NtUserDestroyMenu( HMENU handle )
     return TRUE;
 }
 
-/*******************************************************************
- *           NtUserSetSystemMenu    (win32u.@)
- */
-BOOL WINAPI NtUserSetSystemMenu( HWND hwnd, HMENU menu )
-{
-    return user_callbacks && user_callbacks->pSetSystemMenu( hwnd, menu );
-}
-
 /*******************************************************************
  *           set_window_menu
  *
@@ -1072,6 +1064,21 @@ HMENU WINAPI NtUserGetSystemMenu( HWND hwnd, BOOL revert )
     return revert ? 0 : retvalue;
 }
 
+/**********************************************************************
+ *           NtUserSetSystemMenu    (win32u.@)
+ */
+BOOL WINAPI NtUserSetSystemMenu( HWND hwnd, HMENU menu )
+{
+    WND *win = get_win_ptr( hwnd );
+
+    if (!win || win == WND_OTHER_PROCESS || win == WND_DESKTOP) return FALSE;
+
+    if (win->hSysMenu) NtUserDestroyMenu( win->hSysMenu );
+    win->hSysMenu = user_callbacks ? user_callbacks->get_sys_menu( hwnd, menu ) : NULL;
+    release_win_ptr( win );
+    return TRUE;
+}
+
 /**********************************************************************
  *           NtUserSetMenuDefaultItem    (win32u.@)
  */
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h
index acc3fdf6290..c870037f7b3 100644
--- a/dlls/win32u/ntuser_private.h
+++ b/dlls/win32u/ntuser_private.h
@@ -37,7 +37,6 @@ struct user_callbacks
     BOOL (WINAPI *pEndMenu)(void);
     BOOL (WINAPI *pImmProcessKey)(HWND, HKL, UINT, LPARAM, DWORD);
     BOOL (WINAPI *pImmTranslateMessage)(HWND, UINT, WPARAM, LPARAM);
-    BOOL (WINAPI *pSetSystemMenu)( HWND hwnd, HMENU menu );
     void (CDECL *free_win_ptr)( struct tagWND *win );
     HMENU (CDECL *get_sys_menu)( HWND hwnd, HMENU popup );
     HWND (CDECL *is_menu_active)(void);
diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec
index d94324b1290..d6a51c1d3b9 100644
--- a/dlls/win32u/win32u.spec
+++ b/dlls/win32u/win32u.spec
@@ -1229,7 +1229,7 @@
 @ stub NtUserSetShellWindowEx
 @ stdcall NtUserSetSysColors(long ptr ptr)
 @ stub NtUserSetSystemCursor
-@ stub NtUserSetSystemMenu
+@ stdcall NtUserSetSystemMenu(long long)
 @ stdcall -syscall NtUserSetSystemTimer(long long long)
 @ stub NtUserSetTargetForResourceBrokering
 @ stdcall -syscall NtUserSetThreadDesktop(long)
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h
index c40d2cb2a6f..ea6d67750b4 100644
--- a/dlls/win32u/win32u_private.h
+++ b/dlls/win32u/win32u_private.h
@@ -282,6 +282,7 @@ struct unix_funcs
     BOOL     (WINAPI *pNtUserSetMenu)( HWND hwnd, HMENU menu );
     HWND     (WINAPI *pNtUserSetParent)( HWND hwnd, HWND parent );
     BOOL     (WINAPI *pNtUserSetSysColors)( INT count, const INT *colors, const COLORREF *values );
+    BOOL     (WINAPI *pNtUserSetSystemMenu)( HWND hwnd, HMENU menu );
     LONG     (WINAPI *pNtUserSetWindowLong)( HWND hwnd, INT offset, LONG newval, BOOL ansi );
     LONG_PTR (WINAPI *pNtUserSetWindowLongPtr)( HWND hwnd, INT offset, LONG_PTR newval, BOOL ansi );
     BOOL     (WINAPI *pNtUserSetWindowPos)( HWND hwnd, HWND after, INT x, INT y, INT cx, INT cy, UINT flags );
diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c
index e3e0781bdde..6219b0fa49c 100644
--- a/dlls/win32u/wrappers.c
+++ b/dlls/win32u/wrappers.c
@@ -1185,6 +1185,12 @@ BOOL WINAPI NtUserSetSysColors( INT count, const INT *colors, const COLORREF *va
     return unix_funcs->pNtUserSetSysColors( count, colors, values );
 }
 
+BOOL WINAPI NtUserSetSystemMenu( HWND hwnd, HMENU menu )
+{
+    if (!unix_funcs) return FALSE;
+    return unix_funcs->pNtUserSetSystemMenu( hwnd, menu );
+}
+
 LONG WINAPI NtUserSetWindowLong( HWND hwnd, INT offset, LONG newval, BOOL ansi )
 {
     if (!unix_funcs) return 0;




More information about the wine-cvs mailing list