diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index 3a07adea6..8286cf983 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -22,6 +22,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { +constexpr auto kEmptyPidForCommandResponse = 0ULL; + QChar _toHex(ushort v) { v = v & 0x000F; return QChar::fromLatin1((v >= 10) ? ('a' + (v - 10)) : ('0' + v)); @@ -62,6 +64,26 @@ QString _escapeFrom7bit(const QString &str) { } // namespace +bool StartUrlRequiresActivate(const QString &url) { + const auto urlTrimmed = url.trimmed(); + if (!urlTrimmed.startsWith(qstr("tg://"), Qt::CaseInsensitive) || App::passcoded()) { + return true; + } + const auto command = urlTrimmed.midRef(qstr("tg://").size()); + + using namespace qthelp; + const auto matchOptions = RegExOption::CaseInsensitive; + const auto authMatch = regex_match( + qsl("^passport/?\\?(.+)(#|$)"), + command, + matchOptions); + const auto authLegacyMatch = regex_match( + qsl("^resolve/?\\?domain=telegrampassport&(.+)(#|$)"), + command, + matchOptions); + return !authMatch->hasMatch() && !authLegacyMatch->hasMatch(); +} + Application::Application( not_null launcher, int &argc, diff --git a/Telegram/SourceFiles/application.h b/Telegram/SourceFiles/application.h index 97d430484..d3ce02e5a 100644 --- a/Telegram/SourceFiles/application.h +++ b/Telegram/SourceFiles/application.h @@ -12,6 +12,8 @@ class Launcher; class UpdateChecker; } // namespace Core +bool StartUrlRequiresActivate(const QString &url); + class Application : public QApplication { Q_OBJECT diff --git a/Telegram/SourceFiles/messenger.cpp b/Telegram/SourceFiles/messenger.cpp index f71d179dc..7001b2390 100644 --- a/Telegram/SourceFiles/messenger.cpp +++ b/Telegram/SourceFiles/messenger.cpp @@ -274,7 +274,9 @@ bool Messenger::eventFilter(QObject *object, QEvent *e) { cSetStartUrl(url.mid(0, 8192)); checkStartUrl(); } - _window->activate(); + if (StartUrlRequiresActivate(url)) { + _window->activate(); + } } } break; } diff --git a/Telegram/SourceFiles/passport/passport_panel.cpp b/Telegram/SourceFiles/passport/passport_panel.cpp index e57cb640b..5dc9effe9 100644 --- a/Telegram/SourceFiles/passport/passport_panel.cpp +++ b/Telegram/SourceFiles/passport/passport_panel.cpp @@ -287,11 +287,13 @@ void Panel::showInner(base::unique_qptr inner) { } void Panel::focusInEvent(QFocusEvent *e) { - if (_layer) { - _layer->setInnerFocus(); - } else if (!_inner->isHidden()) { - _inner->setFocus(); - } + crl::on_main(this, [=] { + if (_layer) { + _layer->setInnerFocus(); + } else if (!_inner->isHidden()) { + _inner->setFocus(); + } + }); } void Panel::initGeometry() { diff --git a/Telegram/SourceFiles/passport/passport_panel.h b/Telegram/SourceFiles/passport/passport_panel.h index fb547d3fb..6691463af 100644 --- a/Telegram/SourceFiles/passport/passport_panel.h +++ b/Telegram/SourceFiles/passport/passport_panel.h @@ -92,8 +92,6 @@ private: QPoint _dragStartMousePosition; QPoint _dragStartMyPosition; - int _stateChangedSubscription = 0; - Animation _titleLeft; bool _visible = false; diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.cpp b/Telegram/SourceFiles/passport/passport_panel_controller.cpp index ac1a68d46..f879a5353 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_controller.cpp @@ -663,7 +663,7 @@ void PanelController::editScope(int index, int documentIndex) { return object_ptr( _panel.get(), this, - std::move(GetContactScheme(_editScope->type)), + GetContactScheme(_editScope->type), (valueIt == end(parsed.fields) ? QString() : valueIt->second), @@ -862,4 +862,6 @@ rpl::lifetime &PanelController::lifetime() { return _lifetime; } +PanelController::~PanelController() = default; + } // namespace Passport diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.h b/Telegram/SourceFiles/passport/passport_panel_controller.h index 4f01f4077..b03c64284 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.h +++ b/Telegram/SourceFiles/passport/passport_panel_controller.h @@ -94,6 +94,8 @@ public: rpl::lifetime &lifetime(); + ~PanelController(); + private: void ensurePanelCreated(); diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp index 9a8098a9b..08bec14d2 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_contact.cpp @@ -280,7 +280,9 @@ void PanelEditContact::setupControls( } void PanelEditContact::focusInEvent(QFocusEvent *e) { - _field->setFocusFast(); + crl::on_main(this, [=] { + _field->setFocusFast(); + }); } void PanelEditContact::resizeEvent(QResizeEvent *e) { diff --git a/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp b/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp index cb7c197ca..c909ae8fe 100644 --- a/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_edit_document.cpp @@ -256,11 +256,13 @@ not_null PanelEditDocument::setupContent( } void PanelEditDocument::focusInEvent(QFocusEvent *e) { - for (const auto [index, row] : _details) { - if (row->setFocusFast()) { - return; + crl::on_main(this, [=] { + for (const auto [index, row] : _details) { + if (row->setFocusFast()) { + return; + } } - } + }); } void PanelEditDocument::resizeEvent(QResizeEvent *e) { diff --git a/Telegram/SourceFiles/passport/passport_panel_password.cpp b/Telegram/SourceFiles/passport/passport_panel_password.cpp index c852c3965..b5b8684a1 100644 --- a/Telegram/SourceFiles/passport/passport_panel_password.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_password.cpp @@ -89,16 +89,14 @@ void PanelAskPassword::submit() { _controller->submitPassword(_password->getLastText()); } -void PanelAskPassword::setInnerFocus() { - _password->setFocusFast(); -} - void PanelAskPassword::resizeEvent(QResizeEvent *e) { updateControlsGeometry(); } void PanelAskPassword::focusInEvent(QFocusEvent *e) { - _password->setFocusFast(); + crl::on_main(this, [=] { + _password->setFocusFast(); + }); } void PanelAskPassword::updateControlsGeometry() { diff --git a/Telegram/SourceFiles/passport/passport_panel_password.h b/Telegram/SourceFiles/passport/passport_panel_password.h index 90672d100..2a6233d52 100644 --- a/Telegram/SourceFiles/passport/passport_panel_password.h +++ b/Telegram/SourceFiles/passport/passport_panel_password.h @@ -27,7 +27,6 @@ public: QWidget *parent, not_null controller); - void setInnerFocus(); void submit(); protected: diff --git a/Telegram/gyp/telegram_mac.gypi b/Telegram/gyp/telegram_mac.gypi index 3b47af624..97b7638bb 100644 --- a/Telegram/gyp/telegram_mac.gypi +++ b/Telegram/gyp/telegram_mac.gypi @@ -45,7 +45,6 @@ ], }], [ 'build_macold', { 'xcode_settings': { - 'PRODUCT_BUNDLE_IDENTIFIER': 'com.tdesktop.Telegram', 'OTHER_CPLUSPLUSFLAGS': [ '-nostdinc++' ], 'OTHER_LDFLAGS': [ '-lbase', @@ -77,11 +76,17 @@ ], 'configurations': { 'Debug': { + 'xcode_settings': { + 'PRODUCT_BUNDLE_IDENTIFIER': 'com.tdesktop.TelegramDebugOld', + }, 'library_dirs': [ '<(libs_loc)/macold/crashpad/out/Debug', ], }, 'Release': { + 'xcode_settings': { + 'PRODUCT_BUNDLE_IDENTIFIER': 'com.tdesktop.Telegram', + }, 'library_dirs': [ '<(libs_loc)/macold/crashpad/out/Release', ], @@ -147,13 +152,24 @@ }, }], [ '"<(build_macold)" != "1" and "<(build_macstore)" != "1"', { 'xcode_settings': { - 'PRODUCT_BUNDLE_IDENTIFIER': 'com.tdesktop.Telegram', 'OTHER_LDFLAGS': [ '-lbase', '-lcrashpad_client', '-lcrashpad_util', ], }, + 'configurations': { + 'Debug': { + 'xcode_settings': { + 'PRODUCT_BUNDLE_IDENTIFIER': 'com.tdesktop.TelegramDebug', + }, + }, + 'Release': { + 'xcode_settings': { + 'PRODUCT_BUNDLE_IDENTIFIER': 'com.tdesktop.Telegram', + }, + }, + }, 'postbuilds': [{ 'postbuild_name': 'Force Frameworks path', 'action': [