placementtracker: save geometry restores more explicitly

Geometry restores were only saved when maximize or fullscreen changed, which is
not the only time the geometry restores change. This adds a signal to Window for
that, which fixes a few bugs with windows being moved between screens while
maximized or fullscreened
This commit is contained in:
Xaver Hugl 2024-02-19 15:50:07 +01:00
parent 86db3b4336
commit 2c280b1bb0
4 changed files with 37 additions and 8 deletions

View file

@ -53,6 +53,12 @@ void PlacementTracker::add(Window *window)
connect(window, &Window::interactiveMoveResizeFinished, this, [this, window]() {
saveInteractionCounter(window);
});
connect(window, &Window::maximizeGeometryRestoreChanged, this, [this, window]() {
saveMaximizeGeometryRestore(window);
});
connect(window, &Window::fullscreenGeometryRestoreChanged, this, [this, window]() {
saveFullscreenGeometryRestore(window);
});
WindowData data = dataForWindow(window);
m_data[m_currentKey][window] = data;
m_savedWindows.push_back(window);
@ -161,7 +167,6 @@ void PlacementTracker::saveMaximize(Window *window)
if (m_inhibitCount == 0) {
auto &data = m_data[m_currentKey][window];
data.maximize = window->maximizeMode();
data.geometryRestore = window->geometryRestore();
}
}
@ -170,7 +175,6 @@ void PlacementTracker::saveQuickTile(Window *window)
if (m_inhibitCount == 0) {
auto &data = m_data[m_currentKey][window];
data.quickTile = window->quickTileMode();
data.geometryRestore = window->geometryRestore();
}
}
@ -179,6 +183,21 @@ void PlacementTracker::saveFullscreen(Window *window)
if (m_inhibitCount == 0) {
auto &data = m_data[m_currentKey][window];
data.fullscreen = window->isFullScreen();
}
}
void PlacementTracker::saveMaximizeGeometryRestore(Window *window)
{
if (m_inhibitCount == 0) {
auto &data = m_data[m_currentKey][window];
data.geometryRestore = window->geometryRestore();
}
}
void PlacementTracker::saveFullscreenGeometryRestore(Window *window)
{
if (m_inhibitCount == 0) {
auto &data = m_data[m_currentKey][window];
data.fullscreenGeometryRestore = window->fullscreenGeometryRestore();
}
}

View file

@ -55,6 +55,8 @@ private:
void saveMaximize(Window *window);
void saveQuickTile(Window *window);
void saveFullscreen(Window *window);
void saveMaximizeGeometryRestore(Window *window);
void saveFullscreenGeometryRestore(Window *window);
WindowData dataForWindow(Window *window) const;
QList<Window *> m_savedWindows;

View file

@ -3649,8 +3649,8 @@ void Window::sendToOutput(Output *newOutput)
moveResize(newGeom);
// move geometry restores to the new output as well
m_fullscreenGeometryRestore = moveToArea(m_fullscreenGeometryRestore, oldScreenArea, screenArea);
m_maximizeGeometryRestore = moveToArea(m_maximizeGeometryRestore, oldScreenArea, screenArea);
setFullscreenGeometryRestore(moveToArea(m_fullscreenGeometryRestore, oldScreenArea, screenArea));
setGeometryRestore(moveToArea(m_maximizeGeometryRestore, oldScreenArea, screenArea));
auto tso = workspace()->ensureStackingOrder(transients());
for (auto it = tso.constBegin(), end = tso.constEnd(); it != end; ++it) {
@ -3704,8 +3704,8 @@ void Window::checkWorkspacePosition(QRectF oldGeometry, const VirtualDesktop *ol
if (isRequestedFullScreen() || requestedMaximizeMode() != MaximizeRestore || quickTileMode() != QuickTileMode(QuickTileFlag::None)) {
moveResize(ensureSpecialStateGeometry(newGeom));
m_fullscreenGeometryRestore = moveToArea(m_fullscreenGeometryRestore, oldScreenArea, screenArea);
m_maximizeGeometryRestore = moveToArea(m_maximizeGeometryRestore, oldScreenArea, screenArea);
setFullscreenGeometryRestore(moveToArea(m_fullscreenGeometryRestore, oldScreenArea, screenArea));
setGeometryRestore(moveToArea(m_maximizeGeometryRestore, oldScreenArea, screenArea));
return;
}
@ -3912,7 +3912,10 @@ QRectF Window::fullscreenGeometryRestore() const
void Window::setFullscreenGeometryRestore(const QRectF &geom)
{
m_fullscreenGeometryRestore = geom;
if (m_fullscreenGeometryRestore != geom) {
m_fullscreenGeometryRestore = geom;
Q_EMIT fullscreenGeometryRestoreChanged();
}
}
/**
@ -4014,7 +4017,10 @@ QRectF Window::geometryRestore() const
*/
void Window::setGeometryRestore(const QRectF &rect)
{
m_maximizeGeometryRestore = rect;
if (m_maximizeGeometryRestore != rect) {
m_maximizeGeometryRestore = rect;
Q_EMIT maximizeGeometryRestoreChanged();
}
}
void Window::invalidateDecoration()

View file

@ -1435,6 +1435,8 @@ Q_SIGNALS:
void hiddenByShowDesktopChanged();
void lockScreenOverlayChanged();
void readyForPaintingChanged();
void maximizeGeometryRestoreChanged();
void fullscreenGeometryRestoreChanged();
protected:
Window();