From 7bde317cbb7edb9c99087df331076782dbc7cea7 Mon Sep 17 00:00:00 2001 From: alina sireneva Date: Wed, 15 Jul 2026 22:17:09 +0400 Subject: [PATCH] Configure macOS pull-to-action overscroll distances. The chat list configures the stories strip height as the pull distance, the chat history flags the bottom edge with a doubled threshold whenever the pull to the next channel is available - the macOS soft linear pull curve reaches a given stretch in about half the finger travel of the log curve used on other platforms. --- .../SourceFiles/dialogs/dialogs_widget.cpp | 1 + .../history_view_pull_to_next_channel.cpp | 24 ++++++++++++++++--- .../history_view_pull_to_next_channel.h | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index ac7b80c848..d13295cbbb 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -436,6 +436,7 @@ Widget::Widget( _scroll->setOverscrollTypes( _stories ? OverscrollType::Virtual : OverscrollType::Real, OverscrollType::Real); + _scroll->setOverscrollPullDistances(st::dialogsStoriesFull.height, 0); _innerList = _scroll->setOwnedWidget( object_ptr(this)); _inner = _innerList->add(object_ptr( diff --git a/Telegram/SourceFiles/history/history_view_pull_to_next_channel.cpp b/Telegram/SourceFiles/history/history_view_pull_to_next_channel.cpp index 64f70f34b2..b625eef87b 100644 --- a/Telegram/SourceFiles/history/history_view_pull_to_next_channel.cpp +++ b/Telegram/SourceFiles/history/history_view_pull_to_next_channel.cpp @@ -51,6 +51,18 @@ constexpr auto kReleaseHideDuration = crl::time(250); constexpr auto kPanelDuration = crl::time(320); constexpr auto kBounceDuration = crl::time(400); +[[nodiscard]] int PullThreshold() { +#ifdef Q_OS_MAC + // The macOS pull sides stretch with a soft linear stiffness that + // reaches a given height in about half the finger travel of the + // log curve used on other platforms, so a higher threshold keeps + // a comparable gesture length and avoids accidental triggers. + return st::historyPullNextThreshold * 2; +#else // Q_OS_MAC + return st::historyPullNextThreshold; +#endif // Q_OS_MAC +} + [[nodiscard]] History *FindInList( not_null list, not_null current) { @@ -617,7 +629,7 @@ PullToNextChannel::PullToNextChannel( }, _lifetime); _dwellTimer.setCallback([=] { - if (_pulling && _pull >= float64(st::historyPullNextThreshold)) { + if (_pulling && _pull >= float64(PullThreshold())) { _reached = true; _peakPull = _pull; base::Platform::Haptic(); @@ -639,6 +651,11 @@ void PullToNextChannel::setHistory(History *history) { } _history = history; reset(); + updatePullCurve(); +} + +void PullToNextChannel::updatePullCurve() { + _scroll->setOverscrollPullDistances(0, active() ? PullThreshold() : 0); } bool PullToNextChannel::active() const { @@ -661,8 +678,9 @@ void PullToNextChannel::handleOverscroll( Ui::ElasticScrollPosition position, Ui::ElasticScrollMovement movement) { using Phase = Ui::ElasticScrollMovement; + updatePullCurve(); const auto pull = std::max(position.overscroll, 0); - const auto threshold = st::historyPullNextThreshold; + const auto threshold = PullThreshold(); if (!_pulling) { if (movement != Phase::Progress || pull <= 0 || !active()) { return; @@ -761,7 +779,7 @@ void PullToNextChannel::startExpand(bool ready) { void PullToNextChannel::pushIndicator() { const auto card = float64(st::historyPullNextExpand); - const auto threshold = float64(st::historyPullNextThreshold); + const auto threshold = float64(PullThreshold()); const auto expand = _expand.value(_expandTo ? 1. : 0.); const auto effective = std::min( float64(st::historyPullNextMaxHeight), diff --git a/Telegram/SourceFiles/history/history_view_pull_to_next_channel.h b/Telegram/SourceFiles/history/history_view_pull_to_next_channel.h index f592566217..b1b7ff2c2b 100644 --- a/Telegram/SourceFiles/history/history_view_pull_to_next_channel.h +++ b/Telegram/SourceFiles/history/history_view_pull_to_next_channel.h @@ -51,6 +51,7 @@ private: void handleOverscroll( Ui::ElasticScrollPosition position, Ui::ElasticScrollMovement movement); + void updatePullCurve(); void startExpand(bool ready); void pushIndicator(); void clearState();