Skip to content

Commit 237675b

Browse files
committed
Minor proposal updates
1 parent ee77493 commit 237675b

File tree

1 file changed

+73
-12
lines changed

1 file changed

+73
-12
lines changed

documentation/proposals/Proposal - Windowing 3.0.md

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -334,23 +334,29 @@ public abstract partial class Surface
334334
/// <summary>
335335
/// Executes the <see cref="Tick" /> event. This will also call <see cref="OnUpdate" /> and <see cref="OnRender" />.
336336
/// </summary>
337-
protected virtual void OnTick();
337+
protected internal virtual void OnTick();
338338

339339
/// <summary>
340340
/// Executes the <see cref="Render" /> event if the constraints defined in <see cref="RenderOptions" /> are met.
341341
/// </summary>
342-
protected virtual void OnRender();
342+
protected internal virtual void OnRender();
343343

344344
/// <summary>
345345
/// Executes the <see cref="Update" /> event if the constraints defined in <see cref="UpdateOptions" /> are met.
346346
/// </summary>
347-
protected virtual void OnUpdate();
347+
protected internal virtual void OnUpdate();
348348

349349
/// <summary>
350350
/// Gets the size <b>in pixels</b> of the area drawable within the surface.
351351
/// </summary>
352352
public abstract Vector2 DrawableSize { get; }
353353

354+
/// <summary>
355+
/// Gets a value indicating whether the surface is terminating irrevocably.
356+
/// </summary>
357+
/// <seealso cref="ISurfaceWindow.IsCloseRequested" />
358+
public abstract bool IsTerminating { get; }
359+
354360
/// <summary>
355361
/// Raised when <see cref="DrawableSize" /> changes.
356362
/// </summary>
@@ -1251,6 +1257,13 @@ public readonly record struct DisplayAvailabilityChangeEvent(Surface Surface);
12511257
/// </remarks>
12521258
public readonly record struct DisplayChangeEvent(Surface Surface, IDisplay Display);
12531259

1260+
/// <summary>
1261+
/// Contains properties pertaining to a surface changing to a different video mode.
1262+
/// </summary>
1263+
/// <param name="Surface">The surface changing to a different video mode.</param>
1264+
/// <param name="VideoMode">The video mode the surface has changed to.</param>
1265+
public readonly record struct VideoModeChangeEvent(Surface Surface, VideoMode VideoMode);
1266+
12541267
/// <summary>
12551268
/// Contains properties pertaining to a change in the available video modes for a display.
12561269
/// </summary>
@@ -1281,6 +1294,7 @@ public readonly record struct DisplayCoordinatesEvent(
12811294
/// Represents the properties of a surface whose rendering is intrinsically linked to the composition of a specific
12821295
/// display. In most cases, this translates to "the surface is rendering in exclusive fullscreen mode".
12831296
/// </summary>
1297+
/// <param name="Index">The index of the video mode in <see cref="IDisplay.KnownVideoModes" />.</param>
12841298
/// <param name="Resolution">
12851299
/// The resolution the surface is rendering on its display at, if known. If <c>null</c>, it is highly likely that the
12861300
/// surface is not rendering in exclusive fullscreen mode or otherwise has its rendering intrinsically linked to the
@@ -1297,18 +1311,24 @@ public readonly record struct DisplayCoordinatesEvent(
12971311
/// fullscreen mode. If an individual property is <c>null</c>, it is highly likely that property is not controllable
12981312
/// programmatically.
12991313
/// </remarks>
1300-
public readonly record struct VideoMode(Vector2? Resolution, int? RefreshRate);
1314+
public readonly record struct VideoMode(int Index, Vector2? Resolution, float? RefreshRate);
13011315

13021316
/// <summary>
13031317
/// Represents a display on which a surface can be rendered.
13041318
/// </summary>
13051319
/// <remarks>
1306-
/// These objects may be shared with child windows created using <see cref="ISurfaceChildren" /> and vice versa i.e.
1307-
/// this object can be shared between all surfaces that share a common ancestor (the "root surface"). Beyond that, these
1308-
/// objects are not guaranteed to be valid across surfaces. This allows one event handler to enact changes on multiple
1309-
/// surfaces.
1320+
/// Each surface shall get its own <see cref="IDisplay" /> object for each display. This is primarily to ensure that
1321+
/// users get events dispatched with the surface they expect depending on which <see cref="ISurfaceDisplay" /> the
1322+
/// <see cref="IDisplay" /> was sourced from. However, display objects can be somewhat shared between all surfaces that
1323+
/// share a common ancestor (the "root surface"). Specifically, an object at a given index in
1324+
/// <see cref="ISurfaceDisplay.Available" /> on one surface shall be equatable to the object sourced from the same index
1325+
/// in <see cref="ISurfaceDisplay.Available" /> on another surface with the same root surface. Furthermore,
1326+
/// <see cref="ISurfaceDisplay.Current" /> on one surface shall be assignable to an <see cref="IDisplay" /> object
1327+
/// sourced from another surface with the same root surface, where <see cref="ISurfaceDisplay.Current" /> shall lookup
1328+
/// the equivalent <see cref="IDisplay" /> object from its <see cref="ISurfaceDisplay.Available" /> displays upon
1329+
/// assignment.
13101330
/// </remarks>
1311-
public interface IDisplay
1331+
public interface IDisplay : IEquatable<IDisplay>
13121332
{
13131333
/// <summary>
13141334
/// Gets the position and resolution of the monitor in screen space.
@@ -1325,7 +1345,9 @@ public interface IDisplay
13251345

13261346
/// <summary>
13271347
/// Gets a list of video modes known to be available when this display is <see cref="ISurfaceDisplay.Current" />.
1328-
/// It may be the case that a list of video modes can't be determined until that's the case.
1348+
/// It may be the case that a list of video modes can't be determined until that's the case. Note that inclusion of
1349+
/// a <see cref="VideoMode" /> in this list does not guarantee its presence in
1350+
/// <see cref="ISurfaceDisplay.AvailableVideoModes" />, as this can depend on the state of other components.
13291351
/// </summary>
13301352
IReadOnlyList<VideoMode>? KnownVideoModes { get; }
13311353

@@ -1375,8 +1397,12 @@ public interface ISurfaceDisplay
13751397
VideoMode VideoMode { get; set; }
13761398

13771399
/// <summary>
1378-
/// Gets a list of video modes with which the surface can be rendered. If the surface cannot programmatically change
1379-
/// its video mode, it is expected that this shall return a single element list containing <see cref="VideoMode" />.
1400+
/// Gets a list of video modes known to be available when this display is <see cref="ISurfaceDisplay.Current" />.
1401+
/// It may be the case that a list of video modes can't be determined until that's the case. Furthermore, if
1402+
/// <see cref="ISurfaceWindow"/> is supported, <see cref="ISurfaceWindow.State"/> needs to be
1403+
/// <see cref="WindowState.ExclusiveFullscreen"/> to get access to exclusive fullscreen video modes.
1404+
/// <see cref="WindowState.WindowedFullscreen"/> may be acceptable if the backend supports implicitly switching
1405+
/// between windowed and exclusive fullscreen states, but this is not a requirement.
13801406
/// </summary>
13811407
IReadOnlyList<VideoMode> AvailableVideoModes { get; }
13821408

@@ -1394,6 +1420,11 @@ public interface ISurfaceDisplay
13941420
/// An event raised when <see cref="AvailableVideoModes" /> changes.
13951421
/// </summary>
13961422
event Action<DisplayVideoModeAvailabilityChangeEvent> AvailableVideoModesChanged { add; remove; }
1423+
1424+
/// <summary>
1425+
/// An event raised when <see cref="VideoMode" /> changes.
1426+
/// </summary>
1427+
event Action<VideoModeChangeEvent> VideoModeChanged { add; remove; }
13971428
}
13981429

13991430
public abstract partial class Surface
@@ -1410,6 +1441,36 @@ public abstract partial class Surface
14101441
This proposal repeals the Window Hosts (Monitors) proposal from Silk.NET 1.0 Preview 4. All child surfaces must be
14111442
hosted by another surface or be the "root surface".
14121443

1444+
Note that there are some complex interactions with the `ISurfaceWindow.State` property and `VideoMode` given that the
1445+
former allows changing to exclusive fullscreen and the latter allows changing exclusive fullscreen mode. This raised a
1446+
number of questions about whether using the latter without the former should invoke implicit changes to the former.
1447+
Ultimately, it was decided that this would be bug prone and very hard to implement, as such the following requirements
1448+
are placed on implementors of this component:
1449+
- If the Window component is supported, `AvailableVideoModes` shall return a single-element list containing `default`
1450+
when `ISurfaceWindow.State` is not `WindowState.ExclusiveFullscreen` and not `WindowState.WindowedFullscreen`.
1451+
- If the Window component is supported, `AvailableVideoModes` shall either return a single-element list containing
1452+
`default` or return a list containing the `default` video mode along with all exclusive video modes when
1453+
`ISurfaceWindow.State` is `WindowState.WindowedFullscreen`.
1454+
- If the Window component is supported, `AvailableVideoModes` shall return a list of exclusive video modes when
1455+
`ISurfaceWindow.State` is `WindowState.ExclusiveFullscreen`, except where the `AvailableVideoModes` implementation
1456+
includes exclusive video modes when `ISurfaceWindow.State` is `WindowState.WindowedFullscreen`, in which case
1457+
`AvailableVideoModes` shall return the same list for both `WindowState.WindowedFullscreen` and
1458+
`WindowState.ExclusiveFullscreen`.
1459+
- If the Window component is supported and `ISurfaceWindow.State` is currently `WindowState.ExclusiveFullscreen`,
1460+
`ISurfaceWindow.State` shall be changed to `WindowState.WindowedFullscreen` (raising the appropriate events as
1461+
necessary) when `ISurfaceDisplay.VideoMode` is set to the `default` video mode.
1462+
- If the Window component is supported and `ISurfaceWindow.State` is currently `WindowState.WindowedFullscreen`,
1463+
`ISurfaceWindow.State` shall be changed to `WindowState.ExclusiveFullscreen` (raising the appropriate events as
1464+
necessary) when `ISurfaceDisplay.VideoMode` is set to a non-`default` video mode.
1465+
- If the Window component is not supported, `AvailableVideoModes` shall return a list of video modes supported in
1466+
exclusive fullscreen mode and may also include the `default` video mode for non-exclusive control of the underlying
1467+
window manager. What this means is open to the backend's interpretation, as in lieu of the Window component this could
1468+
simply mean windowed fullscreen, bordered windowed, or basically anything that isn't exclusive fullscreen.
1469+
- `IDisplay.KnownVideoModes`, if the implementation returns a non-`null` value for this property, shall contain all
1470+
video modes that may be included in `AvailableVideoModes` regardless of the `State` property i.e. it includes the
1471+
`default` video mode for non-exclusive and all exclusive fullscreen video modes. This is valid as per the
1472+
`KnownVideoModes` documentation.
1473+
14131474
# The Vulkan Component
14141475

14151476
```cs

0 commit comments

Comments
 (0)