Stub Implementations of UIViewSettings and InputPaneStatics. This will reduce the FIXME clutter of missing UIViewSettings class implementation in .NET applications esp: Paint .Net
-- v4: windows.ui: Add stub IInputPaneStatics implementation. windows.ui: Add stubs for UIViewSettings class.
From: Vijay Kiran Kamuju infyquest@gmail.com
--- dlls/windows.ui/Makefile.in | 3 +- dlls/windows.ui/main.c | 3 + dlls/windows.ui/private.h | 1 + dlls/windows.ui/uiviewsettings.c | 296 +++++++++++++++++++++++++++++++ 4 files changed, 302 insertions(+), 1 deletion(-) create mode 100644 dlls/windows.ui/uiviewsettings.c
diff --git a/dlls/windows.ui/Makefile.in b/dlls/windows.ui/Makefile.in index cfdf2878fac..953991cafba 100644 --- a/dlls/windows.ui/Makefile.in +++ b/dlls/windows.ui/Makefile.in @@ -5,4 +5,5 @@ SOURCES = \ classes.idl \ inputpane.c \ main.c \ - uisettings.c + uisettings.c \ + uiviewsettings.c diff --git a/dlls/windows.ui/main.c b/dlls/windows.ui/main.c index c346ac18461..87b8f87561a 100644 --- a/dlls/windows.ui/main.c +++ b/dlls/windows.ui/main.c @@ -41,6 +41,9 @@ HRESULT WINAPI DllGetActivationFactory( HSTRING classid, IActivationFactory **fa if (!wcscmp( buffer, RuntimeClass_Windows_UI_ViewManagement_UISettings )) IActivationFactory_QueryInterface( uisettings_factory, &IID_IActivationFactory, (void **)factory );
+ if (!wcscmp( buffer, RuntimeClass_Windows_UI_ViewManagement_UIViewSettings )) + IActivationFactory_QueryInterface( uiviewsettings_factory, &IID_IActivationFactory, (void **)factory ); + if (!wcscmp( buffer, RuntimeClass_Windows_UI_ViewManagement_InputPane )) IActivationFactory_QueryInterface( inputpane_factory, &IID_IActivationFactory, (void **)factory );
diff --git a/dlls/windows.ui/private.h b/dlls/windows.ui/private.h index 566fab3a665..6e611e5d5d3 100644 --- a/dlls/windows.ui/private.h +++ b/dlls/windows.ui/private.h @@ -37,6 +37,7 @@ #include "windows.ui.viewmanagement.h"
extern IActivationFactory *uisettings_factory; +extern IActivationFactory *uiviewsettings_factory; extern IActivationFactory *inputpane_factory;
#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ diff --git a/dlls/windows.ui/uiviewsettings.c b/dlls/windows.ui/uiviewsettings.c new file mode 100644 index 00000000000..5f6b05ab2ca --- /dev/null +++ b/dlls/windows.ui/uiviewsettings.c @@ -0,0 +1,296 @@ +/* WinRT Windows.UI Implementation + * + * Copyright (C) 2024 Vijay Kiran Kamuju + * + * 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 "initguid.h" +#include "uiviewsettingsinterop.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(ui); + +struct uiviewsettings +{ + IUIViewSettings IUIViewSettings_iface; + LONG ref; +}; + +static inline struct uiviewsettings *impl_from_IUIViewSettings( IUIViewSettings *iface ) +{ + return CONTAINING_RECORD( iface, struct uiviewsettings, IUIViewSettings_iface ); +} + +static HRESULT WINAPI uiviewsettings_QueryInterface( IUIViewSettings *iface, REFIID iid, void **out ) +{ + struct uiviewsettings *impl = impl_from_IUIViewSettings( 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_IUIViewSettings )) + { + *out = &impl->IUIViewSettings_iface; + } + + if (!*out) + { + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + return E_NOINTERFACE; + } + + IUnknown_AddRef( (IUnknown *)*out ); + return S_OK; +} + +static ULONG WINAPI uiviewsettings_AddRef( IUIViewSettings *iface ) +{ + struct uiviewsettings *impl = impl_from_IUIViewSettings( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI uiviewsettings_Release( IUIViewSettings *iface ) +{ + struct uiviewsettings *impl = impl_from_IUIViewSettings( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + + TRACE( "iface %p, ref %lu.\n", iface, ref ); + + if (!ref) free( impl ); + return ref; +} + +static HRESULT WINAPI uiviewsettings_GetIids( IUIViewSettings *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 uiviewsettings_GetRuntimeClassName( IUIViewSettings *iface, HSTRING *class_name ) +{ + FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI uiviewsettings_GetTrustLevel( IUIViewSettings *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI uiviewsettings_get_UserInteractionMode( IUIViewSettings *iface, enum UserInteractionMode *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static const struct IUIViewSettingsVtbl uiviewsettings_vtbl = +{ + uiviewsettings_QueryInterface, + uiviewsettings_AddRef, + uiviewsettings_Release, + + /* IInspectable methods */ + uiviewsettings_GetIids, + uiviewsettings_GetRuntimeClassName, + uiviewsettings_GetTrustLevel, + + /* IUIViewSettings methods */ + uiviewsettings_get_UserInteractionMode, +}; + +struct uiviewsettings_statics +{ + IActivationFactory IActivationFactory_iface; + IUIViewSettingsInterop IUIViewSettingsInterop_iface; + IUIViewSettingsStatics IUIViewSettingsStatics_iface; + LONG ref; +}; + +static inline struct uiviewsettings_statics *impl_from_IActivationFactory( IActivationFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct uiviewsettings_statics, IActivationFactory_iface ); +} + +static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + struct uiviewsettings_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; + IInspectable_AddRef( *out ); + return S_OK; + } + else if (IsEqualGUID( iid, &IID_IUIViewSettingsInterop )) + { + *out = &impl->IUIViewSettingsInterop_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + else if (IsEqualGUID( iid, &IID_IUIViewSettingsStatics )) + { + *out = &impl->IUIViewSettingsStatics_iface; + IInspectable_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 uiviewsettings_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 uiviewsettings_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 ) +{ + struct uiviewsettings *impl; + + TRACE( "iface %p, instance %p.\n", iface, instance ); + + if (!(impl = calloc( 1, sizeof(*impl) ))) + { + *instance = NULL; + return E_OUTOFMEMORY; + } + + impl->IUIViewSettings_iface.lpVtbl = &uiviewsettings_vtbl; + impl->ref = 1; + + *instance = (IInspectable *)&impl->IUIViewSettings_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, +}; + +DEFINE_IINSPECTABLE( ui_viewsettings_interop, IUIViewSettingsInterop, struct uiviewsettings_statics, IActivationFactory_iface ); + +static HRESULT WINAPI ui_viewsettings_interop_GetForWindow( IUIViewSettingsInterop *iface, HWND window, REFIID riid, void **uiviewsettings ) +{ + struct uiviewsettings_statics *impl = impl_from_IUIViewSettingsInterop( iface ); + + TRACE( "(window %p, riid %s, uiviewsettings %p)\n", window, debugstr_guid( riid ), uiviewsettings ); + + factory_ActivateInstance( &impl->IActivationFactory_iface, (IInspectable **)uiviewsettings ); + return S_OK; +} + +static const struct IUIViewSettingsInteropVtbl ui_viewsettings_interop_vtbl = +{ + ui_viewsettings_interop_QueryInterface, + ui_viewsettings_interop_AddRef, + ui_viewsettings_interop_Release, + + /* IInspectable methods */ + ui_viewsettings_interop_GetIids, + ui_viewsettings_interop_GetRuntimeClassName, + ui_viewsettings_interop_GetTrustLevel, + + /* IUIViewSettingsInterop methods */ + ui_viewsettings_interop_GetForWindow, +}; + +DEFINE_IINSPECTABLE( ui_viewsettings_statics, IUIViewSettingsStatics, struct uiviewsettings_statics, IActivationFactory_iface ); + +static HRESULT WINAPI ui_viewsettings_statics_GetForCurrentView( IUIViewSettingsStatics *iface, IUIViewSettings **uiviewsettings ) +{ + struct uiviewsettings_statics *impl = impl_from_IUIViewSettingsStatics( iface ); + + TRACE( "(uiviewsettings %p)\n", uiviewsettings ); + + factory_ActivateInstance( &impl->IActivationFactory_iface, (IInspectable **)uiviewsettings ); + return S_OK; +} + +static const struct IUIViewSettingsStaticsVtbl ui_viewsettings_statics_vtbl = +{ + ui_viewsettings_statics_QueryInterface, + ui_viewsettings_statics_AddRef, + ui_viewsettings_statics_Release, + + /* IInspectable methods */ + ui_viewsettings_statics_GetIids, + ui_viewsettings_statics_GetRuntimeClassName, + ui_viewsettings_statics_GetTrustLevel, + + /* IUIViewSettingsStatics methods */ + ui_viewsettings_statics_GetForCurrentView, +}; + +static struct uiviewsettings_statics uiviewsettings_statics = +{ + {&factory_vtbl}, + {&ui_viewsettings_interop_vtbl}, + {&ui_viewsettings_statics_vtbl}, + 1, +}; + +IActivationFactory *uiviewsettings_factory = &uiviewsettings_statics.IActivationFactory_iface;
From: Vijay Kiran Kamuju infyquest@gmail.com
--- dlls/windows.ui/inputpane.c | 95 ++++++++++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 13 deletions(-)
diff --git a/dlls/windows.ui/inputpane.c b/dlls/windows.ui/inputpane.c index 383ca877d46..9a34f041d5c 100644 --- a/dlls/windows.ui/inputpane.c +++ b/dlls/windows.ui/inputpane.c @@ -187,7 +187,9 @@ static const struct IInputPane2Vtbl inputpane2_vtbl = struct inputpane_statics { IActivationFactory IActivationFactory_iface; - IInputPaneInterop IInputPaneInterop_iface; + IInputPaneInterop IInputPaneInterop_iface; + IInputPaneStatics IInputPaneStatics_iface; + IInputPaneStatics2 IInputPaneStatics2_iface; LONG ref; };
@@ -216,7 +218,18 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID IInspectable_AddRef( *out ); return S_OK; } - + else if (IsEqualGUID( iid, &IID_IInputPaneStatics )) + { + *out = &impl->IInputPaneStatics_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + else if (IsEqualGUID( iid, &IID_IInputPaneStatics2 )) + { + *out = &impl->IInputPaneStatics2_iface; + IInspectable_AddRef( *out ); + return S_OK; + } FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -289,9 +302,9 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
-DEFINE_IINSPECTABLE( inputpane_interop, IInputPaneInterop, struct inputpane_statics, IActivationFactory_iface ); +DEFINE_IINSPECTABLE( input_pane_interop, IInputPaneInterop, struct inputpane_statics, IActivationFactory_iface );
-static HRESULT WINAPI inputpane_interop_GetForWindow( IInputPaneInterop *iface, HWND window, REFIID riid, void **inputpane ) +static HRESULT WINAPI input_pane_interop_GetForWindow( IInputPaneInterop *iface, HWND window, REFIID riid, void **inputpane ) { struct inputpane_statics *impl = impl_from_IInputPaneInterop( iface );
@@ -301,25 +314,81 @@ static HRESULT WINAPI inputpane_interop_GetForWindow( IInputPaneInterop *iface, return S_OK; }
-static const struct IInputPaneInteropVtbl inputpane_interop_vtbl = +static const struct IInputPaneInteropVtbl input_pane_interop_vtbl = { - inputpane_interop_QueryInterface, - inputpane_interop_AddRef, - inputpane_interop_Release, + input_pane_interop_QueryInterface, + input_pane_interop_AddRef, + input_pane_interop_Release,
/* IInspectable methods */ - inputpane_interop_GetIids, - inputpane_interop_GetRuntimeClassName, - inputpane_interop_GetTrustLevel, + input_pane_interop_GetIids, + input_pane_interop_GetRuntimeClassName, + input_pane_interop_GetTrustLevel,
/* IInputPaneInteropt methods */ - inputpane_interop_GetForWindow, + input_pane_interop_GetForWindow, +}; + +DEFINE_IINSPECTABLE( input_pane_statics, IInputPaneStatics, struct inputpane_statics, IActivationFactory_iface ); + +static HRESULT WINAPI input_pane_statics_GetForCurrentView( IInputPaneStatics *iface, IInputPane **inputpane ) +{ + struct inputpane_statics *impl = impl_from_IInputPaneStatics( iface ); + + TRACE( "(inputpane %p)\n", inputpane ); + + factory_ActivateInstance( &impl->IActivationFactory_iface, (IInspectable **)inputpane ); + return S_OK; +} + +static const struct IInputPaneStaticsVtbl input_pane_statics_vtbl = +{ + input_pane_statics_QueryInterface, + input_pane_statics_AddRef, + input_pane_statics_Release, + + /* IInspectable methods */ + input_pane_statics_GetIids, + input_pane_statics_GetRuntimeClassName, + input_pane_statics_GetTrustLevel, + + /* IInputPaneStatics methods */ + input_pane_statics_GetForCurrentView, +}; + +DEFINE_IINSPECTABLE( input_pane_statics2, IInputPaneStatics2, struct inputpane_statics, IActivationFactory_iface ); + +static HRESULT WINAPI input_pane_statics2_GetForUIContext( IInputPaneStatics2 *iface, IUIContext *context, IInputPane **inputpane ) +{ + struct inputpane_statics *impl = impl_from_IInputPaneStatics2( iface ); + + TRACE( "(context %p, inputpane %p)\n", context, inputpane ); + + factory_ActivateInstance( &impl->IActivationFactory_iface, (IInspectable **)inputpane ); + return S_OK; +} + +static const struct IInputPaneStatics2Vtbl input_pane_statics2_vtbl = +{ + input_pane_statics2_QueryInterface, + input_pane_statics2_AddRef, + input_pane_statics2_Release, + + /* IInspectable methods */ + input_pane_statics2_GetIids, + input_pane_statics2_GetRuntimeClassName, + input_pane_statics2_GetTrustLevel, + + /* IInputPaneStatics2 methods */ + input_pane_statics2_GetForUIContext, };
static struct inputpane_statics inputpane_statics = { {&factory_vtbl}, - {&inputpane_interop_vtbl}, + {&input_pane_interop_vtbl}, + {&input_pane_statics_vtbl}, + {&input_pane_statics2_vtbl}, 1, };