From d39dd6255625021cb5e3596ef4c5b921d59797b5 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 20 Apr 2016 17:59:25 -0300 Subject: Vibrate only once when notification about calendar events. --- src/haptic.cpp | 20 +++++++++++++------- src/snap.cpp | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/haptic.cpp b/src/haptic.cpp index 7430c04..dc2cb82 100644 --- a/src/haptic.cpp +++ b/src/haptic.cpp @@ -37,9 +37,10 @@ class Haptic::Impl { public: - Impl(const Mode& mode): + Impl(const Mode& mode, bool repeat): m_mode(mode), - m_cancellable(g_cancellable_new()) + m_cancellable(g_cancellable_new()), + m_repeat(repeat) { g_bus_get (G_BUS_TYPE_SESSION, m_cancellable, on_bus_ready, this); } @@ -93,11 +94,15 @@ private: // one second on, one second off. m_pattern = std::vector({1000u, 1000u}); break; + } - // Set up a loop to keep repeating the pattern - auto msec = std::accumulate(m_pattern.begin(), m_pattern.end(), 0u); - m_tag = g_timeout_add(msec, call_vibrate_pattern_static, this); + if (m_repeat) + { + // Set up a loop to keep repeating the pattern + auto msec = std::accumulate(m_pattern.begin(), m_pattern.end(), 0u); + m_tag = g_timeout_add(msec, call_vibrate_pattern_static, this); + } call_vibrate_pattern(); } @@ -146,14 +151,15 @@ private: GDBusConnection * m_bus = nullptr; std::vector m_pattern; guint m_tag = 0; + bool m_repeat = false; }; /*** **** ***/ -Haptic::Haptic(const Mode& mode): - impl(new Impl (mode)) +Haptic::Haptic(const Mode& mode, bool repeat): + impl(new Impl (mode, repeat)) { } diff --git a/src/snap.cpp b/src/snap.cpp index 4736498..217b6df 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -117,7 +117,7 @@ public: if (should_vibrate()) { const auto haptic_mode = m_settings->alarm_haptic.get(); if (haptic_mode == "pulse") - haptic = std::make_shared(ain::Haptic::MODE_PULSE); + haptic = std::make_shared(ain::Haptic::MODE_PULSE, appointment.is_ubuntu_alarm()); } // show a notification... -- cgit v1.2.3