Properly implement maximize of ShellClient

Summary:
This brings some more checks from Client to ShellClient. Thus the
states are better adjusted.

Unfortunately the X11 implementation is also slightly adjusted, so could
create regressions in worst case.

BUG: 368393

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3507
This commit is contained in:
Martin Gräßlin 2016-09-16 14:27:50 +02:00
parent d06098ff30
commit 9934f5b575
3 changed files with 46 additions and 4 deletions

View file

@ -178,7 +178,6 @@ void QuickTilingTest::testQuickTiling()
c->sendToScreen(1);
QCOMPARE(c->screen(), 1);
// quick tile should not be changed
QEXPECT_FAIL("maximize", "Maximize loses the state", Continue);
QCOMPARE(c->quickTileMode(), mode);
QTEST(c->geometry(), "secondScreen");
}

View file

@ -3299,6 +3299,7 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
setMaximize(false, false);
} else {
QRect prev_geom_restore = geometryRestore(); // setMaximize() would set moveResizeGeom as geom_restore
m_quickTileMode = QuickTileMaximize;
setMaximize(true, true);
QRect clientArea = workspace()->clientArea(MaximizeArea, this);
if (geometry().top() != clientArea.top()) {
@ -3306,7 +3307,6 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
r.moveTop(clientArea.top());
setGeometry(r);
}
m_quickTileMode = QuickTileMaximize;
setGeometryRestore(prev_geom_restore);
}
emit quickTileModeChanged();
@ -3326,8 +3326,6 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
TabSynchronizer syncer(this, TabGroup::QuickTile|TabGroup::Geometry|TabGroup::Maximized);
setMaximize(false, false);
if (mode != QuickTileNone) {
m_quickTileMode = mode;
// decorations may turn off some borders when tiled
@ -3337,6 +3335,9 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
}
// Store the mode change
m_quickTileMode = mode;
setMaximize(false, false);
emit quickTileModeChanged();
return;

View file

@ -658,6 +658,15 @@ void ShellClient::changeMaximize(bool horizontal, bool vertical, bool adjust)
if (changeMaximizeRecursion) {
return;
}
if (!isResizable()) {
return;
}
const QRect clientArea = isElectricBorderMaximizing() ?
workspace()->clientArea(MaximizeArea, Cursor::pos(), desktop()) :
workspace()->clientArea(MaximizeArea, this);
MaximizeMode oldMode = m_maximizeMode;
StackingUpdatesBlocker blocker(workspace());
RequestGeometryBlocker geometryBlocker(this);
@ -686,12 +695,45 @@ void ShellClient::changeMaximize(bool horizontal, bool vertical, bool adjust)
changeMaximizeRecursion = false;
}
// TODO: borderless maximized windows
// Conditional quick tiling exit points
const auto oldQuickTileMode = quickTileMode();
if (quickTileMode() != QuickTileNone) {
if (oldMode == MaximizeFull &&
!clientArea.contains(m_geomMaximizeRestore.center())) {
// Not restoring on the same screen
// TODO: The following doesn't work for some reason
//quick_tile_mode = QuickTileNone; // And exit quick tile mode manually
} else if ((oldMode == MaximizeVertical && m_maximizeMode == MaximizeRestore) ||
(oldMode == MaximizeFull && m_maximizeMode == MaximizeHorizontal)) {
// Modifying geometry of a tiled window
updateQuickTileMode(QuickTileNone); // Exit quick tile mode without restoring geometry
}
}
// TODO: check rules
if (m_maximizeMode == MaximizeFull) {
m_geomMaximizeRestore = geometry();
// TODO: Client has more checks
if (options->electricBorderMaximize()) {
updateQuickTileMode(QuickTileMaximize);
} else {
updateQuickTileMode(QuickTileNone);
}
if (quickTileMode() != oldQuickTileMode) {
emit quickTileModeChanged();
}
requestGeometry(workspace()->clientArea(MaximizeArea, this));
workspace()->raiseClient(this);
} else {
if (m_maximizeMode == MaximizeRestore) {
updateQuickTileMode(QuickTileNone);
}
if (quickTileMode() != oldQuickTileMode) {
emit quickTileModeChanged();
}
if (m_geomMaximizeRestore.isValid()) {
requestGeometry(m_geomMaximizeRestore);
} else {