From 195d6cded05f7ef5bde695ee047b341a0265eab3 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 24 Mar 2013 00:03:37 +0100 Subject: Fixed timer functions on win32 * changed win32 implementation to QueryPerformaceTimer system function * refactored system utils code * proper tests for time utils and update event creation in application * should fix issue #134 --- src/app/system_linux.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/app/system_linux.cpp') diff --git a/src/app/system_linux.cpp b/src/app/system_linux.cpp index cd785f8..619909d 100644 --- a/src/app/system_linux.cpp +++ b/src/app/system_linux.cpp @@ -17,11 +17,28 @@ #include "app/system_linux.h" +#include "common/logger.h" + #include -SystemDialogResult SystemDialog_Linux(SystemDialogType type, const std::string& title, const std::string& message) +void CSystemUtilsLinux::Init() { + m_zenityAvailable = true; + if (system("zenity --version") != 0) + { + m_zenityAvailable = false; + GetLogger()->Warn("Zenity not available, will fallback to console users dialogs.\n"); + } +} + +SystemDialogResult CSystemUtilsLinux::SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) +{ + if (!m_zenityAvailable) + { + return ConsoleSystemDialog(type, title, message); + } + std::string options = ""; switch (type) { @@ -62,17 +79,17 @@ SystemDialogResult SystemDialog_Linux(SystemDialogType type, const std::string& return result; } -void GetCurrentTimeStamp_Linux(SystemTimeStamp *stamp) +void CSystemUtilsLinux::GetCurrentTimeStamp(SystemTimeStamp *stamp) { clock_gettime(CLOCK_MONOTONIC_RAW, &stamp->clockTime); } -long long GetTimeStampExactResolution_Linux() +long long CSystemUtilsLinux::GetTimeStampExactResolution() { return 1ll; } -long long TimeStampExactDiff_Linux(SystemTimeStamp *before, SystemTimeStamp *after) +long long CSystemUtilsLinux::TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) { return (after->clockTime.tv_nsec - before->clockTime.tv_nsec) + (after->clockTime.tv_sec - before->clockTime.tv_sec) * 1000000000ll; -- cgit v1.2.3-1-g7c22