From 71e457783eb830982aa5f89a3f72ea741f32ffef Mon Sep 17 00:00:00 2001 From: Littleboy Date: Tue, 26 Apr 2011 12:47:03 -0400 Subject: BACKENDS: Add generic TaskbarManager class to handle taskbar integration --- backends/modular-backend.cpp | 3 ++ backends/modular-backend.h | 10 +++-- backends/platform/sdl/sdl.cpp | 17 ++++++++ backends/platform/sdl/sdl.h | 6 ++- common/taskbar.h | 98 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 128 insertions(+), 6 deletions(-) create mode 100644 common/taskbar.h diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index 525170d685..70c352303c 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -33,6 +33,7 @@ ModularBackend::ModularBackend() : _mutexManager(0), + _taskbarManager(0), _graphicsManager(0), _mixer(0) { @@ -43,6 +44,8 @@ ModularBackend::~ModularBackend() { _graphicsManager = 0; delete _mixer; _mixer = 0; + delete _taskbarManager; + _taskbarManager = 0; delete _mutexManager; _mutexManager = 0; } diff --git a/backends/modular-backend.h b/backends/modular-backend.h index 3593130bf5..124a6ad807 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -27,20 +27,21 @@ class GraphicsManager; class MutexManager; +class TaskbarManager; /** * Base class for modular backends. - * + * * It wraps most functions to their manager equivalent, but not * all OSystem functions are implemented here. - * + * * A backend derivated from this class, will need to implement * these functions on its own: * OSystem::pollEvent() * OSystem::getMillis() * OSystem::delayMillis() * OSystem::getTimeAndDate() - * + * * And, it should also initialize all the managers variables * declared in this class, or override their related functions. */ @@ -111,7 +112,7 @@ public: virtual Common::HardwareKeySet *getHardwareKeySet() { return 0; } //@} - + /** @name Mutex handling */ //@{ @@ -141,6 +142,7 @@ protected: /** @name Managers variables */ //@{ + TaskbarManager *_taskbarManager; MutexManager *_mutexManager; GraphicsManager *_graphicsManager; Audio::Mixer *_mixer; diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index fd27c82797..4520b74861 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -31,6 +31,7 @@ #include "backends/platform/sdl/sdl.h" #include "common/config-manager.h" #include "common/EventRecorder.h" +#include "common/taskbar.h" #include "common/textconsole.h" #include "backends/saves/default/default-saves.h" @@ -125,6 +126,9 @@ void OSystem_SDL::init() { if (_timerManager == 0) _timerManager = new SdlTimerManager(); + if (_taskbarManager == 0) + _taskbarManager = new Common::TaskbarManager(); + #ifdef USE_OPENGL // Setup a list with both SDL and OpenGL graphics modes setupGraphicsModes(); @@ -209,6 +213,19 @@ void OSystem_SDL::initBackend() { ModularBackend::initBackend(); } +void OSystem_SDL::engineInit() { + // Add the started engine to the list of recent tasks + _taskbarManager->addRecent(ConfMan.getActiveDomainName(), ConfMan.get("description")); + + // Set the overlay icon the current running engine + _taskbarManager->setOverlayIcon(ConfMan.getActiveDomainName(), ConfMan.get("description")); +} + +void OSystem_SDL::engineDone() { + // Remove overlay icon + _taskbarManager->setOverlayIcon("", ""); +} + void OSystem_SDL::initSDL() { // Check if SDL has not been initialized if (!_initedSDL) { diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 9c08752054..19f913ef45 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -30,7 +30,7 @@ #include "backends/events/sdl/sdl-events.h" #include "backends/log/log.h" -/** +/** * Base OSystem class for all SDL ports. */ class OSystem_SDL : public ModularBackend { @@ -38,7 +38,7 @@ public: OSystem_SDL(); virtual ~OSystem_SDL(); - /** + /** * Pre-initialize backend. It should be called after * instantiating the backend. Early needed managers are * created here. @@ -54,6 +54,8 @@ public: // Override functions from ModularBackend and OSystem virtual void initBackend(); + virtual void engineInit(); + virtual void engineDone(); virtual Common::HardwareKeySet *getHardwareKeySet(); virtual void quit(); virtual void fatalError(); diff --git a/common/taskbar.h b/common/taskbar.h new file mode 100644 index 0000000000..e29fcdcb36 --- /dev/null +++ b/common/taskbar.h @@ -0,0 +1,98 @@ +/* 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$ + */ + +#ifndef COMMON_TASKBAR_MANAGER_H +#define COMMON_TASKBAR_MANAGER_H + +#include "common/str.h" + +namespace Common { + +class TaskbarManager { +public: + /** + * Values representing the taskbar progress state + */ + enum TaskbarProgressState { + NoProgress = 0, + Indeterminate = 1, + Normal = 2, + Error = 4, + Paused = 8 + }; + + TaskbarManager() {} + virtual ~TaskbarManager() {} + + /** + * Sets an overlay icon on the taskbar icon. + * + * When an empty name is given, no icon is shown + * and the current overlay icon (if any) is removed + * + * @param name Path to the icon + * @param description The description + * + * @note on Windows, the icon should be an ICO file + */ + virtual void setOverlayIcon(const String &name, const String &description) {} + + /** + * Sets a progress value on the taskbar icon + * + * @param val The current progress value + * @param max The maximum progress value + */ + virtual void setProgressValue(int val, int max) {} + + /** + * Sets the progress state on the taskbar icon + * + * State can be any of the following: + * - NoProgress: disable display of progress state + * - Indeterminate + * - Normal + * - Error + * - Paused + * + * @param state The progress state + */ + virtual void setProgressState(TaskbarProgressState state) {} + + /** + * Adds an engine to the recent items list + * + * Path is automatically set to the current executable path, + * an icon name is generated (with fallback to default icon) + * and the command line is set to start the engine on click. + * + * @param name The target name. + * @param description The description. + */ + virtual void addRecent(const String &name, const String &description) {} +}; + +} // End of namespace Common + +#endif // COMMON_TASKBAR_MANAGER_H -- cgit v1.2.3 From f67975a487704828a2005a26ed6725b01c2554db Mon Sep 17 00:00:00 2001 From: Littleboy Date: Tue, 26 Apr 2011 12:48:01 -0400 Subject: BACKENDS: Add win32 stubs for taskbar integration --- backends/module.mk | 3 +- backends/platform/sdl/win32/win32.cpp | 6 +++- backends/taskbar/win32/win32-taskbar.cpp | 54 ++++++++++++++++++++++++++++++++ backends/taskbar/win32/win32-taskbar.h | 45 ++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 backends/taskbar/win32/win32-taskbar.cpp create mode 100644 backends/taskbar/win32/win32-taskbar.h diff --git a/backends/module.mk b/backends/module.mk index d1feae4317..7d5b86f561 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -89,7 +89,8 @@ MODULE_OBJS += \ fs/windows/windows-fs.o \ fs/windows/windows-fs-factory.o \ midi/windows.o \ - plugins/win32/win32-provider.o + plugins/win32/win32-provider.o \ + taskbar/win32/win32-taskbar.o endif ifdef AMIGAOS diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 5b14be4417..0fd2fbbd1d 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -36,6 +36,7 @@ #include "backends/platform/sdl/win32/win32.h" #include "backends/fs/windows/windows-fs-factory.h" +#include "backends/taskbar/win32/win32-taskbar.h" #include "common/memstream.h" @@ -81,9 +82,12 @@ void OSystem_Win32::init() { } #endif - // Initialze File System Factory + // Initialize File System Factory _fsFactory = new WindowsFilesystemFactory(); + // Initialize task bar manager + _taskbarManager = new Win32TaskbarManager(); + // Invoke parent implementation of this method OSystem_SDL::init(); } diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp new file mode 100644 index 0000000000..7f76791dfa --- /dev/null +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -0,0 +1,54 @@ +/* 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$ + * + * Original code from EcWin7 - Copyright (C) 2010 Emanuele Colombo + * https://code.google.com/p/dukto/ + */ + +#include "common/scummsys.h" + +#include "common/textconsole.h" + +#include "backends/taskbar/win32/win32-taskbar.h" + +Win32TaskbarManager::Win32TaskbarManager() { +} + +Win32TaskbarManager::~Win32TaskbarManager() { +} + +void Win32TaskbarManager::setOverlayIcon(const Common::String &name, const Common::String &description) { + warning("[Win32TaskbarManager::setOverlayIcon] Not implemented"); +} + +void Win32TaskbarManager::setProgressValue(int val, int max) { + warning("[Win32TaskbarManager::setProgressValue] Not implemented"); +} + +void Win32TaskbarManager::setProgressState(TaskbarProgressState state) { + warning("[Win32TaskbarManager::setProgressState] Not implemented"); +} + +void Win32TaskbarManager::addRecent(const Common::String &name, const Common::String &description) { + warning("[Win32TaskbarManager::addRecent] Not implemented"); +} \ No newline at end of file diff --git a/backends/taskbar/win32/win32-taskbar.h b/backends/taskbar/win32/win32-taskbar.h new file mode 100644 index 0000000000..20c1a8d383 --- /dev/null +++ b/backends/taskbar/win32/win32-taskbar.h @@ -0,0 +1,45 @@ +/* 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$ + * + * 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 + +#include "common/str.h" +#include "common/taskbar.h" + +class Win32TaskbarManager : public Common::TaskbarManager { +public: + Win32TaskbarManager(); + virtual ~Win32TaskbarManager(); + + virtual void setOverlayIcon(const Common::String &name, const Common::String &description); + virtual void setProgressValue(int val, int max); + virtual void setProgressState(TaskbarProgressState state); + virtual void addRecent(const Common::String &name, const Common::String &description); +}; + +#endif // BACKEND_WIN32_TASKBAR_H -- cgit v1.2.3 From c0ec09ac66162d253ab16e1fb9b3a85dfdd176d7 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Thu, 31 Mar 2011 04:46:36 -0400 Subject: BACKENDS: Implement Win32 taskbar progress state and recent list --- backends/platform/sdl/win32/win32.cpp | 1 + backends/taskbar/win32/win32-taskbar.cpp | 144 +++++++++++++++++++++++++++++-- backends/taskbar/win32/win32-taskbar.h | 19 +++- common/taskbar.h | 16 ++-- 4 files changed, 164 insertions(+), 16 deletions(-) diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 0fd2fbbd1d..bb254786d5 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -87,6 +87,7 @@ void OSystem_Win32::init() { // Initialize task bar manager _taskbarManager = new Win32TaskbarManager(); + ((Win32TaskbarManager *)_taskbarManager)->init(); // Invoke parent implementation of this method OSystem_SDL::init(); diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index 7f76791dfa..1ddbde10bc 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -25,30 +25,160 @@ * https://code.google.com/p/dukto/ */ -#include "common/scummsys.h" +#ifdef WIN32 -#include "common/textconsole.h" +// Needed for taskbar functions +#include +#include #include "backends/taskbar/win32/win32-taskbar.h" +#include "common/config-manager.h" +#include "common/textconsole.h" + +#include + +// System.Title property key, values taken from http://msdn.microsoft.com/en-us/library/bb787584.aspx +const PROPERTYKEY PKEY_Title = { /* fmtid = */ { 0xF29F85E0, 0x4FF9, 0x1068, { 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 } }, /* propID = */ 2 }; + Win32TaskbarManager::Win32TaskbarManager() { + _taskbar = NULL; } Win32TaskbarManager::~Win32TaskbarManager() { + if (_taskbar) + _taskbar->Release(); + _taskbar = NULL; + + CoUninitialize(); +} + +void Win32TaskbarManager::init() { + // Do nothing if not running on Windows 7 of later + if (!isWin7OrLater()) + return; + + CoInitialize(NULL); + + // Try creating instance (on fail, _taskbar will contain NULL) + HRESULT hr = CoCreateInstance(CLSID_TaskbarList, + 0, + CLSCTX_INPROC_SERVER, + IID_ITaskbarList3, + reinterpret_cast (&(_taskbar))); + + if (SUCCEEDED(hr)) { + // Initialize taskbar object + if (FAILED(_taskbar->HrInit())) { + _taskbar->Release(); + _taskbar = NULL; + } + } else { + warning("[Win32TaskbarManager::init] Cannot create taskbar instance"); + } } void Win32TaskbarManager::setOverlayIcon(const Common::String &name, const Common::String &description) { + if (_taskbar == NULL) + return; + warning("[Win32TaskbarManager::setOverlayIcon] Not implemented"); } -void Win32TaskbarManager::setProgressValue(int val, int max) { - warning("[Win32TaskbarManager::setProgressValue] Not implemented"); +void Win32TaskbarManager::setProgressValue(int completed, int total) { + if (_taskbar == NULL) + return; + + _taskbar->SetProgressValue(getHwnd(), completed, total); } void Win32TaskbarManager::setProgressState(TaskbarProgressState state) { - warning("[Win32TaskbarManager::setProgressState] Not implemented"); + if (_taskbar == NULL) + return; + + _taskbar->SetProgressState(getHwnd(), (TBPFLAG)state); } void Win32TaskbarManager::addRecent(const Common::String &name, const Common::String &description) { - warning("[Win32TaskbarManager::addRecent] Not implemented"); -} \ No newline at end of file + if (_taskbar == NULL) + return; + + // ANSI version doesn't seem to work correctly with Win7 jump lists, so explicitly use Unicode interface. + IShellLinkW *link; + + // Get the ScummVM executable path. + WCHAR path[MAX_PATH]; + GetModuleFileNameW(NULL, path, MAX_PATH); + + // Create a shell link. + if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC, IID_PPV_ARGS(&link)))) { + // Convert game name and description to Unicode. + LPWSTR game = ansiToUnicode(name.c_str()); + LPWSTR desc = ansiToUnicode(description.c_str()); + + // Set link properties. + link->SetPath(path); + link->SetArguments(game); + link->SetIconLocation(path, 0); // There's no way to get a game-specific icon, is there? + + // The link's display name must be set via property store. + IPropertyStore* propStore; + HRESULT hr = link->QueryInterface(&propStore); + if (SUCCEEDED(hr)) { + PROPVARIANT pv; + pv.vt = VT_LPWSTR; + pv.pwszVal = desc; + + hr = propStore->SetValue(PKEY_Title, pv); + + propStore->Commit(); + propStore->Release(); + } + + // 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; + delete[] desc; + } +} + +bool Win32TaskbarManager::isWin7OrLater() { + OSVERSIONINFOEX versionInfo; + DWORDLONG conditionMask = 0; + + 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); + + return VerifyVersionInfo(&versionInfo, VER_MAJORVERSION | VER_MINORVERSION, conditionMask); +} + +LPWSTR Win32TaskbarManager::ansiToUnicode(const char *s) { + DWORD size = MultiByteToWideChar(0, 0, s, -1, NULL, 0); + + if (size > 0) { + LPWSTR result = new WCHAR[size]; + if (MultiByteToWideChar(0, 0, s, -1, result, size) != 0) + return result; + } + + return NULL; +} + +HWND Win32TaskbarManager::getHwnd() { + SDL_SysWMinfo wmi; + SDL_VERSION(&wmi.version); + + if(!SDL_GetWMInfo(&wmi)) + return NULL; + + return wmi.window; +} + +#endif diff --git a/backends/taskbar/win32/win32-taskbar.h b/backends/taskbar/win32/win32-taskbar.h index 20c1a8d383..d0871d36d2 100644 --- a/backends/taskbar/win32/win32-taskbar.h +++ b/backends/taskbar/win32/win32-taskbar.h @@ -28,18 +28,35 @@ #ifndef BACKEND_WIN32_TASKBAR_H #define BACKEND_WIN32_TASKBAR_H +#ifdef WIN32 + #include "common/str.h" #include "common/taskbar.h" +struct ITaskbarList3; + class Win32TaskbarManager : public Common::TaskbarManager { public: Win32TaskbarManager(); virtual ~Win32TaskbarManager(); + void init(); + virtual void setOverlayIcon(const Common::String &name, const Common::String &description); - virtual void setProgressValue(int val, int max); + virtual void setProgressValue(int completed, int total); virtual void setProgressState(TaskbarProgressState state); virtual void addRecent(const Common::String &name, const Common::String &description); + +private: + HWND _hwnd; + ITaskbarList3 *_taskbar; + + // Helper functions + bool isWin7OrLater(); + LPWSTR ansiToUnicode(const char *s); + HWND getHwnd(); }; +#endif + #endif // BACKEND_WIN32_TASKBAR_H diff --git a/common/taskbar.h b/common/taskbar.h index e29fcdcb36..ea1d218724 100644 --- a/common/taskbar.h +++ b/common/taskbar.h @@ -35,11 +35,11 @@ public: * Values representing the taskbar progress state */ enum TaskbarProgressState { - NoProgress = 0, - Indeterminate = 1, - Normal = 2, - Error = 4, - Paused = 8 + kTaskbarNoProgress = 0, + kTaskbarIndeterminate = 1, + kTaskbarNormal = 2, + kTaskbarError = 4, + kTaskbarPaused = 8 }; TaskbarManager() {} @@ -61,10 +61,10 @@ public: /** * Sets a progress value on the taskbar icon * - * @param val The current progress value - * @param max The maximum progress value + * @param completed The current progress value. + * @param total The maximum progress value. */ - virtual void setProgressValue(int val, int max) {} + virtual void setProgressValue(int completed, int total) {} /** * Sets the progress state on the taskbar icon -- cgit v1.2.3 From 0fd56852b65aed463d79cddc9545511107296809 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Thu, 31 Mar 2011 06:14:30 -0400 Subject: BACKENDS: Add support for custom game icon (recent items list and icon overlay) --- backends/taskbar/win32/win32-taskbar.cpp | 60 +++++++++++++++++++++++++++++--- backends/taskbar/win32/win32-taskbar.h | 3 +- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index 1ddbde10bc..85c87f3680 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -31,12 +31,18 @@ #include #include +// For Bitmap and overlay icons +#include +using namespace Gdiplus; + +// For HWND +#include + #include "backends/taskbar/win32/win32-taskbar.h" #include "common/config-manager.h" #include "common/textconsole.h" - -#include +#include "common/file.h" // System.Title property key, values taken from http://msdn.microsoft.com/en-us/library/bb787584.aspx const PROPERTYKEY PKEY_Title = { /* fmtid = */ { 0xF29F85E0, 0x4FF9, 0x1068, { 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 } }, /* propID = */ 2 }; @@ -82,7 +88,25 @@ void Win32TaskbarManager::setOverlayIcon(const Common::String &name, const Commo if (_taskbar == NULL) return; - warning("[Win32TaskbarManager::setOverlayIcon] Not implemented"); + if (name.empty()) { + _taskbar->SetOverlayIcon(getHwnd(), NULL, L""); + return; + } + + // Compute full icon path + Common::String path = getIconPath(name); + if (path.empty()) + return; + + HICON pIcon = (HICON)::LoadImage(NULL, path.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE); + + // Sets the overlay icon + LPWSTR desc = ansiToUnicode(description.c_str()); + _taskbar->SetOverlayIcon(getHwnd(), pIcon, desc); + + DestroyIcon(pIcon); + + delete[] desc; } void Win32TaskbarManager::setProgressValue(int completed, int total) { @@ -119,7 +143,17 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St // Set link properties. link->SetPath(path); link->SetArguments(game); - link->SetIconLocation(path, 0); // There's no way to get a game-specific icon, is there? + + Common::String iconPath = getIconPath(name); + if (iconPath.empty()) { + link->SetIconLocation(path, 0); // No game-specific icon available + } else { + LPWSTR icon = ansiToUnicode(iconPath.c_str()); + + link->SetIconLocation(icon, 0); + + delete[] icon; + } // The link's display name must be set via property store. IPropertyStore* propStore; @@ -144,6 +178,24 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St } } +Common::String Win32TaskbarManager::getIconPath(Common::String target) { + // Get extra path + 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 + filename = ConfMan.get("gameid") + ".ico"; + + if (!Common::File::exists(filename)) + return ""; + } + + return extra + filename; +} + bool Win32TaskbarManager::isWin7OrLater() { OSVERSIONINFOEX versionInfo; DWORDLONG conditionMask = 0; diff --git a/backends/taskbar/win32/win32-taskbar.h b/backends/taskbar/win32/win32-taskbar.h index d0871d36d2..bdd45a942d 100644 --- a/backends/taskbar/win32/win32-taskbar.h +++ b/backends/taskbar/win32/win32-taskbar.h @@ -48,9 +48,10 @@ public: virtual void addRecent(const Common::String &name, const Common::String &description); private: - HWND _hwnd; ITaskbarList3 *_taskbar; + Common::String getIconPath(Common::String target); + // Helper functions bool isWin7OrLater(); LPWSTR ansiToUnicode(const char *s); -- cgit v1.2.3 From cd7822a29f22fd290a86281d65b965d32f667a49 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Thu, 31 Mar 2011 06:35:16 -0400 Subject: BACKENDS: Add engine-level accessor for TaskbarManager --- backends/modular-backend.cpp | 5 +++++ backends/modular-backend.h | 1 + common/system.h | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index 70c352303c..a2710bc1cf 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -238,3 +238,8 @@ void ModularBackend::displayMessageOnOSD(const char *msg) { void ModularBackend::quit() { exit(0); } + +Common::TaskbarManager *ModularBackend::getTaskbarManager() { + assert(_taskbarManager); + return _taskbarManager; +} diff --git a/backends/modular-backend.h b/backends/modular-backend.h index 124a6ad807..6b5bfff989 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -134,6 +134,7 @@ public: //@{ virtual void quit(); + virtual TaskbarManager *getTaskbarManager(); virtual void displayMessageOnOSD(const char *msg); //@} diff --git a/common/system.h b/common/system.h index d26bc593aa..f556fa22f8 100644 --- a/common/system.h +++ b/common/system.h @@ -42,6 +42,7 @@ struct Rect; class SaveFileManager; class SearchSet; class String; +class TaskbarManager; class TimerManager; class SeekableReadStream; class WriteStream; @@ -1047,6 +1048,14 @@ public: return _savefileManager; } + /** + * Returns the TaskbarManager, used to handle progress bars, + * icon overlay, tasks and recent items list on the taskbar. + * + * @return the TaskbarManager for the current architecture + */ + virtual Common::TaskbarManager *getTaskbarManager() = 0; + /** * Returns the FilesystemFactory object, depending on the current architecture. * -- cgit v1.2.3 From 2be35013f1d014620f222da9ed32110ce77814da Mon Sep 17 00:00:00 2001 From: Littleboy Date: Thu, 31 Mar 2011 06:35:43 -0400 Subject: BACKENDS: Add progress to MassAdd dialog --- gui/massadd.cpp | 9 +++++++++ gui/massadd.h | 1 + 2 files changed, 10 insertions(+) diff --git a/gui/massadd.cpp b/gui/massadd.cpp index b0adce3f47..1578e75b25 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -24,6 +24,7 @@ #include "common/config-manager.h" #include "common/debug.h" #include "common/system.h" +#include "common/taskbar.h" #include "common/translation.h" #include "gui/launcher.h" // For addGameToConf() @@ -60,6 +61,7 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir) : Dialog("MassAdd"), _dirsScanned(0), _oldGamesCount(0), + _dirTotal(0), _okButton(0), _dirProgressText(0), _gameProgressText(0) { @@ -130,6 +132,9 @@ struct GameDescLess { void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { + // Remove progress bar from taskbar + g_system->getTaskbarManager()->setProgressState(Common::TaskbarManager::kTaskbarNoProgress); + // FIXME: It's a really bad thing that we use two arbitrary constants if (cmd == kOkCmd) { // Sort the detected games. This is not strictly necessary, but nice for @@ -226,10 +231,14 @@ void MassAddDialog::handleTickle() { for (Common::FSList::const_iterator file = files.begin(); file != files.end(); ++file) { if (file->isDirectory()) { _scanStack.push(*file); + + _dirTotal++; } } _dirsScanned++; + + g_system->getTaskbarManager()->setProgressValue(_dirsScanned, _dirTotal); } diff --git a/gui/massadd.h b/gui/massadd.h index 15cef7ba68..7350213835 100644 --- a/gui/massadd.h +++ b/gui/massadd.h @@ -60,6 +60,7 @@ private: int _dirsScanned; int _oldGamesCount; + int _dirTotal; Widget *_okButton; StaticTextWidget *_dirProgressText; -- cgit v1.2.3 From 2348eeed4c4c5f6bb55d9d566d7adbfa2f0c1136 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Tue, 26 Apr 2011 13:30:13 -0400 Subject: BACKENDS: Add taskbar integration compat header for MingW --- backends/taskbar/win32/mingw-compat.h | 140 +++++++++++++++++++++++++++++++ backends/taskbar/win32/win32-taskbar.cpp | 35 +++++--- backends/taskbar/win32/win32-taskbar.h | 4 +- 3 files changed, 163 insertions(+), 16 deletions(-) create mode 100644 backends/taskbar/win32/mingw-compat.h 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 +#include +#include +#include +#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 +#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 +#endif #include -// For Bitmap and overlay icons -#include -using namespace Gdiplus; - // For HWND #include @@ -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 (&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 (&(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" -- cgit v1.2.3 From fe347e4339e25607c4f35ca4892ef9f4b4211108 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Tue, 26 Apr 2011 13:31:13 -0400 Subject: TOOLS: Add ole32.lib and uuid.lib to Code::Blocks linked libraries --- devtools/create_project/create_project.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index 29bc5bfcd5..aafbe7585b 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -364,6 +364,11 @@ int main(int argc, char *argv[]) { provider = new CreateProjectTool::CodeBlocksProvider(globalWarnings, projectWarnings); + + // Those libraries are automatically added by MSVC, but we need to add them manually with mingw + setup.libraries.push_back("ole32"); + setup.libraries.push_back("uuid"); + break; case kProjectMSVC: -- cgit v1.2.3 From a523ade3329a36a50c75161279ced7c0d754906f Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 1 Apr 2011 01:04:46 -0400 Subject: BACKENDS: Add stubs for unity taskbar class --- backends/module.mk | 3 +- backends/taskbar/unity/unity-taskbar.cpp | 56 ++++++++++++++++++++++++++++++++ backends/taskbar/unity/unity-taskbar.h | 49 ++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 backends/taskbar/unity/unity-taskbar.cpp create mode 100644 backends/taskbar/unity/unity-taskbar.h diff --git a/backends/module.mk b/backends/module.mk index 7d5b86f561..9869587a51 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -75,7 +75,8 @@ MODULE_OBJS += \ fs/posix/posix-fs.o \ fs/posix/posix-fs-factory.o \ plugins/posix/posix-provider.o \ - saves/posix/posix-saves.o + saves/posix/posix-saves.o \ + taskbar/unity/unity-taskbar.o endif ifdef MACOSX diff --git a/backends/taskbar/unity/unity-taskbar.cpp b/backends/taskbar/unity/unity-taskbar.cpp new file mode 100644 index 0000000000..98616a7587 --- /dev/null +++ b/backends/taskbar/unity/unity-taskbar.cpp @@ -0,0 +1,56 @@ +/* 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$ + * + */ + +#if defined(UNIX) + +#include "backends/taskbar/unity/unity-taskbar.h" + +#include "common/config-manager.h" +#include "common/textconsole.h" +#include "common/file.h" + +UnityTaskbarManager::UnityTaskbarManager() { +} + +UnityTaskbarManager::~UnityTaskbarManager() { +} + +void UnityTaskbarManager::setOverlayIcon(Common::String name, Common::String description) { + warning("[UnityTaskbarManager::setOverlayIcon] Not implemented"); +} + +void UnityTaskbarManager::setProgressValue(int completed, int total) { + warning("[UnityTaskbarManager::setProgressValue] Not implemented"); +} + +void UnityTaskbarManager::setProgressState(TaskbarProgressState state) { + warning("[UnityTaskbarManager::setProgressState] Not implemented"); +} + +void UnityTaskbarManager::addRecent(Common::String name, Common::String description) { + warning("[UnityTaskbarManager::addRecent] Not implemented"); +} + +#endif diff --git a/backends/taskbar/unity/unity-taskbar.h b/backends/taskbar/unity/unity-taskbar.h new file mode 100644 index 0000000000..a49f369cac --- /dev/null +++ b/backends/taskbar/unity/unity-taskbar.h @@ -0,0 +1,49 @@ +/* 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$ + * + */ + +#ifndef BACKEND_UNITY_TASKBAR_H +#define BACKEND_UNITY_TASKBAR_H + +#if defined(UNIX) + +#include "common/str.h" +#include "common/taskbar.h" + +class UnityTaskbarManager : public Common::TaskbarManager { +public: + UnityTaskbarManager(); + virtual ~UnityTaskbarManager(); + + virtual void setOverlayIcon(Common::String name, Common::String description); + virtual void setProgressValue(int completed, int total); + virtual void setProgressState(TaskbarProgressState state); + virtual void addRecent(Common::String name, Common::String description); + +private: +}; + +#endif + +#endif // BACKEND_UNITY_TASKBAR_H -- cgit v1.2.3 From c3d9c6afa57055705849359deaac7c5748d66fe1 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 1 Apr 2011 01:30:12 -0400 Subject: BACKENDS: Add use flag for taskbar integration --- backends/platform/sdl/win32/win32.cpp | 4 +++- backends/taskbar/unity/unity-taskbar.cpp | 2 +- backends/taskbar/unity/unity-taskbar.h | 2 +- backends/taskbar/win32/win32-taskbar.cpp | 2 +- backends/taskbar/win32/win32-taskbar.h | 2 +- configure | 30 ++++++++++++++++++++++++++++++ devtools/create_project/create_project.cpp | 1 + 7 files changed, 38 insertions(+), 5 deletions(-) diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index bb254786d5..0a6702b6d9 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -85,9 +85,11 @@ void OSystem_Win32::init() { // Initialize File System Factory _fsFactory = new WindowsFilesystemFactory(); - // Initialize task bar manager +#if defined(USE_TASKBAR) + // Initialize taskbar manager _taskbarManager = new Win32TaskbarManager(); ((Win32TaskbarManager *)_taskbarManager)->init(); +#endif // Invoke parent implementation of this method OSystem_SDL::init(); diff --git a/backends/taskbar/unity/unity-taskbar.cpp b/backends/taskbar/unity/unity-taskbar.cpp index 98616a7587..4a074abca2 100644 --- a/backends/taskbar/unity/unity-taskbar.cpp +++ b/backends/taskbar/unity/unity-taskbar.cpp @@ -23,7 +23,7 @@ * */ -#if defined(UNIX) +#if defined(UNIX) && defined(USE_TASKBAR) #include "backends/taskbar/unity/unity-taskbar.h" diff --git a/backends/taskbar/unity/unity-taskbar.h b/backends/taskbar/unity/unity-taskbar.h index a49f369cac..cd8efdaf2a 100644 --- a/backends/taskbar/unity/unity-taskbar.h +++ b/backends/taskbar/unity/unity-taskbar.h @@ -26,7 +26,7 @@ #ifndef BACKEND_UNITY_TASKBAR_H #define BACKEND_UNITY_TASKBAR_H -#if defined(UNIX) +#if defined(UNIX) && defined(USE_TASKBAR) #include "common/str.h" #include "common/taskbar.h" diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index 768bf5b64e..91c4e2399c 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -23,7 +23,7 @@ * */ -#if defined(WIN32) +#if defined(WIN32) && defined(USE_TASKBAR) // Needed for taskbar functions #if defined(__GNUC__) diff --git a/backends/taskbar/win32/win32-taskbar.h b/backends/taskbar/win32/win32-taskbar.h index f9ce9c16fc..7d963c19ca 100644 --- a/backends/taskbar/win32/win32-taskbar.h +++ b/backends/taskbar/win32/win32-taskbar.h @@ -26,7 +26,7 @@ #ifndef BACKEND_WIN32_TASKBAR_H #define BACKEND_WIN32_TASKBAR_H -#if defined(WIN32) +#if defined(WIN32) && defined(USE_TASKBAR) #include "common/str.h" #include "common/taskbar.h" diff --git a/configure b/configure index cb06643b34..fca8791b40 100755 --- a/configure +++ b/configure @@ -138,6 +138,7 @@ _fluidsynth=auto _opengl=auto _opengles=auto _readline=auto +_taskbar=auto # Default option behaviour yes/no _debug_build=auto _release_build=auto @@ -771,6 +772,9 @@ Optional Libraries: --with-readline-prefix=DIR Prefix where readline is installed (optional) --disable-readline disable readline support in text console [autodetect] + --with-unity-prefix=DIR Prefix where libunity is installed (optional) + --disable-unity disable unity[autodetect] + Some influential environment variables: LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory @@ -818,6 +822,8 @@ for ac_option in $@; do --disable-fluidsynth) _fluidsynth=no ;; --enable-readline) _readline=yes ;; --disable-readline) _readline=no ;; + --enable-taskbar) _taskbar=yes ;; + --disable-taskbar) _taskbar=no ;; --enable-opengl) _opengl=yes ;; --disable-opengl) _opengl=no ;; --enable-verbose-build) _verbose_build=yes ;; @@ -893,6 +899,11 @@ for ac_option in $@; do READLINE_CFLAGS="-I$arg/include" READLINE_LIBS="-L$arg/lib" ;; + --with-unity-prefix=*) + arg=`echo $ac_option | cut -d '=' -f 2` + UNITY_CFLAGS="-I$arg/include" + UNITY_LIBS="-L$arg/lib" + ;; --with-opengl-prefix=*) arg=`echo $ac_option | cut -d '=' -f 2` OPENGL_CFLAGS="-I$arg/include" @@ -2920,6 +2931,25 @@ define_in_config_h_if_yes "$_readline" 'USE_READLINE' define_in_config_h_if_yes "$_text_console" 'USE_TEXT_CONSOLE_FOR_DEBUGGER' +# +# Check for Unity if taskbar integration is enabled +# +echocheck "taskbar" +if test "$_taskbar" = auto ; then + _taskbar=no + cat > $TMPC << EOF +#include +int main(void) { return 0; } +EOF + cc_check $UNITY_CFLAGS $UNITY_LIBS -lunity && _taskbar=yes +fi +if test "$_taskbar" = yes ; then + LIBS="$LIBS $UNITY_LIBS -lunity" + INCLUDES="$INCLUDES $UNITY_CFLAGS" +fi +define_in_config_h_if_yes "$_taskbar" 'USE_TASKBAR' +echo "$_taskbar" + # # Check for OpenGL (ES) # diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index aafbe7585b..35d08561bf 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -779,6 +779,7 @@ const Feature s_features[] = { { "mt32emu", "USE_MT32EMU", "", true, "integrated MT-32 emulator" }, { "nasm", "USE_NASM", "", true, "IA-32 assembly support" }, // This feature is special in the regard, that it needs additional handling. { "opengl", "USE_OPENGL", "opengl32", true, "OpenGL support" }, + { "taskbar", "USE_TASKBAR", "", true, "Taskbar integration support" }, { "translation", "USE_TRANSLATION", "", true, "Translation support" }, { "vkeybd", "ENABLE_VKEYBD", "", false, "Virtual keyboard support"}, { "langdetect", "USE_DETECTLANG", "", true, "System language detection support" } // This feature actually depends on "translation", there -- cgit v1.2.3 From 984e1968bce3b4a23833719653a5d5751e5c8a04 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 1 Apr 2011 08:01:53 -0400 Subject: BACKENDS: Add WIP Unity support --- backends/platform/sdl/posix/posix.cpp | 6 +++++ backends/taskbar/unity/unity-taskbar.cpp | 43 +++++++++++++++++++++++++++----- backends/taskbar/unity/unity-taskbar.h | 7 ++++-- configure | 23 +++++++++-------- 4 files changed, 61 insertions(+), 18 deletions(-) diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index d757186134..f124a3af7d 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -33,6 +33,7 @@ #include "backends/platform/sdl/posix/posix.h" #include "backends/saves/posix/posix-saves.h" #include "backends/fs/posix/posix-fs-factory.h" +#include "backends/taskbar/unity/unity-taskbar.h" #include #include @@ -49,6 +50,11 @@ void OSystem_POSIX::init() { // Initialze File System Factory _fsFactory = new POSIXFilesystemFactory(); +#if defined(USE_TASKBAR) + // Initialize taskbar manager + _taskbarManager = new UnityTaskbarManager(); +#endif + // Invoke parent implementation of this method OSystem_SDL::init(); } diff --git a/backends/taskbar/unity/unity-taskbar.cpp b/backends/taskbar/unity/unity-taskbar.cpp index 4a074abca2..6c18f0940c 100644 --- a/backends/taskbar/unity/unity-taskbar.cpp +++ b/backends/taskbar/unity/unity-taskbar.cpp @@ -23,33 +23,64 @@ * */ +#include "common/scummsys.h" + #if defined(UNIX) && defined(USE_TASKBAR) #include "backends/taskbar/unity/unity-taskbar.h" -#include "common/config-manager.h" #include "common/textconsole.h" -#include "common/file.h" UnityTaskbarManager::UnityTaskbarManager() { + g_type_init(); + + _launcher = unity_launcher_entry_get_for_desktop_id("scummvm.desktop"); } UnityTaskbarManager::~UnityTaskbarManager() { } -void UnityTaskbarManager::setOverlayIcon(Common::String name, Common::String description) { +void UnityTaskbarManager::setOverlayIcon(const Common::String &name, const Common::String &description) { + if (_launcher == NULL) + return; + warning("[UnityTaskbarManager::setOverlayIcon] Not implemented"); } void UnityTaskbarManager::setProgressValue(int completed, int total) { - warning("[UnityTaskbarManager::setProgressValue] Not implemented"); + if (_launcher == NULL) + return; + + double percentage = (double)completed / (double)total; + unity_launcher_entry_set_progress(_launcher, percentage); + unity_launcher_entry_set_progress_visible(_launcher, TRUE); } void UnityTaskbarManager::setProgressState(TaskbarProgressState state) { - warning("[UnityTaskbarManager::setProgressState] Not implemented"); + if (_launcher == NULL) + return; + + switch (state) { + default: + warning("[UnityTaskbarManager::setProgressState] Unknown state / Not implemented (%d)", state); + // fallback to noprogress state + + case kTaskbarNoProgress: + unity_launcher_entry_set_progress_visible(_launcher, FALSE); + break; + + // Unity only support two progress states as of 3.0: visible or not visible + // We show progress in all of those states + case kTaskbarIndeterminate: + case kTaskbarNormal: + case kTaskbarError: + case kTaskbarPaused: + unity_launcher_entry_set_progress_visible(_launcher, TRUE); + break; + } } -void UnityTaskbarManager::addRecent(Common::String name, Common::String description) { +void UnityTaskbarManager::addRecent(const Common::String &name, const Common::String &description) { warning("[UnityTaskbarManager::addRecent] Not implemented"); } diff --git a/backends/taskbar/unity/unity-taskbar.h b/backends/taskbar/unity/unity-taskbar.h index cd8efdaf2a..0d0484c02e 100644 --- a/backends/taskbar/unity/unity-taskbar.h +++ b/backends/taskbar/unity/unity-taskbar.h @@ -31,17 +31,20 @@ #include "common/str.h" #include "common/taskbar.h" +#include + class UnityTaskbarManager : public Common::TaskbarManager { public: UnityTaskbarManager(); virtual ~UnityTaskbarManager(); - virtual void setOverlayIcon(Common::String name, Common::String description); + virtual void setOverlayIcon(const Common::String &name, const Common::String &description); virtual void setProgressValue(int completed, int total); virtual void setProgressState(TaskbarProgressState state); - virtual void addRecent(Common::String name, Common::String description); + virtual void addRecent(const Common::String &name, const Common::String &description); private: + UnityLauncherEntry *_launcher; }; #endif diff --git a/configure b/configure index fca8791b40..fc0e3c0e3e 100755 --- a/configure +++ b/configure @@ -138,7 +138,7 @@ _fluidsynth=auto _opengl=auto _opengles=auto _readline=auto -_taskbar=auto +_unity=auto # Default option behaviour yes/no _debug_build=auto _release_build=auto @@ -822,8 +822,8 @@ for ac_option in $@; do --disable-fluidsynth) _fluidsynth=no ;; --enable-readline) _readline=yes ;; --disable-readline) _readline=no ;; - --enable-taskbar) _taskbar=yes ;; - --disable-taskbar) _taskbar=no ;; + --enable-unity) _unity=yes ;; + --disable-unity) _unity=no ;; --enable-opengl) _opengl=yes ;; --disable-opengl) _opengl=no ;; --enable-verbose-build) _verbose_build=yes ;; @@ -2934,21 +2934,24 @@ define_in_config_h_if_yes "$_text_console" 'USE_TEXT_CONSOLE_FOR_DEBUGGER' # # Check for Unity if taskbar integration is enabled # -echocheck "taskbar" -if test "$_taskbar" = auto ; then - _taskbar=no +echocheck "unity" +# Unity has a lots of dependency, update the libs and cflags var with them +UNITY_LIBS="$UNITY_LIBS $(pkg-config --libs unity)" +UNITY_CFLAGS="$UNITY_CFLAGS $(pkg-config --cflags unity)" +if test "$_unity" = auto ; then + _unity=no cat > $TMPC << EOF #include int main(void) { return 0; } EOF - cc_check $UNITY_CFLAGS $UNITY_LIBS -lunity && _taskbar=yes + cc_check $UNITY_CFLAGS $UNITY_LIBS -lunity && _unity=yes fi -if test "$_taskbar" = yes ; then +if test "$_unity" = yes ; then LIBS="$LIBS $UNITY_LIBS -lunity" INCLUDES="$INCLUDES $UNITY_CFLAGS" fi -define_in_config_h_if_yes "$_taskbar" 'USE_TASKBAR' -echo "$_taskbar" +define_in_config_h_if_yes "$_unity" 'USE_TASKBAR' +echo "$_unity" # # Check for OpenGL (ES) -- cgit v1.2.3 From cd09b7e74fd9552901505082166b679c39f85ccc Mon Sep 17 00:00:00 2001 From: Littleboy Date: Sat, 2 Apr 2011 19:09:12 -0400 Subject: BACKENDS: Only update unity libs and cflags in auto mode --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index fc0e3c0e3e..37dfc807b7 100755 --- a/configure +++ b/configure @@ -2935,10 +2935,10 @@ define_in_config_h_if_yes "$_text_console" 'USE_TEXT_CONSOLE_FOR_DEBUGGER' # Check for Unity if taskbar integration is enabled # echocheck "unity" -# Unity has a lots of dependency, update the libs and cflags var with them -UNITY_LIBS="$UNITY_LIBS $(pkg-config --libs unity)" -UNITY_CFLAGS="$UNITY_CFLAGS $(pkg-config --cflags unity)" if test "$_unity" = auto ; then + # Unity has a lots of dependency, update the libs and cflags var with them + UNITY_LIBS="$UNITY_LIBS $(pkg-config --libs unity)" + UNITY_CFLAGS="$UNITY_CFLAGS $(pkg-config --cflags unity)" _unity=no cat > $TMPC << EOF #include -- cgit v1.2.3 From 6c14d8a95052b68c9f076d32e520c6befac3d959 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Mon, 4 Apr 2011 12:35:19 -0400 Subject: BACKENDS: Integrate glib main event loop - Unity needs a glib event loop to dispatch events. - Cleanup whitespace and indentation --- backends/platform/sdl/posix/posix.cpp | 9 ++- backends/platform/sdl/sdl.cpp | 2 +- backends/taskbar/unity/unity-taskbar.cpp | 35 ++++++++--- backends/taskbar/unity/unity-taskbar.h | 7 ++- backends/taskbar/win32/mingw-compat.h | 105 +++++++++++++++---------------- backends/taskbar/win32/win32-taskbar.cpp | 38 +++++------ 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 -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 + // Default MSVC headers for ITaskbarList3 and IShellLink + #include #endif #include @@ -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 (&(_taskbar))); + 0, + CLSCTX_INPROC_SERVER, + IID_ITaskbarList3, + reinterpret_cast (&(_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) { -- cgit v1.2.3 From e1dc9cdc0b89609753d3558f9603bef1cc12f1d8 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Mon, 4 Apr 2011 12:49:49 -0400 Subject: BACKENDS: Add support for count status to TaskbarManager - Show the number of found games when using the massadd dialog --- backends/taskbar/unity/unity-taskbar.cpp | 9 ++++ backends/taskbar/unity/unity-taskbar.h | 1 + common/taskbar.h | 74 ++++++++++++++++++-------------- gui/massadd.cpp | 12 +++--- 4 files changed, 59 insertions(+), 37 deletions(-) diff --git a/backends/taskbar/unity/unity-taskbar.cpp b/backends/taskbar/unity/unity-taskbar.cpp index 24347e382f..0de2167a83 100644 --- a/backends/taskbar/unity/unity-taskbar.cpp +++ b/backends/taskbar/unity/unity-taskbar.cpp @@ -88,6 +88,15 @@ void UnityTaskbarManager::addRecent(const Common::String &name, const Common::St warning("[UnityTaskbarManager::addRecent] Not implemented"); } +void UnityTaskbarManager::setCount(int count) { + if (_launcher == NULL) + return; + + unity_launcher_entry_set_count(_launcher, count); + + unity_launcher_entry_set_count_visible(_launcher, (count == 0) ? FALSE : TRUE); +} + // Unity requires the glib event loop to the run to function properly // as events are sent asynchronously bool UnityTaskbarManager::pollEvent(Common::Event &event) { diff --git a/backends/taskbar/unity/unity-taskbar.h b/backends/taskbar/unity/unity-taskbar.h index d8a68a4101..48f403a849 100644 --- a/backends/taskbar/unity/unity-taskbar.h +++ b/backends/taskbar/unity/unity-taskbar.h @@ -43,6 +43,7 @@ public: virtual void setProgressValue(int completed, int total); virtual void setProgressState(TaskbarProgressState state); virtual void addRecent(const Common::String &name, const Common::String &description); + virtual void setCount(int count); // Implementation of the EventSource interface virtual bool pollEvent(Common::Event &event); diff --git a/common/taskbar.h b/common/taskbar.h index ea1d218724..2219e6e04f 100644 --- a/common/taskbar.h +++ b/common/taskbar.h @@ -32,7 +32,7 @@ namespace Common { class TaskbarManager { public: /** - * Values representing the taskbar progress state + * Values representing the taskbar progress state */ enum TaskbarProgressState { kTaskbarNoProgress = 0, @@ -46,51 +46,61 @@ public: virtual ~TaskbarManager() {} /** - * Sets an overlay icon on the taskbar icon. + * Sets an overlay icon on the taskbar icon * * When an empty name is given, no icon is shown * and the current overlay icon (if any) is removed * - * @param name Path to the icon - * @param description The description + * @param name Path to the icon + * @param description The description * * @note on Windows, the icon should be an ICO file */ - virtual void setOverlayIcon(const String &name, const String &description) {} + virtual void setOverlayIcon(const String &name, const String &description) {} - /** - * Sets a progress value on the taskbar icon - * - * @param completed The current progress value. - * @param total The maximum progress value. - */ - virtual void setProgressValue(int completed, int total) {} + /** + * Sets a progress value on the taskbar icon + * + * @param completed The current progress value. + * @param total The maximum progress value. + */ + virtual void setProgressValue(int completed, int total) {} - /** - * Sets the progress state on the taskbar icon - * - * State can be any of the following: - * - NoProgress: disable display of progress state + /** + * Sets the progress state on the taskbar icon + * + * State can be any of the following: + * - NoProgress: disable display of progress state * - Indeterminate * - Normal * - Error * - Paused - * - * @param state The progress state - */ - virtual void setProgressState(TaskbarProgressState state) {} + * + * @param state The progress state + */ + virtual void setProgressState(TaskbarProgressState state) {} + + /** + * Sets the count number associated with the icon as an overlay + * + * @param count The count + * + * @note Setting a count of 0 will hide the count + */ + virtual void setCount(int count) {} + + /** + * Adds an engine to the recent items list + * + * Path is automatically set to the current executable path, + * an icon name is generated (with fallback to default icon) + * and the command line is set to start the engine on click. + * + * @param name The target name. + * @param description The description. + */ + virtual void addRecent(const String &name, const String &description) {} - /** - * Adds an engine to the recent items list - * - * Path is automatically set to the current executable path, - * an icon name is generated (with fallback to default icon) - * and the command line is set to start the engine on click. - * - * @param name The target name. - * @param description The description. - */ - virtual void addRecent(const String &name, const String &description) {} }; } // End of namespace Common diff --git a/gui/massadd.cpp b/gui/massadd.cpp index 1578e75b25..29a2b1886a 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -71,14 +71,14 @@ MassAddDialog::MassAddDialog(const Common::FSNode &startDir) // The dir we start our scan at _scanStack.push(startDir); -// Removed for now... Why would you put a title on mass add dialog called "Mass Add Dialog"? -// new StaticTextWidget(this, "massadddialog_caption", "Mass Add Dialog"); + // Removed for now... Why would you put a title on mass add dialog called "Mass Add Dialog"? + // new StaticTextWidget(this, "massadddialog_caption", "Mass Add Dialog"); _dirProgressText = new StaticTextWidget(this, "MassAdd.DirProgressText", - _("... progress ...")); + _("... progress ...")); _gameProgressText = new StaticTextWidget(this, "MassAdd.GameProgressText", - _("... progress ...")); + _("... progress ...")); _dirProgressText->setAlign(Graphics::kTextAlignCenter); _gameProgressText->setAlign(Graphics::kTextAlignCenter); @@ -132,8 +132,9 @@ struct GameDescLess { void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { - // Remove progress bar from taskbar + // Remove progress bar and count from taskbar g_system->getTaskbarManager()->setProgressState(Common::TaskbarManager::kTaskbarNoProgress); + g_system->getTaskbarManager()->setCount(0); // FIXME: It's a really bad thing that we use two arbitrary constants if (cmd == kOkCmd) { @@ -239,6 +240,7 @@ void MassAddDialog::handleTickle() { _dirsScanned++; g_system->getTaskbarManager()->setProgressValue(_dirsScanned, _dirTotal); + g_system->getTaskbarManager()->setCount(_games.size()); } -- cgit v1.2.3 From 5649ddaf101db5d8ce70e9ba1bfda850c5d00aa5 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Mon, 4 Apr 2011 16:10:58 -0400 Subject: BACKENDS: Move Win32TaskbarManager init code to constructor --- backends/platform/sdl/win32/win32.cpp | 1 - backends/taskbar/win32/win32-taskbar.cpp | 30 +++++++++++++----------------- backends/taskbar/win32/win32-taskbar.h | 2 -- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 0a6702b6d9..08139f0dc2 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -88,7 +88,6 @@ void OSystem_Win32::init() { #if defined(USE_TASKBAR) // Initialize taskbar manager _taskbarManager = new Win32TaskbarManager(); - ((Win32TaskbarManager *)_taskbarManager)->init(); #endif // Invoke parent implementation of this method diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index c630129ea9..fd8cd263e8 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -51,19 +51,7 @@ const PROPERTYKEY PKEY_Title = { /* fmtid = */ { 0xF29F85E0, 0x4FF9, 0x1068, { 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 } }, /* propID = */ 2 }; Win32TaskbarManager::Win32TaskbarManager() { - _taskbar = NULL; -} - -Win32TaskbarManager::~Win32TaskbarManager() { - if (_taskbar) - _taskbar->Release(); - _taskbar = NULL; - - CoUninitialize(); -} - -void Win32TaskbarManager::init() { - // Do nothing if not running on Windows 7 of later + // Do nothing if not running on Windows 7 or later if (!isWin7OrLater()) return; @@ -71,10 +59,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 (&(_taskbar))); + 0, + CLSCTX_INPROC_SERVER, + IID_ITaskbarList3, + reinterpret_cast (&(_taskbar))); if (SUCCEEDED(hr)) { // Initialize taskbar object @@ -87,6 +75,14 @@ void Win32TaskbarManager::init() { } } +Win32TaskbarManager::~Win32TaskbarManager() { + if (_taskbar) + _taskbar->Release(); + _taskbar = NULL; + + CoUninitialize(); +} + 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()); diff --git a/backends/taskbar/win32/win32-taskbar.h b/backends/taskbar/win32/win32-taskbar.h index 7d963c19ca..0fc219e816 100644 --- a/backends/taskbar/win32/win32-taskbar.h +++ b/backends/taskbar/win32/win32-taskbar.h @@ -38,8 +38,6 @@ public: Win32TaskbarManager(); virtual ~Win32TaskbarManager(); - void init(); - virtual void setOverlayIcon(const Common::String &name, const Common::String &description); virtual void setProgressValue(int completed, int total); virtual void setProgressState(TaskbarProgressState state); -- cgit v1.2.3 From fdada1dbffb57e12f5683f54e5bbaf7cc5eafdce Mon Sep 17 00:00:00 2001 From: Littleboy Date: Wed, 6 Apr 2011 19:51:25 -0400 Subject: BACKENDS: Remove UnityTaskbarManager::setOverlayIcon() Unity is not going to provide a way to set a custom overlay icon (the emblem API is being replaced by a simple urgent state) --- backends/taskbar/unity/unity-taskbar.cpp | 7 ------- backends/taskbar/unity/unity-taskbar.h | 1 - 2 files changed, 8 deletions(-) diff --git a/backends/taskbar/unity/unity-taskbar.cpp b/backends/taskbar/unity/unity-taskbar.cpp index 0de2167a83..0045a6fdbd 100644 --- a/backends/taskbar/unity/unity-taskbar.cpp +++ b/backends/taskbar/unity/unity-taskbar.cpp @@ -44,13 +44,6 @@ UnityTaskbarManager::~UnityTaskbarManager() { _loop = NULL; } -void UnityTaskbarManager::setOverlayIcon(const Common::String &name, const Common::String &description) { - if (_launcher == NULL) - return; - - warning("[UnityTaskbarManager::setOverlayIcon] Not implemented"); -} - void UnityTaskbarManager::setProgressValue(int completed, int total) { if (_launcher == NULL) return; diff --git a/backends/taskbar/unity/unity-taskbar.h b/backends/taskbar/unity/unity-taskbar.h index 48f403a849..ed40a6507e 100644 --- a/backends/taskbar/unity/unity-taskbar.h +++ b/backends/taskbar/unity/unity-taskbar.h @@ -39,7 +39,6 @@ public: UnityTaskbarManager(); virtual ~UnityTaskbarManager(); - virtual void setOverlayIcon(const Common::String &name, const Common::String &description); virtual void setProgressValue(int completed, int total); virtual void setProgressState(TaskbarProgressState state); virtual void addRecent(const Common::String &name, const Common::String &description); -- cgit v1.2.3 From 28aa4f0f33c662b8d0c9273011d43237451b9659 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Tue, 26 Apr 2011 15:31:56 -0400 Subject: COMMON: Add overall documentation to TaskbarManager interface --- common/taskbar.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/taskbar.h b/common/taskbar.h index 2219e6e04f..f040af8786 100644 --- a/common/taskbar.h +++ b/common/taskbar.h @@ -29,6 +29,17 @@ namespace Common { +/** + * The TaskbarManager allows interaction with the ScummVM icon in the taskbar. + * + * This allows the application to set a progress bar, an overlay icon and count + * as well as add the started engine to the recent items list (so that the user + * can start the engine directly in one click) + * + * @note functionality will vary between supported platforms (due to API limitations) + * and some of the methods will just be no-ops or approximate the functionality + * as best as possible + */ class TaskbarManager { public: /** -- cgit v1.2.3 From 1e3603b9371204c88a60983cbfb61a4adcef0b94 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Tue, 26 Apr 2011 16:19:20 -0400 Subject: BACKENDS: Add define for Unity-specific taskbar code --- backends/platform/sdl/posix/posix.cpp | 4 ++-- backends/taskbar/unity/unity-taskbar.cpp | 2 +- backends/taskbar/unity/unity-taskbar.h | 2 +- configure | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 94f8d95ffb..05c779a4e0 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -50,7 +50,7 @@ void OSystem_POSIX::init() { // Initialze File System Factory _fsFactory = new POSIXFilesystemFactory(); -#if defined(USE_TASKBAR) +#if defined(USE_TASKBAR) && defined(USE_TASKBAR_UNITY) // Initialize taskbar manager _taskbarManager = new UnityTaskbarManager(); #endif @@ -67,7 +67,7 @@ void OSystem_POSIX::initBackend() { // Invoke parent implementation of this method OSystem_SDL::initBackend(); -#if defined(USE_TASKBAR) +#if defined(USE_TASKBAR) && defined(USE_TASKBAR_UNITY) // 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 diff --git a/backends/taskbar/unity/unity-taskbar.cpp b/backends/taskbar/unity/unity-taskbar.cpp index 0045a6fdbd..49c56b746d 100644 --- a/backends/taskbar/unity/unity-taskbar.cpp +++ b/backends/taskbar/unity/unity-taskbar.cpp @@ -25,7 +25,7 @@ #include "common/scummsys.h" -#if defined(UNIX) && defined(USE_TASKBAR) +#if defined(UNIX) && defined(USE_TASKBAR) && defined(USE_TASKBAR_UNITY) #include "backends/taskbar/unity/unity-taskbar.h" diff --git a/backends/taskbar/unity/unity-taskbar.h b/backends/taskbar/unity/unity-taskbar.h index ed40a6507e..9f14b44d8f 100644 --- a/backends/taskbar/unity/unity-taskbar.h +++ b/backends/taskbar/unity/unity-taskbar.h @@ -26,7 +26,7 @@ #ifndef BACKEND_UNITY_TASKBAR_H #define BACKEND_UNITY_TASKBAR_H -#if defined(UNIX) && defined(USE_TASKBAR) +#if defined(UNIX) && defined(USE_TASKBAR) && defined(USE_TASKBAR_UNITY) #include "common/events.h" #include "common/str.h" diff --git a/configure b/configure index 37dfc807b7..6e39ad3667 100755 --- a/configure +++ b/configure @@ -2951,6 +2951,7 @@ if test "$_unity" = yes ; then INCLUDES="$INCLUDES $UNITY_CFLAGS" fi define_in_config_h_if_yes "$_unity" 'USE_TASKBAR' +define_in_config_h_if_yes "$_unity" 'USE_TASKBAR_UNITY' echo "$_unity" # -- cgit v1.2.3 From 7458073bad16f7f15fe8a98227e7b718ecb8a075 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Wed, 27 Apr 2011 16:07:03 -0400 Subject: COMMON: Update TaskbarManager header with better documentation and examples of use --- common/taskbar.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/common/taskbar.h b/common/taskbar.h index f040af8786..ff9fd9c264 100644 --- a/common/taskbar.h +++ b/common/taskbar.h @@ -30,11 +30,20 @@ namespace Common { /** - * The TaskbarManager allows interaction with the ScummVM icon in the taskbar. + * The TaskbarManager allows interaction with the ScummVM application icon: + * - in the taskbar on Windows 7 and later + * - in the launcher for Unity + * - in the dock on MacOSX + * - ... * - * This allows the application to set a progress bar, an overlay icon and count - * as well as add the started engine to the recent items list (so that the user - * can start the engine directly in one click) + * This allows GUI code and engines to display a progress bar, an overlay icon and/or count + * associated with the ScummVM icon as well as add the started engine to the recent items + * list (so that the user can start the engine directly in one click). + * + * Examples of use: + * - Track search progress and found engines when running the Mass Add dialog + * - Add an entry to the recent items when starting an engine + * - Show the current running engine icon as an overlay * * @note functionality will vary between supported platforms (due to API limitations) * and some of the methods will just be no-ops or approximate the functionality -- cgit v1.2.3 From 30c0966018c78cfe2ea8c7e48d1d75929aa33622 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Thu, 28 Apr 2011 18:10:26 -0400 Subject: CONFIGURE: Disable Unity on non-unix systems and add taskbar support when compiling with mingw - Mingw now links with 2 additional libraries: ole32 and uuid --- configure | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 6e39ad3667..d772303739 100755 --- a/configure +++ b/configure @@ -1781,9 +1781,10 @@ case $_host_os in mingw*) DEFINES="$DEFINES -DWIN32" DEFINES="$DEFINES -D__USE_MINGW_ANSI_STDIO=0" - LIBS="$LIBS -lmingw32 -lwinmm" + LIBS="$LIBS -lmingw32 -lwinmm -lole32 -luuid" OBJS="$OBJS scummvmwinres.o" add_line_to_config_mk 'WIN32 = 1' + add_line_to_config_h "#define USE_TASKBAR" ;; mint*) DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE" @@ -2935,6 +2936,9 @@ define_in_config_h_if_yes "$_text_console" 'USE_TEXT_CONSOLE_FOR_DEBUGGER' # Check for Unity if taskbar integration is enabled # echocheck "unity" +if test "$_unix" = no ; then + _unity=no +else if test "$_unity" = auto ; then # Unity has a lots of dependency, update the libs and cflags var with them UNITY_LIBS="$UNITY_LIBS $(pkg-config --libs unity)" @@ -2952,6 +2956,7 @@ if test "$_unity" = yes ; then fi define_in_config_h_if_yes "$_unity" 'USE_TASKBAR' define_in_config_h_if_yes "$_unity" 'USE_TASKBAR_UNITY' +fi echo "$_unity" # -- cgit v1.2.3 From f843b3f280a1641d11601c9ee248d35944b14b42 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Thu, 28 Apr 2011 18:39:15 -0400 Subject: BACKENDS: Fix Win32TaskbarManager compilation with Mingw It was missing an include for scummsys.h and so couldn't find the defines --- backends/taskbar/win32/win32-taskbar.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index fd8cd263e8..4053708e96 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -22,6 +22,8 @@ * $Id$ * */ + +#include "common/scummsys.h" #if defined(WIN32) && defined(USE_TASKBAR) -- cgit v1.2.3 From 0ae3e4f2897a79b5e9c7df3a5209f101d421426e Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 29 Apr 2011 11:33:18 -0400 Subject: CONFIGURE: Update libunity detection by adding a call to one of unity functions in the cc_check test Some older compilers might not error out on missing headers and will compile (with warnings) unless a symbol is missing --- configure | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure b/configure index d772303739..0f014d9973 100755 --- a/configure +++ b/configure @@ -2946,7 +2946,10 @@ if test "$_unity" = auto ; then _unity=no cat > $TMPC << EOF #include -int main(void) { return 0; } +int main(void) { + unity_launcher_entry_get_for_desktop_id("scummvm.desktop"); + return 0; +} EOF cc_check $UNITY_CFLAGS $UNITY_LIBS -lunity && _unity=yes fi -- cgit v1.2.3 From 79fb0ff223588fd7020ef8f133e74f2fdb35f95e Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 29 Apr 2011 11:54:09 -0400 Subject: CONFIGURE: Update internal libunity handling and add support for disabling taskbar support entirely - Rename internal _unity var to _libunity - Disable libunity support when taskbar integration support is disabled --- configure | 57 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/configure b/configure index 0f014d9973..ef13e0d14f 100755 --- a/configure +++ b/configure @@ -138,7 +138,8 @@ _fluidsynth=auto _opengl=auto _opengles=auto _readline=auto -_unity=auto +_taskbar=yes +_libunity=auto # Default option behaviour yes/no _debug_build=auto _release_build=auto @@ -723,6 +724,7 @@ Optional Features: --disable-scalers exclude scalers --disable-hq-scalers exclude HQ2x and HQ3x scalers --disable-translation don't build support for translated messages + --disable-taskbar don't build support for taskbar and launcher integration --enable-text-console use text console instead of graphical console --enable-verbose-build enable regular echoing of commands during build process @@ -772,8 +774,8 @@ Optional Libraries: --with-readline-prefix=DIR Prefix where readline is installed (optional) --disable-readline disable readline support in text console [autodetect] - --with-unity-prefix=DIR Prefix where libunity is installed (optional) - --disable-unity disable unity[autodetect] + --with-libunity-prefix=DIR Prefix where libunity is installed (optional) + --disable-libunity disable Unity launcher integration [autodetect] Some influential environment variables: LDFLAGS linker flags, e.g. -L if you have libraries in a @@ -822,8 +824,10 @@ for ac_option in $@; do --disable-fluidsynth) _fluidsynth=no ;; --enable-readline) _readline=yes ;; --disable-readline) _readline=no ;; - --enable-unity) _unity=yes ;; - --disable-unity) _unity=no ;; + --enable-taskbar) _taskbar=yes ;; + --disable-taskbar) _taskbar=no ;; + --enable-libunity) _libunity=yes ;; + --disable-libunity) _libunity=no ;; --enable-opengl) _opengl=yes ;; --disable-opengl) _opengl=no ;; --enable-verbose-build) _verbose_build=yes ;; @@ -899,10 +903,10 @@ for ac_option in $@; do READLINE_CFLAGS="-I$arg/include" READLINE_LIBS="-L$arg/lib" ;; - --with-unity-prefix=*) + --with-libunity-prefix=*) arg=`echo $ac_option | cut -d '=' -f 2` - UNITY_CFLAGS="-I$arg/include" - UNITY_LIBS="-L$arg/lib" + LIBUNITY_CFLAGS="-I$arg/include" + LIBUNITY_LIBS="-L$arg/lib" ;; --with-opengl-prefix=*) arg=`echo $ac_option | cut -d '=' -f 2` @@ -1784,7 +1788,6 @@ case $_host_os in LIBS="$LIBS -lmingw32 -lwinmm -lole32 -luuid" OBJS="$OBJS scummvmwinres.o" add_line_to_config_mk 'WIN32 = 1' - add_line_to_config_h "#define USE_TASKBAR" ;; mint*) DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE" @@ -2935,15 +2938,15 @@ define_in_config_h_if_yes "$_text_console" 'USE_TEXT_CONSOLE_FOR_DEBUGGER' # # Check for Unity if taskbar integration is enabled # -echocheck "unity" -if test "$_unix" = no ; then - _unity=no +echocheck "libunity" +if test "$_unix" = no || test "$_taskbar" = no; then + _libunity=no else -if test "$_unity" = auto ; then - # Unity has a lots of dependency, update the libs and cflags var with them - UNITY_LIBS="$UNITY_LIBS $(pkg-config --libs unity)" - UNITY_CFLAGS="$UNITY_CFLAGS $(pkg-config --cflags unity)" - _unity=no +if test "$_libunity" = auto ; then + # Unity has a lots of dependencies, update the libs and cflags var with them + LIBUNITY_LIBS="$LIBUNITY_LIBS $(pkg-config --libs unity)" + LIBUNITY_CFLAGS="$LIBUNITY_CFLAGS $(pkg-config --cflags unity)" + _libunity=no cat > $TMPC << EOF #include int main(void) { @@ -2951,16 +2954,15 @@ int main(void) { return 0; } EOF - cc_check $UNITY_CFLAGS $UNITY_LIBS -lunity && _unity=yes + cc_check $LIBUNITY_CFLAGS $LIBUNITY_LIBS -lunity && _libunity=yes fi -if test "$_unity" = yes ; then - LIBS="$LIBS $UNITY_LIBS -lunity" - INCLUDES="$INCLUDES $UNITY_CFLAGS" +if test "$_libunity" = yes ; then + LIBS="$LIBS $LIBUNITY_LIBS -lunity" + INCLUDES="$INCLUDES $LIBUNITY_CFLAGS" fi -define_in_config_h_if_yes "$_unity" 'USE_TASKBAR' -define_in_config_h_if_yes "$_unity" 'USE_TASKBAR_UNITY' +define_in_config_h_if_yes "$_libunity" 'USE_TASKBAR_UNITY' fi -echo "$_unity" +echo "$_libunity" # # Check for OpenGL (ES) @@ -3137,6 +3139,13 @@ EOF fi fi +# +# Check whether to build taskbar integration support +# +echo_n "Building taskbar integration support... " +define_in_config_if_yes $_taskbar 'USE_TASKBAR' +echo "$_taskbar" + # # Figure out installation directories # -- cgit v1.2.3 From 96148345483dd0e7667f0b7541d5956524181dd5 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 29 Apr 2011 12:15:49 -0400 Subject: BACKENDS/COMMON/GUI: Remove complete support for TaskbarManager when taskbar integration is not enabled --- backends/modular-backend.cpp | 10 ++++++++-- backends/modular-backend.h | 4 ++++ backends/platform/sdl/sdl.cpp | 4 ++++ backends/platform/sdl/sdl.h | 2 ++ common/system.h | 6 +++++- common/taskbar.h | 5 +++++ gui/massadd.cpp | 4 ++++ 7 files changed, 32 insertions(+), 3 deletions(-) diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index a2710bc1cf..4b306be228 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -33,10 +33,11 @@ ModularBackend::ModularBackend() : _mutexManager(0), - _taskbarManager(0), _graphicsManager(0), _mixer(0) { - +#if defined(USE_TASKBAR) + _taskbarManager = 0; +#endif } ModularBackend::~ModularBackend() { @@ -44,8 +45,10 @@ ModularBackend::~ModularBackend() { _graphicsManager = 0; delete _mixer; _mixer = 0; +#if defined(USE_TASKBAR) delete _taskbarManager; _taskbarManager = 0; +#endif delete _mutexManager; _mutexManager = 0; } @@ -239,7 +242,10 @@ void ModularBackend::quit() { exit(0); } +#if defined(USE_TASKBAR) Common::TaskbarManager *ModularBackend::getTaskbarManager() { assert(_taskbarManager); return _taskbarManager; } +#endif + diff --git a/backends/modular-backend.h b/backends/modular-backend.h index 6b5bfff989..fab7fb6a4d 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -134,7 +134,9 @@ public: //@{ virtual void quit(); +#if defined(USE_TASKBAR) virtual TaskbarManager *getTaskbarManager(); +#endif virtual void displayMessageOnOSD(const char *msg); //@} @@ -143,7 +145,9 @@ protected: /** @name Managers variables */ //@{ +#if defined(USE_TASKBAR) TaskbarManager *_taskbarManager; +#endif MutexManager *_mutexManager; GraphicsManager *_graphicsManager; Audio::Mixer *_mixer; diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 4743dbb558..85ea177a39 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -126,8 +126,10 @@ void OSystem_SDL::init() { if (_timerManager == 0) _timerManager = new SdlTimerManager(); +#if defined(USE_TASKBAR) if (_taskbarManager == 0) _taskbarManager = new Common::TaskbarManager(); +#endif #ifdef USE_OPENGL // Setup a list with both SDL and OpenGL graphics modes @@ -213,6 +215,7 @@ void OSystem_SDL::initBackend() { ModularBackend::initBackend(); } +#if defined(USE_TASKBAR) void OSystem_SDL::engineInit() { // Add the started engine to the list of recent tasks _taskbarManager->addRecent(ConfMan.getActiveDomainName(), ConfMan.get("description")); @@ -225,6 +228,7 @@ void OSystem_SDL::engineDone() { // Remove overlay icon _taskbarManager->setOverlayIcon("", ""); } +#endif void OSystem_SDL::initSDL() { // Check if SDL has not been initialized diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 19f913ef45..395b2b3aac 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -54,8 +54,10 @@ public: // Override functions from ModularBackend and OSystem virtual void initBackend(); +#if defined(USE_TASKBAR) virtual void engineInit(); virtual void engineDone(); +#endif virtual Common::HardwareKeySet *getHardwareKeySet(); virtual void quit(); virtual void fatalError(); diff --git a/common/system.h b/common/system.h index f556fa22f8..0bfa980800 100644 --- a/common/system.h +++ b/common/system.h @@ -42,7 +42,9 @@ struct Rect; class SaveFileManager; class SearchSet; class String; -class TaskbarManager; +#if defined(USE_TASKBAR) + class TaskbarManager; +#endif class TimerManager; class SeekableReadStream; class WriteStream; @@ -1048,6 +1050,7 @@ public: return _savefileManager; } +#if defined(USE_TASKBAR) /** * Returns the TaskbarManager, used to handle progress bars, * icon overlay, tasks and recent items list on the taskbar. @@ -1055,6 +1058,7 @@ public: * @return the TaskbarManager for the current architecture */ virtual Common::TaskbarManager *getTaskbarManager() = 0; +#endif /** * Returns the FilesystemFactory object, depending on the current architecture. diff --git a/common/taskbar.h b/common/taskbar.h index ff9fd9c264..023227e5e0 100644 --- a/common/taskbar.h +++ b/common/taskbar.h @@ -25,8 +25,11 @@ #ifndef COMMON_TASKBAR_MANAGER_H #define COMMON_TASKBAR_MANAGER_H +#include "common/scummsys.h" #include "common/str.h" +#if defined(USE_TASKBAR) + namespace Common { /** @@ -125,4 +128,6 @@ public: } // End of namespace Common +#endif + #endif // COMMON_TASKBAR_MANAGER_H diff --git a/gui/massadd.cpp b/gui/massadd.cpp index 29a2b1886a..70580e8b9c 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -132,9 +132,11 @@ struct GameDescLess { void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { +#if defined(USE_TASKBAR) // Remove progress bar and count from taskbar g_system->getTaskbarManager()->setProgressState(Common::TaskbarManager::kTaskbarNoProgress); g_system->getTaskbarManager()->setCount(0); +#endif // FIXME: It's a really bad thing that we use two arbitrary constants if (cmd == kOkCmd) { @@ -239,8 +241,10 @@ void MassAddDialog::handleTickle() { _dirsScanned++; +#if defined(USE_TASKBAR) g_system->getTaskbarManager()->setProgressValue(_dirsScanned, _dirTotal); g_system->getTaskbarManager()->setCount(_games.size()); +#endif } -- cgit v1.2.3 From 5dff6c2c081756feb61fd273da903019e33363a1 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Jun 2011 11:06:05 -0400 Subject: BACKENDS: Allow use of excluded functions needed by Win32TaskbarManager --- backends/taskbar/win32/win32-taskbar.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index 4053708e96..c05b91d9f3 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -22,7 +22,15 @@ * $Id$ * */ - + +// We need certain functions that are excluded by default +#undef NONLS +#undef NOICONS +#include +#if defined(ARRAYSIZE) + #undef ARRAYSIZE +#endif + #include "common/scummsys.h" #if defined(WIN32) && defined(USE_TASKBAR) -- cgit v1.2.3 From 599695bc4f70c28c556e2c78822eda6ef29d2faa Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Jun 2011 11:24:38 -0400 Subject: COMMON: Change TaskbarManager to the new module slot interface --- backends/modular-backend.cpp | 16 +--------------- backends/modular-backend.h | 15 ++++----------- common/system.cpp | 9 +++++++++ common/system.h | 15 +++++++++++++-- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp index 4b306be228..525170d685 100644 --- a/backends/modular-backend.cpp +++ b/backends/modular-backend.cpp @@ -35,9 +35,7 @@ ModularBackend::ModularBackend() _mutexManager(0), _graphicsManager(0), _mixer(0) { -#if defined(USE_TASKBAR) - _taskbarManager = 0; -#endif + } ModularBackend::~ModularBackend() { @@ -45,10 +43,6 @@ ModularBackend::~ModularBackend() { _graphicsManager = 0; delete _mixer; _mixer = 0; -#if defined(USE_TASKBAR) - delete _taskbarManager; - _taskbarManager = 0; -#endif delete _mutexManager; _mutexManager = 0; } @@ -241,11 +235,3 @@ void ModularBackend::displayMessageOnOSD(const char *msg) { void ModularBackend::quit() { exit(0); } - -#if defined(USE_TASKBAR) -Common::TaskbarManager *ModularBackend::getTaskbarManager() { - assert(_taskbarManager); - return _taskbarManager; -} -#endif - diff --git a/backends/modular-backend.h b/backends/modular-backend.h index fab7fb6a4d..3593130bf5 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -27,21 +27,20 @@ class GraphicsManager; class MutexManager; -class TaskbarManager; /** * Base class for modular backends. - * + * * It wraps most functions to their manager equivalent, but not * all OSystem functions are implemented here. - * + * * A backend derivated from this class, will need to implement * these functions on its own: * OSystem::pollEvent() * OSystem::getMillis() * OSystem::delayMillis() * OSystem::getTimeAndDate() - * + * * And, it should also initialize all the managers variables * declared in this class, or override their related functions. */ @@ -112,7 +111,7 @@ public: virtual Common::HardwareKeySet *getHardwareKeySet() { return 0; } //@} - + /** @name Mutex handling */ //@{ @@ -134,9 +133,6 @@ public: //@{ virtual void quit(); -#if defined(USE_TASKBAR) - virtual TaskbarManager *getTaskbarManager(); -#endif virtual void displayMessageOnOSD(const char *msg); //@} @@ -145,9 +141,6 @@ protected: /** @name Managers variables */ //@{ -#if defined(USE_TASKBAR) - TaskbarManager *_taskbarManager; -#endif MutexManager *_mutexManager; GraphicsManager *_graphicsManager; Audio::Mixer *_mixer; diff --git a/common/system.cpp b/common/system.cpp index fae7a3ef34..2dab687872 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -32,6 +32,7 @@ #include "common/fs.h" #include "common/savefile.h" #include "common/str.h" +#include "common/taskbar.h" #include "common/textconsole.h" #include "backends/audiocd/default/default-audiocd.h" @@ -45,6 +46,9 @@ OSystem::OSystem() { _eventManager = 0; _timerManager = 0; _savefileManager = 0; +#if defined(USE_TASKBAR) + _taskbarManager = 0; +#endif _fsFactory = 0; } @@ -58,6 +62,11 @@ OSystem::~OSystem() { delete _timerManager; _timerManager = 0; +#if defined(USE_TASKBAR) + delete _taskbarManager; + _taskbarManager = 0; +#endif + delete _savefileManager; _savefileManager = 0; diff --git a/common/system.h b/common/system.h index 0bfa980800..24728a918c 100644 --- a/common/system.h +++ b/common/system.h @@ -43,7 +43,7 @@ class SaveFileManager; class SearchSet; class String; #if defined(USE_TASKBAR) - class TaskbarManager; +class TaskbarManager; #endif class TimerManager; class SeekableReadStream; @@ -152,6 +152,15 @@ protected: */ Common::SaveFileManager *_savefileManager; +#if defined(USE_TASKBAR) + /** + * No default value is provided for _savefileManager by OSystem. + * + * @note _savefileManager is deleted by the OSystem destructor. + */ + Common::TaskbarManager *_taskbarManager; +#endif + /** * No default value is provided for _fsFactory by OSystem. * @@ -1057,7 +1066,9 @@ public: * * @return the TaskbarManager for the current architecture */ - virtual Common::TaskbarManager *getTaskbarManager() = 0; + virtual Common::TaskbarManager *getTaskbarManager() { + return _taskbarManager; + } #endif /** -- cgit v1.2.3 From 8729af342f42a68893ac473841373002e2a06e9d Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Jun 2011 11:57:06 -0400 Subject: CONFIGURE: Disable check for unity when compiling with mingw (pkg-config is not available) --- configure | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/configure b/configure index ef13e0d14f..3f3eeb852a 100755 --- a/configure +++ b/configure @@ -2943,18 +2943,26 @@ if test "$_unix" = no || test "$_taskbar" = no; then _libunity=no else if test "$_libunity" = auto ; then - # Unity has a lots of dependencies, update the libs and cflags var with them - LIBUNITY_LIBS="$LIBUNITY_LIBS $(pkg-config --libs unity)" - LIBUNITY_CFLAGS="$LIBUNITY_CFLAGS $(pkg-config --cflags unity)" - _libunity=no - cat > $TMPC << EOF + case $_host_os in + mingw*) + # pkgconfig and unity are not supported on mingw + _libunity=no + ;; + *) + # Unity has a lots of dependencies, update the libs and cflags var with them + LIBUNITY_LIBS="$LIBUNITY_LIBS $(pkg-config --libs unity)" + LIBUNITY_CFLAGS="$LIBUNITY_CFLAGS $(pkg-config --cflags unity)" + _libunity=no + cat > $TMPC << EOF #include int main(void) { unity_launcher_entry_get_for_desktop_id("scummvm.desktop"); return 0; } EOF - cc_check $LIBUNITY_CFLAGS $LIBUNITY_LIBS -lunity && _libunity=yes + cc_check $LIBUNITY_CFLAGS $LIBUNITY_LIBS -lunity && _libunity=yes + ;; + esac fi if test "$_libunity" = yes ; then LIBS="$LIBS $LIBUNITY_LIBS -lunity" -- cgit v1.2.3 From 179630b46b8e24d6c87c114f97efa076a8fc19fa Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Jun 2011 12:30:40 -0400 Subject: CONFIGURE: Only add linking to ole32 and uuid when taskbar support is compiled for Win32 We also show the type of taskbar integration being compiled. --- configure | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 3f3eeb852a..87f4b86ae6 100755 --- a/configure +++ b/configure @@ -1785,7 +1785,7 @@ case $_host_os in mingw*) DEFINES="$DEFINES -DWIN32" DEFINES="$DEFINES -D__USE_MINGW_ANSI_STDIO=0" - LIBS="$LIBS -lmingw32 -lwinmm -lole32 -luuid" + LIBS="$LIBS -lmingw32 -lwinmm" OBJS="$OBJS scummvmwinres.o" add_line_to_config_mk 'WIN32 = 1' ;; @@ -3152,7 +3152,23 @@ fi # echo_n "Building taskbar integration support... " define_in_config_if_yes $_taskbar 'USE_TASKBAR' -echo "$_taskbar" +if test "$_taskbar" = yes; then + case $_host_os in + mingw*) + LIBS="$LIBS -lole32 -luuid" + echo "win32" + ;; + *) + if test "$_unity" = yes; then + echo "unity" + else + echo "$_taskbar" + fi + ;; + esac +else + echo "$_taskbar" +fi # # Figure out installation directories -- cgit v1.2.3 From 149a8f8f11765107cbfe9e3c3b5e8fb27e621470 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Jun 2011 12:31:34 -0400 Subject: BACKENDS: Fix compilation of Win32TaskbarManager with mingw --- backends/taskbar/win32/mingw-compat.h | 3 +++ backends/taskbar/win32/win32-taskbar.cpp | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/backends/taskbar/win32/mingw-compat.h b/backends/taskbar/win32/mingw-compat.h index 3ee4b9aa5d..06968b62ff 100644 --- a/backends/taskbar/win32/mingw-compat.h +++ b/backends/taskbar/win32/mingw-compat.h @@ -34,6 +34,9 @@ #if defined(__GNUC__) #ifdef __MINGW32__ +#ifdef _WIN32_WINNT + #undef _WIN32_WINNT +#endif #define _WIN32_WINNT 0x0501 #include #include diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index c05b91d9f3..3754a03c76 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -23,16 +23,12 @@ * */ -// We need certain functions that are excluded by default -#undef NONLS -#undef NOICONS -#include -#if defined(ARRAYSIZE) - #undef ARRAYSIZE +// We cannot use common/scummsys.h directly as it will include +// windows.h and we need to do it by hand to allow excluded functions +#if defined(HAVE_CONFIG_H) +#include "config.h" #endif -#include "common/scummsys.h" - #if defined(WIN32) && defined(USE_TASKBAR) // Needed for taskbar functions @@ -43,6 +39,14 @@ #error Only compilation with MingW is supported #endif #else + // We need certain functions that are excluded by default + #undef NONLS + #undef NOICONS + #include + #if defined(ARRAYSIZE) + #undef ARRAYSIZE + #endif + // Default MSVC headers for ITaskbarList3 and IShellLink #include #endif @@ -51,6 +55,8 @@ // For HWND #include +#include "common/scummsys.h" + #include "backends/taskbar/win32/win32-taskbar.h" #include "common/config-manager.h" -- cgit v1.2.3 From 96c1e97459dbcd5422dbdf42df9c370c086d6a22 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Jun 2011 12:47:31 -0400 Subject: CONFIGURE: Add minimum version of Unity --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 87f4b86ae6..df0c948825 100755 --- a/configure +++ b/configure @@ -2950,8 +2950,8 @@ if test "$_libunity" = auto ; then ;; *) # Unity has a lots of dependencies, update the libs and cflags var with them - LIBUNITY_LIBS="$LIBUNITY_LIBS $(pkg-config --libs unity)" - LIBUNITY_CFLAGS="$LIBUNITY_CFLAGS $(pkg-config --cflags unity)" + LIBUNITY_LIBS="$LIBUNITY_LIBS $(pkg-config --libs unity = 3.8.4)" + LIBUNITY_CFLAGS="$LIBUNITY_CFLAGS $(pkg-config --cflags unity = 3.8.4)" _libunity=no cat > $TMPC << EOF #include -- cgit v1.2.3 From 154c584d44d689f0a7b521b49c5ce245a52fb992 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 16 Jun 2011 16:09:20 -0400 Subject: BACKENDS: Enhance Win32TaskbarManager::getIconPath() We now look for an iconsPath configuration variable with the path to the icons folder. In addition, we look if there is an "icons" subfolder (useful when using extrapath to store icons) --- backends/taskbar/win32/win32-taskbar.cpp | 35 +++++++++++++++++++++++--------- backends/taskbar/win32/win32-taskbar.h | 7 +++++++ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index 3754a03c76..0cfd81e3f2 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -201,20 +201,35 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St } Common::String Win32TaskbarManager::getIconPath(Common::String target) { - // Get extra path - Common::String extra = ConfMan.get("extrapath"); - - Common::String filename = target + ".ico"; + // We first try to look for a iconspath configuration variable then + // fallback to the extra path + // + // Icons can be either in a subfolder named "icons" or directly in the path + + Common::String iconsPath = ConfMan.get("iconspath"); + Common::String extraPath = ConfMan.get("extrapath"); + +#define TRY_ICON_PATH(path) { \ + Common::FSNode node((path)); \ + if (node.exists()) \ + return (path); \ +} - if (!Common::File::exists(filename)) { - // Try with the game id instead of the domain name - filename = ConfMan.get("gameid") + ".ico"; + if (!iconsPath.empty()) { + TRY_ICON_PATH(iconsPath + "/" + target + ".ico"); + TRY_ICON_PATH(iconsPath + "/" + ConfMan.get("gameid") + ".ico"); + TRY_ICON_PATH(iconsPath + "/icons/" + target + ".ico"); + TRY_ICON_PATH(iconsPath + "/icons/" + ConfMan.get("gameid") + ".ico"); + } - if (!Common::File::exists(filename)) - return ""; + if (!extraPath.empty()) { + TRY_ICON_PATH(extraPath + "/" + target + ".ico"); + TRY_ICON_PATH(extraPath + "/" + ConfMan.get("gameid") + ".ico"); + TRY_ICON_PATH(extraPath + "/icons/" + target + ".ico"); + TRY_ICON_PATH(extraPath + "/icons/" + ConfMan.get("gameid") + ".ico"); } - return extra + filename; + return ""; } bool Win32TaskbarManager::isWin7OrLater() { diff --git a/backends/taskbar/win32/win32-taskbar.h b/backends/taskbar/win32/win32-taskbar.h index 0fc219e816..3415a79bd7 100644 --- a/backends/taskbar/win32/win32-taskbar.h +++ b/backends/taskbar/win32/win32-taskbar.h @@ -46,6 +46,13 @@ public: private: ITaskbarList3 *_taskbar; + /** + * Get the path to an icon for the game + * + * @param target The game target + * + * @return The icon path (or "" if no icon was found) + */ Common::String getIconPath(Common::String target); // Helper functions -- cgit v1.2.3