From c87925bae30c698ab36999afe04179343db42f6d Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 3 Dec 2021 12:55:30 +0100 Subject: [PATCH] win32u: Move NtUserShowCursor implementation from user32. Signed-off-by: Jacek Caban Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/user32/cursoricon.c | 27 ---------------- dlls/user32/user32.spec | 2 +- dlls/win32u/Makefile.in | 1 + dlls/win32u/cursoricon.c | 63 ++++++++++++++++++++++++++++++++++++ dlls/win32u/driver.c | 6 ++++ dlls/win32u/gdiobj.c | 1 + dlls/win32u/win32u.spec | 2 +- dlls/win32u/win32u_private.h | 1 + dlls/win32u/wrappers.c | 5 +++ 9 files changed, 79 insertions(+), 29 deletions(-) create mode 100644 dlls/win32u/cursoricon.c diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index b02ee6d8723..eb033e72005 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -1933,33 +1933,6 @@ HCURSOR WINAPI DECLSPEC_HOTPATCH SetCursor( HCURSOR hCursor /* [in] Handle of cu return hOldCursor; } -/*********************************************************************** - * ShowCursor (USER32.@) - */ -INT WINAPI DECLSPEC_HOTPATCH ShowCursor( BOOL bShow ) -{ - HCURSOR cursor; - int increment = bShow ? 1 : -1; - int count; - - SERVER_START_REQ( set_cursor ) - { - req->flags = SET_CURSOR_COUNT; - req->show_count = increment; - wine_server_call( req ); - cursor = wine_server_ptr_handle( reply->prev_handle ); - count = reply->prev_count + increment; - } - SERVER_END_REQ; - - TRACE("%d, count=%d\n", bShow, count ); - - if (bShow && !count) USER_Driver->pSetCursor( cursor ); - else if (!bShow && count == -1) USER_Driver->pSetCursor( 0 ); - - return count; -} - /*********************************************************************** * GetCursor (USER32.@) */ diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 9955add4252..a89bcdc8c56 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -736,7 +736,7 @@ @ stdcall SetWindowsHookExW(long long long long) @ stdcall SetWindowsHookW(long ptr) @ stdcall ShowCaret(long) -@ stdcall ShowCursor(long) +@ stdcall -import ShowCursor(long) NtUserShowCursor @ stdcall ShowOwnedPopups(long long) @ stdcall ShowScrollBar(long long long) @ stub ShowStartGlass diff --git a/dlls/win32u/Makefile.in b/dlls/win32u/Makefile.in index 184271174f2..41c252be59c 100644 --- a/dlls/win32u/Makefile.in +++ b/dlls/win32u/Makefile.in @@ -13,6 +13,7 @@ C_SRCS = \ brush.c \ clipboard.c \ clipping.c \ + cursoricon.c \ dc.c \ dib.c \ dibdrv/bitblt.c \ diff --git a/dlls/win32u/cursoricon.c b/dlls/win32u/cursoricon.c new file mode 100644 index 00000000000..8d297e838c9 --- /dev/null +++ b/dlls/win32u/cursoricon.c @@ -0,0 +1,63 @@ +/* + * Cursor and icon support + * + * Copyright 1995 Alexandre Julliard + * Copyright 1996 Martin Von Loewis + * Copyright 1997 Alex Korobka + * Copyright 1998 Turchanov Sergey + * Copyright 2007 Henri Verbeet + * Copyright 2009 Vincent Povirk for CodeWeavers + * Copyright 2016 Dmitry Timoshkov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#if 0 +#pragma makedep unix +#endif + +#include "win32u_private.h" +#include "wine/server.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(cursor); + + +/*********************************************************************** + * NtUserShowCursor (win32u.@) + */ +INT WINAPI NtUserShowCursor( BOOL show ) +{ + HCURSOR cursor; + int increment = show ? 1 : -1; + int count; + + SERVER_START_REQ( set_cursor ) + { + req->flags = SET_CURSOR_COUNT; + req->show_count = increment; + wine_server_call( req ); + cursor = wine_server_ptr_handle( reply->prev_handle ); + count = reply->prev_count + increment; + } + SERVER_END_REQ; + + TRACE("%d, count=%d\n", show, count ); + + if (show && !count) user_driver->pSetCursor( cursor ); + else if (!show && count == -1) user_driver->pSetCursor( 0 ); + + return count; +} diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c index 5d43daf2355..adffdaca8d2 100644 --- a/dlls/win32u/driver.c +++ b/dlls/win32u/driver.c @@ -1032,6 +1032,11 @@ static BOOL CDECL loaderdrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDE return load_driver()->pEnumDisplaySettingsEx( name, num, mode, flags ); } +static void CDECL loaderdrv_SetCursor( HCURSOR cursor ) +{ + load_driver()->pSetCursor( cursor ); +} + static void CDECL loaderdrv_UpdateClipboard(void) { load_driver()->pUpdateClipboard(); @@ -1055,6 +1060,7 @@ static const struct user_driver_funcs lazy_load_driver = .pChangeDisplaySettingsEx = loaderdrv_ChangeDisplaySettingsEx, .pEnumDisplaySettingsEx = loaderdrv_EnumDisplaySettingsEx, .pUpdateDisplayDevices = loaderdrv_UpdateDisplayDevices, + .pSetCursor = loaderdrv_SetCursor, .pUpdateClipboard = loaderdrv_UpdateClipboard, .pScrollDC = nulldrv_ScrollDC, }; diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c index e0a036f4d0d..e68c9126cd6 100644 --- a/dlls/win32u/gdiobj.c +++ b/dlls/win32u/gdiobj.c @@ -1182,6 +1182,7 @@ static struct unix_funcs unix_funcs = NtUserIsClipboardFormatAvailable, NtUserMapVirtualKeyEx, NtUserScrollDC, + NtUserShowCursor, NtUserToUnicodeEx, NtUserUnregisterHotKey, NtUserVkKeyScanEx, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index 82c232617fb..95bddc09e5a 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1258,7 +1258,7 @@ @ stub NtUserSetWindowsHookAW @ stub NtUserSetWindowsHookEx @ stub NtUserShowCaret -@ stub NtUserShowCursor +@ stdcall NtUserShowCursor(long) @ stub NtUserShowScrollBar @ stub NtUserShowSystemCursor @ stub NtUserShowWindow diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index d301d8b6b8b..c8b5e0f4246 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -214,6 +214,7 @@ struct unix_funcs UINT (WINAPI *pNtUserMapVirtualKeyEx)( UINT code, UINT type, HKL layout ); BOOL (WINAPI *pNtUserScrollDC)( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip, HRGN ret_update_rgn, RECT *update_rect ); + INT (WINAPI *pNtUserShowCursor)( BOOL show ); INT (WINAPI *pNtUserToUnicodeEx)( UINT virt, UINT scan, const BYTE *state, WCHAR *str, int size, UINT flags, HKL layout ); BOOL (WINAPI *pNtUserUnregisterHotKey)( HWND hwnd, INT id ); diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c index 4b9a291bf6b..a9a72eaa903 100644 --- a/dlls/win32u/wrappers.c +++ b/dlls/win32u/wrappers.c @@ -676,6 +676,11 @@ BOOL WINAPI NtUserScrollDC( HDC hdc, INT dx, INT dy, const RECT *scroll, const R return unix_funcs->pNtUserScrollDC( hdc, dx, dy, scroll, clip, ret_update_rgn, update_rect ); } +INT WINAPI NtUserShowCursor( BOOL show ) +{ + return unix_funcs->pNtUserShowCursor( show ); +} + INT WINAPI NtUserToUnicodeEx( UINT virt, UINT scan, const BYTE *state, WCHAR *str, int size, UINT flags, HKL layout ) {