[PATCH 7/8] dinput: Exit internal thread when no devices are acquired.
Rémi Bernon
rbernon at codeweavers.com
Wed Jan 5 07:58:41 CST 2022
And after a 1s timeout, so that the message window used for rawinput
device registration stays alive for a while even when no devices are
acquired. This is required for some of the tests to pass.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52263
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/dinput/dinput_main.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
index 9903a02c42f..764eada6762 100644
--- a/dlls/dinput/dinput_main.c
+++ b/dlls/dinput/dinput_main.c
@@ -1264,6 +1264,7 @@ static DWORD WINAPI dinput_thread_proc( void *params )
HANDLE events[128], start_event = params;
HHOOK kbd_hook = NULL, mouse_hook = NULL;
struct dinput_device *impl, *next;
+ DWORD timeout = INFINITE;
SIZE_T events_count = 0;
HANDLE finished_event;
HRESULT hr;
@@ -1280,7 +1281,8 @@ static DWORD WINAPI dinput_thread_proc( void *params )
PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE );
SetEvent( start_event );
- while ((ret = MsgWaitForMultipleObjectsEx( events_count, events, INFINITE, QS_ALLINPUT, 0 )) <= events_count)
+ while ((ret = MsgWaitForMultipleObjectsEx( events_count, events, timeout, QS_ALLINPUT, 0 )) <= events_count ||
+ ret == WAIT_TIMEOUT)
{
UINT kbd_cnt = 0, mice_cnt = 0;
@@ -1351,6 +1353,17 @@ static DWORD WINAPI dinput_thread_proc( void *params )
events[events_count++] = impl->read_event;
}
+ if (!list_empty( &acquired_device_list ) || !list_empty( &acquired_rawmouse_list ) ||
+ !list_empty( &acquired_mouse_list ) || !list_empty( &acquired_keyboard_list ))
+ timeout = INFINITE;
+ else if (ret == WAIT_TIMEOUT)
+ {
+ di_em_win = 0;
+ LeaveCriticalSection( &dinput_hook_crit );
+ goto done;
+ }
+ else timeout = 1000;
+
LeaveCriticalSection( &dinput_hook_crit );
}
--
2.34.1
More information about the wine-devel
mailing list