From: Paul Gofman pgofman@codeweavers.com
--- dlls/windows.gaming.ui.gamebar/main.c | 79 +++++++++++++++++++ dlls/windows.gaming.ui.gamebar/private.h | 38 +++++++++ .../windows.gaming.ui.gamebar/tests/gamebar.c | 35 +++++++- 3 files changed, 148 insertions(+), 4 deletions(-)
diff --git a/dlls/windows.gaming.ui.gamebar/main.c b/dlls/windows.gaming.ui.gamebar/main.c index ef4ed94d566..9f567376a34 100644 --- a/dlls/windows.gaming.ui.gamebar/main.c +++ b/dlls/windows.gaming.ui.gamebar/main.c @@ -24,9 +24,12 @@
WINE_DEFAULT_DEBUG_CHANNEL(gamebar);
+static EventRegistrationToken dummy_token = {.value = 0xdeadbeef}; + struct gamebar_statics { IActivationFactory IActivationFactory_iface; + IGameBarStatics IGameBarStatics_iface; LONG ref; };
@@ -50,6 +53,13 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID return S_OK; }
+ if (IsEqualGUID( iid, &IID_IGameBarStatics )) + { + *out = &impl->IGameBarStatics_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -108,9 +118,78 @@ static const struct IActivationFactoryVtbl factory_vtbl = factory_ActivateInstance, };
+DEFINE_IINSPECTABLE( statics, IGameBarStatics, struct gamebar_statics, IActivationFactory_iface ) + +static HRESULT WINAPI statics_add_VisibilityChanged( IGameBarStatics *iface, + IEventHandler_IInspectable *handler, + EventRegistrationToken *token ) +{ + FIXME( "iface %p, handler %p, token %p stub.\n", iface, handler, token ); + *token = dummy_token; + return S_OK; +} + +static HRESULT WINAPI statics_remove_VisibilityChanged( IGameBarStatics *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub.\n", iface, token.value ); + return S_OK; +} + +static HRESULT WINAPI statics_add_IsInputRedirectedChanged( IGameBarStatics *iface, + IEventHandler_IInspectable *handler, + EventRegistrationToken *token ) +{ + FIXME( "iface %p, handler %p, token %p stub.\n", iface, handler, token ); + *token = dummy_token; + return S_OK; +} + +static HRESULT WINAPI statics_remove_IsInputRedirectedChanged( IGameBarStatics *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub.\n", iface, token.value ); + return S_OK; +} + +static HRESULT WINAPI statics_get_Visible( IGameBarStatics *iface, BOOLEAN *value) +{ + TRACE( "iface %p, value %p.\n", iface, value ); + + if (!value) return E_INVALIDARG; + *value = FALSE; + return S_OK; +} + +static HRESULT WINAPI statics_get_IsInputRedirected( IGameBarStatics *iface, BOOLEAN *value ) +{ + TRACE( "iface %p, value %p.\n", iface, value ); + + if (!value) return E_INVALIDARG; + *value = FALSE; + return S_OK; +} + +static const struct IGameBarStaticsVtbl statics_vtbl = +{ + statics_QueryInterface, + statics_AddRef, + statics_Release, + /* IInspectable methods */ + statics_GetIids, + statics_GetRuntimeClassName, + statics_GetTrustLevel, + /* IGameBarStatics methods */ + statics_add_VisibilityChanged, + statics_remove_VisibilityChanged, + statics_add_IsInputRedirectedChanged, + statics_remove_IsInputRedirectedChanged, + statics_get_Visible, + statics_get_IsInputRedirected, +}; + static struct gamebar_statics gamebar_statics = { {&factory_vtbl}, + {&statics_vtbl}, 1, };
diff --git a/dlls/windows.gaming.ui.gamebar/private.h b/dlls/windows.gaming.ui.gamebar/private.h index 545f4a2fd24..85f87b56e7b 100644 --- a/dlls/windows.gaming.ui.gamebar/private.h +++ b/dlls/windows.gaming.ui.gamebar/private.h @@ -29,3 +29,41 @@ #define WIDL_using_Windows_Gaming_UI #include "activation.h" #include "windows.gaming.ui.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.gaming.ui.gamebar/tests/gamebar.c b/dlls/windows.gaming.ui.gamebar/tests/gamebar.c index 503e0809157..a68d4619362 100644 --- a/dlls/windows.gaming.ui.gamebar/tests/gamebar.c +++ b/dlls/windows.gaming.ui.gamebar/tests/gamebar.c @@ -38,8 +38,10 @@ static void test_GameBarStatics(void) static const WCHAR *gamebar_statics_name = L"Windows.Gaming.UI.GameBar";
IActivationFactory *factory = NULL; - IInspectable *inspectable = NULL; - IAgileObject *agile_object = NULL; + IInspectable *inspectable = NULL, *tmp_inspectable = NULL; + IAgileObject *agile_object = NULL, *tmp_agile_object = NULL; + IGameBarStatics *gamebar_statics = NULL; + BOOLEAN value; HSTRING str; HRESULT hr; LONG ref; @@ -62,11 +64,36 @@ static void test_GameBarStatics(void) hr = IActivationFactory_QueryInterface(factory, &IID_IAgileObject, (void **)&agile_object); ok(hr == S_OK, "got hr %#lx.\n", hr);
+ hr = IActivationFactory_QueryInterface(factory, &IID_IGameBarStatics, (void **)&gamebar_statics); + ok(hr == S_OK, "got hr %#lx.\n", hr); + + hr = IGameBarStatics_QueryInterface(gamebar_statics, &IID_IInspectable, (void **)&tmp_inspectable); + ok(hr == S_OK, "got hr %#lx.\n", hr); + ok(tmp_inspectable == inspectable, "got %p, expected %p.\n", tmp_inspectable, inspectable); + IInspectable_Release(tmp_inspectable); + + hr = IGameBarStatics_QueryInterface(gamebar_statics, &IID_IAgileObject, (void **)&tmp_agile_object); + ok(hr == S_OK, "got hr %#lx.\n", hr); + ok(tmp_agile_object == agile_object, "got %p, expected %p.\n", tmp_agile_object, agile_object); + IAgileObject_Release(tmp_agile_object); + + value = TRUE; + hr = IGameBarStatics_get_Visible(gamebar_statics, &value); + ok(hr == S_OK, "got hr %#lx.\n", hr); + ok(!value, "got %d.\n", value); + + value = TRUE; + hr = IGameBarStatics_get_IsInputRedirected(gamebar_statics, &value); + ok(hr == S_OK, "got hr %#lx.\n", hr); + ok(!value, "got %d.\n", value); + ref = IAgileObject_Release(agile_object); - ok(ref == 3, "got ref %ld.\n", ref); + ok(ref == 4, "got ref %ld.\n", ref); ref = IInspectable_Release(inspectable); - ok(ref == 2, "got ref %ld.\n", ref); + ok(ref == 3, "got ref %ld.\n", ref); ref = IActivationFactory_Release(factory); + ok(ref == 2, "got ref %ld.\n", ref); + ref = IGameBarStatics_Release(gamebar_statics); ok(ref == 1, "got ref %ld.\n", ref); }