File: 1026_qml-Disallow-resizing-unresizeable-windows-follow-ma.patch

package info (click to toggle)
lomiri 0.5.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,088 kB
  • sloc: cpp: 39,498; python: 2,559; javascript: 1,426; ansic: 1,012; sh: 289; xml: 252; makefile: 69
file content (71 lines) | stat: -rw-r--r-- 3,038 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From e6b3a2f006d3fb2ca3276b8473173becd11f74af Mon Sep 17 00:00:00 2001
From: Alfred Neumayer <dev.beidl@gmail.com>
Date: Thu, 7 Mar 2024 14:50:13 +0100
Subject: [PATCH 6/8] qml: Disallow resizing unresizeable windows & follow
 maximum/minimum geometry

- Set window geometry based on surface's minimum and maximum limits
- Prevent resize handles from doing anything when minimum and maximum limits match

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

--- a/qml/Stage/ApplicationWindow.qml
+++ b/qml/Stage/ApplicationWindow.qml
@@ -30,6 +30,7 @@
     readonly property string title: surface && surface.name !== "" ? surface.name : d.name
     readonly property QtObject focusedSurface: d.focusedSurface.surface
     readonly property alias surfaceInitialized: d.surfaceInitialized
+    readonly property bool supportsResize: d.surfaceOldEnoughToBeResized && d.supportsSurfaceResize
 
     // to be set from outside
     property QtObject surface
@@ -49,6 +50,15 @@
 
     signal sizeChanged(size size)
 
+    onSizeChanged: {
+        let width = Math.max(size.width, root.minimumWidth)
+        width = Math.min(width, root.maximumWidth)
+        let height = Math.max(size.height, root.minimumHeight)
+        height = Math.min(height, root.maximumHeight)
+        implicitWidth = width
+        implicitHeight = height
+    }
+
     Connections {
         target: surface
         function onReady() {  d.surfaceUp() }
@@ -104,6 +114,8 @@
                 &&
                 ((application.supportedOrientations & Qt.LandscapeOrientation)
                  || (application.supportedOrientations & Qt.InvertedLandscapeOrientation))
+                &&
+                !((root.minimumWidth === root.maximumWidth) && (root.minimumHeight === root.maximumHeight))
 
         property bool surfaceOldEnoughToBeResized: false
 
--- a/qml/Stage/DecoratedWindow.qml
+++ b/qml/Stage/DecoratedWindow.qml
@@ -33,6 +33,7 @@
     property alias application: applicationWindow.application
     property alias surface: applicationWindow.surface
     readonly property alias focusedSurface: applicationWindow.focusedSurface
+    readonly property alias supportsResize: applicationWindow.supportsResize
     property alias active: decoration.active
     readonly property alias title: applicationWindow.title
     property alias maximizeButtonShown: decoration.maximizeButtonShown
@@ -182,10 +183,6 @@
 //        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))))