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