From d3741bd530cdd20eccb09f7f6e960d4c2465ac3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 30 Aug 2016 13:16:52 +0200 Subject: [PATCH] Set the restore geometry after placing a ShellClient for the first time Summary: The restore geometry gets initially set to 0/0xsize before the placement is done. When going into updateClientArea and then afterwards into AbstractClient::checkWorkspacePosition the geometry restory is used for calculating the new position. This results in windows getting moved to 0/0 when e.g. plugging in a new screen or a panel changes, etc. This change ensures that the restore geometry is set correctly after the first placement. BUG: 366696 Reviewers: #kwin, #plasma_on_wayland, bshah Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2627 --- autotests/integration/plasma_surface_test.cpp | 1 - shell_client.cpp | 8 +++++++- shell_client.h | 3 +++ workspace.cpp | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/autotests/integration/plasma_surface_test.cpp b/autotests/integration/plasma_surface_test.cpp index 5e6c728d9a..3ff802236d 100644 --- a/autotests/integration/plasma_surface_test.cpp +++ b/autotests/integration/plasma_surface_test.cpp @@ -232,7 +232,6 @@ void PlasmaSurfaceTest::testOSDPlacement() QCOMPARE(screens()->geometry(0), geometries.at(0)); QCOMPARE(screens()->geometry(1), geometries.at(1)); - QEXPECT_FAIL("", "Geometry should not change due to a screen being added", Continue); QCOMPARE(c->geometry(), QRect(590, 649, 100, 50)); } diff --git a/shell_client.cpp b/shell_client.cpp index e9d56297ab..25507c3b10 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -21,6 +21,7 @@ along with this program. If not, see . #include "composite.h" #include "cursor.h" #include "deleted.h" +#include "placement.h" #include "screens.h" #include "wayland_server.h" #include "workspace.h" @@ -478,7 +479,6 @@ void ShellClient::doSetGeometry(const QRect &rect) if (m_unmapped && m_geomMaximizeRestore.isEmpty() && !geom.isEmpty()) { // use first valid geometry as restore geometry - // TODO: needs to interact with placing. The first valid geometry should be the placed one m_geomMaximizeRestore = geom; } @@ -1223,4 +1223,10 @@ void ShellClient::finishCompositing(ReleaseReason releaseReason) Toplevel::finishCompositing(releaseReason); } +void ShellClient::placeIn(QRect &area) +{ + Placement::self()->place(this, area); + setGeometryRestore(geometry()); +} + } diff --git a/shell_client.h b/shell_client.h index ac3e1f62a2..9fd06bec98 100644 --- a/shell_client.h +++ b/shell_client.h @@ -127,6 +127,9 @@ public: bool setupCompositing() override; void finishCompositing(ReleaseReason releaseReason = ReleaseReason::Release) override; + // TODO: const-ref + void placeIn(QRect &area); + protected: void addDamage(const QRegion &damage) override; bool belongsToSameApplication(const AbstractClient *other, bool active_hack) const override; diff --git a/workspace.cpp b/workspace.cpp index bfcc2a8f17..d2971de365 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -381,7 +381,7 @@ void Workspace::init() placementDone = true; } if (!placementDone) { - Placement::self()->place(c, area); + c->placeIn(area); } m_allClients.append(c); if (!unconstrained_stacking_order.contains(c)) @@ -401,7 +401,7 @@ void Workspace::init() // TODO: when else should we send the client through placement? if (c->hasTransientPlacementHint()) { QRect area = clientArea(PlacementArea, Screens::self()->current(), c->desktop()); - Placement::self()->place(c, area); + c->placeIn(area); } x_stacking_dirty = true; updateStackingOrder(true);