diff options
author | Robert Tari <robert@tari.in> | 2021-08-30 01:26:19 +0200 |
---|---|---|
committer | Robert Tari <robert@tari.in> | 2021-08-30 01:26:19 +0200 |
commit | 22e66866c7b17fc655479ca911269b86cb80a744 (patch) | |
tree | e0aa6e6a8f50fd8451e03efc17b89d8c8c3de781 /src/haptic.cpp | |
parent | 1f8263dedf9b7e6f9e06492bd69f2436e36171a2 (diff) | |
parent | 38e5efecbb3154a83a70c1c762802ec7927b3caa (diff) | |
download | ayatana-indicator-datetime-22e66866c7b17fc655479ca911269b86cb80a744.tar.gz ayatana-indicator-datetime-22e66866c7b17fc655479ca911269b86cb80a744.tar.bz2 ayatana-indicator-datetime-22e66866c7b17fc655479ca911269b86cb80a744.zip |
Merge branch 'tari01-pr/ubports-patches'
Attributes GH PR #46: https://github.com/AyatanaIndicators/ayatana-indicator-datetime/pull/46
Diffstat (limited to 'src/haptic.cpp')
-rw-r--r-- | src/haptic.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
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<uint32_t>({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<uint32_t> 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)) { } |