[PATCH 2/8] win32u: Move WM_KEYF1 implementation from user32.

Jacek Caban wine at gitlab.winehq.org
Wed Jun 15 06:44:33 CDT 2022


From: Jacek Caban <jacek at codeweavers.com>

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
---
 dlls/user32/defwnd.c         | 23 -----------------------
 dlls/win32u/defwnd.c         | 27 +++++++++++++++++++++++++++
 dlls/win32u/menu.c           |  6 ++++++
 dlls/win32u/message.c        |  2 +-
 dlls/win32u/win32u_private.h |  2 ++
 dlls/win32u/window.c         |  4 ++--
 6 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/dlls/user32/defwnd.c b/dlls/user32/defwnd.c
index df5aa9353f4..6f2c3013aaa 100644
--- a/dlls/user32/defwnd.c
+++ b/dlls/user32/defwnd.c
@@ -435,29 +435,6 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
                 SendMessageW( parent, msg, wParam, lParam );
             break;
         }
-    case WM_KEYF1:
-        {
-            HELPINFO hi;
-
-            hi.cbSize = sizeof(HELPINFO);
-            GetCursorPos( &hi.MousePos );
-            if (MENU_IsMenuActive())
-            {
-                hi.iContextType = HELPINFO_MENUITEM;
-                hi.hItemHandle = MENU_IsMenuActive();
-                hi.iCtrlId = MenuItemFromPoint( hwnd, hi.hItemHandle, hi.MousePos );
-                hi.dwContextId = GetMenuContextHelpId( hi.hItemHandle );
-            }
-            else
-            {
-                hi.iContextType = HELPINFO_WINDOW;
-                hi.hItemHandle = hwnd;
-                hi.iCtrlId = GetWindowLongPtrA( hwnd, GWLP_ID );
-                hi.dwContextId = GetWindowContextHelpId( hwnd );
-            }
-            SendMessageW( hwnd, WM_HELP, 0, (LPARAM)&hi );
-            break;
-        }
 
     case WM_INPUTLANGCHANGEREQUEST:
         NtUserActivateKeyboardLayout( (HKL)lParam, 0 );
diff --git a/dlls/win32u/defwnd.c b/dlls/win32u/defwnd.c
index f9a23bcee3f..3705cbf8022 100644
--- a/dlls/win32u/defwnd.c
+++ b/dlls/win32u/defwnd.c
@@ -1766,6 +1766,33 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
     case WM_SYSCOMMAND:
         result = handle_sys_command( hwnd, wparam, lparam );
         break;
+
+    case WM_KEYF1:
+        {
+            HELPINFO hi;
+
+            hi.cbSize = sizeof(HELPINFO);
+            get_cursor_pos( &hi.MousePos );
+            if (is_menu_active())
+            {
+                MENUINFO info = { .cbSize = sizeof(info), .fMask = MIM_HELPID };
+                hi.iContextType = HELPINFO_MENUITEM;
+                hi.hItemHandle = is_menu_active();
+                hi.iCtrlId = NtUserMenuItemFromPoint( hwnd, hi.hItemHandle,
+                                                      hi.MousePos.x, hi.MousePos.y );
+                get_menu_info( hi.hItemHandle, &info );
+                hi.dwContextId = info.dwContextHelpID;
+            }
+            else
+            {
+                hi.iContextType = HELPINFO_WINDOW;
+                hi.hItemHandle = hwnd;
+                hi.iCtrlId = get_window_long_ptr( hwnd, GWLP_ID, FALSE );
+                hi.dwContextId = get_window_context_help_id( hwnd );
+            }
+            send_message( hwnd, WM_HELP, 0, (LPARAM)&hi );
+            break;
+        }
     }
 
     return result;
diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c
index d84af186da9..8ccece38e74 100644
--- a/dlls/win32u/menu.c
+++ b/dlls/win32u/menu.c
@@ -2492,3 +2492,9 @@ LRESULT popup_menu_window_proc( HWND hwnd, UINT message, WPARAM wparam, LPARAM l
     }
     return 0;
 }
+
+HWND is_menu_active(void)
+{
+    if (!user_callbacks) return 0;
+    return user_callbacks->is_menu_active();
+}
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c
index cea1a33812a..f5315ec5dd4 100644
--- a/dlls/win32u/message.c
+++ b/dlls/win32u/message.c
@@ -1346,7 +1346,7 @@ static BOOL process_keyboard_message( MSG *msg, UINT hw_id, HWND hwnd_filter,
         else if (msg->message == WM_KEYUP)
         {
             /* Handle VK_APPS key by posting a WM_CONTEXTMENU message */
-            if (msg->wParam == VK_APPS && user_callbacks && !user_callbacks->is_menu_active())
+            if (msg->wParam == VK_APPS && !is_menu_active())
                 NtUserPostMessage( msg->hwnd, WM_CONTEXTMENU, (WPARAM)msg->hwnd, -1 );
         }
     }
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h
index d3f060669a4..80fe2e027e0 100644
--- a/dlls/win32u/win32u_private.h
+++ b/dlls/win32u/win32u_private.h
@@ -402,6 +402,7 @@ extern BOOL get_menu_info( HMENU handle, MENUINFO *info ) DECLSPEC_HIDDEN;
 extern INT get_menu_item_count( HMENU handle ) DECLSPEC_HIDDEN;
 extern UINT get_menu_state( HMENU handle, UINT item_id, UINT flags ) DECLSPEC_HIDDEN;
 extern BOOL is_menu( HMENU handle ) DECLSPEC_HIDDEN;
+extern HWND is_menu_active(void) DECLSPEC_HIDDEN;
 extern LRESULT popup_menu_window_proc( HWND hwnd, UINT message, WPARAM wparam,
                                        LPARAM lparam ) DECLSPEC_HIDDEN;
 extern BOOL set_window_menu( HWND hwnd, HMENU handle ) DECLSPEC_HIDDEN;
@@ -463,6 +464,7 @@ extern HWND get_parent( HWND hwnd ) DECLSPEC_HIDDEN;
 extern HWND get_hwnd_message_parent(void) DECLSPEC_HIDDEN;
 extern DPI_AWARENESS_CONTEXT get_window_dpi_awareness_context( HWND hwnd ) DECLSPEC_HIDDEN;
 extern MINMAXINFO get_min_max_info( HWND hwnd ) DECLSPEC_HIDDEN;
+extern DWORD get_window_context_help_id( HWND hwnd ) DECLSPEC_HIDDEN;
 extern HWND get_window_relative( HWND hwnd, UINT rel ) DECLSPEC_HIDDEN;
 extern DWORD get_window_thread( HWND hwnd, DWORD *process ) DECLSPEC_HIDDEN;
 extern HWND is_current_process_window( HWND hwnd ) DECLSPEC_HIDDEN;
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c
index 94f285de2bb..5575b9a0381 100644
--- a/dlls/win32u/window.c
+++ b/dlls/win32u/window.c
@@ -4524,7 +4524,7 @@ BOOL WINAPI NtUserFlashWindowEx( FLASHWINFO *info )
 }
 
 /* see GetWindowContextHelpId */
-static DWORD get_window_context_help_id( HWND hwnd )
+DWORD get_window_context_help_id( HWND hwnd )
 {
     DWORD retval;
     WND *win = get_win_ptr( hwnd );
@@ -4759,7 +4759,7 @@ BOOL WINAPI NtUserDestroyWindow( HWND hwnd )
 
     if (call_hooks( WH_CBT, HCBT_DESTROYWND, (WPARAM)hwnd, 0, TRUE )) return FALSE;
 
-    if (user_callbacks && user_callbacks->is_menu_active() == hwnd)
+    if (user_callbacks && is_menu_active() == hwnd)
         user_callbacks->pEndMenu();
 
     is_child = (get_window_long( hwnd, GWL_STYLE ) & WS_CHILD) != 0;
-- 
GitLab


https://gitlab.winehq.org/wine/wine/-/merge_requests/250



More information about the wine-devel mailing list