Commit 5d548179 authored by Xaver Hugl's avatar Xaver Hugl

Fix fullscreen moveresize and set geometry restore to the screen a fullscreen client gets moved to

parent bd626d95
......@@ -1000,14 +1000,15 @@ void AbstractClient::finishMoveResize(bool cancel)
checkScreen(); // needs to be done because clientFinishUserMovedResized has not yet re-activated online alignment
if (screen() != moveResizeStartScreen()) {
workspace()->sendClientToScreen(this, screen()); // checks rule validity
if (maximizeMode() != MaximizeRestore)
if (maximizeMode() != MaximizeRestore) {
checkWorkspacePosition();
}
}
if (isElectricBorderMaximizing()) {
setQuickTileMode(electricBorderMode());
setElectricBorderMaximizing(false);
} else if (!cancel) {
} else if (!cancel && !isFullScreen()) {
QRect geom_restore = geometryRestore();
if (!(maximizeMode() & MaximizeHorizontal)) {
geom_restore.setX(frameGeometry().x());
......@@ -3065,7 +3066,7 @@ void AbstractClient::sendToScreen(int newScreen)
}
}
}
if (screen() == newScreen) // Don't use isOnScreen(), that's true even when only partially
if (screen() == newScreen && !isFullScreen()) // Don't use isOnScreen(), that's true even when only partially
return;
GeometryUpdatesBlocker blocker(this);
......@@ -3107,14 +3108,34 @@ void AbstractClient::sendToScreen(int newScreen)
keepInArea(screenArea);
}
// align geom_restore - checkWorkspacePosition operates on it
setGeometryRestore(frameGeometry());
if (isFullScreen()) {
QRect newFullScreenGeometryRestore = screenArea;
if (!(maximizeMode() & MaximizeVertical)) {
newFullScreenGeometryRestore.setHeight(geometryRestore().height());
}
if (!(maximizeMode() & MaximizeHorizontal)) {
newFullScreenGeometryRestore.setWidth(geometryRestore().width());
}
newFullScreenGeometryRestore.setSize(newFullScreenGeometryRestore.size().boundedTo(screenArea.size()));
QSize move = (screenArea.size() - newFullScreenGeometryRestore.size()) / 2;
newFullScreenGeometryRestore.translate(move.width(), move.height());
checkWorkspacePosition(oldGeom);
QRect newGeometryRestore = QRect(screenArea.topLeft(), geometryRestore().size().boundedTo(screenArea.size()));
move = (screenArea.size() - newGeometryRestore.size()) / 2;
newGeometryRestore.translate(move.width(), move.height());
// re-align geom_restore to constrained geometry
setGeometryRestore(frameGeometry());
setFullscreenGeometryRestore(newFullScreenGeometryRestore);
setGeometryRestore(newGeometryRestore);
checkWorkspacePosition(oldGeom);
} else {
// align geom_restore - checkWorkspacePosition operates on it
setGeometryRestore(frameGeometry());
checkWorkspacePosition(oldGeom);
// re-align geom_restore to constrained geometry
setGeometryRestore(frameGeometry());
}
// finally reset special states
// NOTICE that MaximizeRestore/QuickTileFlag::None checks are required.
// eg. setting QuickTileFlag::None would break maximization
......@@ -3142,7 +3163,7 @@ void AbstractClient::checkWorkspacePosition(QRect oldGeometry, int oldDesktop, Q
if (!oldClientGeometry.isValid())
oldClientGeometry = oldGeometry.adjusted(border[Left], border[Top], -border[Right], -border[Bottom]);
if (isFullScreen()) {
QRect area = workspace()->clientArea(FullScreenArea, geometryRestore().center(), desktop());
QRect area = workspace()->clientArea(FullScreenArea, fullscreenGeometryRestore().center(), desktop());
if (frameGeometry() != area)
setFrameGeometry(area);
return;
......@@ -3560,4 +3581,13 @@ bool AbstractClient::isPlaceable() const
return true;
}
QRect AbstractClient::fullscreenGeometryRestore() const
{
return m_fullscreenGeometryRestore;
}
void AbstractClient::setFullscreenGeometryRestore(const QRect &geom)
{
m_fullscreenGeometryRestore = geom;
}
}
......@@ -868,6 +868,8 @@ public:
return m_windowManagementInterface;
}
QRect fullscreenGeometryRestore() const;
public Q_SLOTS:
virtual void closeWindow() = 0;
......@@ -1222,6 +1224,8 @@ protected:
void setKeyboardGeometryRestore(const QRect &geom);
QRect m_virtualKeyboardGeometry;
void setFullscreenGeometryRestore(const QRect &geom);
private Q_SLOTS:
void shadeHover();
void shadeUnhover();
......@@ -1278,6 +1282,7 @@ private:
QRect m_clientGeometryBeforeUpdateBlocking;
QRect m_keyboardGeometryRestore;
QRect m_maximizeGeometryRestore;
QRect m_fullscreenGeometryRestore;
struct {
bool enabled = false;
......
......@@ -21,9 +21,6 @@ var fullScreenEffect = {
var oldGeometry, newGeometry;
oldGeometry = window.oldGeometry;
newGeometry = window.geometry;
if (oldGeometry.width == newGeometry.width && oldGeometry.height == newGeometry.height)
oldGeometry = window.olderGeometry;
window.olderGeometry = window.oldGeometry;
window.oldGeometry = newGeometry;
window.fullScreenAnimation1 = animate({
window: window,
......@@ -81,7 +78,6 @@ var fullScreenEffect = {
}
}
window.oldGeometry = window.geometry;
window.olderGeometry = oldGeometry;
},
init: function () {
effect.configChanged.connect(fullScreenEffect.loadConfig);
......
......@@ -133,7 +133,7 @@ void Workspace::storeClient(KConfigGroup &cg, int num, X11Client *c)
cg.writeEntry(QLatin1String("resourceClass") + n, c->resourceClass().constData());
cg.writeEntry(QLatin1String("geometry") + n, QRect(c->calculateGravitation(true), c->clientSize())); // FRAME
cg.writeEntry(QLatin1String("restore") + n, c->geometryRestore());
cg.writeEntry(QLatin1String("fsrestore") + n, c->geometryFSRestore());
cg.writeEntry(QLatin1String("fsrestore") + n, c->fullscreenGeometryRestore());
cg.writeEntry(QLatin1String("maximize") + n, (int) c->maximizeMode());
cg.writeEntry(QLatin1String("fullscreen") + n, (int) c->fullScreenMode());
cg.writeEntry(QLatin1String("desktop") + n, c->desktop());
......
......@@ -743,12 +743,14 @@ bool X11Client::manage(xcb_window_t w, bool isMapped)
}
if (session->fullscreen != FullScreenNone) {
setFullScreen(true, false);
geom_fs_restore = session->fsrestore;
setFullscreenGeometryRestore(session->fsrestore);
}
QRect checkedGeometryRestore = geometryRestore();
checkOffscreenPosition(&checkedGeometryRestore, area);
checkOffscreenPosition(&geom_fs_restore, area);
setGeometryRestore(checkedGeometryRestore);
QRect checkedFullscreenGeometryRestore = fullscreenGeometryRestore();
checkOffscreenPosition(&checkedFullscreenGeometryRestore, area);
setFullscreenGeometryRestore(checkedFullscreenGeometryRestore);
} else {
// Window may want to be maximized
// done after checking that the window isn't larger than the workarea, so that
......@@ -4597,7 +4599,7 @@ void X11Client::setFullScreen(bool set, bool user)
if (wasFullscreen) {
workspace()->updateFocusMousePosition(Cursors::self()->mouse()->pos()); // may cause leave event
} else {
geom_fs_restore = frameGeometry();
setFullscreenGeometryRestore(frameGeometry());
}
if (set) {
......@@ -4623,9 +4625,9 @@ void X11Client::setFullScreen(bool set, bool user)
setFrameGeometry(workspace()->clientArea(FullScreenArea, this));
}
} else {
Q_ASSERT(!geom_fs_restore.isNull());
Q_ASSERT(!fullscreenGeometryRestore().isNull());
const int currentScreen = screen();
setFrameGeometry(QRect(geom_fs_restore.topLeft(), constrainFrameSize(geom_fs_restore.size())));
setFrameGeometry(QRect(fullscreenGeometryRestore().topLeft(), constrainFrameSize(fullscreenGeometryRestore().size())));
if(currentScreen != screen()) {
workspace()->sendClientToScreen(this, currentScreen);
}
......
......@@ -144,9 +144,6 @@ public:
void setFullScreen(bool set, bool user = true) override;
bool isFullScreen() const override;
bool userCanSetFullScreen() const override;
QRect geometryFSRestore() const {
return geom_fs_restore; // only for session saving
}
int fullScreenMode() const {
return m_fullscreenMode; // only for session saving
}
......@@ -484,7 +481,6 @@ private:
MaximizeMode max_mode;
QRect m_bufferGeometry = QRect(0, 0, 100, 100);
QRect geom_fs_restore;
xcb_colormap_t m_colormap;
QString cap_normal, cap_iconic, cap_suffix;
Group* in_group;
......
......@@ -1545,7 +1545,7 @@ void XdgToplevelClient::setFullScreen(bool set, bool user)
if (wasFullscreen) {
workspace()->updateFocusMousePosition(Cursors::self()->mouse()->pos()); // may cause leave event
} else {
m_fullScreenGeometryRestore = frameGeometry();
setFullscreenGeometryRestore(frameGeometry());
}
m_isFullScreen = set;
......@@ -1566,10 +1566,10 @@ void XdgToplevelClient::setFullScreen(bool set, bool user)
setFrameGeometry(workspace()->clientArea(FullScreenArea, screen, desktop()));
} else {
m_fullScreenRequestedOutput.clear();
if (m_fullScreenGeometryRestore.isValid()) {
if (fullscreenGeometryRestore().isValid()) {
int currentScreen = screen();
setFrameGeometry(QRect(m_fullScreenGeometryRestore.topLeft(),
constrainFrameSize(m_fullScreenGeometryRestore.size())));
setFrameGeometry(QRect(fullscreenGeometryRestore().topLeft(),
constrainFrameSize(fullscreenGeometryRestore().size())));
if( currentScreen != screen())
workspace()->sendClientToScreen( this, currentScreen );
} else {
......
......@@ -208,7 +208,6 @@ private:
KWaylandServer::XdgToplevelInterface::States m_acknowledgedStates;
KWaylandServer::XdgToplevelInterface::States m_initialStates;
QMap<quint32, PingReason> m_pings;
QRect m_fullScreenGeometryRestore;
NET::WindowType m_windowType = NET::Normal;
MaximizeMode m_maximizeMode = MaximizeRestore;
MaximizeMode m_requestedMaximizeMode = MaximizeRestore;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment