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/taskbar/unity/unity-taskbar.cpp | 35 +++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'backends/taskbar/unity/unity-taskbar.cpp') 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 -- cgit v1.2.3