From: Fabian Maurer dark.shadow4@web.de
--- dlls/windows.ui/Makefile.in | 1 + dlls/windows.ui/inputpane.c | 325 ++++++++++++++++++++++++++ dlls/windows.ui/main.c | 3 + dlls/windows.ui/private.h | 1 + include/Makefile.in | 1 + include/inputpaneinteropt.idl | 27 +++ include/windows.ui.viewmanagement.idl | 88 +++++++ 7 files changed, 446 insertions(+) create mode 100644 dlls/windows.ui/inputpane.c create mode 100644 include/inputpaneinteropt.idl
diff --git a/dlls/windows.ui/Makefile.in b/dlls/windows.ui/Makefile.in index 3389b364090..cfdf2878fac 100644 --- a/dlls/windows.ui/Makefile.in +++ b/dlls/windows.ui/Makefile.in @@ -3,5 +3,6 @@ IMPORTS = combase advapi32
SOURCES = \ classes.idl \ + inputpane.c \ main.c \ uisettings.c diff --git a/dlls/windows.ui/inputpane.c b/dlls/windows.ui/inputpane.c new file mode 100644 index 00000000000..2cd7db3f479 --- /dev/null +++ b/dlls/windows.ui/inputpane.c @@ -0,0 +1,325 @@ +/* WinRT Windows.UI Implementation + * + * Copyright (C) 2023 Mohamad Al-Jaf + * + * 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 "inputpaneinteropt.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(ui); + +struct inputpane +{ + IInputPane IInputPane_iface; + IInputPane2 IInputPane2_iface; + LONG ref; +}; + +static inline struct inputpane *impl_from_IInputPane( IInputPane *iface ) +{ + return CONTAINING_RECORD( iface, struct inputpane, IInputPane_iface ); +} + +static HRESULT WINAPI inputpane_QueryInterface( IInputPane *iface, REFIID iid, void **out ) +{ + struct inputpane *impl = impl_from_IInputPane( 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_IInputPane )) + { + *out = &impl->IInputPane_iface; + } + else if (IsEqualGUID( iid, &IID_IInputPane2)) + { + *out = &impl->IInputPane2_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 inputpane_AddRef( IInputPane *iface ) +{ + struct inputpane *impl = impl_from_IInputPane( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI inputpane_Release( IInputPane *iface ) +{ + struct inputpane *impl = impl_from_IInputPane( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + + TRACE( "iface %p, ref %lu.\n", iface, ref ); + + if (!ref) free( impl ); + return ref; +} + +static HRESULT WINAPI inputpane_GetIids( IInputPane *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 inputpane_GetRuntimeClassName( IInputPane *iface, HSTRING *class_name ) +{ + FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI inputpane_GetTrustLevel( IInputPane *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI inputpane_add_Showing( IInputPane *iface, ITypedEventHandler_InputPane_InputPaneVisibilityEventArgs *handler, EventRegistrationToken *token ) +{ + FIXME( "iface %p, handler %p, token %p stub!\n", iface, handler, token); + return E_NOTIMPL; +} + +static HRESULT WINAPI inputpane_remove_Showing( IInputPane *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI inputpane_add_Hiding( IInputPane *iface, ITypedEventHandler_InputPane_InputPaneVisibilityEventArgs *handler, EventRegistrationToken *token ) +{ + FIXME( "iface %p, handler %p, token %p stub!\n", iface, handler, token); + return E_NOTIMPL; +} + +static HRESULT WINAPI inputpane_remove_Hiding( IInputPane *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI inputpane_OccludedRect( IInputPane *iface, Rect *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static const struct IInputPaneVtbl inputpane_vtbl = +{ + inputpane_QueryInterface, + inputpane_AddRef, + inputpane_Release, + + /* IInspectable methods */ + inputpane_GetIids, + inputpane_GetRuntimeClassName, + inputpane_GetTrustLevel, + + /* IInputPane methods */ + inputpane_add_Showing, + inputpane_remove_Showing, + inputpane_add_Hiding, + inputpane_remove_Hiding, + inputpane_OccludedRect, +}; + +DEFINE_IINSPECTABLE( inputpane2, IInputPane2, struct inputpane, IInputPane_iface ); + +static HRESULT WINAPI inputpane2_TryShow(IInputPane2 *iface, boolean *result) +{ + FIXME( "iface %p, result %p stub!\n", iface, result ); + return E_NOTIMPL; +} + +static HRESULT WINAPI inputpane2_TryHide(IInputPane2 *iface, boolean *result) +{ + FIXME( "iface %p, result %p stub!\n", iface, result ); + return S_OK; +} + +static const struct IInputPane2Vtbl inputpane2_vtbl = +{ + inputpane2_QueryInterface, + inputpane2_AddRef, + inputpane2_Release, + + /* IInspectable methods */ + inputpane2_GetIids, + inputpane2_GetRuntimeClassName, + inputpane2_GetTrustLevel, + + /* IInputPane2 methods */ + inputpane2_TryShow, + inputpane2_TryHide, +}; + +struct inputpane_statics +{ + IActivationFactory IActivationFactory_iface; + IInputPaneInterop IInputPaneInterop_iface; + LONG ref; +}; + +static inline struct inputpane_statics *impl_from_IActivationFactory( IActivationFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct inputpane_statics, IActivationFactory_iface ); +} + +static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + struct inputpane_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_IInputPaneInterop )) + { + *out = &impl->IInputPaneInterop_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 inputpane_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 inputpane_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 inputpane *impl; + + TRACE( "iface %p, instance %p.\n", iface, instance ); + + if (!(impl = calloc( 1, sizeof(*impl) ))) + { + *instance = NULL; + return E_OUTOFMEMORY; + } + + impl->IInputPane_iface.lpVtbl = &inputpane_vtbl; + impl->IInputPane2_iface.lpVtbl = &inputpane2_vtbl; + impl->ref = 1; + + *instance = (IInspectable *)&impl->IInputPane_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( inputpane_interop, IInputPaneInterop, struct inputpane_statics, IActivationFactory_iface ); + +static HRESULT WINAPI inputpane_interop_GetForWindow(IInputPaneInterop *iface, HWND window, REFIID riid, void **inputpane) +{ + struct inputpane_statics *impl = impl_from_IInputPaneInterop(iface); + + TRACE("(window %p, riid %s, inputpane %p)\n", window, debugstr_guid( riid ), inputpane); + + factory_ActivateInstance(&impl->IActivationFactory_iface, (IInspectable**)inputpane); + return S_OK; +} + +static const struct IInputPaneInteropVtbl inputpane_interop_vtbl = +{ + inputpane_interop_QueryInterface, + inputpane_interop_AddRef, + inputpane_interop_Release, + + /* IInspectable methods */ + inputpane_interop_GetIids, + inputpane_interop_GetRuntimeClassName, + inputpane_interop_GetTrustLevel, + + /* IInputPaneInteropt methods */ + inputpane_interop_GetForWindow, +}; + +static struct inputpane_statics inputpane_statics = +{ + {&factory_vtbl}, + {&inputpane_interop_vtbl}, + 1, +}; + +IActivationFactory *inputpane_factory = &inputpane_statics.IActivationFactory_iface; diff --git a/dlls/windows.ui/main.c b/dlls/windows.ui/main.c index 490536c33b7..c346ac18461 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_InputPane )) + IActivationFactory_QueryInterface( inputpane_factory, &IID_IActivationFactory, (void **)factory ); + if (*factory) return S_OK; return CLASS_E_CLASSNOTAVAILABLE; } diff --git a/dlls/windows.ui/private.h b/dlls/windows.ui/private.h index 60a928ca865..566fab3a665 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 *inputpane_factory;
#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ static inline impl_type *impl_from( iface_type *iface ) \ diff --git a/include/Makefile.in b/include/Makefile.in index 40a71d45a1f..a65e0d02476 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -375,6 +375,7 @@ SOURCES = \ inaddr.h \ indexsrv.idl \ initguid.h \ + inputpaneinteropt.idl \ inputscope.idl \ inseng.idl \ inspectable.idl \ diff --git a/include/inputpaneinteropt.idl b/include/inputpaneinteropt.idl new file mode 100644 index 00000000000..bd327c66cd4 --- /dev/null +++ b/include/inputpaneinteropt.idl @@ -0,0 +1,27 @@ +/* + * Copyright 2023 Fabian Maurer + * + * 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 + */ + +import "inspectable.idl"; + +[ + uuid(75cf2c57-9195-4931-8332-f0b409e916af) +] +interface IInputPaneInterop : IInspectable +{ + HRESULT GetForWindow([in] HWND window, [in] REFIID riid, [out, retval, iid_is(riid)] void **inputpane); +} diff --git a/include/windows.ui.viewmanagement.idl b/include/windows.ui.viewmanagement.idl index b98d34ff685..8d325f09c6b 100644 --- a/include/windows.ui.viewmanagement.idl +++ b/include/windows.ui.viewmanagement.idl @@ -45,10 +45,19 @@ namespace Windows.UI.ViewManagement interface IUISettings5; interface IUISettings6;
+ interface IInputPane; + interface IInputPane2; + interface IInputPaneControl; + interface IInputPaneVisibilityEventArgs; + interface IInputPaneStatics; + runtimeclass UISettings; + runtimeclass InputPane; + runtimeclass InputPaneVisibilityEventArgs;
declare { interface Windows.Foundation.TypedEventHandler<Windows.UI.ViewManagement.UISettings *, IInspectable *>; + interface Windows.Foundation.TypedEventHandler<Windows.UI.ViewManagement.InputPane*, Windows.UI.ViewManagement.InputPaneVisibilityEventArgs*>; }
[ @@ -171,6 +180,64 @@ namespace Windows.UI.ViewManagement [eventremove] HRESULT ColorValuesChanged([in] EventRegistrationToken cookie); }
+ [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.UI.ViewManagement.InputPane), + uuid(640ada70-06f3-4c87-a678-9829c9127c28) + ] + interface IInputPane : IInspectable + { + [eventadd] HRESULT Showing([in] Windows.Foundation.TypedEventHandler<Windows.UI.ViewManagement.InputPane*, Windows.UI.ViewManagement.InputPaneVisibilityEventArgs*> *handler, [out, retval] EventRegistrationToken *token); + [eventremove] HRESULT Showing([in] EventRegistrationToken token); + [eventadd] HRESULT Hiding([in] Windows.Foundation.TypedEventHandler<Windows.UI.ViewManagement.InputPane*, Windows.UI.ViewManagement.InputPaneVisibilityEventArgs*> *handler, [out, retval] EventRegistrationToken *token); + [eventremove] HRESULT Hiding([in] EventRegistrationToken token); + [propget] HRESULT OccludedRect([out, retval] Windows.Foundation.Rect *value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.UI.ViewManagement.InputPane), + uuid(8a6b3f26-7090-4793-944c-c3f2cde26276) + ] + interface IInputPane2 : IInspectable + { + HRESULT TryShow([out, retval] boolean *result); + HRESULT TryHide([out, retval] boolean *result); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.UI.ViewManagement.InputPane), + uuid(088bb24f-962f-489d-aa6e-c6be1a0a6e52) + ] + interface IInputPaneControl : IInspectable + { + [propget] HRESULT Visible([out, retval] boolean *value); + [propput] HRESULT Visible([in] boolean value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.UI.ViewManagement.InputPaneVisibilityEventArgs), + uuid(d243e016-d907-4fcc-bb8d-f77baa5028f1) + ] + interface IInputPaneVisibilityEventArgs : IInspectable + { + [propget] HRESULT OccludedRect([out, retval] Windows.Foundation.Rect *value); + [propput] HRESULT EnsuredFocusedElementInView([in] boolean value); + [propget] HRESULT EnsuredFocusedElementInView([out, retval] boolean *value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.UI.ViewManagement.InputPane), + uuid(95f4af3a-ef47-424a-9741-fd2815eba2bd) + ] + interface IInputPaneStatics : IInspectable + { + HRESULT GetForCurrentView([out, retval] Windows.UI.ViewManagement.InputPane **inputPane); + } + [ activatable(Windows.Foundation.UniversalApiContract, 1.0), contract(Windows.Foundation.UniversalApiContract, 1.0), @@ -182,4 +249,25 @@ namespace Windows.UI.ViewManagement [contract(Windows.Foundation.UniversalApiContract, 1.0)] interface Windows.UI.ViewManagement.IUISettings2; [contract(Windows.Foundation.UniversalApiContract, 1.0)] interface Windows.UI.ViewManagement.IUISettings3; } + + [ + static(Windows.UI.ViewManagement.IInputPaneStatics, Windows.Foundation.UniversalApiContract, 1.0), + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(standard) + ] + runtimeclass InputPane + { + [default] interface Windows.UI.ViewManagement.IInputPane; + [contract(Windows.Foundation.UniversalApiContract, 1.0)] interface Windows.UI.ViewManagement.IInputPane2; + [contract(Windows.Foundation.UniversalApiContract, 1.0)] interface Windows.UI.ViewManagement.IInputPaneControl; + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(standard) + ] + runtimeclass InputPaneVisibilityEventArgs + { + [default] interface Windows.UI.ViewManagement.IInputPaneVisibilityEventArgs; + } }