From 3357ede5ebec644190313d266f4467ac383f2987 Mon Sep 17 00:00:00 2001 From: Alfred Neumayer Date: Sun, 3 Mar 2024 12:56:39 +0100 Subject: [PATCH 4/8] qml: Resize Window Decoration with surfaces Apparent in GIMP with its splash screen, the decorations draw outside of the surfaces geometry limits. React to surface's sizeChanged signals and pass the new value on to the decoration to set the size accordingly. Signed-off-by: Mike Gabriel --- qml/Stage/ApplicationWindow.qml | 3 +++ qml/Stage/DecoratedWindow.qml | 4 ++++ qml/Stage/SurfaceContainer.qml | 9 +++++++++ 3 files changed, 16 insertions(+) --- a/qml/Stage/ApplicationWindow.qml +++ b/qml/Stage/ApplicationWindow.qml @@ -47,6 +47,8 @@ readonly property int widthIncrement: surface ? surface.widthIncrement : 0 readonly property int heightIncrement: surface ? surface.heightIncrement : 0 + signal sizeChanged(size size) + Connections { target: surface function onReady() { d.surfaceUp() } @@ -146,6 +148,7 @@ requestedWidth: root.requestedWidth requestedHeight: root.requestedHeight surfaceOrientationAngle: application && application.rotatesWindowContents ? root.surfaceOrientationAngle : 0 + onSizeChanged: root.sizeChanged(size) } Loader { --- a/qml/Stage/DecoratedWindow.qml +++ b/qml/Stage/DecoratedWindow.qml @@ -181,6 +181,10 @@ // onRequestedWidthChanged: oldRequestedWidth = requestedWidth // onRequestedHeightChanged: oldRequestedHeight = requestedHeight focus: true + onSizeChanged: { + implicitWidth = size.width + implicitHeight = size.height + } property real itemScale: 1 property real minSize: Math.min(root.scaleToPreviewSize, Math.min(requestedHeight, Math.min(requestedWidth, Math.min(implicitHeight, implicitWidth)))) --- a/qml/Stage/SurfaceContainer.qml +++ b/qml/Stage/SurfaceContainer.qml @@ -43,6 +43,8 @@ property bool hadSurface: false + signal sizeChanged(size size) + onSurfaceChanged: { // Not a binding because animations might remove the surface from the surfaceItem // programatically (in order to signal that a zombie surface is free for deletion), @@ -81,6 +83,13 @@ enabled: root.interactive antialiasing: !root.interactive orientationAngle: root.surfaceOrientationAngle + + Connections { + target: surfaceItem.surface + onSizeChanged: { + root.sizeChanged(value) + } + } } TouchGate {