| | |
| | | private readonly IDiagnosticsService _diagnostics; |
| | | private readonly IRuntimeEventBus _events; |
| | | private readonly IRuntimeSurfaceController _surfaces; |
| | | private readonly DisplayChangeMonitor _displayMonitor; |
| | | private readonly SemaphoreSlim _lock = new(1, 1); |
| | | private AppSettingsDocument _settings = new(); |
| | | private IReadOnlyList<PluginDescriptor> _pluginSnapshot = []; |
| | |
| | | IWin32InteropService interop, |
| | | IDiagnosticsService diagnostics, |
| | | IRuntimeEventBus events, |
| | | IRuntimeSurfaceController surfaces) |
| | | IRuntimeSurfaceController surfaces, |
| | | DisplayChangeMonitor displayMonitor) |
| | | { |
| | | _configuration = configuration; |
| | | _plugins = plugins; |
| | |
| | | _diagnostics = diagnostics; |
| | | _events = events; |
| | | _surfaces = surfaces; |
| | | _displayMonitor = displayMonitor; |
| | | } |
| | | |
| | | public async Task<OperationResult<AppRuntimeState>> StartAsync(CancellationToken cancellationToken = default) |
| | |
| | | { |
| | | await _surfaces.ApplyWidgetLayoutAsync(ToSurfaceLayout(layout), cancellationToken).ConfigureAwait(false); |
| | | } |
| | | |
| | | _displayMonitor.DisplayChanged += () => OnDisplayTopologyChangedAsync(); |
| | | _displayMonitor.Start(); |
| | | |
| | | _diagnostics.Record(DiagnosticSeverity.Info, DiagnosticCodes.ApplicationStarted, "Desktop runtime started."); |
| | | var state = BuildState(); |
| | |
| | | } |
| | | } |
| | | |
| | | public async Task OnDisplayTopologyChangedAsync(CancellationToken cancellationToken = default) |
| | | { |
| | | await _lock.WaitAsync(cancellationToken).ConfigureAwait(false); |
| | | try |
| | | { |
| | | ReconcileCurrentMonitors(); |
| | | await _layout.SaveAsync(cancellationToken).ConfigureAwait(false); |
| | | await _surfaces.SyncAllLayoutsAsync(cancellationToken).ConfigureAwait(false); |
| | | await _surfaces.SyncWallpaperMonitorsAsync(cancellationToken).ConfigureAwait(false); |
| | | await _surfaces.ReattachDesktopLayersAsync(cancellationToken).ConfigureAwait(false); |
| | | |
| | | var state = BuildState(); |
| | | await _events.PublishAsync(new RuntimeEvent { Name = "display.topologyChanged", Payload = state }, cancellationToken).ConfigureAwait(false); |
| | | await PublishStatusAsync(state, cancellationToken).ConfigureAwait(false); |
| | | } |
| | | finally |
| | | { |
| | | _lock.Release(); |
| | | } |
| | | } |
| | | |
| | | private async Task<OperationResult<AppRuntimeState>> UpdateRuntimeFlagAsync( |
| | | string eventName, |
| | | Action update, |
| | |
| | | IsLocked = _isGlobalLocked || layout.IsLocked, |
| | | Opacity = layout.Opacity, |
| | | ClickThrough = _isEditMode || _isSafeInputMode ? false : layout.ClickThrough, |
| | | DisplayPriority = layout.DisplayPriority |
| | | DisplayLayer = layout.DisplayLayer |
| | | }; |
| | | |
| | | private WidgetLayout ToSurfaceLayout(WidgetLayout layout) |