diff options
author | Littleboy | 2011-04-04 12:35:19 -0400 |
---|---|---|
committer | Julien | 2011-06-16 14:22:51 -0400 |
commit | 6c14d8a95052b68c9f076d32e520c6befac3d959 (patch) | |
tree | 065d18cf4d35158c62ba6a39ec0029dc564d46c4 /backends/taskbar/unity | |
parent | cd09b7e74fd9552901505082166b679c39f85ccc (diff) | |
download | scummvm-rg350-6c14d8a95052b68c9f076d32e520c6befac3d959.tar.gz scummvm-rg350-6c14d8a95052b68c9f076d32e520c6befac3d959.tar.bz2 scummvm-rg350-6c14d8a95052b68c9f076d32e520c6befac3d959.zip |
BACKENDS: Integrate glib main event loop
- Unity needs a glib event loop to dispatch events.
- Cleanup whitespace and indentation
Diffstat (limited to 'backends/taskbar/unity')
-rw-r--r-- | backends/taskbar/unity/unity-taskbar.cpp | 35 | ||||
-rw-r--r-- | backends/taskbar/unity/unity-taskbar.h | 7 |
2 files changed, 34 insertions, 8 deletions
diff --git a/backends/taskbar/unity/unity-taskbar.cpp b/backends/taskbar/unity/unity-taskbar.cpp index 6c18f0940c..24347e382f 100644 --- a/backends/taskbar/unity/unity-taskbar.cpp +++ b/backends/taskbar/unity/unity-taskbar.cpp @@ -32,27 +32,31 @@ #include "common/textconsole.h" UnityTaskbarManager::UnityTaskbarManager() { - g_type_init(); + g_type_init(); - _launcher = unity_launcher_entry_get_for_desktop_id("scummvm.desktop"); + _loop = g_main_loop_new(NULL, FALSE); + + _launcher = unity_launcher_entry_get_for_desktop_id("scummvm.desktop"); } UnityTaskbarManager::~UnityTaskbarManager() { + g_main_loop_unref(_loop); + _loop = NULL; } void UnityTaskbarManager::setOverlayIcon(const Common::String &name, const Common::String &description) { if (_launcher == NULL) - return; + return; warning("[UnityTaskbarManager::setOverlayIcon] Not implemented"); } void UnityTaskbarManager::setProgressValue(int completed, int total) { - if (_launcher == NULL) - return; + if (_launcher == NULL) + return; - double percentage = (double)completed / (double)total; - unity_launcher_entry_set_progress(_launcher, percentage); + double percentage = (double)completed / (double)total; + unity_launcher_entry_set_progress(_launcher, percentage); unity_launcher_entry_set_progress_visible(_launcher, TRUE); } @@ -84,4 +88,21 @@ void UnityTaskbarManager::addRecent(const Common::String &name, const Common::St warning("[UnityTaskbarManager::addRecent] Not implemented"); } +// Unity requires the glib event loop to the run to function properly +// as events are sent asynchronously +bool UnityTaskbarManager::pollEvent(Common::Event &event) { + if (!_loop) + return false; + + // Get context + GMainContext *context = g_main_loop_get_context(_loop); + if (!context) + return false; + + // Dispatch events + g_main_context_iteration(context, FALSE); + + return false; +} + #endif diff --git a/backends/taskbar/unity/unity-taskbar.h b/backends/taskbar/unity/unity-taskbar.h index 0d0484c02e..d8a68a4101 100644 --- a/backends/taskbar/unity/unity-taskbar.h +++ b/backends/taskbar/unity/unity-taskbar.h @@ -28,12 +28,13 @@ #if defined(UNIX) && defined(USE_TASKBAR) +#include "common/events.h" #include "common/str.h" #include "common/taskbar.h" #include <unity.h> -class UnityTaskbarManager : public Common::TaskbarManager { +class UnityTaskbarManager : public Common::TaskbarManager, public Common::EventSource { public: UnityTaskbarManager(); virtual ~UnityTaskbarManager(); @@ -43,7 +44,11 @@ public: virtual void setProgressState(TaskbarProgressState state); virtual void addRecent(const Common::String &name, const Common::String &description); + // Implementation of the EventSource interface + virtual bool pollEvent(Common::Event &event); + private: + GMainLoop *_loop; UnityLauncherEntry *_launcher; }; |