From c42460760357194398ffd758b7426af3d739e910 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 2 May 2019 14:02:54 +0300 Subject: [PATCH] Added passcode lock handler for touchbar. --- Telegram/SourceFiles/platform/mac/touchbar.h | 1 + Telegram/SourceFiles/platform/mac/touchbar.mm | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/Telegram/SourceFiles/platform/mac/touchbar.h b/Telegram/SourceFiles/platform/mac/touchbar.h index dec5806c64..9f3311d349 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar.h +++ b/Telegram/SourceFiles/platform/mac/touchbar.h @@ -36,6 +36,7 @@ static NSTouchBarItemIdentifier _Nullable currentPosition = [NSString stringWith @interface TouchBar : NSTouchBar @property TouchBarType touchBarType; +@property TouchBarType touchBarTypeBeforeLock; @property(retain) NSDictionary * _Nullable touchbarItems; @property(retain) NSTouchBar * _Nullable touchBarMain; diff --git a/Telegram/SourceFiles/platform/mac/touchbar.mm b/Telegram/SourceFiles/platform/mac/touchbar.mm index d426011385..065b5821e4 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar.mm +++ b/Telegram/SourceFiles/platform/mac/touchbar.mm @@ -268,6 +268,16 @@ auto lifetime = rpl::lifetime(); } }, lifetime); + Core::App().passcodeLockChanges( + ) | rpl::start_with_next([=](bool locked) { + if (locked) { + self.touchBarTypeBeforeLock = self.touchBarType; + [self setTouchBar:TouchBarType::None]; + } else { + [self setTouchBar:self.touchBarTypeBeforeLock]; + } + }, lifetime); + return self; } @@ -341,6 +351,8 @@ auto lifetime = rpl::lifetime(); [self.view setTouchBar:_touchBarMain]; } else if (type == TouchBarType::AudioPlayer) { [self.view setTouchBar:_touchBarAudioPlayer]; + } else if (type == TouchBarType::None) { + [self.view setTouchBar:nil]; } }