1 /* WinRT Windows.Gaming.UI.GameBar implementation
3 * Copyright 2022 Paul Gofman for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(gamebar
);
27 static EventRegistrationToken dummy_token
= {.value
= 0xdeadbeef};
29 struct gamebar_statics
31 IActivationFactory IActivationFactory_iface
;
32 IGameBarStatics IGameBarStatics_iface
;
36 static inline struct gamebar_statics
*impl_from_IActivationFactory( IActivationFactory
*iface
)
38 return CONTAINING_RECORD( iface
, struct gamebar_statics
, IActivationFactory_iface
);
41 static HRESULT WINAPI
factory_QueryInterface( IActivationFactory
*iface
, REFIID iid
, void **out
)
43 struct gamebar_statics
*impl
= impl_from_IActivationFactory( iface
);
45 TRACE( "iface %p, iid %s, out %p.\n", iface
, debugstr_guid( iid
), out
);
47 if (IsEqualGUID( iid
, &IID_IUnknown
) ||
48 IsEqualGUID( iid
, &IID_IInspectable
) ||
49 IsEqualGUID( iid
, &IID_IAgileObject
) ||
50 IsEqualGUID( iid
, &IID_IActivationFactory
))
52 *out
= &impl
->IActivationFactory_iface
;
53 IInspectable_AddRef( *out
);
57 if (IsEqualGUID( iid
, &IID_IGameBarStatics
))
59 *out
= &impl
->IGameBarStatics_iface
;
60 IInspectable_AddRef( *out
);
64 FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid
) );
69 static ULONG WINAPI
factory_AddRef( IActivationFactory
*iface
)
71 struct gamebar_statics
*impl
= impl_from_IActivationFactory( iface
);
72 ULONG ref
= InterlockedIncrement( &impl
->ref
);
73 TRACE( "iface %p increasing refcount to %lu.\n", iface
, ref
);
77 static ULONG WINAPI
factory_Release( IActivationFactory
*iface
)
79 struct gamebar_statics
*impl
= impl_from_IActivationFactory( iface
);
80 ULONG ref
= InterlockedDecrement( &impl
->ref
);
81 TRACE( "iface %p decreasing refcount to %lu.\n", iface
, ref
);
85 static HRESULT WINAPI
factory_GetIids( IActivationFactory
*iface
, ULONG
*iid_count
, IID
**iids
)
87 FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface
, iid_count
, iids
);
91 static HRESULT WINAPI
factory_GetRuntimeClassName( IActivationFactory
*iface
, HSTRING
*class_name
)
93 FIXME( "iface %p, class_name %p stub!\n", iface
, class_name
);
97 static HRESULT WINAPI
factory_GetTrustLevel( IActivationFactory
*iface
, TrustLevel
*trust_level
)
99 FIXME( "iface %p, trust_level %p stub!\n", iface
, trust_level
);
103 static HRESULT WINAPI
factory_ActivateInstance( IActivationFactory
*iface
, IInspectable
**instance
)
105 FIXME( "iface %p, instance %p stub!\n", iface
, instance
);
109 static const struct IActivationFactoryVtbl factory_vtbl
=
111 factory_QueryInterface
,
114 /* IInspectable methods */
116 factory_GetRuntimeClassName
,
117 factory_GetTrustLevel
,
118 /* IActivationFactory methods */
119 factory_ActivateInstance
,
122 DEFINE_IINSPECTABLE( statics
, IGameBarStatics
, struct gamebar_statics
, IActivationFactory_iface
)
124 static HRESULT WINAPI
statics_add_VisibilityChanged( IGameBarStatics
*iface
,
125 IEventHandler_IInspectable
*handler
,
126 EventRegistrationToken
*token
)
128 FIXME( "iface %p, handler %p, token %p stub.\n", iface
, handler
, token
);
129 *token
= dummy_token
;
133 static HRESULT WINAPI
statics_remove_VisibilityChanged( IGameBarStatics
*iface
, EventRegistrationToken token
)
135 FIXME( "iface %p, token %#I64x stub.\n", iface
, token
.value
);
139 static HRESULT WINAPI
statics_add_IsInputRedirectedChanged( IGameBarStatics
*iface
,
140 IEventHandler_IInspectable
*handler
,
141 EventRegistrationToken
*token
)
143 FIXME( "iface %p, handler %p, token %p stub.\n", iface
, handler
, token
);
144 *token
= dummy_token
;
148 static HRESULT WINAPI
statics_remove_IsInputRedirectedChanged( IGameBarStatics
*iface
, EventRegistrationToken token
)
150 FIXME( "iface %p, token %#I64x stub.\n", iface
, token
.value
);
154 static HRESULT WINAPI
statics_get_Visible( IGameBarStatics
*iface
, BOOLEAN
*value
)
156 TRACE( "iface %p, value %p.\n", iface
, value
);
158 if (!value
) return E_POINTER
;
163 static HRESULT WINAPI
statics_get_IsInputRedirected( IGameBarStatics
*iface
, BOOLEAN
*value
)
165 TRACE( "iface %p, value %p.\n", iface
, value
);
167 if (!value
) return E_POINTER
;
172 static const struct IGameBarStaticsVtbl statics_vtbl
=
174 statics_QueryInterface
,
177 /* IInspectable methods */
179 statics_GetRuntimeClassName
,
180 statics_GetTrustLevel
,
181 /* IGameBarStatics methods */
182 statics_add_VisibilityChanged
,
183 statics_remove_VisibilityChanged
,
184 statics_add_IsInputRedirectedChanged
,
185 statics_remove_IsInputRedirectedChanged
,
187 statics_get_IsInputRedirected
,
190 static struct gamebar_statics gamebar_statics
=
197 static IActivationFactory
*gamebar_factory
= &gamebar_statics
.IActivationFactory_iface
;
199 HRESULT WINAPI
DllGetClassObject( REFCLSID clsid
, REFIID riid
, void **out
)
201 FIXME("clsid %s, riid %s, out %p stub!\n", debugstr_guid(clsid
), debugstr_guid(riid
), out
);
203 return CLASS_E_CLASSNOTAVAILABLE
;
206 HRESULT WINAPI
DllGetActivationFactory( HSTRING class_str
, IActivationFactory
**factory
)
208 const WCHAR
*buffer
= WindowsGetStringRawBuffer( class_str
, NULL
);
210 TRACE( "class %s, factory %p.\n", debugstr_w(buffer
), factory
);
214 if (!wcscmp( buffer
, RuntimeClass_Windows_Gaming_UI_GameBar
))
215 IActivationFactory_QueryInterface( gamebar_factory
, &IID_IActivationFactory
, (void **)factory
);
217 if (*factory
) return S_OK
;
218 return CLASS_E_CLASSNOTAVAILABLE
;
221 BOOL WINAPI
DllMain( HINSTANCE instance
, DWORD reason
, void *reserved
)
223 TRACE( "instance %p, reason %lu, reserved %p.\n", instance
, reason
, reserved
);
227 case DLL_PROCESS_ATTACH
:
228 DisableThreadLibraryCalls( instance
);