From: Zhiyi Zhang <zzhang(a)codeweavers.com> --- configure.ac | 2 + dlls/windows.ui.core.textinput/Makefile.in | 6 + dlls/windows.ui.core.textinput/classes.idl | 28 ++++ dlls/windows.ui.core.textinput/main.c | 135 ++++++++++++++++++ dlls/windows.ui.core.textinput/private.h | 31 ++++ .../tests/Makefile.in | 5 + .../tests/textinput.c | 82 +++++++++++ .../windows.ui.core.textinput.spec | 3 + 8 files changed, 292 insertions(+) create mode 100644 dlls/windows.ui.core.textinput/Makefile.in create mode 100644 dlls/windows.ui.core.textinput/classes.idl create mode 100644 dlls/windows.ui.core.textinput/main.c create mode 100644 dlls/windows.ui.core.textinput/private.h create mode 100644 dlls/windows.ui.core.textinput/tests/Makefile.in create mode 100644 dlls/windows.ui.core.textinput/tests/textinput.c create mode 100644 dlls/windows.ui.core.textinput/windows.ui.core.textinput.spec diff --git a/configure.ac b/configure.ac index 0ab295b0f52..39d68b13635 100644 --- a/configure.ac +++ b/configure.ac @@ -3336,6 +3336,8 @@ WINE_CONFIG_MAKEFILE(dlls/windows.system.profile.systemid) WINE_CONFIG_MAKEFILE(dlls/windows.system.profile.systemid/tests) WINE_CONFIG_MAKEFILE(dlls/windows.system.profile.systemmanufacturers) WINE_CONFIG_MAKEFILE(dlls/windows.system.profile.systemmanufacturers/tests) +WINE_CONFIG_MAKEFILE(dlls/windows.ui.core.textinput) +WINE_CONFIG_MAKEFILE(dlls/windows.ui.core.textinput/tests) WINE_CONFIG_MAKEFILE(dlls/windows.ui.xaml) WINE_CONFIG_MAKEFILE(dlls/windows.ui.xaml/tests) WINE_CONFIG_MAKEFILE(dlls/windows.ui) diff --git a/dlls/windows.ui.core.textinput/Makefile.in b/dlls/windows.ui.core.textinput/Makefile.in new file mode 100644 index 00000000000..11890311a75 --- /dev/null +++ b/dlls/windows.ui.core.textinput/Makefile.in @@ -0,0 +1,6 @@ +MODULE = windows.ui.core.textinput.dll +IMPORTS = combase + +SOURCES = \ + classes.idl \ + main.c diff --git a/dlls/windows.ui.core.textinput/classes.idl b/dlls/windows.ui.core.textinput/classes.idl new file mode 100644 index 00000000000..71c1bf98634 --- /dev/null +++ b/dlls/windows.ui.core.textinput/classes.idl @@ -0,0 +1,28 @@ +/* + * Runtime Classes for windows.ui.core.textinput.dll + * + * Copyright 2025 Zhiyi Zhang for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#pragma makedep register +#pragma winrt ns_prefix + +import "windows.ui.viewmanagement.core.idl"; + +namespace Windows.UI.ViewManagement.Core { + runtimeclass CoreInputView; +} diff --git a/dlls/windows.ui.core.textinput/main.c b/dlls/windows.ui.core.textinput/main.c new file mode 100644 index 00000000000..b40bdf3cdff --- /dev/null +++ b/dlls/windows.ui.core.textinput/main.c @@ -0,0 +1,135 @@ +/* WinRT Windows.UI.ViewManagement.Core.CoreInputView Implementation + * + * Copyright 2025 Zhiyi Zhang for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "initguid.h" +#include "private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(coreinputview); + +struct core_input_view_statics +{ + IActivationFactory IActivationFactory_iface; + LONG ref; +}; + +static inline struct core_input_view_statics *impl_from_IActivationFactory(IActivationFactory *iface) +{ + return CONTAINING_RECORD(iface, struct core_input_view_statics, IActivationFactory_iface); +} + +static HRESULT WINAPI factory_QueryInterface(IActivationFactory *iface, REFIID iid, void **out) +{ + struct core_input_view_statics *impl = impl_from_IActivationFactory(iface); + + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_IUnknown) + || IsEqualGUID(iid, &IID_IInspectable) + || IsEqualGUID(iid, &IID_IActivationFactory)) + { + *out = &impl->IActivationFactory_iface; + IActivationFactory_AddRef(*out); + return S_OK; + } + + FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI factory_AddRef(IActivationFactory *iface) +{ + struct core_input_view_statics *impl = impl_from_IActivationFactory(iface); + ULONG ref = InterlockedIncrement(&impl->ref); + TRACE("iface %p, ref %lu.\n", iface, ref); + return ref; +} + +static ULONG WINAPI factory_Release(IActivationFactory *iface) +{ + struct core_input_view_statics *impl = impl_from_IActivationFactory(iface); + ULONG ref = InterlockedDecrement(&impl->ref); + TRACE("iface %p, ref %lu.\n", iface, ref); + return ref; +} + +static HRESULT WINAPI factory_GetIids(IActivationFactory *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 factory_GetRuntimeClassName(IActivationFactory *iface, HSTRING *class_name) +{ + FIXME("iface %p, class_name %p stub!\n", iface, class_name); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_GetTrustLevel(IActivationFactory *iface, TrustLevel *trust_level) +{ + FIXME("iface %p, trust_level %p stub!\n", iface, trust_level); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_ActivateInstance(IActivationFactory *iface, IInspectable **instance) +{ + FIXME("iface %p, instance %p stub!\n", iface, instance); + return E_NOTIMPL; +} + +static const struct IActivationFactoryVtbl factory_vtbl = +{ + factory_QueryInterface, + factory_AddRef, + factory_Release, + /* IInspectable methods */ + factory_GetIids, + factory_GetRuntimeClassName, + factory_GetTrustLevel, + /* IActivationFactory methods */ + factory_ActivateInstance, +}; + +static struct core_input_view_statics core_input_view_statics = +{ + {&factory_vtbl}, + 1, +}; + +static IActivationFactory *core_input_view_factory = &core_input_view_statics.IActivationFactory_iface; + +HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **out) +{ + FIXME("clsid %s, riid %s, out %p stub!\n", debugstr_guid(clsid), debugstr_guid(riid), out); + return CLASS_E_CLASSNOTAVAILABLE; +} + +HRESULT WINAPI DllGetActivationFactory(HSTRING classid, IActivationFactory **factory) +{ + const WCHAR *name = WindowsGetStringRawBuffer(classid, NULL); + + TRACE("classid %s, factory %p.\n", debugstr_hstring(classid), factory); + + *factory = NULL; + + if (!wcscmp(name, RuntimeClass_Windows_UI_ViewManagement_Core_CoreInputView)) + IActivationFactory_QueryInterface(core_input_view_factory, &IID_IActivationFactory, (void **)factory); + + return *factory ? S_OK : CLASS_E_CLASSNOTAVAILABLE; +} diff --git a/dlls/windows.ui.core.textinput/private.h b/dlls/windows.ui.core.textinput/private.h new file mode 100644 index 00000000000..dfc22192e31 --- /dev/null +++ b/dlls/windows.ui.core.textinput/private.h @@ -0,0 +1,31 @@ +/* WinRT Windows.UI.ViewManagement.Core.CoreInputView Implementation + * + * Copyright 2025 Zhiyi Zhang for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> +#include <stddef.h> + +#define COBJMACROS +#include "windef.h" +#include "winbase.h" +#include "winstring.h" +#include "activation.h" +#include "wine/debug.h" + +#define WIDL_using_Windows_UI_ViewManagement_Core +#include "windows.ui.viewmanagement.core.h" diff --git a/dlls/windows.ui.core.textinput/tests/Makefile.in b/dlls/windows.ui.core.textinput/tests/Makefile.in new file mode 100644 index 00000000000..c48c26350c0 --- /dev/null +++ b/dlls/windows.ui.core.textinput/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = windows.ui.core.textinput.dll +IMPORTS = combase + +SOURCES = \ + textinput.c diff --git a/dlls/windows.ui.core.textinput/tests/textinput.c b/dlls/windows.ui.core.textinput/tests/textinput.c new file mode 100644 index 00000000000..30c4e81fe48 --- /dev/null +++ b/dlls/windows.ui.core.textinput/tests/textinput.c @@ -0,0 +1,82 @@ +/* + * Copyright 2025 Zhiyi Zhang for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> +#define COBJMACROS +#include "initguid.h" +#include "windef.h" +#include "winbase.h" +#include "winstring.h" +#include "roapi.h" +#include "wine/test.h" + +#define WIDL_using_Windows_UI_ViewManagement_Core +#include "windows.ui.viewmanagement.core.h" + +#define check_interface(obj, iid, supported) _check_interface(__LINE__, obj, iid, supported) +static void _check_interface(unsigned int line, void *obj, const IID *iid, BOOL supported) +{ + IUnknown *iface = obj, *unknown; + HRESULT hr; + + hr = IUnknown_QueryInterface(iface, iid, (void **)&unknown); + ok_(__FILE__, line)(hr == S_OK || (!supported && hr == E_NOINTERFACE), "Got unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + IUnknown_Release(unknown); +} + +static void test_CoreInputViewStatics(void) +{ + 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; + } + + check_interface(factory, &IID_IUnknown, TRUE); + check_interface(factory, &IID_IInspectable, TRUE); + check_interface(factory, &IID_IActivationFactory, TRUE); + check_interface(factory, &IID_IAgileObject, FALSE); + + ref = IActivationFactory_Release(factory); + ok(ref == 1, "Got unexpected refcount %ld.\n", ref); +} + +START_TEST(textinput) +{ + HRESULT hr; + + hr = RoInitialize(RO_INIT_MULTITHREADED); + ok(hr == S_OK, "RoInitialize failed, hr %#lx\n", hr); + + test_CoreInputViewStatics(); + + RoUninitialize(); +} diff --git a/dlls/windows.ui.core.textinput/windows.ui.core.textinput.spec b/dlls/windows.ui.core.textinput/windows.ui.core.textinput.spec new file mode 100644 index 00000000000..31a5eafe950 --- /dev/null +++ b/dlls/windows.ui.core.textinput/windows.ui.core.textinput.spec @@ -0,0 +1,3 @@ +@ stdcall -private DllGetActivationFactory(ptr ptr) +@ stdcall -private DllCanUnloadNow() +@ stdcall -private DllGetClassObject(ptr ptr ptr) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9269