2 * Copyright 2019 Alistair Leslie-Hughes
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/heap.h"
27 #include "wine/debug.h"
29 #include "directmanipulation.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(manipulation
);
33 static HINSTANCE dm_instance
;
35 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, void *reserved
)
37 TRACE("(%p, %u, %p)\n", instance
, reason
, reserved
);
41 case DLL_WINE_PREATTACH
:
42 return FALSE
; /* prefer native version */
43 case DLL_PROCESS_ATTACH
:
44 dm_instance
= instance
;
45 DisableThreadLibraryCalls(instance
);
52 HRESULT WINAPI
DllRegisterServer(void)
54 return __wine_register_resources( dm_instance
);
57 HRESULT WINAPI
DllUnregisterServer(void)
59 return __wine_unregister_resources( dm_instance
);
62 HRESULT WINAPI
DllCanUnloadNow(void)
68 struct directmanipulation
70 IDirectManipulationManager2 IDirectManipulationManager2_iface
;
71 IDirectManipulationUpdateManager
*updatemanager
;
75 struct directupdatemanager
77 IDirectManipulationUpdateManager IDirectManipulationUpdateManager_iface
;
81 static inline struct directmanipulation
*impl_from_IDirectManipulationManager2(IDirectManipulationManager2
*iface
)
83 return CONTAINING_RECORD(iface
, struct directmanipulation
, IDirectManipulationManager2_iface
);
86 static inline struct directupdatemanager
*impl_from_IDirectManipulationUpdateManager(IDirectManipulationUpdateManager
*iface
)
88 return CONTAINING_RECORD(iface
, struct directupdatemanager
, IDirectManipulationUpdateManager_iface
);
91 static HRESULT WINAPI
update_manager_QueryInterface(IDirectManipulationUpdateManager
*iface
, REFIID riid
,void **ppv
)
93 struct directupdatemanager
*This
= impl_from_IDirectManipulationUpdateManager(iface
);
95 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(riid
), ppv
);
97 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
98 IsEqualGUID(riid
, &IID_IDirectManipulationUpdateManager
)) {
99 IUnknown_AddRef(iface
);
104 FIXME("(%p)->(%s,%p), not found\n", This
, debugstr_guid(riid
), ppv
);
105 return E_NOINTERFACE
;
108 ULONG WINAPI
update_manager_AddRef(IDirectManipulationUpdateManager
*iface
)
110 struct directupdatemanager
*This
= impl_from_IDirectManipulationUpdateManager(iface
);
111 ULONG ref
= InterlockedIncrement(&This
->ref
);
113 TRACE("(%p) ref=%u\n", This
, ref
);
118 ULONG WINAPI
update_manager_Release(IDirectManipulationUpdateManager
*iface
)
120 struct directupdatemanager
*This
= impl_from_IDirectManipulationUpdateManager(iface
);
121 ULONG ref
= InterlockedDecrement(&This
->ref
);
123 TRACE("(%p) ref=%u\n", This
, ref
);
132 static HRESULT WINAPI
update_manager_RegisterWaitHandleCallback(IDirectManipulationUpdateManager
*iface
, HANDLE handle
,
133 IDirectManipulationUpdateHandler
*handler
, DWORD
*cookie
)
135 struct directupdatemanager
*This
= impl_from_IDirectManipulationUpdateManager(iface
);
136 FIXME("%p, %p, %p, %p\n", This
, handle
, handler
, cookie
);
140 static HRESULT WINAPI
update_manager_UnregisterWaitHandleCallback(IDirectManipulationUpdateManager
*iface
, DWORD cookie
)
142 struct directupdatemanager
*This
= impl_from_IDirectManipulationUpdateManager(iface
);
143 FIXME("%p, %x\n", This
, cookie
);
147 static HRESULT WINAPI
update_manager_Update(IDirectManipulationUpdateManager
*iface
, IDirectManipulationFrameInfoProvider
*provider
)
149 struct directupdatemanager
*This
= impl_from_IDirectManipulationUpdateManager(iface
);
150 FIXME("%p, %p\n", This
, provider
);
154 struct IDirectManipulationUpdateManagerVtbl updatemanagerVtbl
=
156 update_manager_QueryInterface
,
157 update_manager_AddRef
,
158 update_manager_Release
,
159 update_manager_RegisterWaitHandleCallback
,
160 update_manager_UnregisterWaitHandleCallback
,
161 update_manager_Update
164 static HRESULT
create_update_manager(IDirectManipulationUpdateManager
**obj
)
166 struct directupdatemanager
*object
;
168 object
= heap_alloc(sizeof(*object
));
170 return E_OUTOFMEMORY
;
172 object
->IDirectManipulationUpdateManager_iface
.lpVtbl
= &updatemanagerVtbl
;
175 *obj
= &object
->IDirectManipulationUpdateManager_iface
;
180 static HRESULT WINAPI
direct_manip_QueryInterface(IDirectManipulationManager2
*iface
, REFIID riid
, void **ppv
)
182 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
183 IsEqualGUID(riid
, &IID_IDirectManipulationManager
) ||
184 IsEqualGUID(riid
, &IID_IDirectManipulationManager2
)) {
185 IUnknown_AddRef(iface
);
190 FIXME("(%p)->(%s,%p),not found\n", iface
, debugstr_guid(riid
), ppv
);
191 return E_NOINTERFACE
;
194 static ULONG WINAPI
direct_manip_AddRef(IDirectManipulationManager2
*iface
)
196 struct directmanipulation
*This
= impl_from_IDirectManipulationManager2(iface
);
197 ULONG ref
= InterlockedIncrement(&This
->ref
);
199 TRACE("(%p) ref=%u\n", This
, ref
);
204 static ULONG WINAPI
direct_manip_Release(IDirectManipulationManager2
*iface
)
206 struct directmanipulation
*This
= impl_from_IDirectManipulationManager2(iface
);
207 ULONG ref
= InterlockedDecrement(&This
->ref
);
209 TRACE("(%p) ref=%u\n", This
, ref
);
213 if(This
->updatemanager
)
214 IDirectManipulationUpdateManager_Release(This
->updatemanager
);
220 static HRESULT WINAPI
direct_manip_Activate(IDirectManipulationManager2
*iface
, HWND window
)
222 struct directmanipulation
*This
= impl_from_IDirectManipulationManager2(iface
);
223 FIXME("%p, %p\n", This
, window
);
227 static HRESULT WINAPI
direct_manip_Deactivate(IDirectManipulationManager2
*iface
, HWND window
)
229 struct directmanipulation
*This
= impl_from_IDirectManipulationManager2(iface
);
230 FIXME("%p, %p\n", This
, window
);
234 static HRESULT WINAPI
direct_manip_RegisterHitTestTarget(IDirectManipulationManager2
*iface
, HWND window
,
235 HWND hittest
, DIRECTMANIPULATION_HITTEST_TYPE type
)
237 struct directmanipulation
*This
= impl_from_IDirectManipulationManager2(iface
);
238 FIXME("%p, %p, %p, %d\n", This
, window
, hittest
, type
);
242 static HRESULT WINAPI
direct_manip_ProcessInput(IDirectManipulationManager2
*iface
, const MSG
*msg
, BOOL
*handled
)
244 struct directmanipulation
*This
= impl_from_IDirectManipulationManager2(iface
);
245 FIXME("%p, %p, %p\n", This
, msg
, handled
);
249 static HRESULT WINAPI
direct_manip_GetUpdateManager(IDirectManipulationManager2
*iface
, REFIID riid
, void **obj
)
251 struct directmanipulation
*This
= impl_from_IDirectManipulationManager2(iface
);
254 TRACE("%p, %s, %p\n", This
, debugstr_guid(riid
), obj
);
257 if(IsEqualGUID(riid
, &IID_IDirectManipulationUpdateManager
))
259 if(!This
->updatemanager
)
261 hr
= create_update_manager(&This
->updatemanager
);
270 IDirectManipulationUpdateManager_AddRef(This
->updatemanager
);
271 *obj
= This
->updatemanager
;
275 FIXME("Interface %s currently not supported.\n", debugstr_guid(riid
));
280 static HRESULT WINAPI
direct_manip_CreateViewport(IDirectManipulationManager2
*iface
, IDirectManipulationFrameInfoProvider
*frame
,
281 HWND window
, REFIID riid
, void **obj
)
283 struct directmanipulation
*This
= impl_from_IDirectManipulationManager2(iface
);
284 FIXME("%p, %p, %p, %s, %p\n", This
, frame
, window
, debugstr_guid(riid
), obj
);
288 static HRESULT WINAPI
direct_manip_CreateContent(IDirectManipulationManager2
*iface
, IDirectManipulationFrameInfoProvider
*frame
,
289 REFCLSID clsid
, REFIID riid
, void **obj
)
291 struct directmanipulation
*This
= impl_from_IDirectManipulationManager2(iface
);
292 FIXME("%p, %p, %s, %p\n", This
, frame
, debugstr_guid(riid
), obj
);
296 static HRESULT WINAPI
direct_manip_CreateBehavior(IDirectManipulationManager2
*iface
, REFCLSID clsid
, REFIID riid
, void **obj
)
298 struct directmanipulation
*This
= impl_from_IDirectManipulationManager2(iface
);
299 FIXME("%p, %s, %s, %p\n", This
, debugstr_guid(clsid
), debugstr_guid(riid
), obj
);
303 static const struct IDirectManipulationManager2Vtbl directmanipVtbl
=
305 direct_manip_QueryInterface
,
307 direct_manip_Release
,
308 direct_manip_Activate
,
309 direct_manip_Deactivate
,
310 direct_manip_RegisterHitTestTarget
,
311 direct_manip_ProcessInput
,
312 direct_manip_GetUpdateManager
,
313 direct_manip_CreateViewport
,
314 direct_manip_CreateContent
,
315 direct_manip_CreateBehavior
318 static HRESULT WINAPI
DirectManipulation_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
320 struct directmanipulation
*object
;
323 TRACE("(%p, %s, %p)\n", outer
, debugstr_guid(riid
), ppv
);
327 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
329 return E_OUTOFMEMORY
;
331 object
->IDirectManipulationManager2_iface
.lpVtbl
= &directmanipVtbl
;
334 ret
= direct_manip_QueryInterface(&object
->IDirectManipulationManager2_iface
, riid
, ppv
);
335 direct_manip_Release(&object
->IDirectManipulationManager2_iface
);
340 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
344 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IClassFactory
, riid
)) {
349 IUnknown_AddRef((IUnknown
*)*ppv
);
353 WARN("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
354 return E_NOINTERFACE
;
357 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
359 TRACE("(%p)\n", iface
);
363 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
365 TRACE("(%p)\n", iface
);
369 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL fLock
)
371 TRACE("(%p)->(%x)\n", iface
, fLock
);
375 static const IClassFactoryVtbl DirectFactoryVtbl
= {
376 ClassFactory_QueryInterface
,
378 ClassFactory_Release
,
379 DirectManipulation_CreateInstance
,
380 ClassFactory_LockServer
383 static IClassFactory direct_factory
= { &DirectFactoryVtbl
};
385 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
387 if(IsEqualGUID(&CLSID_DirectManipulationManager
, rclsid
) ||
388 IsEqualGUID(&CLSID_DirectManipulationSharedManager
, rclsid
) ) {
389 TRACE("(CLSID_DirectManipulationManager %s %p)\n", debugstr_guid(riid
), ppv
);
390 return IClassFactory_QueryInterface(&direct_factory
, riid
, ppv
);
393 FIXME("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
394 return CLASS_E_CLASSNOTAVAILABLE
;