Commit 296fdee9 authored by Rafaël Carré's avatar Rafaël Carré

Update workarounds for incomplete mingw headers

The so-called "Vista/7 helpers" only define interfaces missing from mingw*

Remove duplicate declarations already in all mingw headers, include the
correct headers instead.

Link video outputs against libuuid to get the existing UUID instead of
defining our own.

Define the C interfaces as Microsoft does it by using lpVtbl for the
virtual table pointer.
See http://blogs.msdn.com/b/oldnewthing/archive/2004/02/05/68017.aspx

Define a C++ interface to TaskbarList3 for qt4, keep the C for video outputs.
Define only a C++ interface to IApplicationAssociationRegistrationUI

Define TaskbarList3->SetTabActive() correctly.
See http://msdn.microsoft.com/en-us/library/windows/desktop/dd391699(v=vs.85).aspx

ifdef the TaskbarList3 interface because mingw-w64 defines it already.
(cherry picked from commit 9394c716)
Signed-off-by: default avatarRafaël Carré <funman@videolan.org>
parent f33b24f4
......@@ -3267,7 +3267,7 @@ if test "${enable_directx}" != "no"; then
[ VLC_ADD_PLUGIN([direct3d])
VLC_ADD_LIBS([direct3d],[-lgdi32])
])
VLC_ADD_LIBS([direct3d directx glwin32],[-lole32])
VLC_ADD_LIBS([direct3d directx glwin32],[-lole32 -luuid])
fi
fi
......@@ -3297,7 +3297,7 @@ AC_ARG_ENABLE(wingdi,
if test "${enable_wingdi}" != "no"; then
if test "${SYS}" = "mingw32"; then
VLC_ADD_PLUGIN([wingdi])
VLC_ADD_LIBS([wingdi],[-lgdi32 -lole32])
VLC_ADD_LIBS([wingdi],[-lgdi32 -lole32 -luuid])
fi
if test "${SYS}" = "mingwce"; then
VLC_ADD_PLUGIN([wingdi wingapi])
......
/*****************************************************************************
* vlc_windows_interfaces.h : Vista/7 helpers
* vlc_windows_interfaces.h : Replacement for incomplete MinGW headers
****************************************************************************
*
* Copyright (C) 2009-2010 VideoLAN
......@@ -21,61 +21,27 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VISTAASSOC_H
#define VISTAASSOC_H
#ifndef MINGW_WORKAROUNDS_H
#define MINGW_WORKAROUNDS_H
#include <commctrl.h>
#ifndef STDCALL
#define STDCALL
#ifdef __MINGW32__
# include <_mingw.h>
#endif
#define CLSCTX_INPROC_SERVER 1
typedef GUID IID;
#ifndef _REFIID_DEFINED
# ifdef __cplusplus
# define REFIID const IID&
# else
# define REFIID const IID* const
# endif
#ifdef __MINGW64_VERSION_MAJOR /* mingw.org lacks this header */
# include <shobjidl.h>
#endif
const GUID clsid_IApplication2 = { 0x1968106d,0xf3b5,0x44cf,{0x89,0x0e,0x11,0x6f,0xcb,0x9e,0xce,0xf1}};
const GUID IID_IApplicationAssociationRegistrationUI = {0x1f76a169,0xf994,0x40ac, {0x8f,0xc8,0x09,0x59,0xe8,0x87,0x47,0x10}};
#include <commctrl.h>
#include <basetyps.h>
#include <objbase.h>
const GUID clsid_ITaskbarList ={ 0x56FDF344,0xFD6D,0x11d0,{0x95,0x8A,0x00,0x60,0x97,0xC9,0xA0,0x90}};
/* mingw.org fails to define this */
#ifndef __ITaskbarList3_INTERFACE_DEFINED__
#define __ITaskbarList3_INTERFACE_DEFINED__
const GUID CLSID_TaskbarList ={ 0x56FDF344,0xFD6D,0x11d0,{0x95,0x8A,0x00,0x60,0x97,0xC9,0xA0,0x90}};
const GUID IID_ITaskbarList3 = { 0xea1afb91,0x9e28,0x4b86,{0x90,0xe9,0x9e,0x9f,0x8a,0x5e,0xef,0xaf}};
#ifndef __IUnknown_INTERFACE_DEFINED__
#undef IUnknown
typedef struct _IUnknown IUnknown;
#endif
typedef struct _IApplicationAssociationRegistrationUI IApplicationAssociationRegistrationUI;
typedef struct _ITaskbarList3 ITaskbarList3;
typedef struct IUnknown_vt
{
long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
void **ppvObject);
long (STDCALL *AddRef)(IUnknown *This);
long (STDCALL *Release)(IUnknown *This);
} IUnknown_vt;
struct _IUnknown { IUnknown_vt* vt; };
#ifndef __IUnknown_INTERFACE_DEFINED__
typedef IUnknown *LPUNKNOWN;
#endif
typedef struct IApplicationAssociationRegistrationUI_vt
{
/* IUnknown methods */
long (STDCALL *QueryInterface)(IUnknown *This, const GUID *riid,
void **ppvObject);
long (STDCALL *AddRef)(IUnknown *This);
long (STDCALL *Release)(IUnknown *This);
long (STDCALL *LaunchAdvancedAssociationUI)(IApplicationAssociationRegistrationUI *This, LPCWSTR app);
} IApplicationAssociationRegistrationUI_vt;
struct _IApplicationAssociationRegistrationUI { IApplicationAssociationRegistrationUI_vt* vt; };
typedef IApplicationAssociationRegistrationUI *LPAPPASSOCREGUI, *PAPPASSOCREGUI;
typedef enum TBPFLAG
{
......@@ -86,12 +52,6 @@ typedef enum TBPFLAG
TBPF_PAUSED = 0x8
} TBPFLAG;
typedef enum TBATFLAG
{
TBATF_USEMDITHUMBNAIL = 0x1,
TBATF_USEMDILIVEPREVIEW = 0x2
} TBATFLAG;
typedef struct tagTHUMBBUTTON
{
DWORD dwMask;
......@@ -105,90 +65,177 @@ typedef struct tagTHUMBBUTTON
typedef struct tagTHUMBBUTTON *LPTHUMBBUTTON;
// THUMBBUTTON flags
#define THBF_ENABLED 0x0000
#define THBF_DISABLED 0x0001
#define THBF_DISMISSONCLICK 0x0002
#define THBF_NOBACKGROUND 0x0004
#define THBF_HIDDEN 0x0008
// THUMBBUTTON mask
#define THB_BITMAP 0x0001
#define THB_ICON 0x0002
#define THB_TOOLTIP 0x0004
#define THB_FLAGS 0x0008
#define THBN_CLICKED 0x1800
typedef struct ITaskbarList3Vtbl
typedef enum THUMBBUTTONMASK {
THB_BITMAP = 0x1,
THB_ICON = 0x2,
THB_TOOLTIP = 0x4,
THB_FLAGS = 0x8
} THUMBBUTTONMASK;
typedef enum THUMBBUTTONFLAGS {
THBF_ENABLED = 0x0,
THBF_DISABLED = 0x1,
THBF_DISMISSONCLICK = 0x2,
THBF_NOBACKGROUND = 0x4,
THBF_HIDDEN = 0x8,
THBF_NONINTERACTIVE = 0x10
} THUMBBUTTONFLAGS;
#ifndef THBN_CLICKED
# define THBN_CLICKED 0x1800
#endif
#ifdef __cplusplus
interface ITaskbarList : public IUnknown {
public:
virtual HRESULT WINAPI HrInit(void) = 0;
virtual HRESULT WINAPI AddTab(HWND hwnd) = 0;
virtual HRESULT WINAPI DeleteTab(HWND hwnd) = 0;
virtual HRESULT WINAPI ActivateTab(HWND hwnd) = 0;
virtual HRESULT WINAPI SetActiveAlt(HWND hwnd) = 0;
};
interface ITaskbarList2 : public ITaskbarList {
public:
virtual HRESULT WINAPI MarkFullscreenWindow(HWND hwnd,WINBOOL fFullscreen) = 0;
};
interface ITaskbarList3 : public ITaskbarList2
{
virtual HRESULT STDMETHODCALLTYPE SetProgressValue(
HWND hwnd,
ULONGLONG ullCompleted,
ULONGLONG ullTotal) = 0;
virtual HRESULT STDMETHODCALLTYPE SetProgressState(
HWND hwnd,
TBPFLAG tbpFlags) = 0;
virtual HRESULT STDMETHODCALLTYPE RegisterTab(
HWND hwndTab,
HWND hwndMDI) = 0;
virtual HRESULT STDMETHODCALLTYPE UnregisterTab(
HWND hwndTab) = 0;
virtual HRESULT STDMETHODCALLTYPE SetTabOrder(
HWND hwndTab,
HWND hwndInsertBefore) = 0;
virtual HRESULT STDMETHODCALLTYPE SetTabActive(
HWND hwndTab,
HWND hwndMDI,
DWORD dwReserved) = 0;
virtual HRESULT STDMETHODCALLTYPE ThumbBarAddButtons(
HWND hwnd,
UINT cButtons,
LPTHUMBBUTTON pButton) = 0;
virtual HRESULT STDMETHODCALLTYPE ThumbBarUpdateButtons(
HWND hwnd,
UINT cButtons,
LPTHUMBBUTTON pButton) = 0;
virtual HRESULT STDMETHODCALLTYPE ThumbBarSetImageList(
HWND hwnd,
HIMAGELIST himl) = 0;
virtual HRESULT STDMETHODCALLTYPE SetOverlayIcon(
HWND hwnd,
HICON hIcon,
LPCWSTR pszDescription) = 0;
virtual HRESULT STDMETHODCALLTYPE SetThumbnailTooltip(
HWND hwnd,
LPCWSTR pszTip) = 0;
virtual HRESULT STDMETHODCALLTYPE SetThumbnailClip(
HWND hwnd,
RECT *prcClip) = 0;
};
#else /* !__cplusplus */
struct ITaskbarList3Vtbl;
struct ITaskbarList3 { struct ITaskbarList3Vtbl* lpVtbl; };
typedef struct ITaskbarList3 ITaskbarList3;
struct ITaskbarList3Vtbl
{
long ( STDCALL *QueryInterface )(ITaskbarList3 * This, REFIID riid, void **ppvObject);
long ( WINAPI *QueryInterface )(ITaskbarList3 * This, REFIID riid, void **ppvObject);
long ( STDCALL *AddRef )( ITaskbarList3 * This);
long ( WINAPI *AddRef )(ITaskbarList3 *This);
long ( STDCALL *Release )( ITaskbarList3 * This);
long ( WINAPI *Release )(ITaskbarList3 *This);
long ( STDCALL *HrInit )( ITaskbarList3 * This);
long ( WINAPI *HrInit )(ITaskbarList3 *This);
long ( STDCALL *AddTab )( ITaskbarList3 * This, HWND hwnd);
long ( WINAPI *AddTab )(ITaskbarList3 *This, HWND hwnd);
long ( STDCALL *DeleteTab )( ITaskbarList3 * This, HWND hwnd);
long ( WINAPI *DeleteTab )(ITaskbarList3 *This, HWND hwnd);
long ( STDCALL *ActivateTab )( ITaskbarList3 * This, HWND hwnd);
long ( WINAPI *ActivateTab )(ITaskbarList3 *This, HWND hwnd);
long ( STDCALL *SetActiveAlt )( ITaskbarList3 * This, HWND hwnd);
long ( WINAPI *SetActiveAlt )(ITaskbarList3 *This, HWND hwnd);
long ( STDCALL *MarkFullscreenWindow )( ITaskbarList3 * This, HWND hwnd,
long ( WINAPI *MarkFullscreenWindow )(ITaskbarList3 *This, HWND hwnd,
BOOL fFullscreen);
long ( STDCALL *SetProgressValue )( ITaskbarList3 * This, HWND hwnd,
long ( WINAPI *SetProgressValue )(ITaskbarList3 *This, HWND hwnd,
ULONGLONG ullCompleted, ULONGLONG ullTotal);
long ( STDCALL *SetProgressState )( ITaskbarList3 * This, HWND hwnd,
long ( WINAPI *SetProgressState )(ITaskbarList3 *This, HWND hwnd,
TBPFLAG tbpFlags);
long ( STDCALL *RegisterTab )( ITaskbarList3 * This, HWND hwndTab, HWND hwndMDI);
long ( WINAPI *RegisterTab )( ITaskbarList3 *This, HWND hwndTab, HWND hwndMDI);
long ( STDCALL *UnregisterTab )( ITaskbarList3 * This, HWND hwndTab);
long ( WINAPI *UnregisterTab )(ITaskbarList3 *This, HWND hwndTab);
long ( STDCALL *SetTabOrder )( ITaskbarList3 * This, HWND hwndTab,
long ( WINAPI *SetTabOrder )(ITaskbarList3 *This, HWND hwndTab,
HWND hwndInsertBefore);
long ( STDCALL *SetTabActive )( ITaskbarList3 * This, HWND hwndTab,
HWND hwndMDI, TBATFLAG tbatFlags);
long ( WINAPI *SetTabActive )(ITaskbarList3 *This, HWND hwndTab,
HWND hwndMDI, DWORD dwReserved);
long ( STDCALL *ThumbBarAddButtons )( ITaskbarList3 * This, HWND hwnd,
long ( WINAPI *ThumbBarAddButtons )(ITaskbarList3 *This, HWND hwnd,
UINT cButtons, LPTHUMBBUTTON pButton);
long ( STDCALL *ThumbBarUpdateButtons )( ITaskbarList3 * This, HWND hwnd,
long ( WINAPI *ThumbBarUpdateButtons )(ITaskbarList3 *This, HWND hwnd,
UINT cButtons, LPTHUMBBUTTON pButton);
long ( STDCALL *ThumbBarSetImageList )( ITaskbarList3 * This, HWND hwnd,
long ( WINAPI *ThumbBarSetImageList )(ITaskbarList3 *This, HWND hwnd,
HIMAGELIST himl);
long ( STDCALL *SetOverlayIcon )( ITaskbarList3 * This, HWND hwnd,
long ( WINAPI *SetOverlayIcon )(ITaskbarList3 *This, HWND hwnd,
HICON hIcon, LPCWSTR pszDescription);
long ( STDCALL *SetThumbnailTooltip )( ITaskbarList3 * This, HWND hwnd,
long ( WINAPI *SetThumbnailTooltip )(ITaskbarList3 *This, HWND hwnd,
LPCWSTR pszTip);
long ( STDCALL *SetThumbnailClip )( ITaskbarList3 * This, HWND hwnd,
long ( WINAPI *SetThumbnailClip )(ITaskbarList3 *This, HWND hwnd,
RECT *prcClip);
} ITaskbarList3Vtbl;
struct _ITaskbarList3 { ITaskbarList3Vtbl* vt; };
typedef ITaskbarList3 *LPTASKBARLIST3, *PTASKBARLIST3;
};
#endif /* __cplusplus */
#endif /* __ITaskbarList3_INTERFACE_DEFINED__ */
/* mingw-w64 also fails to define this as of 2.0.1 */
#ifndef __IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__
#define __IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__
const GUID IID_IApplicationAssociationRegistrationUI = {0x1f76a169,0xf994,0x40ac, {0x8f,0xc8,0x09,0x59,0xe8,0x87,0x47,0x10}};
const GUID CLSID_ApplicationAssociationRegistrationUI = { 0x1968106d,0xf3b5,0x44cf,{0x89,0x0e,0x11,0x6f,0xcb,0x9e,0xce,0xf1}};
#ifdef __cplusplus
extern "C" {
#endif
HRESULT WINAPI CoCreateInstance(const GUID *,LPUNKNOWN,DWORD,REFIID,PVOID*);
HRESULT WINAPI CoInitialize(PVOID);
void WINAPI CoUninitialize(void);
#ifdef __cplusplus
interface IApplicationAssociationRegistrationUI : public IUnknown
{
virtual HRESULT STDMETHODCALLTYPE LaunchAdvancedAssociationUI(
LPCWSTR pszAppRegName) = 0;
};
#endif
#endif /* __cplusplus */
#endif /* __IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__ */
#endif //VISTAASSOC_H
#endif //MINGW_WORKAROUNDS_H
......@@ -925,15 +925,15 @@ bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
void SPrefsPanel::assoDialog()
{
LPAPPASSOCREGUI p_appassoc;
IApplicationAssociationRegistrationUI *p_appassoc;
CoInitialize( 0 );
if( S_OK == CoCreateInstance( &clsid_IApplication2,
if( S_OK == CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
NULL, CLSCTX_INPROC_SERVER,
IID_IApplicationAssociationRegistrationUI,
(void **)&p_appassoc) )
{
if(S_OK == p_appassoc->vt->LaunchAdvancedAssociationUI(p_appassoc, L"VLC" ) )
if(S_OK == p_appassoc->LaunchAdvancedAssociationUI(L"VLC" ) )
{
CoUninitialize();
return;
......
......@@ -267,7 +267,7 @@ MainInterface::~MainInterface()
if( himl )
ImageList_Destroy( himl );
if(p_taskbl)
p_taskbl->vt->Release(p_taskbl);
p_taskbl->Release();
CoUninitialize();
#endif
......
......@@ -172,7 +172,7 @@ private:
#ifdef WIN32
HIMAGELIST himl;
LPTASKBARLIST3 p_taskbl;
ITaskbarList3 *p_taskbl;
UINT taskbar_wmsg;
void createTaskBarButtons();
#endif
......
......@@ -79,12 +79,12 @@ void MainInterface::createTaskBarButtons()
CoInitialize( 0 );
if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
if( S_OK == CoCreateInstance( CLSID_TaskbarList,
NULL, CLSCTX_INPROC_SERVER,
IID_ITaskbarList3,
(void **)&p_taskbl) )
{
p_taskbl->vt->HrInit(p_taskbl);
p_taskbl->HrInit();
if( (himl = ImageList_Create( 20, //cx
20, //cy
......@@ -114,7 +114,7 @@ void MainInterface::createTaskBarButtons()
// Define an array of two buttons. These buttons provide images through an
// image list and also provide tooltips.
DWORD dwMask = THB_BITMAP | THB_FLAGS;
THUMBBUTTONMASK dwMask = THUMBBUTTONMASK(THB_BITMAP | THB_FLAGS);
THUMBBUTTON thbButtons[3];
thbButtons[0].dwMask = dwMask;
......@@ -132,12 +132,12 @@ void MainInterface::createTaskBarButtons()
thbButtons[2].iBitmap = 3;
thbButtons[2].dwFlags = THBF_HIDDEN;
HRESULT hr = p_taskbl->vt->ThumbBarSetImageList(p_taskbl, winId(), himl );
HRESULT hr = p_taskbl->ThumbBarSetImageList(winId(), himl );
if(S_OK != hr)
msg_Err( p_intf, "ThumbBarSetImageList failed with error %08lx", hr );
else
{
hr = p_taskbl->vt->ThumbBarAddButtons(p_taskbl, winId(), 3, thbButtons);
hr = p_taskbl->ThumbBarAddButtons(winId(), 3, thbButtons);
if(S_OK != hr)
msg_Err( p_intf, "ThumbBarAddButtons failed with error %08lx", hr );
}
......@@ -244,7 +244,7 @@ void MainInterface::changeThumbbarButtons( int i_status )
// Define an array of three buttons. These buttons provide images through an
// image list and also provide tooltips.
DWORD dwMask = THB_BITMAP | THB_FLAGS;
THUMBBUTTONMASK dwMask = THUMBBUTTONMASK(THB_BITMAP | THB_FLAGS);
THUMBBUTTON thbButtons[3];
//prev
......@@ -285,7 +285,7 @@ void MainInterface::changeThumbbarButtons( int i_status )
default:
return;
}
HRESULT hr = p_taskbl->vt->ThumbBarUpdateButtons(p_taskbl, this->winId(), 3, thbButtons);
HRESULT hr = p_taskbl->ThumbBarUpdateButtons(this->winId(), 3, thbButtons);
if(S_OK != hr)
msg_Err( p_intf, "ThumbBarUpdateButtons failed with error %08lx", hr );
}
......@@ -291,12 +291,12 @@ static void CommonChangeThumbnailClip(vout_display_t *vd, bool show)
CoInitialize(0);
void *ptr;
if (S_OK == CoCreateInstance(&clsid_ITaskbarList,
if (S_OK == CoCreateInstance(&CLSID_TaskbarList,
NULL, CLSCTX_INPROC_SERVER,
&IID_ITaskbarList3,
&ptr)) {
LPTASKBARLIST3 taskbl = ptr;
taskbl->vt->HrInit(taskbl);
ITaskbarList3 *taskbl = ptr;
taskbl->lpVtbl->HrInit(taskbl);
HWND hroot = GetAncestor(sys->hwnd,GA_ROOT);
RECT relative;
......@@ -310,11 +310,11 @@ static void CommonChangeThumbnailClip(vout_display_t *vd, bool show)
relative.right = video.right - video.left + relative.left;
relative.bottom = video.bottom - video.top + relative.top - 25;
}
if (S_OK != taskbl->vt->SetThumbnailClip(taskbl, hroot,
if (S_OK != taskbl->lpVtbl->SetThumbnailClip(taskbl, hroot,
show ? &relative : NULL))
msg_Err(vd, "SetThumbNailClip failed");
taskbl->vt->Release(taskbl);
taskbl->lpVtbl->Release(taskbl);
}
CoUninitialize();
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment