aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/sdl/posix/posix.cpp9
-rw-r--r--backends/platform/sdl/sdl.cpp2
-rw-r--r--backends/taskbar/unity/unity-taskbar.cpp35
-rw-r--r--backends/taskbar/unity/unity-taskbar.h7
-rw-r--r--backends/taskbar/win32/mingw-compat.h105
-rw-r--r--backends/taskbar/win32/win32-taskbar.cpp38
6 files changed, 113 insertions, 83 deletions
diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp
index f124a3af7d..94f8d95ffb 100644
--- a/backends/platform/sdl/posix/posix.cpp
+++ b/backends/platform/sdl/posix/posix.cpp
@@ -51,8 +51,8 @@ void OSystem_POSIX::init() {
_fsFactory = new POSIXFilesystemFactory();
#if defined(USE_TASKBAR)
- // Initialize taskbar manager
- _taskbarManager = new UnityTaskbarManager();
+ // Initialize taskbar manager
+ _taskbarManager = new UnityTaskbarManager();
#endif
// Invoke parent implementation of this method
@@ -66,6 +66,11 @@ void OSystem_POSIX::initBackend() {
// Invoke parent implementation of this method
OSystem_SDL::initBackend();
+
+#if defined(USE_TASKBAR)
+ // Register the taskbar manager as an event source (this is necessary for the glib event loop to be run)
+ _eventManager->getEventDispatcher()->registerSource((UnityTaskbarManager *)_taskbarManager, false);
+#endif
}
bool OSystem_POSIX::hasFeature(Feature f) {
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 4520b74861..4743dbb558 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -385,7 +385,7 @@ void OSystem_SDL::setupIcon() {
if (sscanf(scummvm_icon[0], "%d %d %d %d", &w, &h, &ncols, &nbytes) != 4) {
warning("Wrong format of scummvm_icon[0] (%s)", scummvm_icon[0]);
-
+
return;
}
if ((w > 512) || (h > 512) || (ncols > 255) || (nbytes > 1)) {
diff --git a/backends/taskbar/unity/unity-taskbar.cpp b/backends/taskbar/unity/unity-taskbar.cpp
index 6c18f0940c..24347e382f 100644
--- a/backends/taskbar/unity/unity-taskbar.cpp
+++ b/backends/taskbar/unity/unity-taskbar.cpp
@@ -32,27 +32,31 @@
#include "common/textconsole.h"
UnityTaskbarManager::UnityTaskbarManager() {
- g_type_init();
+ g_type_init();
- _launcher = unity_launcher_entry_get_for_desktop_id("scummvm.desktop");
+ _loop = g_main_loop_new(NULL, FALSE);
+
+ _launcher = unity_launcher_entry_get_for_desktop_id("scummvm.desktop");
}
UnityTaskbarManager::~UnityTaskbarManager() {
+ g_main_loop_unref(_loop);
+ _loop = NULL;
}
void UnityTaskbarManager::setOverlayIcon(const Common::String &name, const Common::String &description) {
if (_launcher == NULL)
- return;
+ return;
warning("[UnityTaskbarManager::setOverlayIcon] Not implemented");
}
void UnityTaskbarManager::setProgressValue(int completed, int total) {
- if (_launcher == NULL)
- return;
+ if (_launcher == NULL)
+ return;
- double percentage = (double)completed / (double)total;
- unity_launcher_entry_set_progress(_launcher, percentage);
+ double percentage = (double)completed / (double)total;
+ unity_launcher_entry_set_progress(_launcher, percentage);
unity_launcher_entry_set_progress_visible(_launcher, TRUE);
}
@@ -84,4 +88,21 @@ void UnityTaskbarManager::addRecent(const Common::String &name, const Common::St
warning("[UnityTaskbarManager::addRecent] Not implemented");
}
+// Unity requires the glib event loop to the run to function properly
+// as events are sent asynchronously
+bool UnityTaskbarManager::pollEvent(Common::Event &event) {
+ if (!_loop)
+ return false;
+
+ // Get context
+ GMainContext *context = g_main_loop_get_context(_loop);
+ if (!context)
+ return false;
+
+ // Dispatch events
+ g_main_context_iteration(context, FALSE);
+
+ return false;
+}
+
#endif
diff --git a/backends/taskbar/unity/unity-taskbar.h b/backends/taskbar/unity/unity-taskbar.h
index 0d0484c02e..d8a68a4101 100644
--- a/backends/taskbar/unity/unity-taskbar.h
+++ b/backends/taskbar/unity/unity-taskbar.h
@@ -28,12 +28,13 @@
#if defined(UNIX) && defined(USE_TASKBAR)
+#include "common/events.h"
#include "common/str.h"
#include "common/taskbar.h"
#include <unity.h>
-class UnityTaskbarManager : public Common::TaskbarManager {
+class UnityTaskbarManager : public Common::TaskbarManager, public Common::EventSource {
public:
UnityTaskbarManager();
virtual ~UnityTaskbarManager();
@@ -43,7 +44,11 @@ public:
virtual void setProgressState(TaskbarProgressState state);
virtual void addRecent(const Common::String &name, const Common::String &description);
+ // Implementation of the EventSource interface
+ virtual bool pollEvent(Common::Event &event);
+
private:
+ GMainLoop *_loop;
UnityLauncherEntry *_launcher;
};
diff --git a/backends/taskbar/win32/mingw-compat.h b/backends/taskbar/win32/mingw-compat.h
index 6324de3b34..3ee4b9aa5d 100644
--- a/backends/taskbar/win32/mingw-compat.h
+++ b/backends/taskbar/win32/mingw-compat.h
@@ -48,8 +48,8 @@ DEFINE_GUID(IID_IPropertyStore,0x886d8eeb,0x8cf2,0x4446,0x8d,0x02,0xcd,0xba,0x1d
// Property key
typedef struct _tagpropertykey {
- GUID fmtid;
- DWORD pid;
+ GUID fmtid;
+ DWORD pid;
} PROPERTYKEY;
#define REFPROPERTYKEY const PROPERTYKEY &
@@ -59,78 +59,77 @@ typedef struct tagPROPVARIANT 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;
+ 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
+ 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
+ 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;
+ 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
+ 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;
+ // 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__
diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp
index 91c4e2399c..c630129ea9 100644
--- a/backends/taskbar/win32/win32-taskbar.cpp
+++ b/backends/taskbar/win32/win32-taskbar.cpp
@@ -28,13 +28,13 @@
// Needed for taskbar functions
#if defined(__GNUC__)
#ifdef __MINGW32__
- #include "backends/taskbar/win32/mingw-compat.h"
+ #include "backends/taskbar/win32/mingw-compat.h"
#else
- #error Only compilation with MingW is supported
+ #error Only compilation with MingW is supported
#endif
#else
- // Default MSVC headers for ITaskbarList3 and IShellLink
- #include <SDKDDKVer.h>
+ // Default MSVC headers for ITaskbarList3 and IShellLink
+ #include <SDKDDKVer.h>
#endif
#include <shlobj.h>
@@ -71,10 +71,10 @@ void Win32TaskbarManager::init() {
// Try creating instance (on fail, _taskbar will contain NULL)
HRESULT hr = CoCreateInstance(CLSID_TaskbarList,
- 0,
- CLSCTX_INPROC_SERVER,
- IID_ITaskbarList3,
- reinterpret_cast<void**> (&(_taskbar)));
+ 0,
+ CLSCTX_INPROC_SERVER,
+ IID_ITaskbarList3,
+ reinterpret_cast<void**> (&(_taskbar)));
if (SUCCEEDED(hr)) {
// Initialize taskbar object
@@ -105,8 +105,8 @@ void Win32TaskbarManager::setOverlayIcon(const Common::String &name, const Commo
HICON pIcon = (HICON)::LoadImage(NULL, path.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
if (!pIcon) {
- warning("[Win32TaskbarManager::setOverlayIcon] Cannot load icon!");
- return;
+ warning("[Win32TaskbarManager::setOverlayIcon] Cannot load icon!");
+ return;
}
// Sets the overlay icon
@@ -206,18 +206,18 @@ Common::String Win32TaskbarManager::getIconPath(Common::String target) {
}
bool Win32TaskbarManager::isWin7OrLater() {
- OSVERSIONINFOEX versionInfo;
- DWORDLONG conditionMask = 0;
+ OSVERSIONINFOEX versionInfo;
+ DWORDLONG conditionMask = 0;
- ZeroMemory(&versionInfo, sizeof(OSVERSIONINFOEX));
- versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- versionInfo.dwMajorVersion = 6;
- versionInfo.dwMinorVersion = 1;
+ ZeroMemory(&versionInfo, sizeof(OSVERSIONINFOEX));
+ versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ versionInfo.dwMajorVersion = 6;
+ versionInfo.dwMinorVersion = 1;
- VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
- VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
+ VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
+ VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
- return VerifyVersionInfo(&versionInfo, VER_MAJORVERSION | VER_MINORVERSION, conditionMask);
+ return VerifyVersionInfo(&versionInfo, VER_MAJORVERSION | VER_MINORVERSION, conditionMask);
}
LPWSTR Win32TaskbarManager::ansiToUnicode(const char *s) {