| | |
| | | _settings = await _configuration.LoadAppSettingsAsync(cancellationToken).ConfigureAwait(false); |
| | | _isEditMode = _settings.Runtime.EditMode; |
| | | _isSafeInputMode = _settings.Runtime.SafeInputMode; |
| | | await _surfaces.ApplyEditModeAsync(_isEditMode, cancellationToken).ConfigureAwait(false); |
| | | await _surfaces.ApplySafeInputModeAsync(_isSafeInputMode, cancellationToken).ConfigureAwait(false); |
| | | |
| | | await _layout.LoadAsync(cancellationToken).ConfigureAwait(false); |
| | | ReconcileCurrentMonitors(); |
| | | await _layout.SaveAsync(cancellationToken).ConfigureAwait(false); |
| | | |
| | | _pluginSnapshot = await _plugins.ScanAsync(cancellationToken).ConfigureAwait(false); |
| | | foreach (var layout in _layout.GetAll().Where(layout => layout.IsVisible)) |
| | | { |
| | | await _surfaces.ApplyWidgetLayoutAsync(ToSurfaceLayout(layout), cancellationToken).ConfigureAwait(false); |
| | | } |
| | | |
| | | _diagnostics.Record(DiagnosticSeverity.Info, DiagnosticCodes.ApplicationStarted, "Desktop runtime started."); |
| | | var state = BuildState(); |
| | | await PublishStatusAsync(state, cancellationToken).ConfigureAwait(false); |
| | |
| | | try |
| | | { |
| | | _isGlobalLocked = enabled; |
| | | await ApplyAllWidgetLayoutsAsync(cancellationToken).ConfigureAwait(false); |
| | | var state = BuildState(); |
| | | await _events.PublishAsync(new RuntimeEvent { Name = "app.globalLockedChanged", Payload = state }, cancellationToken).ConfigureAwait(false); |
| | | await PublishStatusAsync(state, cancellationToken).ConfigureAwait(false); |
| | |
| | | try |
| | | { |
| | | _pluginSnapshot = await _plugins.ScanAsync(cancellationToken).ConfigureAwait(false); |
| | | await ApplyAllWidgetLayoutsAsync(cancellationToken).ConfigureAwait(false); |
| | | var state = BuildState(); |
| | | await _events.PublishAsync(new RuntimeEvent { Name = "plugin.reloaded", Payload = state.Plugins }, cancellationToken).ConfigureAwait(false); |
| | | await PublishStatusAsync(state, cancellationToken).ConfigureAwait(false); |
| | |
| | | return OperationResult<WidgetRuntimeState>.Failure(result.ErrorCode ?? "WidgetLayoutUpdateFailed", result.Message ?? "Widget layout update failed."); |
| | | } |
| | | |
| | | await _surfaces.ApplyWidgetLayoutAsync(result.Value, cancellationToken).ConfigureAwait(false); |
| | | await _surfaces.ApplyWidgetLayoutAsync(ToSurfaceLayout(result.Value), cancellationToken).ConfigureAwait(false); |
| | | await _layout.SaveAsync(cancellationToken).ConfigureAwait(false); |
| | | var runtimeState = ToWidgetRuntimeState(result.Value); |
| | | await _events.PublishAsync(new RuntimeEvent { Name = "widget.layoutChanged", Payload = runtimeState }, cancellationToken).ConfigureAwait(false); |
| | |
| | | await _configuration.SaveAppSettingsAsync(_settings, cancellationToken).ConfigureAwait(false); |
| | | } |
| | | |
| | | private async Task ApplyAllWidgetLayoutsAsync(CancellationToken cancellationToken) |
| | | { |
| | | foreach (var layout in _layout.GetAll()) |
| | | { |
| | | cancellationToken.ThrowIfCancellationRequested(); |
| | | await _surfaces.ApplyWidgetLayoutAsync(ToSurfaceLayout(layout), cancellationToken).ConfigureAwait(false); |
| | | } |
| | | } |
| | | |
| | | private AppRuntimeState BuildState() |
| | | { |
| | | return new AppRuntimeState |
| | |
| | | IsVisible = layout.IsVisible, |
| | | IsLocked = _isGlobalLocked || layout.IsLocked, |
| | | Opacity = layout.Opacity, |
| | | ClickThrough = _isEditMode || _isSafeInputMode ? false : layout.ClickThrough |
| | | ClickThrough = _isEditMode || _isSafeInputMode ? false : layout.ClickThrough, |
| | | DisplayLayer = layout.DisplayLayer |
| | | }; |
| | | |
| | | private WidgetLayout ToSurfaceLayout(WidgetLayout layout) |
| | | => _isGlobalLocked ? layout with { IsLocked = true } : layout; |
| | | |
| | | private static bool IsGeometryPatch(WidgetLayoutPatch patch) |
| | | => patch.Bounds is not null || patch.MonitorId is not null || patch.Scale is not null; |
| | | } |