From 4a53c479e8647636b327a81d9f3537d7d5c0ae03 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 21 Jun 2022 00:42:05 +0200 Subject: [PATCH] win32u: Move WM_GETTEXT implementation from user32. Signed-off-by: Jacek Caban --- dlls/user32/defwnd.c | 71 ---------------------------------------------------- dlls/win32u/defwnd.c | 34 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 71 deletions(-) diff --git a/dlls/user32/defwnd.c b/dlls/user32/defwnd.c index c72789ac963..d29846ad623 100644 --- a/dlls/user32/defwnd.c +++ b/dlls/user32/defwnd.c @@ -30,8 +30,6 @@ #include "win.h" #include "user_private.h" #include "controls.h" -#include "wine/server.h" -#include "wine/exception.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(win); @@ -73,28 +71,6 @@ HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType ) } -static LPARAM DEFWND_GetTextA( WND *wndPtr, LPSTR dest, WPARAM wParam ) -{ - LPARAM result = 0; - - __TRY - { - if (wndPtr->text) - { - if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1, - dest, wParam, NULL, NULL )) dest[wParam-1] = 0; - result = strlen( dest ); - } - else dest[0] = '\0'; - } - __EXCEPT_PAGE_FAULT - { - return 0; - } - __ENDTRY - return result; -} - /*********************************************************************** * DefWindowProcA (USER32.@) * @@ -145,19 +121,6 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam result = NC_HandleSysCommand( hwnd, wParam, lParam ); break; - case WM_GETTEXT: - if (wParam) - { - LPSTR dest = (LPSTR)lParam; - WND *wndPtr = WIN_GetPtr( hwnd ); - - if (!wndPtr) break; - result = DEFWND_GetTextA( wndPtr, dest, wParam ); - - WIN_ReleasePtr( wndPtr ); - } - break; - case WM_IME_CHAR: if (HIBYTE(wParam)) PostMessageA( hwnd, WM_CHAR, HIBYTE(wParam), lParam ); PostMessageA( hwnd, WM_CHAR, LOBYTE(wParam), lParam ); @@ -236,28 +199,6 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam } -static LPARAM DEFWND_GetTextW( WND *wndPtr, LPWSTR dest, WPARAM wParam ) -{ - LPARAM result = 0; - - __TRY - { - if (wndPtr->text) - { - lstrcpynW( dest, wndPtr->text, wParam ); - result = lstrlenW( dest ); - } - else dest[0] = '\0'; - } - __EXCEPT_PAGE_FAULT - { - return 0; - } - __ENDTRY - - return result; -} - /*********************************************************************** * DefWindowProcW (USER32.@) Calls default window message handler * @@ -315,18 +256,6 @@ LRESULT WINAPI DefWindowProcW( result = NC_HandleSysCommand( hwnd, wParam, lParam ); break; - case WM_GETTEXT: - if (wParam) - { - LPWSTR dest = (LPWSTR)lParam; - WND *wndPtr = WIN_GetPtr( hwnd ); - - if (!wndPtr) break; - result = DEFWND_GetTextW( wndPtr, dest, wParam ); - WIN_ReleasePtr( wndPtr ); - } - break; - case WM_IME_CHAR: PostMessageW( hwnd, WM_CHAR, wParam, lParam ); break; diff --git a/dlls/win32u/defwnd.c b/dlls/win32u/defwnd.c index c54dbdb710c..af51b933d49 100644 --- a/dlls/win32u/defwnd.c +++ b/dlls/win32u/defwnd.c @@ -2519,6 +2519,40 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, } break; + case WM_GETTEXT: + if (wparam) + { + WND *win; + + if (!(win = get_win_ptr( hwnd ))) break; + + __TRY + { + if (ansi) + { + char *dest = (char *)lparam; + if (win->text) + result = win32u_wctomb( &ansi_cp, dest, wparam - 1, + win->text, wcslen( win->text )); + dest[result] = 0; + } + else + { + WCHAR *dest = (WCHAR *)lparam; + if (win->text) result = min( wcslen( win->text ), wparam - 1 ); + if (result) memcpy( dest, win->text, result * sizeof(WCHAR) ); + dest[result] = 0; + } + } + __EXCEPT + { + } + __ENDTRY + + release_win_ptr( win ); + } + break; + case WM_SETICON: result = (LRESULT)set_window_icon( hwnd, wparam, (HICON)lparam ); if ((get_window_long( hwnd, GWL_STYLE ) & WS_CAPTION) == WS_CAPTION) -- 2.11.4.GIT