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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user