Jacek Caban : win32u: Move desktop window proc implementation from user32.

Alexandre Julliard julliard at winehq.org
Thu May 19 16:15:13 CDT 2022


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu May 19 14:23:17 2022 +0200

win32u: Move desktop window proc implementation from user32.

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

---

 dlls/user32/desktop.c        | 27 +++++----------------------
 dlls/win32u/defwnd.c         | 37 +++++++++++++++++++++++++++++++++++++
 dlls/win32u/message.c        |  2 ++
 dlls/win32u/win32u_private.h |  1 +
 include/ntuser.h             |  1 +
 5 files changed, 46 insertions(+), 22 deletions(-)

diff --git a/dlls/user32/desktop.c b/dlls/user32/desktop.c
index 9d1484fdcbb..f2905b0efac 100644
--- a/dlls/user32/desktop.c
+++ b/dlls/user32/desktop.c
@@ -95,30 +95,13 @@ LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lP
     switch (message)
     {
     case WM_NCCREATE:
-    {
-        CREATESTRUCTW *cs = (CREATESTRUCTW *)lParam;
-        const GUID *guid = cs->lpCreateParams;
-
-        if (guid)
-        {
-            ATOM atom;
-            WCHAR buffer[37];
-
-            if (NtUserGetAncestor( hwnd, GA_PARENT )) return FALSE;  /* refuse to create non-desktop window */
-
-            swprintf( buffer, ARRAY_SIZE(buffer), L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-                      guid->Data1, guid->Data2, guid->Data3,
-                      guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
-                      guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
-            atom = GlobalAddAtomW( buffer );
-            SetPropW( hwnd, L"__wine_display_device_guid", ULongToHandle( atom ) );
-        }
-        return TRUE;
-    }
     case WM_NCCALCSIZE:
-        return 0;
+        return NtUserMessageCall( hwnd, message, wParam, lParam, 0, NtUserDesktopWindowProc, FALSE );
+
     default:
-        return DefWindowProcW( hwnd, message, wParam, lParam );
+        if (message < WM_USER)
+            return DefWindowProcW( hwnd, message, wParam, lParam );
+        return NtUserMessageCall( hwnd, message, wParam, lParam, 0, NtUserDesktopWindowProc, FALSE );
     }
 }
 
diff --git a/dlls/win32u/defwnd.c b/dlls/win32u/defwnd.c
index 27120a96d98..444abd1657f 100644
--- a/dlls/win32u/defwnd.c
+++ b/dlls/win32u/defwnd.c
@@ -384,3 +384,40 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
 
     return result;
 }
+
+LRESULT desktop_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
+{
+    static const WCHAR wine_display_device_guidW[] =
+        {'_','_','w','i','n','e','_','d','i','s','p','l','a','y','_','d','e','v','i','c','e',
+         '_','g','u','i','d',0};
+
+    switch (msg)
+    {
+    case WM_NCCREATE:
+    {
+        CREATESTRUCTW *cs = (CREATESTRUCTW *)lparam;
+        const GUID *guid = cs->lpCreateParams;
+
+        if (guid)
+        {
+            ATOM atom = 0;
+            char buffer[37];
+            WCHAR bufferW[37];
+
+            if (NtUserGetAncestor( hwnd, GA_PARENT )) return FALSE;  /* refuse to create non-desktop window */
+
+            sprintf( buffer, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+                     (unsigned int)guid->Data1, guid->Data2, guid->Data3,
+                     guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
+                     guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
+            NtAddAtom( bufferW, asciiz_to_unicode( bufferW, buffer ) - sizeof(WCHAR), &atom );
+            NtUserSetProp( hwnd, wine_display_device_guidW, ULongToHandle( atom ) );
+        }
+        return TRUE;
+    }
+    case WM_NCCALCSIZE:
+        return 0;
+    }
+
+    return default_window_proc( hwnd, msg, wparam, lparam, FALSE );
+}
diff --git a/dlls/win32u/message.c b/dlls/win32u/message.c
index e67f9adcbe7..6bb9aa455f5 100644
--- a/dlls/win32u/message.c
+++ b/dlls/win32u/message.c
@@ -2890,6 +2890,8 @@ LRESULT WINAPI NtUserMessageCall( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
 {
     switch (type)
     {
+    case NtUserDesktopWindowProc:
+        return desktop_window_proc( hwnd, msg, wparam, lparam );
     case NtUserDefWindowProc:
         return default_window_proc( hwnd, msg, wparam, lparam, ansi );
     case NtUserCallWindowProc:
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h
index c7340018830..2d69cbef78e 100644
--- a/dlls/win32u/win32u_private.h
+++ b/dlls/win32u/win32u_private.h
@@ -360,6 +360,7 @@ extern void register_window_surface( struct window_surface *old,
 /* defwnd.c */
 extern LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
                                     BOOL ansi ) DECLSPEC_HIDDEN;
+extern LRESULT desktop_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN;
 extern void fill_rect( HDC dc, const RECT *rect, HBRUSH hbrush ) DECLSPEC_HIDDEN;
 
 /* hook.c */
diff --git a/include/ntuser.h b/include/ntuser.h
index c7490eaad0a..29de027a334 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -181,6 +181,7 @@ struct render_synthesized_format_params
 /* NtUserMessageCall codes */
 enum
 {
+    NtUserDesktopWindowProc   = 0x029d,
     NtUserDefWindowProc       = 0x029e,
     NtUserCallWindowProc      = 0x02ab,
     NtUserSendMessage         = 0x02b1,




More information about the wine-cvs mailing list