[PATCH v2 1/2] oleacc: Check proper UI thread for window focus.

Connor McAdams cmcadams at codeweavers.com
Thu Aug 12 11:53:27 CDT 2021


From: Connor McAdams <conmanx360 at gmail.com>

When RPC is done in a multi-threaded apartment environment, this method
may be called in a thread other than the one that the object was created
in. To account for this, make sure to check the UI thread the HWND
belongs to rather than the one belonging to the current thread.

Signed-off-by: Connor McAdams <conmanx360 at gmail.com>
---
 dlls/oleacc/client.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/dlls/oleacc/client.c b/dlls/oleacc/client.c
index 3b33be55a21..a726c607109 100644
--- a/dlls/oleacc/client.c
+++ b/dlls/oleacc/client.c
@@ -227,6 +227,7 @@ static HRESULT WINAPI Client_get_accRole(IAccessible *iface, VARIANT varID, VARI
 static HRESULT WINAPI Client_get_accState(IAccessible *iface, VARIANT varID, VARIANT *pvarState)
 {
     Client *This = impl_from_Client(iface);
+    GUITHREADINFO info;
     LONG style;
 
     TRACE("(%p)->(%s %p)\n", This, debugstr_variant(&varID), pvarState);
@@ -244,7 +245,10 @@ static HRESULT WINAPI Client_get_accState(IAccessible *iface, VARIANT varID, VAR
         V_I4(pvarState) |= STATE_SYSTEM_UNAVAILABLE;
     else if(IsWindow(This->hwnd))
         V_I4(pvarState) |= STATE_SYSTEM_FOCUSABLE;
-    if(GetFocus() == This->hwnd)
+
+    info.cbSize = sizeof(info);
+    if(GetGUIThreadInfo(GetWindowThreadProcessId(This->hwnd, NULL), &info) &&
+            info.hwndFocus == This->hwnd)
         V_I4(pvarState) |= STATE_SYSTEM_FOCUSED;
     if(!(style & WS_VISIBLE))
         V_I4(pvarState) |= STATE_SYSTEM_INVISIBLE;
-- 
2.25.1




More information about the wine-devel mailing list