From 9873e6d75cfc2a54a69f6fb34e1e4c6c6d42fd7d Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 4 May 2019 10:01:10 +0300 Subject: [PATCH] Fixed seeking of slider from audio player in touchbar. --- Telegram/SourceFiles/platform/mac/touchbar.mm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/platform/mac/touchbar.mm b/Telegram/SourceFiles/platform/mac/touchbar.mm index 218dc85633..ca89e934bb 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar.mm +++ b/Telegram/SourceFiles/platform/mac/touchbar.mm @@ -484,8 +484,15 @@ auto lifetime = rpl::lifetime(); } - (void) seekbarChanged:(NSSliderTouchBarItem *)sender { - Core::Sandbox::Instance().customEnterFromEventLoop([&] { - Media::Player::instance()->finishSeeking(kSongType, sender.slider.doubleValue); + // https://stackoverflow.com/a/45891017 + NSEvent *event = [[NSApplication sharedApplication] currentEvent]; + bool touchUp = [event touchesMatchingPhase:NSTouchPhaseEnded inView:nil].count > 0; + Core::Sandbox::Instance().customEnterFromEventLoop([=] { + if (touchUp) { + Media::Player::instance()->finishSeeking(kSongType, sender.slider.doubleValue); + } else { + Media::Player::instance()->startSeeking(kSongType); + } }); }