2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Better handle window hide / activate in macOS. #1278

When we hide window by 'x' title button or by cmd+w key we try to
deactivate the whole application (so some other app gets activated).

When we activate the application in any way we check if the main
window is hidden and if it is - we show it and activate it.
This commit is contained in:
John Preston
2017-02-18 16:32:38 +03:00
parent 6e1b6e6e53
commit 843089733b
4 changed files with 32 additions and 9 deletions

View File

@@ -912,13 +912,28 @@ void AppClass::checkLocalTime() {
}
void AppClass::onAppStateChanged(Qt::ApplicationState state) {
if (state == Qt::ApplicationActive) {
handleAppActivated();
} else {
handleAppDeactivated();
}
}
void AppClass::handleAppActivated() {
checkLocalTime();
if (_window) {
_window->updateIsActive((state == Qt::ApplicationActive) ? Global::OnlineFocusTimeout() : Global::OfflineBlurTimeout());
if (_window->isHidden()) {
_window->showFromTray();
}
_window->updateIsActive(Global::OnlineFocusTimeout());
}
if (state != Qt::ApplicationActive) {
Ui::Tooltip::Hide();
}
void AppClass::handleAppDeactivated() {
if (_window) {
_window->updateIsActive(Global::OfflineBlurTimeout());
}
Ui::Tooltip::Hide();
}
void AppClass::call_handleHistoryUpdate() {