From b52de65bea25f3e49f4feefc6b6ec3668a6798d2 Mon Sep 17 00:00:00 2001
From: Alfred Neumayer <dev.beidl@gmail.com>
Date: Sun, 3 Mar 2024 23:10:29 +0100
Subject: [PATCH 5/8] qml: Rework application window surface clipping

Don't pass the pointer too many layers down, instead rely
on a good old bool property for handling the switch.

Signed-off-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
---
 qml/Stage/ApplicationWindow.qml | 4 ++--
 qml/Stage/DecoratedWindow.qml   | 3 ++-
 qml/Stage/Stage.qml             | 2 +-
 qml/Stage/SurfaceContainer.qml  | 3 ---
 4 files changed, 5 insertions(+), 7 deletions(-)

--- a/qml/Stage/ApplicationWindow.qml
+++ b/qml/Stage/ApplicationWindow.qml
@@ -38,7 +38,7 @@
     property int requestedWidth: -1
     property int requestedHeight: -1
     property real splashRotation: 0
-    property var stage : null
+    property bool clip: false
 
     readonly property int minimumWidth: surface ? surface.minimumWidth : 0
     readonly property int minimumHeight: surface ? surface.minimumHeight : 0
@@ -147,7 +147,7 @@
         requestedWidth: root.requestedWidth
         requestedHeight: root.requestedHeight
         surfaceOrientationAngle: application && application.rotatesWindowContents ? root.surfaceOrientationAngle : 0
-        stage: root.stage
+        clip: root.clip
         onSizeChanged: root.sizeChanged(size)
     }
 
--- a/qml/Stage/DecoratedWindow.qml
+++ b/qml/Stage/DecoratedWindow.qml
@@ -39,7 +39,6 @@
     property alias interactive: applicationWindow.interactive
     readonly property alias orientationChangesEnabled: applicationWindow.orientationChangesEnabled
     property alias windowControlButtonsVisible: decoration.windowControlButtonsVisible
-    property alias stage: applicationWindow.stage
     property PanelState panelState
 
     // Changing this will actually add/remove a decoration, meaning, requestedHeight will take the decoration into account.
@@ -83,6 +82,8 @@
 
     property alias altDragEnabled: altDragHandler.enabled
 
+    property alias clipSurface: applicationWindow.clip
+
     property Item windowMargins
 
     signal closeClicked()
--- a/qml/Stage/Stage.qml
+++ b/qml/Stage/Stage.qml
@@ -2099,7 +2099,6 @@
                     objectName: "decoratedWindow"
                     anchors.left: appDelegate.left
                     anchors.top: appDelegate.top
-                    stage: root
                     application: model.application
                     surface: model.window.surface
                     active: model.window.focused
@@ -2116,6 +2115,7 @@
                     panelState: root.panelState
                     altDragEnabled: root.mode == "windowed"
                     lightMode: root.lightMode
+                    clipSurface: root.mode === "windowed"
 
                     requestedWidth: appDelegate.requestedWidth
                     requestedHeight: appDelegate.requestedHeight
--- a/qml/Stage/SurfaceContainer.qml
+++ b/qml/Stage/SurfaceContainer.qml
@@ -36,7 +36,6 @@
     property bool interactive
     property int surfaceOrientationAngle: 0
     property bool isPromptSurface: false
-    property var stage : null
     // FIME - dont export, use interactive property. Need to fix qtmir to handle consumesInputChanged
     // to update surface activeFocus. See mock MirSurfaceItem.
     property alias consumesInput: surfaceItem.consumesInput
@@ -82,8 +81,6 @@
         antialiasing: !root.interactive
         orientationAngle: root.surfaceOrientationAngle
 
-        clip: stage && stage.mode === "windowed"
-
         Connections {
             target: surfaceItem.surface
             onSizeChanged: {
