From: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/windows.ui.core.textinput/main.c | 305 +++++++++++++++++- dlls/windows.ui.core.textinput/private.h | 2 + .../tests/textinput.c | 46 +++ 3 files changed, 351 insertions(+), 2 deletions(-) diff --git a/dlls/windows.ui.core.textinput/main.c b/dlls/windows.ui.core.textinput/main.c index 848e6ec421f..bf79d4760a1 100644 --- a/dlls/windows.ui.core.textinput/main.c +++ b/dlls/windows.ui.core.textinput/main.c @@ -22,6 +22,291 @@ WINE_DEFAULT_DEBUG_CHANNEL(coreinputview); +struct core_input_view +{ + ICoreInputView ICoreInputView_iface; + ICoreInputView2 ICoreInputView2_iface; + ICoreInputView3 ICoreInputView3_iface; + ICoreInputView4 ICoreInputView4_iface; + LONG ref; +}; + +static inline struct core_input_view *impl_from_ICoreInputView(ICoreInputView *iface) +{ + return CONTAINING_RECORD(iface, struct core_input_view, ICoreInputView_iface); +} + +static HRESULT WINAPI core_input_view_QueryInterface(ICoreInputView *iface, REFIID iid, void **out) +{ + struct core_input_view *impl = impl_from_ICoreInputView(iface); + + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + *out = NULL; + + if (IsEqualGUID(iid, &IID_IUnknown) + || IsEqualGUID(iid, &IID_IInspectable) + || IsEqualGUID(iid, &IID_IAgileObject) + || IsEqualGUID(iid, &IID_ICoreInputView)) + { + *out = &impl->ICoreInputView_iface; + } + else if (IsEqualGUID(iid, &IID_ICoreInputView2)) + { + *out = &impl->ICoreInputView2_iface; + } + else if (IsEqualGUID(iid, &IID_ICoreInputView3)) + { + *out = &impl->ICoreInputView3_iface; + } + else if (IsEqualGUID(iid, &IID_ICoreInputView4)) + { + *out = &impl->ICoreInputView4_iface; + } + + if (*out) + { + IUnknown_AddRef((IUnknown *)*out); + return S_OK; + } + + FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI core_input_view_AddRef(ICoreInputView *iface) +{ + struct core_input_view *impl = impl_from_ICoreInputView(iface); + ULONG ref = InterlockedIncrement(&impl->ref); + TRACE("iface %p, ref %lu.\n", iface, ref); + return ref; +} + +static ULONG WINAPI core_input_view_Release(ICoreInputView *iface) +{ + struct core_input_view *impl = impl_from_ICoreInputView(iface); + ULONG ref = InterlockedDecrement(&impl->ref); + + TRACE("iface %p, ref %lu.\n", iface, ref); + + if (!ref) + free(impl); + return ref; +} + +static HRESULT WINAPI core_input_view_GetIids(ICoreInputView *iface, ULONG *iid_count, IID **iids) +{ + FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view_GetRuntimeClassName(ICoreInputView *iface, HSTRING *class_name) +{ + FIXME("iface %p, class_name %p stub!\n", iface, class_name); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view_GetTrustLevel(ICoreInputView *iface, TrustLevel *trust_level) +{ + FIXME("iface %p, trust_level %p stub!\n", iface, trust_level); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view_add_OcclusionsChanged(ICoreInputView *iface, + ITypedEventHandler_CoreInputView_CoreInputViewOcclusionsChangedEventArgs *handler, + EventRegistrationToken *token) +{ + FIXME("iface %p, handler %p, token %p stub!\n", iface, handler, token); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view_remove_OcclusionsChanged(ICoreInputView *iface, + EventRegistrationToken token) +{ + FIXME("iface %p, token %I64x stub!\n", iface, token.value); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view_GetCoreInputViewOcclusions(ICoreInputView *iface, + IVectorView_CoreInputViewOcclusion **result) +{ + FIXME("iface %p, result %p stub!\n", iface, result); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view_TryShowPrimaryView(ICoreInputView *iface, boolean *result) +{ + FIXME("iface %p, boolean %p stub!\n", iface, result); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view_TryHidePrimaryView(ICoreInputView *iface, boolean *result) +{ + FIXME("iface %p, boolean %p stub!\n", iface, result); + return E_NOTIMPL; +} + +static const struct ICoreInputViewVtbl core_input_view_vtbl = +{ + core_input_view_QueryInterface, + core_input_view_AddRef, + core_input_view_Release, + /* IInspectable methods */ + core_input_view_GetIids, + core_input_view_GetRuntimeClassName, + core_input_view_GetTrustLevel, + /* ICoreInputView methods */ + core_input_view_add_OcclusionsChanged, + core_input_view_remove_OcclusionsChanged, + core_input_view_GetCoreInputViewOcclusions, + core_input_view_TryShowPrimaryView, + core_input_view_TryHidePrimaryView, +}; + +DEFINE_IINSPECTABLE(core_input_view2, ICoreInputView2, struct core_input_view, ICoreInputView_iface) + +static HRESULT WINAPI core_input_view2_add_XYFocusTransferringFromPrimaryView(ICoreInputView2 *iface, + ITypedEventHandler_CoreInputView_CoreInputViewTransferringXYFocusEventArgs *handler, + EventRegistrationToken *token) +{ + FIXME("iface %p, handler %p, token %p stub!\n", iface, handler, token); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view2_remove_XYFocusTransferringFromPrimaryView(ICoreInputView2 *iface, + EventRegistrationToken token) +{ + FIXME("iface %p, token %I64x stub!\n", iface, token.value); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view2_add_XYFocusTransferredToPrimaryView(ICoreInputView2 *iface, + ITypedEventHandler_CoreInputView_IInspectable *handler, + EventRegistrationToken *token) +{ + FIXME("iface %p, handler %p, token %p stub!\n", iface, handler, token); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view2_remove_XYFocusTransferredToPrimaryView(ICoreInputView2 *iface, + EventRegistrationToken token) +{ + FIXME("iface %p, token %I64x stub!\n", iface, token.value); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view2_TryTransferXYFocusToPrimaryView(ICoreInputView2 *iface, + Rect origin, + CoreInputViewXYFocusTransferDirection direction, + boolean *result) +{ + FIXME("iface %p, origin (%f,%f %fx%f), direction %d, result %p stub!\n", iface, origin.X, + origin.Y, origin.Width, origin.Height, direction, result); + return E_NOTIMPL; +} + +static const struct ICoreInputView2Vtbl core_input_view2_vtbl = +{ + core_input_view2_QueryInterface, + core_input_view2_AddRef, + core_input_view2_Release, + /* IInspectable methods */ + core_input_view2_GetIids, + core_input_view2_GetRuntimeClassName, + core_input_view2_GetTrustLevel, + /* ICoreInputView2 methods */ + core_input_view2_add_XYFocusTransferringFromPrimaryView, + core_input_view2_remove_XYFocusTransferringFromPrimaryView, + core_input_view2_add_XYFocusTransferredToPrimaryView, + core_input_view2_remove_XYFocusTransferredToPrimaryView, + core_input_view2_TryTransferXYFocusToPrimaryView, +}; + +DEFINE_IINSPECTABLE(core_input_view3, ICoreInputView3, struct core_input_view, ICoreInputView_iface) + +static HRESULT WINAPI core_input_view3_TryShow(ICoreInputView3 *iface, boolean *result) +{ + FIXME("iface %p, result %p stub!\n", iface, result); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view3_TryShowWithKind(ICoreInputView3 *iface, + CoreInputViewKind type, + boolean *result) +{ + FIXME("iface %p, type %d, result %p stub!\n", iface, type, result); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view3_TryHide(ICoreInputView3 *iface, boolean *result) +{ + FIXME("iface %p, result %p stub!\n", iface, result); + return E_NOTIMPL; +} + +static const struct ICoreInputView3Vtbl core_input_view3_vtbl = +{ + core_input_view3_QueryInterface, + core_input_view3_AddRef, + core_input_view3_Release, + /* IInspectable methods */ + core_input_view3_GetIids, + core_input_view3_GetRuntimeClassName, + core_input_view3_GetTrustLevel, + /* ICoreInputView3 methods */ + core_input_view3_TryShow, + core_input_view3_TryShowWithKind, + core_input_view3_TryHide, +}; + +DEFINE_IINSPECTABLE(core_input_view4, ICoreInputView4, struct core_input_view, ICoreInputView_iface) + +static HRESULT WINAPI core_input_view4_add_PrimaryViewShowing(ICoreInputView4 *iface, + ITypedEventHandler_CoreInputView_CoreInputViewShowingEventArgs *handler, + EventRegistrationToken *token) +{ + FIXME("iface %p, handler %p, token %p stub!\n", iface, handler, token); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view4_remove_PrimaryViewShowing(ICoreInputView4 *iface, + EventRegistrationToken token) +{ + FIXME("iface %p, token %I64x stub!\n", iface, token.value); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view4_add_PrimaryViewHiding(ICoreInputView4 *iface, + ITypedEventHandler_CoreInputView_CoreInputViewHidingEventArgs *handler, + EventRegistrationToken *token) +{ + FIXME("iface %p, handler %p, token %p stub!\n", iface, handler, token); + return E_NOTIMPL; +} + +static HRESULT WINAPI core_input_view4_remove_PrimaryViewHiding(ICoreInputView4 *iface, + EventRegistrationToken token) +{ + FIXME("iface %p, token %I64x stub!\n", iface, token.value); + return E_NOTIMPL; +} + +static const struct ICoreInputView4Vtbl core_input_view4_vtbl = +{ + core_input_view4_QueryInterface, + core_input_view4_AddRef, + core_input_view4_Release, + /* IInspectable methods */ + core_input_view4_GetIids, + core_input_view4_GetRuntimeClassName, + core_input_view4_GetTrustLevel, + /* ICoreInputView4 methods */ + core_input_view4_add_PrimaryViewShowing, + core_input_view4_remove_PrimaryViewShowing, + core_input_view4_add_PrimaryViewHiding, + core_input_view4_remove_PrimaryViewHiding, +}; + struct core_input_view_statics { IActivationFactory IActivationFactory_iface; @@ -120,8 +405,24 @@ DEFINE_IINSPECTABLE(core_input_view_statics, ICoreInputViewStatics, struct core_ static HRESULT WINAPI core_input_view_statics_GetForCurrentView(ICoreInputViewStatics *iface, ICoreInputView **result) { - FIXME("iface %p, result %p stub!\n", iface, result); - return E_NOTIMPL; + struct core_input_view *view; + + FIXME("iface %p, result %p semi-stub.\n", iface, result); + + if (!(view = calloc(1, sizeof(*view)))) + { + *result = NULL; + return E_OUTOFMEMORY; + } + + view->ICoreInputView_iface.lpVtbl = &core_input_view_vtbl; + view->ICoreInputView2_iface.lpVtbl = &core_input_view2_vtbl; + view->ICoreInputView3_iface.lpVtbl = &core_input_view3_vtbl; + view->ICoreInputView4_iface.lpVtbl = &core_input_view4_vtbl; + view->ref = 1; + + *result = &view->ICoreInputView_iface; + return S_OK; } static const struct ICoreInputViewStaticsVtbl core_input_view_statics_vtbl = diff --git a/dlls/windows.ui.core.textinput/private.h b/dlls/windows.ui.core.textinput/private.h index 64093ca9512..13e476f7abb 100644 --- a/dlls/windows.ui.core.textinput/private.h +++ b/dlls/windows.ui.core.textinput/private.h @@ -27,6 +27,8 @@ #include "activation.h" #include "wine/debug.h" +#define WIDL_using_Windows_Foundation +#define WIDL_using_Windows_Foundation_Collections #define WIDL_using_Windows_UI_ViewManagement_Core #include "windows.ui.viewmanagement.core.h" diff --git a/dlls/windows.ui.core.textinput/tests/textinput.c b/dlls/windows.ui.core.textinput/tests/textinput.c index 6c12aee239e..43e1a2a477d 100644 --- a/dlls/windows.ui.core.textinput/tests/textinput.c +++ b/dlls/windows.ui.core.textinput/tests/textinput.c @@ -70,6 +70,51 @@ static void test_CoreInputViewStatics(void) ok(ref == 1, "Got unexpected refcount %ld.\n", ref); } +static void test_CoreInputView(void) +{ + ICoreInputViewStatics *core_input_view_statics; + ICoreInputView *core_input_view; + IActivationFactory *factory; + HSTRING str = NULL; + HRESULT hr; + LONG ref; + + hr = WindowsCreateString(RuntimeClass_Windows_UI_ViewManagement_Core_CoreInputView, + wcslen(RuntimeClass_Windows_UI_ViewManagement_Core_CoreInputView), &str); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + hr = RoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory); + WindowsDeleteString(str); + ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG), "got hr %#lx.\n", hr); + if (hr == REGDB_E_CLASSNOTREG) + { + win_skip("%s runtimeclass not registered, skipping tests.\n", + wine_dbgstr_w(RuntimeClass_Windows_UI_ViewManagement_Core_CoreInputView)); + return; + } + + hr = IActivationFactory_QueryInterface(factory, &IID_ICoreInputViewStatics, + (void **)&core_input_view_statics); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = ICoreInputViewStatics_GetForCurrentView(core_input_view_statics, &core_input_view); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + check_interface(core_input_view, &IID_IUnknown, TRUE); + check_interface(core_input_view, &IID_IInspectable, TRUE); + check_interface(core_input_view, &IID_IAgileObject, TRUE); + check_interface(core_input_view, &IID_ICoreInputView, TRUE); + check_interface(core_input_view, &IID_ICoreInputView2, TRUE); + check_interface(core_input_view, &IID_ICoreInputView3, TRUE); + check_interface(core_input_view, &IID_ICoreInputView4, TRUE); + + ICoreInputView_Release(core_input_view); + + ref = ICoreInputViewStatics_Release(core_input_view_statics); + ok(ref == 2, "Got unexpected refcount %ld.\n", ref); + ref = IActivationFactory_Release(factory); + ok(ref == 1, "Got unexpected refcount %ld.\n", ref); +} + START_TEST(textinput) { HRESULT hr; @@ -78,6 +123,7 @@ START_TEST(textinput) ok(hr == S_OK, "RoInitialize failed, hr %#lx\n", hr); test_CoreInputViewStatics(); + test_CoreInputView(); RoUninitialize(); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9269