@@ -75,6 +75,15 @@ public protocol AppBackend {
75
75
var requiresToggleSwitchSpacer : Bool { get }
76
76
/// The default style for toggles.
77
77
var defaultToggleStyle : ToggleStyle { get }
78
+ /// If `true`, all images in a window will get updated when the window's
79
+ /// scale factor changes (``EnvironmentValues/windowScaleFactor``).
80
+ ///
81
+ /// Backends based on modern UI frameworks can usually get away with setting
82
+ /// this to `false`, but backends such as `Gtk3Backend` have to set this to
83
+ /// `true` to properly support HiDPI (aka Retina) displays because they
84
+ /// manually rescale the image meaning that it must get rescaled when the
85
+ /// scale factor changes.
86
+ var requiresImageUpdateOnScaleFactorChange : Bool { get }
78
87
79
88
/// Often in UI frameworks (such as Gtk), code is run in a callback
80
89
/// after starting the app, and hence this generic root window creation
@@ -164,6 +173,23 @@ public protocol AppBackend {
164
173
/// may or may not override the previous handler.
165
174
func setRootEnvironmentChangeHandler( to action: @escaping ( ) -> Void )
166
175
176
+ /// Computes a window's environment based off the root environment. This may involve
177
+ /// updating ``EnvironmentValues/windowScaleFactor`` etc.
178
+ func computeWindowEnvironment(
179
+ window: Window ,
180
+ rootEnvironment: EnvironmentValues
181
+ ) -> EnvironmentValues
182
+ /// Sets the handler to be notified when the window's contribution to the
183
+ /// environment may have to be recomputed. Use this for things such as
184
+ /// updating a window's scale factor in the environment when the window
185
+ /// changes displays.
186
+ ///
187
+ /// In future this may be useful for color space handling.
188
+ func setWindowEnvironmentChangeHandler(
189
+ of window: Window ,
190
+ to action: @escaping ( ) -> Void
191
+ )
192
+
167
193
/// Sets the handler for URLs directed to the application (e.g. URLs
168
194
/// associated with a custom URL scheme).
169
195
func setIncomingURLHandler( to action: @escaping ( URL ) -> Void )
0 commit comments