From 0931e4f8cc1cd5f7a6c64e0f78f6e58371b6a7da Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 26 Aug 2021 13:03:48 +0300 Subject: [PATCH] effects/overview: Pad screen borders in qml This makes it easier to spot if the effect is activated while there is only one maximized window. Note that anchors.margins cannot be used unfortunately as it won't take effect until the ExpoLayout item is fully constructed. It may take a couple of cycles for the geometry to settle down, which makes reasoning about how the effect works difficult. BUG: 312146 --- src/effects/overview/expolayout.cpp | 10 +++++----- src/effects/overview/qml/ScreenView.qml | 1 + src/effects/overview/qml/WindowHeap.qml | 6 +++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/effects/overview/expolayout.cpp b/src/effects/overview/expolayout.cpp index a00ba2a8d4..5f843a4e33 100644 --- a/src/effects/overview/expolayout.cpp +++ b/src/effects/overview/expolayout.cpp @@ -687,13 +687,13 @@ void ExpoLayout::calculateWindowTransformationsNatural() if (bounds == area) { scale = 1.0; // Don't add borders to the screen } else if (area.width() / qreal(bounds.width()) < area.height() / qreal(bounds.height())) { - scale = (area.width() - 2 * m_spacing) / qreal(bounds.width()); + scale = area.width() / qreal(bounds.width()); } else { - scale = (area.height() - 2 * m_spacing) / qreal(bounds.height()); + scale = area.height() / qreal(bounds.height()); } // Make bounding rect fill the screen size for later steps - bounds = QRect((bounds.x() * scale - (area.width() - 2 * m_spacing - bounds.width() * scale) / 2 - m_spacing) / scale, - (bounds.y() * scale - (area.height() - 2 * m_spacing - bounds.height() * scale) / 2 - m_spacing) / scale, + bounds = QRect(bounds.x() - (area.width() / scale - bounds.width()) / 2, + bounds.y() - (area.height() / scale - bounds.height()) / 2, area.width() / scale, area.height() / scale); @@ -711,7 +711,7 @@ void ExpoLayout::calculateWindowTransformationsNatural() if (m_fillGaps) { // Don't expand onto or over the border QRegion borderRegion(area.adjusted(-200, -200, 200, 200)); - borderRegion ^= area.adjusted(m_spacing / scale, m_spacing / scale, -m_spacing / scale, -m_spacing / scale); + borderRegion ^= area; bool moved; do { diff --git a/src/effects/overview/qml/ScreenView.qml b/src/effects/overview/qml/ScreenView.qml index 6ec971df82..77832123a6 100644 --- a/src/effects/overview/qml/ScreenView.qml +++ b/src/effects/overview/qml/ScreenView.qml @@ -85,6 +85,7 @@ FocusScope { y: heapArea.y width: heapArea.width height: heapArea.height + padding: PlasmaCore.Units.largeSpacing focus: true animationEnabled: container.animationEnabled organized: container.organized diff --git a/src/effects/overview/qml/WindowHeap.qml b/src/effects/overview/qml/WindowHeap.qml index 4b56241326..849c3974e3 100644 --- a/src/effects/overview/qml/WindowHeap.qml +++ b/src/effects/overview/qml/WindowHeap.qml @@ -24,12 +24,16 @@ FocusScope { property alias model: windowsRepeater.model property int selectedIndex: -1 property bool animationEnabled: false + property real padding: 0 required property bool organized ExpoLayout { id: expoLayout - anchors.fill: parent + x: heap.padding + y: heap.padding + width: parent.width - 2 * heap.padding + height: parent.height - 2 * heap.padding mode: effect.layout focus: true spacing: PlasmaCore.Units.largeSpacing