On Wed, May 25, 2022 at 02:37:39PM -0400, Connor McAdams wrote:
static void test_UiaProviderFromIAccessible(void) diff --git a/dlls/uiautomationcore/uia_provider.c b/dlls/uiautomationcore/uia_provider.c index ab2b8305b10..69bc78e34c0 100644 --- a/dlls/uiautomationcore/uia_provider.c +++ b/dlls/uiautomationcore/uia_provider.c @@ -32,6 +32,25 @@ static void variant_init_i4(VARIANT *v, int val) V_I4(v) = val; }
+static void variant_init_bool(VARIANT *v, BOOL val) +{
- V_VT(v) = VT_BOOL;
- V_BOOL(v) = val ? VARIANT_TRUE : VARIANT_FALSE;
+}
+static BOOL msaa_check_acc_state(IAccessible *acc, VARIANT cid, LONG flag)
DWORD/ULONG flag.
+{
- HRESULT hr;
- VARIANT v;
- VariantInit(&v);
- hr = IAccessible_get_accState(acc, cid, &v);
- if (SUCCEEDED(hr) && V_VT(&v) == VT_I4 && (V_I4(&v) & flag))
return TRUE;
- return FALSE;
+}
static LONG msaa_role_to_uia_control_type(LONG role) { switch (role) @@ -214,6 +233,26 @@ HRESULT WINAPI msaa_provider_GetPropertyValue(IRawElementProviderSimple *iface,
break;
- case UIA_HasKeyboardFocusPropertyId:
variant_init_bool(ret_val, msaa_check_acc_state(msaa_prov->acc, msaa_prov->cid,
STATE_SYSTEM_FOCUSED));
Unless you have need for these two helpers down the line, I'd combine them, i.e. have _check_acc_state() return a VARIANT.
Huw.
P.S. bonus points will be awarded for using gitlab to send v2 ;-)