Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48950 Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- v2: - Give test window a nonzero size and make it visible - Test hwnd associated with accessibility object with check_acc_hwnd --- dlls/oleacc/main.c | 23 +++++++++++++++----- dlls/oleacc/tests/main.c | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 6 deletions(-)
diff --git a/dlls/oleacc/main.c b/dlls/oleacc/main.c index 3ce616ae0c1..eb0429d7afe 100644 --- a/dlls/oleacc/main.c +++ b/dlls/oleacc/main.c @@ -263,18 +263,29 @@ LRESULT WINAPI LresultFromObject( REFIID riid, WPARAM wParam, LPUNKNOWN pAcc ) return atom; }
-HRESULT WINAPI AccessibleObjectFromPoint( POINT ptScreen, IAccessible** ppacc, VARIANT* pvarChild ) -{ - FIXME("{%d,%d} %p %p: stub\n", ptScreen.x, ptScreen.y, ppacc, pvarChild ); - return E_NOTIMPL; -} - static void variant_init_i4( VARIANT *v, int val ) { V_VT(v) = VT_I4; V_I4(v) = val; }
+HRESULT WINAPI AccessibleObjectFromPoint( POINT point, IAccessible** acc, VARIANT* child_id ) +{ + HRESULT hr; + + FIXME("{%d,%d} %p %p: semi-stub\n", point.x, point.y, acc, child_id); + + if (!acc || !child_id) + return E_INVALIDARG; + + hr = AccessibleObjectFromWindow(WindowFromPoint(point), OBJID_CLIENT, &IID_IAccessible, (void **)acc); + + if (SUCCEEDED(hr)) + variant_init_i4(child_id, CHILDID_SELF); + + return hr; +} + HRESULT WINAPI AccessibleObjectFromEvent( HWND hwnd, DWORD object_id, DWORD child_id, IAccessible **acc_out, VARIANT *child_id_out ) { diff --git a/dlls/oleacc/tests/main.c b/dlls/oleacc/tests/main.c index 8c234aee8aa..072a058da66 100644 --- a/dlls/oleacc/tests/main.c +++ b/dlls/oleacc/tests/main.c @@ -1304,6 +1304,52 @@ static void test_default_client_accessible_object(void) IAccessible_Release(acc); }
+static void test_AccessibleObjectFromPoint(void) +{ + IAccessible *acc; + VARIANT cid; + HRESULT hr; + HWND hwnd; + RECT rect; + POINT point = {0, 0}; + + VariantInit(&cid); + + hr = AccessibleObjectFromPoint(point, NULL, NULL); + ok(hr == E_INVALIDARG, "got %x\n", hr); + + hr = AccessibleObjectFromPoint(point, &acc, NULL); + ok(hr == E_INVALIDARG, "got %x\n", hr); + + hr = AccessibleObjectFromPoint(point, NULL, &cid); + ok(hr == E_INVALIDARG, "got %x\n", hr); + ok(V_VT(&cid) == VT_EMPTY, "got %#x, expected %#x\n", V_VT(&cid), VT_EMPTY); + + hwnd = CreateWindowA("oleacc_test", "test", WS_OVERLAPPEDWINDOW, 0, 0, 400, 300, NULL, NULL, NULL, NULL); + ok(hwnd != NULL, "CreateWindow failed\n"); + + /* test_window_proc doesn't return an IAccessible object for OBJID_CLIENT */ + hr = SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)&DefWindowProcA); + ok(hr != 0, "SetWindowLongPtr failed\n"); + + /* AccessibleObjectFromPoint ignores invisible windows */ + ShowWindow(hwnd, SW_SHOW); + + hr = GetWindowRect(hwnd, &rect); + ok(hr, "GetWindowRect failed\n"); + + point.x = (rect.left + rect.right) / 2; + point.y = (rect.top + rect.bottom) / 2; + hr = AccessibleObjectFromPoint(point, &acc, &cid); + ok(hr == S_OK, "got %x\n", hr); + check_acc_hwnd((IUnknown*)acc, hwnd); + ok(V_VT(&cid) == VT_I4, "got %#x, expected %#x\n", V_VT(&cid), VT_I4); + ok(V_I4(&cid) == CHILDID_SELF, "got %#x, expected %#x\n", V_I4(&cid), CHILDID_SELF); + IAccessible_Release(acc); + + DestroyWindow(hwnd); +} + static void test_CAccPropServices(void) { IAccPropServices *acc_prop_services; @@ -1749,6 +1795,7 @@ START_TEST(main) test_default_client_accessible_object(); test_AccessibleChildren(&Accessible); test_AccessibleObjectFromEvent(); + test_AccessibleObjectFromPoint(); test_CreateStdAccessibleObject_classes(); test_default_edit_accessible_object();
Hi Alex,
On 11/24/21 17:28, Alex Henrie wrote:
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48950 Signed-off-by: Alex Henrie alexhenrie24@gmail.com
v2:
- Give test window a nonzero size and make it visible
- Test hwnd associated with accessibility object with check_acc_hwnd
dlls/oleacc/main.c | 23 +++++++++++++++----- dlls/oleacc/tests/main.c | 47 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 6 deletions(-)
I've sent complete implementation of the function. I didn't test if it helps with the bug you have linked.
Thanks, Piotr
On Thu, Nov 25, 2021 at 10:16 AM Piotr Caban piotr.caban@gmail.com wrote:
On 11/24/21 17:28, Alex Henrie wrote:
I've sent complete implementation of the function. I didn't test if it helps with the bug you have linked.
Thanks Piotr, your version looks much better, and it does fix the linked bug.
-Alex