M6 Windows: composizione condivisa Febe.App per Server e Desktop; Febe per Windows (WPF) con l'interfaccia in WebView2, area di notifica, istanza unica, «Browser di Febe» su WebView2 con CDP filtrato (WebView2CdpSession) e ripieghi di S2 (composizione, Edge), guscio nativo, avvisi, spostamento verificato della cartella dei dati, icona del marchio; un solo Febe.exe, installatore NSIS e zip portabile; guida docs/windows.md e prove dal vivo S1–S3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
Claude committed 2026-10-13 21:50:25 +00:00
1 parent dc4d1fc738
commit b443adfa8b
73 files changed
+7914 -699

No files matched your search

+107
View File
@@ -0,0 +1,107 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;
using Febe.App;
using Febe.Desktop.Browser;
using Febe.Desktop.Core;
using Febe.Desktop.Native;
using Febe.Web.Native;
using Microsoft.Web.WebView2.Core;
using Microsoft.Win32;
namespace Febe.Desktop;
/// <summary>The Windows-only part the desktop platform needs (WebView2, Edge's window, native shell, notifications).</summary>
internal sealed class DesktopShell(Dispatcher ui, ImageSource? icon, INativeShell native, IAlertChannel notifications) : IDesktopShell
{
public INativeShell Native { get; } = native;
public IAlertChannel? Notifications { get; } = notifications;
public string? WebView2Version()
{
try
{
return CoreWebView2Environment.GetAvailableBrowserVersionString();
}
catch (WebView2RuntimeNotFoundException)
{
return null;
}
}
public IFebeBrowser CreateWebView2Browser(WebView2BrowserSettings settings, FebePlatformContext context) =>
new WebView2Browser(ui, settings, context, icon);
public string? FindEdge()
{
string? appPath = null;
foreach (var hive in new[] { Registry.CurrentUser, Registry.LocalMachine })
{
using var key = hive.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe", writable: false);
if (key?.GetValue(null) is string value && !string.IsNullOrWhiteSpace(value))
{
appPath = value;
break;
}
}
return EdgeLocator.Find(EdgeLocator.Candidates(
appPath,
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)));
}
public Task ShowProcessWindowAsync(int processId, CancellationToken ct) => ui.InvokeAsync(() =>
{
if (MainWindowOf(processId) is not { } window)
{
return;
}
if (Win32.IsIconic(window))
{
Win32.ShowWindow(window, Win32.SwRestore);
}
var area = SystemParameters.WorkArea;
var dpi = Win32.SystemScale;
Win32.SetWindowPos(window, IntPtr.Zero, (int)(area.Left * dpi) + 40, (int)(area.Top * dpi) + 40, 0, 0, Win32.SwpNoSize | Win32.SwpNoZOrder);
Win32.SetForegroundWindow(window);
}).Task;
public Task HideProcessWindowAsync(int processId, CancellationToken ct) => ui.InvokeAsync(() =>
{
if (MainWindowOf(processId) is not { } window)
{
return;
}
// Out of view, never minimised (S2): just right of every screen.
var dpi = Win32.SystemScale;
var x = (int)((SystemParameters.VirtualScreenLeft + SystemParameters.VirtualScreenWidth) * dpi) + 64;
var y = (int)(SystemParameters.VirtualScreenTop * dpi);
if (Win32.IsIconic(window))
{
Win32.ShowWindow(window, Win32.SwShowNoActivate);
}
Win32.SetWindowPos(window, IntPtr.Zero, x, y, 0, 0, Win32.SwpNoSize | Win32.SwpNoZOrder | Win32.SwpNoActivate);
}).Task;
private static IntPtr? MainWindowOf(int processId)
{
try
{
using var process = Process.GetProcessById(processId);
process.Refresh();
return process.MainWindowHandle == IntPtr.Zero ? null : process.MainWindowHandle;
}
catch (Exception ex) when (ex is ArgumentException or InvalidOperationException)
{
return null;
}
}
}