For React Native.
From: Zhiyi Zhang zzhang@codeweavers.com
--- include/windows.ui.viewmanagement.idl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/include/windows.ui.viewmanagement.idl b/include/windows.ui.viewmanagement.idl index 0132e5f5091..cfb63c5a07e 100644 --- a/include/windows.ui.viewmanagement.idl +++ b/include/windows.ui.viewmanagement.idl @@ -51,6 +51,7 @@ namespace Windows.UI.ViewManagement typedef enum UserInteractionMode UserInteractionMode; typedef enum ViewSizePreference ViewSizePreference;
+ interface IAccessibilitySettings; interface IApplicationView; interface IApplicationView2; interface IApplicationView3; @@ -97,6 +98,7 @@ namespace Windows.UI.ViewManagement interface IInputPaneStatics; interface IInputPaneStatics2;
+ runtimeclass AccessibilitySettings; #ifndef _WINDOWS_UI runtimeclass ApplicationView; #endif @@ -117,6 +119,7 @@ namespace Windows.UI.ViewManagement runtimeclass ViewModePreferences;
declare { + interface Windows.Foundation.TypedEventHandler<Windows.UI.ViewManagement.AccessibilitySettings *, IInspectable *>; #ifndef _WINDOWS_UI interface Windows.Foundation.TypedEventHandler<Windows.UI.ViewManagement.ApplicationView *, IInspectable *>; interface Windows.Foundation.TypedEventHandler<Windows.UI.ViewManagement.ApplicationView *, Windows.UI.ViewManagement.ApplicationViewConsolidatedEventArgs *>; @@ -309,6 +312,19 @@ namespace Windows.UI.ViewManagement Custom = 6, };
+ [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.UI.ViewManagement.AccessibilitySettings), + uuid(fe0e8147-c4c0-4562-b962-1327b52ad5b9) + ] + interface IAccessibilitySettings : IInspectable + { + [propget] HRESULT HighContrast([out, retval] boolean *value); + [propget] HRESULT HighContrastScheme([out, retval] HSTRING *value); + [eventadd] HRESULT HighContrastChanged([in] Windows.Foundation.TypedEventHandler<Windows.UI.ViewManagement.AccessibilitySettings *, IInspectable *> *handler, [out, retval] EventRegistrationToken *cookie); + [eventremove] HRESULT HighContrastChanged([in] EventRegistrationToken cookie); + } + #ifndef _WINDOWS_UI [ contract(Windows.Foundation.UniversalApiContract, 1.0), @@ -846,6 +862,16 @@ namespace Windows.UI.ViewManagement HRESULT CreateDefault([in] Windows.UI.ViewManagement.ApplicationViewMode mode, [out, retval] Windows.UI.ViewManagement.ViewModePreferences **result); }
+ [ + activatable(Windows.Foundation.UniversalApiContract, 1.0), + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile) + ] + runtimeclass AccessibilitySettings + { + [default] interface Windows.UI.ViewManagement.IAccessibilitySettings; + } + #ifndef _WINDOWS_UI [ contract(Windows.Foundation.UniversalApiContract, 1.0),
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/windows.ui/tests/Makefile.in | 2 +- dlls/windows.ui/tests/uisettings.c | 63 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/dlls/windows.ui/tests/Makefile.in b/dlls/windows.ui/tests/Makefile.in index ddaf0262cf0..88e5e4d08d9 100644 --- a/dlls/windows.ui/tests/Makefile.in +++ b/dlls/windows.ui/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = windows.ui.dll -IMPORTS = combase advapi32 +IMPORTS = combase advapi32 user32
SOURCES = \ uisettings.c diff --git a/dlls/windows.ui/tests/uisettings.c b/dlls/windows.ui/tests/uisettings.c index 898b43e3167..6d1a6d72e8b 100644 --- a/dlls/windows.ui/tests/uisettings.c +++ b/dlls/windows.ui/tests/uisettings.c @@ -334,6 +334,68 @@ static void test_UISettings_weak_ref(void) ok( ref == 1, "got ref %ld.\n", ref ); }
+static void test_AccessibilitySettings(void) +{ + static const WCHAR *class_name = RuntimeClass_Windows_UI_ViewManagement_AccessibilitySettings; + HIGHCONTRASTW high_contrast = {0}; + IAccessibilitySettings *settings; + IActivationFactory *factory; + IInspectable *inspectable; + boolean value; + HSTRING str; + HRESULT hr; + BOOL ret; + LONG ref; + + hr = WindowsCreateString( class_name, wcslen( class_name ), &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory ); + todo_wine + ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "got hr %#lx.\n", hr ); + if (FAILED( hr )) + { + todo_wine + win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( class_name ) ); + WindowsDeleteString( str ); + 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 ); + check_interface( factory, &IID_IAccessibilitySettings, FALSE ); + + hr = RoActivateInstance( str, &inspectable ); + ok( hr == S_OK, "Got unexpected hr %#lx.\n", hr ); + WindowsDeleteString( str ); + + hr = IInspectable_QueryInterface( inspectable, &IID_IAccessibilitySettings, (void **)&settings ); + ok( hr == S_OK, "Got unexpected hr %#lx.\n", hr ); + + check_interface( inspectable, &IID_IUnknown, TRUE ); + check_interface( inspectable, &IID_IInspectable, TRUE ); + check_interface( inspectable, &IID_IAgileObject, TRUE ); + check_interface( inspectable, &IID_IAccessibilitySettings, TRUE ); + + hr = IAccessibilitySettings_get_HighContrast( settings, &value ); + todo_wine + ok( hr == S_OK, "Got unexpected hr %#lx.\n", hr ); + if ( hr == S_OK ) + { + high_contrast.cbSize = sizeof(high_contrast); + ret = SystemParametersInfoW( SPI_GETHIGHCONTRAST, sizeof(high_contrast), &high_contrast, 0 ); + ok( ret, "SystemParametersInfoW failed, error %lu.\n", GetLastError() ); + ok( value == !!(high_contrast.dwFlags & HCF_HIGHCONTRASTON), "Got unexpected high contrast value.\n" ); + } + + IAccessibilitySettings_Release( settings ); + IInspectable_Release( inspectable ); + ref = IActivationFactory_Release( factory ); + ok( ref == 1, "got ref %ld.\n", ref ); +} + START_TEST(uisettings) { HRESULT hr; @@ -343,6 +405,7 @@ START_TEST(uisettings)
test_UISettings(); test_UISettings_weak_ref(); + test_AccessibilitySettings();
RoUninitialize(); }
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/windows.ui/Makefile.in | 1 + dlls/windows.ui/accessibilitysettings.c | 247 ++++++++++++++++++++++++ dlls/windows.ui/main.c | 3 + dlls/windows.ui/private.h | 1 + dlls/windows.ui/tests/uisettings.c | 2 - 5 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 dlls/windows.ui/accessibilitysettings.c
diff --git a/dlls/windows.ui/Makefile.in b/dlls/windows.ui/Makefile.in index e88a40188b1..e6b49738898 100644 --- a/dlls/windows.ui/Makefile.in +++ b/dlls/windows.ui/Makefile.in @@ -2,6 +2,7 @@ MODULE = windows.ui.dll IMPORTS = combase advapi32
SOURCES = \ + accessibilitysettings.c \ classes.idl \ inputpane.c \ main.c \ diff --git a/dlls/windows.ui/accessibilitysettings.c b/dlls/windows.ui/accessibilitysettings.c new file mode 100644 index 00000000000..a04d59a6cd8 --- /dev/null +++ b/dlls/windows.ui/accessibilitysettings.c @@ -0,0 +1,247 @@ +/* WinRT Windows.UI.ViewManagement.AccessibilitySettings 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 "private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(ui); + +struct accessibilitysettings +{ + IAccessibilitySettings IAccessibilitySettings_iface; + LONG ref; +}; + +static inline struct accessibilitysettings *impl_from_IAccessibilitySettings(IAccessibilitySettings *iface) +{ + return CONTAINING_RECORD(iface, struct accessibilitysettings, IAccessibilitySettings_iface); +} + +static HRESULT WINAPI accessibilitysettings_QueryInterface(IAccessibilitySettings *iface, + REFIID iid, void **out) +{ + struct accessibilitysettings *impl = impl_from_IAccessibilitySettings(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_IAgileObject) + || IsEqualGUID(iid, &IID_IAccessibilitySettings)) + { + *out = &impl->IAccessibilitySettings_iface; + IAccessibilitySettings_AddRef(&impl->IAccessibilitySettings_iface); + return S_OK; + } + + *out = NULL; + FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI accessibilitysettings_AddRef(IAccessibilitySettings *iface) +{ + struct accessibilitysettings *impl = impl_from_IAccessibilitySettings(iface); + ULONG ref = InterlockedIncrement(&impl->ref); + TRACE("iface %p, ref %lu.\n", iface, ref); + return ref; +} + +static ULONG WINAPI accessibilitysettings_Release(IAccessibilitySettings *iface) +{ + struct accessibilitysettings *impl = impl_from_IAccessibilitySettings(iface); + ULONG ref = InterlockedDecrement(&impl->ref); + + TRACE("iface %p, ref %lu.\n", iface, ref); + + if (!ref) + free(impl); + return ref; +} + +static HRESULT WINAPI accessibilitysettings_GetIids(IAccessibilitySettings *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 accessibilitysettings_GetRuntimeClassName(IAccessibilitySettings *iface, + HSTRING *class_name) +{ + FIXME("iface %p, class_name %p stub!\n", iface, class_name); + return E_NOTIMPL; +} + +static HRESULT WINAPI accessibilitysettings_GetTrustLevel(IAccessibilitySettings *iface, + TrustLevel *trust_level) +{ + FIXME("iface %p, trust_level %p stub!\n", iface, trust_level); + return E_NOTIMPL; +} + +static HRESULT WINAPI accessibilitysettings_get_HighContrast(IAccessibilitySettings *iface, + boolean *value) +{ + FIXME("iface %p, value %p stub!\n", iface, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI accessibilitysettings_get_HighContrastScheme(IAccessibilitySettings *iface, + HSTRING *value) +{ + FIXME("iface %p, value %p stub!\n", iface, value); + return E_NOTIMPL; +} + +static HRESULT WINAPI accessibilitysettings_add_HighContrastChanged(IAccessibilitySettings *iface, + ITypedEventHandler_AccessibilitySettings_IInspectable *handler, + EventRegistrationToken *cookie) +{ + FIXME("iface %p, handler %p, cookie %p stub!\n", iface, handler, cookie); + return E_NOTIMPL; +} + +static HRESULT WINAPI accessibilitysettings_remove_HighContrastChanged(IAccessibilitySettings *iface, + EventRegistrationToken cookie) +{ + FIXME("iface %p, cookie %I64x stub!\n", iface, cookie.value); + return E_NOTIMPL; +} + +static const struct IAccessibilitySettingsVtbl accessibilitysettings_vtbl = +{ + accessibilitysettings_QueryInterface, + accessibilitysettings_AddRef, + accessibilitysettings_Release, + /* IInspectable methods */ + accessibilitysettings_GetIids, + accessibilitysettings_GetRuntimeClassName, + accessibilitysettings_GetTrustLevel, + /* IAccessibilitySettings methods */ + accessibilitysettings_get_HighContrast, + accessibilitysettings_get_HighContrastScheme, + accessibilitysettings_add_HighContrastChanged, + accessibilitysettings_remove_HighContrastChanged, +}; + +struct factory +{ + IActivationFactory IActivationFactory_iface; + LONG ref; +}; + +static inline struct factory *impl_from_IActivationFactory(IActivationFactory *iface) +{ + return CONTAINING_RECORD(iface, struct factory, IActivationFactory_iface); +} + +static HRESULT WINAPI factory_QueryInterface(IActivationFactory *iface, REFIID iid, void **out) +{ + struct factory *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; + IInspectable_AddRef(*out); + return S_OK; + } + + *out = NULL; + FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + return E_NOINTERFACE; +} + +static ULONG WINAPI factory_AddRef(IActivationFactory *iface) +{ + struct factory *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 factory *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) +{ + struct accessibilitysettings *impl; + + TRACE("iface %p, instance %p.\n", iface, instance); + + if (!(impl = calloc(1, sizeof(*impl)))) + { + *instance = NULL; + return E_OUTOFMEMORY; + } + + impl->IAccessibilitySettings_iface.lpVtbl = &accessibilitysettings_vtbl; + impl->ref = 1; + + *instance = (IInspectable *)&impl->IAccessibilitySettings_iface; + return S_OK; +} + +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 factory factory = +{ + {&factory_vtbl}, + 1, +}; + +IActivationFactory *accessibilitysettings_factory = &factory.IActivationFactory_iface; diff --git a/dlls/windows.ui/main.c b/dlls/windows.ui/main.c index 87b8f87561a..57f8dfb1c3f 100644 --- a/dlls/windows.ui/main.c +++ b/dlls/windows.ui/main.c @@ -38,6 +38,9 @@ HRESULT WINAPI DllGetActivationFactory( HSTRING classid, IActivationFactory **fa
*factory = NULL;
+ if (!wcscmp( buffer, RuntimeClass_Windows_UI_ViewManagement_AccessibilitySettings )) + IActivationFactory_QueryInterface( accessibilitysettings_factory, &IID_IActivationFactory, (void **)factory ); + if (!wcscmp( buffer, RuntimeClass_Windows_UI_ViewManagement_UISettings )) IActivationFactory_QueryInterface( uisettings_factory, &IID_IActivationFactory, (void **)factory );
diff --git a/dlls/windows.ui/private.h b/dlls/windows.ui/private.h index 6e611e5d5d3..9901bbbc88e 100644 --- a/dlls/windows.ui/private.h +++ b/dlls/windows.ui/private.h @@ -36,6 +36,7 @@ #define WIDL_using_Windows_UI_ViewManagement #include "windows.ui.viewmanagement.h"
+extern IActivationFactory *accessibilitysettings_factory; extern IActivationFactory *uisettings_factory; extern IActivationFactory *uiviewsettings_factory; extern IActivationFactory *inputpane_factory; diff --git a/dlls/windows.ui/tests/uisettings.c b/dlls/windows.ui/tests/uisettings.c index 6d1a6d72e8b..3abf62730ec 100644 --- a/dlls/windows.ui/tests/uisettings.c +++ b/dlls/windows.ui/tests/uisettings.c @@ -351,11 +351,9 @@ static void test_AccessibilitySettings(void) ok( hr == S_OK, "got hr %#lx.\n", hr );
hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory ); - todo_wine ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "got hr %#lx.\n", hr ); if (FAILED( hr )) { - todo_wine win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( class_name ) ); WindowsDeleteString( str ); return;
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/windows.ui/Makefile.in | 2 +- dlls/windows.ui/accessibilitysettings.c | 11 +++++++++-- dlls/windows.ui/tests/uisettings.c | 13 +++++-------- 3 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/dlls/windows.ui/Makefile.in b/dlls/windows.ui/Makefile.in index e6b49738898..5bef78b300e 100644 --- a/dlls/windows.ui/Makefile.in +++ b/dlls/windows.ui/Makefile.in @@ -1,5 +1,5 @@ MODULE = windows.ui.dll -IMPORTS = combase advapi32 +IMPORTS = combase advapi32 user32
SOURCES = \ accessibilitysettings.c \ diff --git a/dlls/windows.ui/accessibilitysettings.c b/dlls/windows.ui/accessibilitysettings.c index a04d59a6cd8..f1dfe588b75 100644 --- a/dlls/windows.ui/accessibilitysettings.c +++ b/dlls/windows.ui/accessibilitysettings.c @@ -99,8 +99,15 @@ static HRESULT WINAPI accessibilitysettings_GetTrustLevel(IAccessibilitySettings static HRESULT WINAPI accessibilitysettings_get_HighContrast(IAccessibilitySettings *iface, boolean *value) { - FIXME("iface %p, value %p stub!\n", iface, value); - return E_NOTIMPL; + HIGHCONTRASTW high_contrast = {.cbSize = sizeof(high_contrast)}; + + TRACE("iface %p, value %p.\n", iface, value); + + if (!SystemParametersInfoW(SPI_GETHIGHCONTRAST, sizeof(high_contrast), &high_contrast, 0)) + return E_FAIL; + + *value = !!(high_contrast.dwFlags & HCF_HIGHCONTRASTON); + return S_OK; }
static HRESULT WINAPI accessibilitysettings_get_HighContrastScheme(IAccessibilitySettings *iface, diff --git a/dlls/windows.ui/tests/uisettings.c b/dlls/windows.ui/tests/uisettings.c index 3abf62730ec..4ab05d14ddd 100644 --- a/dlls/windows.ui/tests/uisettings.c +++ b/dlls/windows.ui/tests/uisettings.c @@ -378,15 +378,12 @@ static void test_AccessibilitySettings(void) check_interface( inspectable, &IID_IAccessibilitySettings, TRUE );
hr = IAccessibilitySettings_get_HighContrast( settings, &value ); - todo_wine ok( hr == S_OK, "Got unexpected hr %#lx.\n", hr ); - if ( hr == S_OK ) - { - high_contrast.cbSize = sizeof(high_contrast); - ret = SystemParametersInfoW( SPI_GETHIGHCONTRAST, sizeof(high_contrast), &high_contrast, 0 ); - ok( ret, "SystemParametersInfoW failed, error %lu.\n", GetLastError() ); - ok( value == !!(high_contrast.dwFlags & HCF_HIGHCONTRASTON), "Got unexpected high contrast value.\n" ); - } + + high_contrast.cbSize = sizeof(high_contrast); + ret = SystemParametersInfoW( SPI_GETHIGHCONTRAST, sizeof(high_contrast), &high_contrast, 0 ); + ok( ret, "SystemParametersInfoW failed, error %lu.\n", GetLastError() ); + ok( value == !!(high_contrast.dwFlags & HCF_HIGHCONTRASTON), "Got unexpected high contrast value.\n" );
IAccessibilitySettings_Release( settings ); IInspectable_Release( inspectable );