@@ -52,7 +52,9 @@ public final class WindowGroupNode<Content: View>: SceneGraphNode {
5252 self . scene,
5353 proposedWindowSize: newSize,
5454 backend: backend,
55- environment: parentEnvironment
55+ environment: parentEnvironment,
56+ windowSizeIsFinal:
57+ !backend. isWindowProgrammaticallyResizable ( window)
5658 )
5759 }
5860 }
@@ -66,16 +68,17 @@ public final class WindowGroupNode<Content: View>: SceneGraphNode {
6668 fatalError ( " Scene updated with a backend incompatible with the window it was given " )
6769 }
6870
69- let isFixedSize = backend. isFixedSizeWindow ( window)
71+ let isProgramaticallyResizable =
72+ backend. isWindowProgrammaticallyResizable ( window)
7073
7174 _ = update (
7275 newScene,
73- proposedWindowSize: isFirstUpdate && !isFixedSize
76+ proposedWindowSize: isFirstUpdate && isProgramaticallyResizable
7477 ? ( newScene ?? scene) . defaultSize
7578 : backend. size ( ofWindow: window) ,
7679 backend: backend,
7780 environment: environment,
78- windowSizeIsFinal: isFixedSize
81+ windowSizeIsFinal: !isProgramaticallyResizable
7982 )
8083 }
8184
@@ -119,16 +122,18 @@ public final class WindowGroupNode<Content: View>: SceneGraphNode {
119122 }
120123 . with ( \. window, window)
121124
122- // Perform a dry-run update of the root view to check if the window needs to
123- // change size.
124- let contentResult = viewGraph. update (
125- with: newScene? . body,
126- proposedSize: proposedWindowSize,
127- environment: environment,
128- dryRun: !windowSizeIsFinal
129- )
130-
125+ let dryRunResult : ViewUpdateResult ?
131126 if !windowSizeIsFinal {
127+ // Perform a dry-run update of the root view to check if the window
128+ // needs to change size.
129+ let contentResult = viewGraph. update (
130+ with: newScene? . body,
131+ proposedSize: proposedWindowSize,
132+ environment: environment,
133+ dryRun: true
134+ )
135+ dryRunResult = contentResult
136+
132137 let newWindowSize = computeNewWindowSize (
133138 currentProposedSize: proposedWindowSize,
134139 backend: backend,
@@ -148,6 +153,8 @@ public final class WindowGroupNode<Content: View>: SceneGraphNode {
148153 windowSizeIsFinal: false
149154 )
150155 }
156+ } else {
157+ dryRunResult = nil
151158 }
152159
153160 let finalContentResult = viewGraph. update (
@@ -178,14 +185,14 @@ public final class WindowGroupNode<Content: View>: SceneGraphNode {
178185 // Anyway, Gtk3Backend isn't really intended to be a recommended
179186 // backend so I think this is a fine solution for now (people should
180187 // only use Gtk3Backend if they can't use GtkBackend).
181- if finalContentResult. size != contentResult . size {
188+ if let dryRunResult , finalContentResult. size != dryRunResult . size {
182189 print (
183190 """
184191 warning: Final window content size didn't match dry-run size. This is a sign that
185192 either view size caching is broken or that backend.naturalSize(of:) is
186193 broken (or both).
187- -> contentSize : \( contentResult . size)
188- -> finalContentSize : \( finalContentResult. size)
194+ -> dryRunResult.size : \( dryRunResult . size)
195+ -> finalContentResult.size : \( finalContentResult. size)
189196 """
190197 )
191198
@@ -203,17 +210,20 @@ public final class WindowGroupNode<Content: View>: SceneGraphNode {
203210 scene,
204211 proposedWindowSize: newWindowSize,
205212 backend: backend,
206- environment: environment
213+ environment: environment,
214+ windowSizeIsFinal: true
207215 )
208216 }
209217 }
210218
219+ // Set this even if the window isn't programmatically resizable
220+ // because the window may still be user resizable.
211221 if scene. resizability. isResizable {
212222 backend. setMinimumSize (
213223 ofWindow: window,
214224 to: SIMD2 (
215- contentResult . size. minimumWidth,
216- contentResult . size. minimumHeight
225+ finalContentResult . size. minimumWidth,
226+ finalContentResult . size. minimumHeight
217227 )
218228 )
219229 }
@@ -222,8 +232,8 @@ public final class WindowGroupNode<Content: View>: SceneGraphNode {
222232 ofChildAt: 0 ,
223233 in: containerWidget. into ( ) ,
224234 to: SIMD2 (
225- ( proposedWindowSize. x - contentResult . size. size. x) / 2 ,
226- ( proposedWindowSize. y - contentResult . size. size. y) / 2
235+ ( proposedWindowSize. x - finalContentResult . size. size. x) / 2 ,
236+ ( proposedWindowSize. y - finalContentResult . size. size. y) / 2
227237 )
228238 )
229239
0 commit comments