Backport a fix for custom window title.

This commit is contained in:
John Preston 2019-10-20 14:23:02 +04:00
parent 27a83a7a09
commit 768a3d5a12

View file

@ -54,6 +54,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
- (void) screenIsUnlocked:(NSNotification *)aNotification;
- (void) windowWillEnterFullScreen:(NSNotification *)aNotification;
- (void) windowWillExitFullScreen:(NSNotification *)aNotification;
- (void) windowDidExitFullScreen:(NSNotification *)aNotification;
@end // @interface MainWindowObserver
@ -138,6 +139,7 @@ public:
void willEnterFullScreen();
void willExitFullScreen();
void didExitFullScreen();
bool clipboardHasText();
@ -148,6 +150,7 @@ public:
private:
void initCustomTitle();
void refreshWeakTitleReferences();
void enforceCorrectStyleMask();
not_null<MainWindow*> _public;
friend class MainWindow;
@ -211,6 +214,10 @@ private:
_private->willExitFullScreen();
}
- (void) windowDidExitFullScreen:(NSNotification *)aNotification {
_private->didExitFullScreen();
}
@end // @implementation MainWindowObserver
namespace Platform {
@ -284,6 +291,7 @@ void MainWindow::Private::initCustomTitle() {
[[NSNotificationCenter defaultCenter] addObserver:_observer selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:_nativeWindow];
[[NSNotificationCenter defaultCenter] addObserver:_observer selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:_nativeWindow];
[[NSNotificationCenter defaultCenter] addObserver:_observer selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:_nativeWindow];
// Qt has bug with layer-backed widgets containing QOpenGLWidgets.
// See https://bugreports.qt.io/browse/QTBUG-64494
@ -403,6 +411,17 @@ void MainWindow::Private::willEnterFullScreen() {
void MainWindow::Private::willExitFullScreen() {
_inFullScreen = false;
_public->setTitleVisible(true);
enforceCorrectStyleMask();
}
void MainWindow::Private::didExitFullScreen() {
enforceCorrectStyleMask();
}
void MainWindow::Private::enforceCorrectStyleMask() {
if (_nativeWindow && _public->_customTitleHeight > 0) {
[_nativeWindow setStyleMask:[_nativeWindow styleMask] | NSFullSizeContentViewWindowMask];
}
}
void MainWindow::Private::enableShadow(WId winId) {