diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index 50c98da2e..00d0ff1e2 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -33,6 +33,7 @@ "ktg_settings_sticker_scale_both_about": "When enabled, sticker maximum width will be changed along with sticker height.", "ktg_settings_emoji_outline": "Big emoji outline", "ktg_settings_disable_up_edit": "Disable edit by Up key", + "ktg_settings_auto_scroll_unfocused": "Unfocused auto-scroll", "ktg_settings_always_show_scheduled": "Always show scheduled", "ktg_settings_chat_list_compact": "Compact chat list", "ktg_fonts_title": "Fonts", diff --git a/Telegram/SourceFiles/kotato/kotato_settings.cpp b/Telegram/SourceFiles/kotato/kotato_settings.cpp index 614962af2..59d72a637 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -406,6 +406,9 @@ const std::map> DefinitionMap { { "profile_top_mute", { .type = SettingType::BoolSetting, .defaultValue = false, }}, + { "auto_scroll_unfocused", { + .type = SettingType::BoolSetting, + .defaultValue = false, }}, { "folders/local", { .scope = SettingScope::Account, .type = SettingType::QJsonArraySetting, }}, diff --git a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp index 972ad0fdb..20e68fe52 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp @@ -202,6 +202,12 @@ void SetupKotatoChats( SettingsMenuJsonSwitch(ktg_settings_top_bar_mute, profile_top_mute); SettingsMenuJsonSwitch(ktg_settings_disable_up_edit, disable_up_edit); +#ifndef Q_OS_WIN + if (Ui::Platform::IsOverlapped(container, QRect()).has_value()) { + SettingsMenuJsonSwitch(ktg_settings_auto_scroll_unfocused, auto_scroll_unfocused); + } +#endif + AddButton( container, rktr("ktg_settings_chat_list_compact"), diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 1d12884a9..c0666bca5 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "mainwindow.h" +#include "kotato/kotato_settings.h" #include "data/data_document.h" #include "data/data_session.h" #include "data/data_document_media.h" @@ -543,6 +544,16 @@ bool MainWindow::doWeMarkAsRead() { if (!_main || Ui::isLayerShown()) { return false; } + if (::Kotato::JsonSettings::GetBool("auto_scroll_unfocused")) { + // for tile grid in case other windows have shadows + // i've seen some windows with >70px shadow margins + const auto margin = style::ConvertScale(100); + const auto inner = body()->rect(); + return Ui::IsContentVisible( + this, + inner.marginsRemoved(QMargins(margin, margin, margin, margin))) + && _main->doWeMarkAsRead(); + } return isActive() && _main->doWeMarkAsRead(); }