aboutsummaryrefslogtreecommitdiff
path: root/backends/taskbar
diff options
context:
space:
mode:
authorLittleboy2011-04-26 13:30:13 -0400
committerJulien2011-06-16 10:36:39 -0400
commit2348eeed4c4c5f6bb55d9d566d7adbfa2f0c1136 (patch)
tree21cb6047d5550dd3366702ed9a1509a01fa7b9c7 /backends/taskbar
parent2be35013f1d014620f222da9ed32110ce77814da (diff)
downloadscummvm-rg350-2348eeed4c4c5f6bb55d9d566d7adbfa2f0c1136.tar.gz
scummvm-rg350-2348eeed4c4c5f6bb55d9d566d7adbfa2f0c1136.tar.bz2
scummvm-rg350-2348eeed4c4c5f6bb55d9d566d7adbfa2f0c1136.zip
BACKENDS: Add taskbar integration compat header for MingW
Diffstat (limited to 'backends/taskbar')
-rw-r--r--backends/taskbar/win32/mingw-compat.h140
-rw-r--r--backends/taskbar/win32/win32-taskbar.cpp35
-rw-r--r--backends/taskbar/win32/win32-taskbar.h4
3 files changed, 163 insertions, 16 deletions
diff --git a/backends/taskbar/win32/mingw-compat.h b/backends/taskbar/win32/mingw-compat.h
new file mode 100644
index 0000000000..6324de3b34
--- /dev/null
+++ b/backends/taskbar/win32/mingw-compat.h
@@ -0,0 +1,140 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+// TODO: Remove header when the latest changes to the Windows SDK have been integrated into MingW
+// For reference, the interface definitions here are imported the SDK headers and from the
+// EcWin7 project (https://code.google.com/p/dukto/)
+
+#ifndef BACKEND_WIN32_TASKBAR_MINGW_H
+#define BACKEND_WIN32_TASKBAR_MINGW_H
+
+#if defined(WIN32)
+#if defined(__GNUC__)
+#ifdef __MINGW32__
+
+#define _WIN32_WINNT 0x0501
+#include <windows.h>
+#include <commctrl.h>
+#include <initguid.h>
+#include <shlwapi.h>
+#define CMIC_MASK_ASYNCOK SEE_MASK_ASYNCOK
+
+// Taskbar GUID definitions
+DEFINE_GUID(CLSID_TaskbarList,0x56fdf344,0xfd6d,0x11d0,0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90);
+DEFINE_GUID(IID_ITaskbarList3,0xea1afb91,0x9e28,0x4b86,0x90,0xE9,0x9e,0x9f,0x8a,0x5e,0xef,0xaf);
+DEFINE_GUID(IID_IPropertyStore,0x886d8eeb,0x8cf2,0x4446,0x8d,0x02,0xcd,0xba,0x1d,0xbd,0xcf,0x99);
+
+// Property key
+typedef struct _tagpropertykey {
+ GUID fmtid;
+ DWORD pid;
+} PROPERTYKEY;
+
+#define REFPROPERTYKEY const PROPERTYKEY &
+
+typedef struct tagPROPVARIANT PROPVARIANT;
+#define REFPROPVARIANT const PROPVARIANT &
+
+// Property store
+DECLARE_INTERFACE_(IPropertyStore, IUnknown) {
+ STDMETHOD (GetCount) (DWORD *cProps) PURE;
+ STDMETHOD (GetAt) (DWORD iProp, PROPERTYKEY *pkey) PURE;
+ STDMETHOD (GetValue) (REFPROPERTYKEY key, PROPVARIANT *pv) PURE;
+ STDMETHOD (SetValue) (REFPROPERTYKEY key, REFPROPVARIANT propvar) PURE;
+ STDMETHOD (Commit) (void) PURE;
+};
+typedef IPropertyStore *LPIPropertyStore;
+
+// Mingw-specific defines for taskbar integration
+typedef enum THUMBBUTTONMASK {
+ THB_BITMAP = 0x1,
+ THB_ICON = 0x2,
+ THB_TOOLTIP = 0x4,
+ THB_FLAGS = 0x8
+} THUMBBUTTONMASK;
+
+typedef enum THUMBBUTTONFLAGS {
+ THBF_ENABLED = 0,
+ THBF_DISABLED = 0x1,
+ THBF_DISMISSONCLICK = 0x2,
+ THBF_NOBACKGROUND = 0x4,
+ THBF_HIDDEN = 0x8,
+ THBF_NONINTERACTIVE = 0x10
+} THUMBBUTTONFLAGS;
+
+typedef struct THUMBBUTTON {
+ THUMBBUTTONMASK dwMask;
+ UINT iId;
+ UINT iBitmap;
+ HICON hIcon;
+ WCHAR szTip[260];
+ THUMBBUTTONFLAGS dwFlags;
+} THUMBBUTTON;
+typedef struct THUMBBUTTON *LPTHUMBBUTTON;
+
+typedef enum TBPFLAG {
+ TBPF_NOPROGRESS = 0,
+ TBPF_INDETERMINATE = 0x1,
+ TBPF_NORMAL = 0x2,
+ TBPF_ERROR = 0x4,
+ TBPF_PAUSED = 0x8
+} TBPFLAG;
+
+// Taskbar interface
+DECLARE_INTERFACE_(ITaskbarList3, IUnknown) {
+ // IUnknown
+ STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
+ STDMETHOD_(ULONG,AddRef) (THIS) PURE;
+ STDMETHOD_(ULONG,Release) (THIS) PURE;
+ // ITaskbarList
+ STDMETHOD(HrInit) (THIS) PURE;
+ STDMETHOD(AddTab) (THIS_ HWND hwnd) PURE;
+ STDMETHOD(DeleteTab) (THIS_ HWND hwnd) PURE;
+ STDMETHOD(ActivateTab) (THIS_ HWND hwnd) PURE;
+ STDMETHOD(SetActiveAlt) (THIS_ HWND hwnd) PURE;
+ STDMETHOD (MarkFullscreenWindow) (THIS_ HWND hwnd, int fFullscreen) PURE;
+ // ITaskbarList3
+ STDMETHOD (SetProgressValue) (THIS_ HWND hwnd, ULONGLONG ullCompleted, ULONGLONG ullTotal) PURE;
+ STDMETHOD (SetProgressState) (THIS_ HWND hwnd, TBPFLAG tbpFlags) PURE;
+ STDMETHOD (RegisterTab) (THIS_ HWND hwndTab, HWND hwndMDI) PURE;
+ STDMETHOD (UnregisterTab) (THIS_ HWND hwndTab) PURE;
+ STDMETHOD (SetTabOrder) (THIS_ HWND hwndTab, HWND hwndInsertBefore) PURE;
+ STDMETHOD (SetTabActive) (THIS_ HWND hwndTab, HWND hwndMDI, DWORD dwReserved) PURE;
+ STDMETHOD (ThumbBarAddButtons) (THIS_ HWND hwnd, UINT cButtons, LPTHUMBBUTTON pButton) PURE;
+ STDMETHOD (ThumbBarUpdateButtons) (THIS_ HWND hwnd, UINT cButtons, LPTHUMBBUTTON pButton) PURE;
+ STDMETHOD (ThumbBarSetImageList) (THIS_ HWND hwnd, HIMAGELIST himl) PURE;
+ STDMETHOD (SetOverlayIcon) (THIS_ HWND hwnd, HICON hIcon, LPCWSTR pszDescription) PURE;
+ STDMETHOD (SetThumbnailTooltip) (THIS_ HWND hwnd, LPCWSTR pszTip) PURE;
+ STDMETHOD (SetThumbnailClip) (THIS_ HWND hwnd, RECT *prcClip) PURE;
+};
+
+
+typedef ITaskbarList3 *LPITaskbarList3;
+
+#endif // __MINGW32__
+#endif // __GNUC__
+#endif // WIN32
+
+#endif // BACKEND_WIN32_TASKBAR_MINGW_H
diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp
index 85c87f3680..768bf5b64e 100644
--- a/backends/taskbar/win32/win32-taskbar.cpp
+++ b/backends/taskbar/win32/win32-taskbar.cpp
@@ -21,20 +21,23 @@
* $URL$
* $Id$
*
- * Original code from EcWin7 - Copyright (C) 2010 Emanuele Colombo
- * https://code.google.com/p/dukto/
*/
-#ifdef WIN32
+#if defined(WIN32)
// Needed for taskbar functions
-#include <SDKDDKVer.h>
+#if defined(__GNUC__)
+#ifdef __MINGW32__
+ #include "backends/taskbar/win32/mingw-compat.h"
+#else
+ #error Only compilation with MingW is supported
+#endif
+#else
+ // Default MSVC headers for ITaskbarList3 and IShellLink
+ #include <SDKDDKVer.h>
+#endif
#include <shlobj.h>
-// For Bitmap and overlay icons
-#include <gdiplus.h>
-using namespace Gdiplus;
-
// For HWND
#include <SDL_syswm.h>
@@ -85,6 +88,8 @@ void Win32TaskbarManager::init() {
}
void Win32TaskbarManager::setOverlayIcon(const Common::String &name, const Common::String &description) {
+ //warning("[Win32TaskbarManager::setOverlayIcon] Setting overlay icon to: %s (%s)", name.c_str(), description.c_str());
+
if (_taskbar == NULL)
return;
@@ -99,6 +104,10 @@ void Win32TaskbarManager::setOverlayIcon(const Common::String &name, const Commo
return;
HICON pIcon = (HICON)::LoadImage(NULL, path.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
+ if (!pIcon) {
+ warning("[Win32TaskbarManager::setOverlayIcon] Cannot load icon!");
+ return;
+ }
// Sets the overlay icon
LPWSTR desc = ansiToUnicode(description.c_str());
@@ -124,6 +133,8 @@ void Win32TaskbarManager::setProgressState(TaskbarProgressState state) {
}
void Win32TaskbarManager::addRecent(const Common::String &name, const Common::String &description) {
+ //warning("[Win32TaskbarManager::addRecent] Adding recent list entry: %s (%s)", name.c_str(), description.c_str());
+
if (_taskbar == NULL)
return;
@@ -135,7 +146,7 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St
GetModuleFileNameW(NULL, path, MAX_PATH);
// Create a shell link.
- if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC, IID_PPV_ARGS(&link)))) {
+ if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC, IID_IShellLinkW, reinterpret_cast<void**> (&link)))) {
// Convert game name and description to Unicode.
LPWSTR game = ansiToUnicode(name.c_str());
LPWSTR desc = ansiToUnicode(description.c_str());
@@ -157,7 +168,7 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St
// The link's display name must be set via property store.
IPropertyStore* propStore;
- HRESULT hr = link->QueryInterface(&propStore);
+ HRESULT hr = link->QueryInterface(IID_IPropertyStore, reinterpret_cast<void**> (&(propStore)));
if (SUCCEEDED(hr)) {
PROPVARIANT pv;
pv.vt = VT_LPWSTR;
@@ -169,8 +180,7 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St
propStore->Release();
}
- // SHAddToRecentDocs will cause the games to be added to the Recent list, allowing the
- // user to pin them.
+ // SHAddToRecentDocs will cause the games to be added to the Recent list, allowing the user to pin them.
SHAddToRecentDocs(SHARD_LINK, link);
link->Release();
delete[] game;
@@ -183,7 +193,6 @@ Common::String Win32TaskbarManager::getIconPath(Common::String target) {
Common::String extra = ConfMan.get("extrapath");
Common::String filename = target + ".ico";
- Common::String path = extra + filename;
if (!Common::File::exists(filename)) {
// Try with the game id instead of the domain name
diff --git a/backends/taskbar/win32/win32-taskbar.h b/backends/taskbar/win32/win32-taskbar.h
index bdd45a942d..f9ce9c16fc 100644
--- a/backends/taskbar/win32/win32-taskbar.h
+++ b/backends/taskbar/win32/win32-taskbar.h
@@ -21,14 +21,12 @@
* $URL$
* $Id$
*
- * Original code from EcWin7 - Copyright (C) 2010 Emanuele Colombo
- * https://code.google.com/p/dukto/
*/
#ifndef BACKEND_WIN32_TASKBAR_H
#define BACKEND_WIN32_TASKBAR_H
-#ifdef WIN32
+#if defined(WIN32)
#include "common/str.h"
#include "common/taskbar.h"