2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Fix saving maximized state on Linux

This commit is contained in:
Ilya Fedin
2020-09-18 13:09:05 +04:00
committed by John Preston
parent 70c993774a
commit 4c2779bbaf
4 changed files with 38 additions and 10 deletions

View File

@@ -236,6 +236,11 @@ void MainWindow::init() {
&QWindow::windowStateChanged,
this,
[=](Qt::WindowState state) { handleStateChanged(state); });
connect(
windowHandle(),
&QWindow::visibleChanged,
this,
[=](bool visible) { handleVisibleChanged(visible); });
updatePalette();
@@ -278,6 +283,19 @@ void MainWindow::handleActiveChanged() {
});
}
void MainWindow::handleVisibleChanged(bool visible) {
if (visible) {
if (_maximizedBeforeHide) {
DEBUG_LOG(("Window Pos: Window was maximized before hidding, setting maximized."));
setWindowState(Qt::WindowMaximized);
}
} else {
_maximizedBeforeHide = cWindowPos().maximized;
}
handleVisibleChangedHook(visible);
}
void MainWindow::updatePalette() {
Ui::ForceFullRepaint(this);
@@ -521,8 +539,15 @@ void MainWindow::updateUnreadCounter() {
}
void MainWindow::savePosition(Qt::WindowState state) {
if (state == Qt::WindowActive) state = windowHandle()->windowState();
if (state == Qt::WindowMinimized || !positionInited()) return;
if (state == Qt::WindowActive) {
state = windowHandle()->windowState();
}
if (state == Qt::WindowMinimized
|| !isVisible()
|| !positionInited()) {
return;
}
auto savedPosition = cWindowPos();
auto realPosition = savedPosition;