From: navi <navi@vlhl.dev> --- dlls/user32/tests/cursoricon.c | 4 +--- dlls/win32u/cursoricon.c | 4 +++- include/wine/server_protocol.h | 4 ++-- server/process.c | 1 + server/process.h | 1 + server/protocol.def | 1 + server/queue.c | 5 +++++ server/request_handlers.h | 1 + server/request_trace.h | 1 + 9 files changed, 16 insertions(+), 6 deletions(-) diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index bc42563b0e4..c72c4e68e29 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -751,9 +751,7 @@ static void test_initial_cursor(void) /* Check what handle GetCursor() returns if a cursor is not set yet. */ SetLastError(0xdeadbeef); cursor2 = LoadCursorA(NULL, (LPCSTR)IDC_WAIT); - todo_wine { - ok(cursor == cursor2, "cursor (%p) is not IDC_WAIT (%p).\n", cursor, cursor2); - } + ok(cursor == cursor2, "cursor (%p) is not IDC_WAIT (%p).\n", cursor, cursor2); error = GetLastError(); ok(error == 0xdeadbeef, "Last error: 0x%08lx\n", error); } diff --git a/dlls/win32u/cursoricon.c b/dlls/win32u/cursoricon.c index b7bb8112476..6bf9dde8a0b 100644 --- a/dlls/win32u/cursoricon.c +++ b/dlls/win32u/cursoricon.c @@ -136,15 +136,17 @@ HCURSOR WINAPI NtUserSetCursor( HCURSOR cursor ) HCURSOR WINAPI NtUserGetCursor(void) { HCURSOR ret; + bool is_set; SERVER_START_REQ( set_cursor ) { req->flags = 0; wine_server_call( req ); ret = wine_server_ptr_handle( reply->prev_handle ); + is_set = reply->ever_set; } SERVER_END_REQ; - return ret; + return is_set ? ret : LoadImageW(NULL, (LPCWSTR) IDC_WAIT, IMAGE_CURSOR, 0, 0, LR_SHARED | LR_DEFAULTSIZE); } HICON alloc_cursoricon_handle( BOOL is_icon ) diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 7904152d18e..50ffd959959 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -5787,7 +5787,7 @@ struct set_cursor_reply int new_y; struct rectangle new_clip; unsigned int last_change; - char __pad_52[4]; + unsigned int ever_set; }; #define SET_CURSOR_HANDLE 0x01 #define SET_CURSOR_COUNT 0x02 @@ -7148,6 +7148,6 @@ union generic_reply struct d3dkmt_mutex_release_reply d3dkmt_mutex_release_reply; }; -#define SERVER_PROTOCOL_VERSION 951 +#define SERVER_PROTOCOL_VERSION 952 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/process.c b/server/process.c index f3aa6797662..0f7c4690942 100644 --- a/server/process.c +++ b/server/process.c @@ -702,6 +702,7 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla process->rawinput_device_count = 0; process->rawinput_mouse = NULL; process->rawinput_kbd = NULL; + process->set_cursor = 0; memset( &process->image_info, 0, sizeof(process->image_info) ); list_init( &process->rawinput_entry ); list_init( &process->kernel_object ); diff --git a/server/process.h b/server/process.h index dff766d60d3..b8576caed4c 100644 --- a/server/process.h +++ b/server/process.h @@ -90,6 +90,7 @@ struct process struct list rawinput_entry; /* entry in the rawinput process list */ struct list kernel_object; /* list of kernel object pointers */ struct pe_image_info image_info; /* main exe image info */ + int set_cursor; /* has the process ever set a cursor */ }; /* process functions */ diff --git a/server/protocol.def b/server/protocol.def index 7b467618f7a..e59025faf3e 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -4057,6 +4057,7 @@ struct handle_info int new_y; struct rectangle new_clip; /* new clip rectangle */ unsigned int last_change; /* time of last position change */ + unsigned int ever_set; @END #define SET_CURSOR_HANDLE 0x01 #define SET_CURSOR_COUNT 0x02 diff --git a/server/queue.c b/server/queue.c index a04b53b70de..945834ec8d7 100644 --- a/server/queue.c +++ b/server/queue.c @@ -4019,6 +4019,7 @@ DECL_HANDLER(set_user_input_time) DECL_HANDLER(set_cursor) { struct msg_queue *queue = get_current_queue(); + struct process *process = current->process; user_handle_t prev_cursor, new_cursor; struct thread_input *input; input_shm_t *input_shm; @@ -4047,7 +4048,10 @@ DECL_HANDLER(set_cursor) SHARED_WRITE_BEGIN( input_shm, input_shm_t ) { if (req->flags & SET_CURSOR_HANDLE) + { shared->cursor = req->handle; + process->set_cursor = 1; + } if (req->flags & SET_CURSOR_COUNT) { queue->cursor_count += req->show_count; @@ -4067,6 +4071,7 @@ DECL_HANDLER(set_cursor) reply->new_y = desktop_shm->cursor.y; reply->new_clip = desktop_shm->cursor.clip; reply->last_change = desktop_shm->cursor.last_change; + reply->ever_set = process->set_cursor; } /* Get the history of the 64 last cursor positions */ diff --git a/server/request_handlers.h b/server/request_handlers.h index 23ced153af8..8d20a2a7a27 100644 --- a/server/request_handlers.h +++ b/server/request_handlers.h @@ -2256,6 +2256,7 @@ C_ASSERT( offsetof(struct set_cursor_reply, new_x) == 24 ); C_ASSERT( offsetof(struct set_cursor_reply, new_y) == 28 ); C_ASSERT( offsetof(struct set_cursor_reply, new_clip) == 32 ); C_ASSERT( offsetof(struct set_cursor_reply, last_change) == 48 ); +C_ASSERT( offsetof(struct set_cursor_reply, ever_set) == 52 ); C_ASSERT( sizeof(struct set_cursor_reply) == 56 ); C_ASSERT( sizeof(struct get_cursor_history_request) == 16 ); C_ASSERT( sizeof(struct get_cursor_history_reply) == 8 ); diff --git a/server/request_trace.h b/server/request_trace.h index 58fb6a37516..226ed898123 100644 --- a/server/request_trace.h +++ b/server/request_trace.h @@ -3255,6 +3255,7 @@ static void dump_set_cursor_reply( const struct set_cursor_reply *req ) fprintf( stderr, ", new_y=%d", req->new_y ); dump_rectangle( ", new_clip=", &req->new_clip ); fprintf( stderr, ", last_change=%08x", req->last_change ); + fprintf( stderr, ", ever_set=%08x", req->ever_set ); } static void dump_get_cursor_history_request( const struct get_cursor_history_request *req ) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11441