uiautomationcore: Make sure event thread is started when listening for WinEvents.
Signed-off-by: Connor McAdams <cmcadams@codeweavers.com>
This commit is contained in:
parent
81caccbf84
commit
fded7c1d71
2 changed files with 15 additions and 5 deletions
|
@ -79,8 +79,12 @@ static BOOL CALLBACK uia_win_event_enum_top_level_hwnds(HWND hwnd, LPARAM lparam
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL uia_clientside_event_start_event_thread(struct uia_event *event);
|
||||||
HRESULT uia_event_add_win_event_hwnd(struct uia_event *event, HWND hwnd)
|
HRESULT uia_event_add_win_event_hwnd(struct uia_event *event, HWND hwnd)
|
||||||
{
|
{
|
||||||
|
if (!uia_clientside_event_start_event_thread(event))
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
if (hwnd == GetDesktopWindow())
|
if (hwnd == GetDesktopWindow())
|
||||||
EnumWindows(uia_win_event_enum_top_level_hwnds, (LPARAM)&event->u.clientside.win_event_hwnd_map);
|
EnumWindows(uia_win_event_enum_top_level_hwnds, (LPARAM)&event->u.clientside.win_event_hwnd_map);
|
||||||
|
|
||||||
|
@ -630,6 +634,14 @@ static void uia_stop_event_thread(void)
|
||||||
LeaveCriticalSection(&event_thread_cs);
|
LeaveCriticalSection(&event_thread_cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL uia_clientside_event_start_event_thread(struct uia_event *event)
|
||||||
|
{
|
||||||
|
if (!event->u.clientside.event_thread_started)
|
||||||
|
event->u.clientside.event_thread_started = uia_start_event_thread();
|
||||||
|
|
||||||
|
return event->u.clientside.event_thread_started;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IWineUiaEvent interface.
|
* IWineUiaEvent interface.
|
||||||
*/
|
*/
|
||||||
|
@ -679,7 +691,7 @@ static ULONG WINAPI uia_event_Release(IWineUiaEvent *iface)
|
||||||
if (event->event_type == EVENT_TYPE_CLIENTSIDE)
|
if (event->event_type == EVENT_TYPE_CLIENTSIDE)
|
||||||
{
|
{
|
||||||
uia_cache_request_destroy(&event->u.clientside.cache_req);
|
uia_cache_request_destroy(&event->u.clientside.cache_req);
|
||||||
if (event->u.clientside.git_cookie)
|
if (event->u.clientside.event_thread_started)
|
||||||
uia_stop_event_thread();
|
uia_stop_event_thread();
|
||||||
uia_hwnd_map_destroy(&event->u.clientside.win_event_hwnd_map);
|
uia_hwnd_map_destroy(&event->u.clientside.win_event_hwnd_map);
|
||||||
}
|
}
|
||||||
|
@ -1160,17 +1172,14 @@ HRESULT uia_event_add_serverside_event_adviser(IWineUiaEvent *serverside_event,
|
||||||
*/
|
*/
|
||||||
if (!event->u.clientside.git_cookie)
|
if (!event->u.clientside.git_cookie)
|
||||||
{
|
{
|
||||||
if (!uia_start_event_thread())
|
if (!uia_clientside_event_start_event_thread(event))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
hr = register_interface_in_git((IUnknown *)&event->IWineUiaEvent_iface, &IID_IWineUiaEvent,
|
hr = register_interface_in_git((IUnknown *)&event->IWineUiaEvent_iface, &IID_IWineUiaEvent,
|
||||||
&event->u.clientside.git_cookie);
|
&event->u.clientside.git_cookie);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
|
||||||
uia_stop_event_thread();
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!(adv_events = calloc(1, sizeof(*adv_events))))
|
if (!(adv_events = calloc(1, sizeof(*adv_events))))
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
|
@ -142,6 +142,7 @@ struct uia_event
|
||||||
void *callback_data;
|
void *callback_data;
|
||||||
|
|
||||||
struct rb_tree win_event_hwnd_map;
|
struct rb_tree win_event_hwnd_map;
|
||||||
|
BOOL event_thread_started;
|
||||||
DWORD git_cookie;
|
DWORD git_cookie;
|
||||||
} clientside;
|
} clientside;
|
||||||
struct {
|
struct {
|
||||||
|
|
Loading…
Add table
Reference in a new issue