Update with recovered code from VM binaries (Jan 1)
Recovered from decompiled OpenMaui.Controls.Linux.dll: - SkiaShell.cs: FlyoutHeader, FlyoutFooter, scroll support (918 -> 1325 lines) - X11Window.cs: Cursor support (XCreateFontCursor, XDefineCursor) - All handlers with dark mode support - All services with latest implementations - LinuxApplication with theme change handling
This commit is contained in:
@@ -1,66 +1,68 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Maui.ApplicationModel;
|
||||
|
||||
namespace Microsoft.Maui.Platform.Linux.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Linux browser implementation using xdg-open.
|
||||
/// </summary>
|
||||
public class BrowserService : IBrowser
|
||||
{
|
||||
public async Task<bool> OpenAsync(string uri)
|
||||
{
|
||||
return await OpenAsync(new Uri(uri), BrowserLaunchMode.SystemPreferred);
|
||||
}
|
||||
public async Task<bool> OpenAsync(string uri)
|
||||
{
|
||||
return await OpenAsync(new Uri(uri), (BrowserLaunchMode)0);
|
||||
}
|
||||
|
||||
public async Task<bool> OpenAsync(string uri, BrowserLaunchMode launchMode)
|
||||
{
|
||||
return await OpenAsync(new Uri(uri), launchMode);
|
||||
}
|
||||
public async Task<bool> OpenAsync(string uri, BrowserLaunchMode launchMode)
|
||||
{
|
||||
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
|
||||
return await OpenAsync(new Uri(uri), launchMode);
|
||||
}
|
||||
|
||||
public async Task<bool> OpenAsync(Uri uri)
|
||||
{
|
||||
return await OpenAsync(uri, BrowserLaunchMode.SystemPreferred);
|
||||
}
|
||||
public async Task<bool> OpenAsync(Uri uri)
|
||||
{
|
||||
return await OpenAsync(uri, (BrowserLaunchMode)0);
|
||||
}
|
||||
|
||||
public async Task<bool> OpenAsync(Uri uri, BrowserLaunchMode launchMode)
|
||||
{
|
||||
return await OpenAsync(uri, new BrowserLaunchOptions { LaunchMode = launchMode });
|
||||
}
|
||||
public async Task<bool> OpenAsync(Uri uri, BrowserLaunchMode launchMode)
|
||||
{
|
||||
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
|
||||
return await this.OpenAsync(uri, new BrowserLaunchOptions
|
||||
{
|
||||
LaunchMode = launchMode
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<bool> OpenAsync(Uri uri, BrowserLaunchOptions options)
|
||||
{
|
||||
if (uri == null)
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
|
||||
try
|
||||
{
|
||||
var uriString = uri.AbsoluteUri;
|
||||
|
||||
// Use xdg-open which respects user's default browser
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "xdg-open",
|
||||
Arguments = $"\"{uriString}\"",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
CreateNoWindow = true
|
||||
};
|
||||
|
||||
using var process = Process.Start(startInfo);
|
||||
if (process == null)
|
||||
return false;
|
||||
|
||||
await process.WaitForExitAsync();
|
||||
return process.ExitCode == 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public async Task<bool> OpenAsync(Uri uri, BrowserLaunchOptions options)
|
||||
{
|
||||
if (uri == null)
|
||||
{
|
||||
throw new ArgumentNullException("uri");
|
||||
}
|
||||
try
|
||||
{
|
||||
string absoluteUri = uri.AbsoluteUri;
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "xdg-open",
|
||||
Arguments = "\"" + absoluteUri + "\"",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
CreateNoWindow = true
|
||||
};
|
||||
using Process process = Process.Start(startInfo);
|
||||
if (process == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
await process.WaitForExitAsync();
|
||||
return process.ExitCode == 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user