[PATCH 0/3] MR10234: include: Add windows.graphics.display.idl.
For React Native. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10234
From: Zhiyi Zhang <zzhang@codeweavers.com> --- include/Makefile.in | 1 + include/windows.graphics.display.idl | 229 +++++++++++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100644 include/windows.graphics.display.idl diff --git a/include/Makefile.in b/include/Makefile.in index 626091317f9..fb2c59bfcb2 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -911,6 +911,7 @@ SOURCES = \ windows.graphics.capture.interop.idl \ windows.graphics.directx.direct3d11.idl \ windows.graphics.directx.idl \ + windows.graphics.display.idl \ windows.graphics.effects.idl \ windows.graphics.holographic.idl \ windows.graphics.idl \ diff --git a/include/windows.graphics.display.idl b/include/windows.graphics.display.idl new file mode 100644 index 00000000000..7a9750cc9d4 --- /dev/null +++ b/include/windows.graphics.display.idl @@ -0,0 +1,229 @@ +/* + * Copyright 2026 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 + */ + +#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "inspectable.idl"; +import "asyncinfo.idl"; +import "eventtoken.idl"; +import "windowscontracts.idl"; +import "windows.foundation.idl"; +import "windows.graphics.idl"; +import "windows.storage.streams.idl"; + +namespace Windows.Graphics.Display { + typedef enum AdvancedColorKind AdvancedColorKind; + typedef enum DisplayOrientations DisplayOrientations; + typedef enum HdrMetadataFormat HdrMetadataFormat; + typedef enum ResolutionScale ResolutionScale; + + interface IAdvancedColorInfo; + interface IDisplayInformationStatics; + + runtimeclass AdvancedColorInfo; + runtimeclass DisplayInformation; + + declare { + interface Windows.Foundation.TypedEventHandler<Windows.Graphics.Display.DisplayInformation *, IInspectable *>; + } + + [ + contract(Windows.Foundation.UniversalApiContract, 6.0) + ] + enum AdvancedColorKind + { + StandardDynamicRange = 0, + WideColorGamut = 1, + HighDynamicRange = 2 + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + flags + ] + enum DisplayOrientations + { + None = 0x0, + Landscape = 0x1, + Portrait = 0x2, + LandscapeFlipped = 0x4, + PortraitFlipped = 0x8 + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 6.0) + ] + enum HdrMetadataFormat + { + Hdr10 = 0, + Hdr10Plus = 1 + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0) + ] + enum ResolutionScale + { + Invalid = 0, + Scale100Percent = 100, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale120Percent = 120, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale125Percent = 125, + Scale140Percent = 140, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale150Percent = 150, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale160Percent = 160, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale175Percent = 175, + Scale180Percent = 180, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale200Percent = 200, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale225Percent = 225, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale250Percent = 250, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale300Percent = 300, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale350Percent = 350, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale400Percent = 400, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale450Percent = 450, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] Scale500Percent = 500 + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 6.0), + exclusiveto(Windows.Graphics.Display.AdvancedColorInfo), + uuid(8797dcfb-b229-4081-ae9a-2cc85e34ad6a) + ] + interface IAdvancedColorInfo : IInspectable + { + [propget] HRESULT CurrentAdvancedColorKind([out, retval] Windows.Graphics.Display.AdvancedColorKind *value); + [propget] HRESULT RedPrimary([out, retval] Windows.Foundation.Point *value); + [propget] HRESULT GreenPrimary([out, retval] Windows.Foundation.Point *value); + [propget] HRESULT BluePrimary([out, retval] Windows.Foundation.Point *value); + [propget] HRESULT WhitePoint([out, retval] Windows.Foundation.Point *value); + [propget] HRESULT MaxLuminanceInNits([out, retval] FLOAT *value); + [propget] HRESULT MinLuminanceInNits([out, retval] FLOAT *value); + [propget] HRESULT MaxAverageFullFrameLuminanceInNits([out, retval] FLOAT *value); + [propget] HRESULT SdrWhiteLevelInNits([out, retval] FLOAT *value); + HRESULT IsHdrMetadataFormatCurrentlySupported([in] Windows.Graphics.Display.HdrMetadataFormat format, [out, retval] boolean *result); + HRESULT IsAdvancedColorKindAvailable([in] Windows.Graphics.Display.AdvancedColorKind kind, [out, retval] boolean *result); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Graphics.Display.DisplayInformation), + uuid(bed112ae-adc3-4dc9-ae65-851f4d7d4799) + ] + interface IDisplayInformation : IInspectable + { + [propget] HRESULT CurrentOrientation([out, retval] Windows.Graphics.Display.DisplayOrientations *value); + [propget] HRESULT NativeOrientation([out, retval] Windows.Graphics.Display.DisplayOrientations *value); + [eventadd] HRESULT OrientationChanged([in] Windows.Foundation.TypedEventHandler<Windows.Graphics.Display.DisplayInformation *, IInspectable *> *handler, [out, retval] EventRegistrationToken *token); + [eventremove] HRESULT OrientationChanged([in] EventRegistrationToken token); + [propget] HRESULT ResolutionScale([out, retval] Windows.Graphics.Display.ResolutionScale *value); + [propget] HRESULT LogicalDpi([out, retval] FLOAT *value); + [propget] HRESULT RawDpiX([out, retval] FLOAT *value); + [propget] HRESULT RawDpiY([out, retval] FLOAT *value); + [eventadd] HRESULT DpiChanged([in] Windows.Foundation.TypedEventHandler<Windows.Graphics.Display.DisplayInformation *, IInspectable *> *handler, [out, retval] EventRegistrationToken *token); + [eventremove] HRESULT DpiChanged([in] EventRegistrationToken token); + [propget] HRESULT StereoEnabled([out, retval] boolean *value); + [eventadd] HRESULT StereoEnabledChanged([in] Windows.Foundation.TypedEventHandler<Windows.Graphics.Display.DisplayInformation *, IInspectable *> *handler, [out, retval] EventRegistrationToken *token); + [eventremove] HRESULT StereoEnabledChanged([in] EventRegistrationToken token); + HRESULT GetColorProfileAsync([out, retval] Windows.Foundation.IAsyncOperation<Windows.Storage.Streams.IRandomAccessStream *> **async_info); + [eventadd] HRESULT ColorProfileChanged([in] Windows.Foundation.TypedEventHandler<Windows.Graphics.Display.DisplayInformation *, IInspectable *> *handler, [out, retval] EventRegistrationToken *token); + [eventremove] HRESULT ColorProfileChanged([in] EventRegistrationToken token); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Graphics.Display.DisplayInformation), + uuid(4dcd0021-fad1-4b8e-8edf-775887b8bf19) + ] + interface IDisplayInformation2 : IInspectable + requires Windows.Graphics.Display.IDisplayInformation + { + [propget] HRESULT RawPixelsPerViewPixel([out, retval] DOUBLE *value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 2.0), + exclusiveto(Windows.Graphics.Display.DisplayInformation), + uuid(db15011d-0f09-4466-8ff3-11de9a3c929a) + ] + interface IDisplayInformation3 : IInspectable + { + [propget] HRESULT DiagonalSizeInInches([out, retval] Windows.Foundation.IReference<DOUBLE> **value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 3.0), + exclusiveto(Windows.Graphics.Display.DisplayInformation), + uuid(c972ce2f-1242-46be-b536-e1aafe9e7acf) + ] + interface IDisplayInformation4 : IInspectable + { + [propget] HRESULT ScreenWidthInRawPixels([out, retval] UINT32 *value); + [propget] HRESULT ScreenHeightInRawPixels([out, retval] UINT32 *value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 6.0), + exclusiveto(Windows.Graphics.Display.DisplayInformation), + uuid(3a5442dc-2cde-4a8d-80d1-21dc5adcc1aa) + ] + interface IDisplayInformation5 : IInspectable + { + HRESULT GetAdvancedColorInfo([out, retval] Windows.Graphics.Display.AdvancedColorInfo **value); + [eventadd] HRESULT AdvancedColorInfoChanged([in] Windows.Foundation.TypedEventHandler<Windows.Graphics.Display.DisplayInformation *, IInspectable *> *handler, [out, retval] EventRegistrationToken *token); + [eventremove] HRESULT AdvancedColorInfoChanged([in] EventRegistrationToken token); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Graphics.Display.DisplayInformation), + uuid(c6a02a6c-d452-44dc-ba07-96f3c6adf9d1) + ] + interface IDisplayInformationStatics : IInspectable + { + HRESULT GetForCurrentView([out, retval] Windows.Graphics.Display.DisplayInformation **current); + [propget] HRESULT AutoRotationPreferences([out, retval] Windows.Graphics.Display.DisplayOrientations *value); + [propput] HRESULT AutoRotationPreferences([in] Windows.Graphics.Display.DisplayOrientations value); + [eventadd] HRESULT DisplayContentsInvalidated([in] Windows.Foundation.TypedEventHandler<Windows.Graphics.Display.DisplayInformation *, IInspectable *> *handler, [out, retval] EventRegistrationToken *token); + [eventremove] HRESULT DisplayContentsInvalidated([in] EventRegistrationToken token); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 6.0), + marshaling_behavior(agile), + threading(both) + ] + runtimeclass AdvancedColorInfo + { + [default] interface Windows.Graphics.Display.IAdvancedColorInfo; + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + static(Windows.Graphics.Display.IDisplayInformationStatics, Windows.Foundation.UniversalApiContract, 1.0) + ] + runtimeclass DisplayInformation + { + [default] interface Windows.Graphics.Display.IDisplayInformation; + [contract(Windows.Foundation.UniversalApiContract, 1.0)] interface Windows.Graphics.Display.IDisplayInformation2; + [contract(Windows.Foundation.UniversalApiContract, 2.0)] interface Windows.Graphics.Display.IDisplayInformation3; + [contract(Windows.Foundation.UniversalApiContract, 3.0)] interface Windows.Graphics.Display.IDisplayInformation4; + [contract(Windows.Foundation.UniversalApiContract, 6.0)] interface Windows.Graphics.Display.IDisplayInformation5; + } +} -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10234
From: Zhiyi Zhang <zzhang@codeweavers.com> --- configure.ac | 2 + dlls/windows.graphics/Makefile.in | 6 + dlls/windows.graphics/classes.idl | 29 +++++ dlls/windows.graphics/main.c | 135 ++++++++++++++++++++ dlls/windows.graphics/private.h | 31 +++++ dlls/windows.graphics/tests/Makefile.in | 5 + dlls/windows.graphics/tests/graphics.c | 83 ++++++++++++ dlls/windows.graphics/windows.graphics.spec | 3 + 8 files changed, 294 insertions(+) create mode 100644 dlls/windows.graphics/Makefile.in create mode 100644 dlls/windows.graphics/classes.idl create mode 100644 dlls/windows.graphics/main.c create mode 100644 dlls/windows.graphics/private.h create mode 100644 dlls/windows.graphics/tests/Makefile.in create mode 100644 dlls/windows.graphics/tests/graphics.c create mode 100644 dlls/windows.graphics/windows.graphics.spec diff --git a/configure.ac b/configure.ac index 0dc80907084..ea868f8e6ea 100644 --- a/configure.ac +++ b/configure.ac @@ -3306,6 +3306,8 @@ WINE_CONFIG_MAKEFILE(dlls/windows.gaming.ui.gamebar) WINE_CONFIG_MAKEFILE(dlls/windows.gaming.ui.gamebar/tests) WINE_CONFIG_MAKEFILE(dlls/windows.globalization) WINE_CONFIG_MAKEFILE(dlls/windows.globalization/tests) +WINE_CONFIG_MAKEFILE(dlls/windows.graphics) +WINE_CONFIG_MAKEFILE(dlls/windows.graphics/tests) WINE_CONFIG_MAKEFILE(dlls/windows.media.devices) WINE_CONFIG_MAKEFILE(dlls/windows.media.devices/tests) WINE_CONFIG_MAKEFILE(dlls/windows.media.mediacontrol) diff --git a/dlls/windows.graphics/Makefile.in b/dlls/windows.graphics/Makefile.in new file mode 100644 index 00000000000..ce91ff8f53e --- /dev/null +++ b/dlls/windows.graphics/Makefile.in @@ -0,0 +1,6 @@ +MODULE = windows.graphics.dll +IMPORTS = combase + +SOURCES = \ + classes.idl \ + main.c diff --git a/dlls/windows.graphics/classes.idl b/dlls/windows.graphics/classes.idl new file mode 100644 index 00000000000..82ab26f70c5 --- /dev/null +++ b/dlls/windows.graphics/classes.idl @@ -0,0 +1,29 @@ +/* + * Runtime Classes for windows.graphics.dll + * + * Copyright 2026 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.graphics.display.idl"; + +namespace Windows.Graphics.Display { + runtimeclass AdvancedColorInfo; + runtimeclass DisplayInformation; +} diff --git a/dlls/windows.graphics/main.c b/dlls/windows.graphics/main.c new file mode 100644 index 00000000000..0d85af5d71b --- /dev/null +++ b/dlls/windows.graphics/main.c @@ -0,0 +1,135 @@ +/* WinRT Windows.Graphics Implementation + * + * Copyright 2026 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(display); + +struct display_info_statics +{ + IActivationFactory IActivationFactory_iface; + LONG ref; +}; + +static inline struct display_info_statics *impl_from_IActivationFactory( IActivationFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct display_info_statics, IActivationFactory_iface ); +} + +static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + struct display_info_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 display_info_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 display_info_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 display_info_statics display_info_statics = +{ + {&factory_vtbl}, + 1, +}; + +static IActivationFactory *display_info_factory = &display_info_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_Graphics_Display_DisplayInformation )) + IActivationFactory_QueryInterface( display_info_factory, &IID_IActivationFactory, (void **)factory ); + + return *factory ? S_OK : CLASS_E_CLASSNOTAVAILABLE; +} diff --git a/dlls/windows.graphics/private.h b/dlls/windows.graphics/private.h new file mode 100644 index 00000000000..05a2a4f6d5e --- /dev/null +++ b/dlls/windows.graphics/private.h @@ -0,0 +1,31 @@ +/* WinRT Windows.Graphics Implementation + * + * Copyright 2026 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_Graphics_Display +#include "windows.graphics.display.h" diff --git a/dlls/windows.graphics/tests/Makefile.in b/dlls/windows.graphics/tests/Makefile.in new file mode 100644 index 00000000000..867c7036079 --- /dev/null +++ b/dlls/windows.graphics/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = windows.graphics.dll +IMPORTS = combase + +SOURCES = \ + graphics.c diff --git a/dlls/windows.graphics/tests/graphics.c b/dlls/windows.graphics/tests/graphics.c new file mode 100644 index 00000000000..e4332826eb7 --- /dev/null +++ b/dlls/windows.graphics/tests/graphics.c @@ -0,0 +1,83 @@ +/* + * Copyright 2026 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_Graphics_Display +#include "windows.graphics.display.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_DisplayInformationStatics(void) +{ + IActivationFactory *factory; + HSTRING str = NULL; + HRESULT hr; + LONG ref; + + hr = WindowsCreateString( RuntimeClass_Windows_Graphics_Display_DisplayInformation, + wcslen( RuntimeClass_Windows_Graphics_Display_DisplayInformation ), &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_Graphics_Display_DisplayInformation) ); + return; + } + + check_interface( factory, &IID_IUnknown, TRUE ); + check_interface( factory, &IID_IInspectable, TRUE ); + check_interface( factory, &IID_IActivationFactory, TRUE ); + todo_wine + check_interface( factory, &IID_IDisplayInformationStatics, TRUE ); + check_interface( factory, &IID_IAgileObject, FALSE ); + + ref = IActivationFactory_Release( factory ); + ok(ref == 1, "Got unexpected refcount %ld.\n", ref); +} + +START_TEST(graphics) +{ + HRESULT hr; + + hr = RoInitialize( RO_INIT_MULTITHREADED ); + ok( hr == S_OK, "RoInitialize failed, hr %#lx\n", hr ); + + test_DisplayInformationStatics(); + + RoUninitialize(); +} diff --git a/dlls/windows.graphics/windows.graphics.spec b/dlls/windows.graphics/windows.graphics.spec new file mode 100644 index 00000000000..31a5eafe950 --- /dev/null +++ b/dlls/windows.graphics/windows.graphics.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/10234
From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/windows.graphics/main.c | 63 ++++++++++++++++++++++++++ dlls/windows.graphics/private.h | 40 ++++++++++++++++ dlls/windows.graphics/tests/graphics.c | 1 - 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/dlls/windows.graphics/main.c b/dlls/windows.graphics/main.c index 0d85af5d71b..25a571975e5 100644 --- a/dlls/windows.graphics/main.c +++ b/dlls/windows.graphics/main.c @@ -25,6 +25,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(display); struct display_info_statics { IActivationFactory IActivationFactory_iface; + IDisplayInformationStatics IDisplayInformationStatics_iface; LONG ref; }; @@ -47,6 +48,12 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID IActivationFactory_AddRef( *out ); return S_OK; } + else if (IsEqualGUID( iid, &IID_IDisplayInformationStatics )) + { + *out = &impl->IDisplayInformationStatics_iface; + IDisplayInformationStatics_AddRef( *out ); + return S_OK; + } FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; @@ -106,9 +113,65 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, }; +DEFINE_IINSPECTABLE( display_info_statics, IDisplayInformationStatics, struct display_info_statics, + IActivationFactory_iface ) + +static HRESULT WINAPI display_info_statics_GetForCurrentView( IDisplayInformationStatics *iface, + IDisplayInformation **current ) +{ + FIXME( "iface %p, current %p stub!\n", iface, current ); + return E_NOTIMPL; +} + +static HRESULT WINAPI display_info_statics_get_AutoRotationPreferences( IDisplayInformationStatics *iface, + DisplayOrientations *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI display_info_statics_put_AutoRotationPreferences( IDisplayInformationStatics *iface, + DisplayOrientations value ) +{ + FIXME( "iface %p, value %#x stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI display_info_statics_add_DisplayContentsInvalidated( IDisplayInformationStatics *iface, + ITypedEventHandler_DisplayInformation_IInspectable *handler, EventRegistrationToken *token ) +{ + FIXME( "iface %p, handler %p, token %p stub!\n", iface, handler, token ); + return E_NOTIMPL; +} + +static HRESULT WINAPI display_info_statics_remove_DisplayContentsInvalidated( IDisplayInformationStatics *iface, + EventRegistrationToken token ) +{ + FIXME( "iface %p, token %I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static const struct IDisplayInformationStaticsVtbl display_info_statics_vtbl = +{ + display_info_statics_QueryInterface, + display_info_statics_AddRef, + display_info_statics_Release, + /* IInspectable methods */ + display_info_statics_GetIids, + display_info_statics_GetRuntimeClassName, + display_info_statics_GetTrustLevel, + /* IDisplayInformationStatics methods */ + display_info_statics_GetForCurrentView, + display_info_statics_get_AutoRotationPreferences, + display_info_statics_put_AutoRotationPreferences, + display_info_statics_add_DisplayContentsInvalidated, + display_info_statics_remove_DisplayContentsInvalidated +}; + static struct display_info_statics display_info_statics = { {&factory_vtbl}, + {&display_info_statics_vtbl}, 1, }; diff --git a/dlls/windows.graphics/private.h b/dlls/windows.graphics/private.h index 05a2a4f6d5e..64e2920bb40 100644 --- a/dlls/windows.graphics/private.h +++ b/dlls/windows.graphics/private.h @@ -27,5 +27,45 @@ #include "activation.h" #include "wine/debug.h" +#define WIDL_using_Windows_Foundation #define WIDL_using_Windows_Graphics_Display #include "windows.graphics.display.h" + +#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ + static inline impl_type *impl_from( iface_type *iface ) \ + { \ + return CONTAINING_RECORD( iface, impl_type, iface_mem ); \ + } \ + static HRESULT WINAPI pfx##_QueryInterface( iface_type *iface, REFIID iid, void **out ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_QueryInterface( (IInspectable *)(expr), iid, out ); \ + } \ + static ULONG WINAPI pfx##_AddRef( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_AddRef( (IInspectable *)(expr) ); \ + } \ + static ULONG WINAPI pfx##_Release( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_Release( (IInspectable *)(expr) ); \ + } \ + static HRESULT WINAPI pfx##_GetIids( iface_type *iface, ULONG *iid_count, IID **iids ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetIids( (IInspectable *)(expr), iid_count, iids ); \ + } \ + static HRESULT WINAPI pfx##_GetRuntimeClassName( iface_type *iface, HSTRING *class_name ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetRuntimeClassName( (IInspectable *)(expr), class_name ); \ + } \ + static HRESULT WINAPI pfx##_GetTrustLevel( iface_type *iface, TrustLevel *trust_level ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetTrustLevel( (IInspectable *)(expr), trust_level ); \ + } + +#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, &impl->base_iface ) diff --git a/dlls/windows.graphics/tests/graphics.c b/dlls/windows.graphics/tests/graphics.c index e4332826eb7..031bddbdcf3 100644 --- a/dlls/windows.graphics/tests/graphics.c +++ b/dlls/windows.graphics/tests/graphics.c @@ -62,7 +62,6 @@ static void test_DisplayInformationStatics(void) check_interface( factory, &IID_IUnknown, TRUE ); check_interface( factory, &IID_IInspectable, TRUE ); check_interface( factory, &IID_IActivationFactory, TRUE ); - todo_wine check_interface( factory, &IID_IDisplayInformationStatics, TRUE ); check_interface( factory, &IID_IAgileObject, FALSE ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10234
participants (2)
-
Zhiyi Zhang -
Zhiyi Zhang (@zhiyi)