Fix incomplete functionality, nullable warnings, and async issues

Incomplete functionality fixes:
- SkiaEditor: Wire up Completed event to fire on focus lost
- X11InputMethodService: Remove unused _commitCallback field
- SkiaWebView: Set _isProperlyReparented when reparenting succeeds,
  use _lastMainX/_lastMainY to track main window position,
  add _isEmbedded guard to prevent double embedding

Nullable reference fixes:
- Easing: Reorder BounceOut before BounceIn (static init order)
- GestureManager: Use local command variable instead of re-accessing
- SkiaShell: Handle null Title with ?? operator
- GLibNative: Use null! for closure pattern
- LinuxProgramHost: Default title if null
- SkiaWebView.LoadHtml: Add null/empty check for html
- SystemThemeService: Initialize Colors with default values
- DeviceDisplayService/AppInfoService: Use var for nullable env vars
- EmailService: Add null check for message parameter

Async fixes:
- SkiaImage: Use _ = for fire-and-forget async calls
- SystemTrayService: Convert async method without await to sync Task

Reduces warnings from 156 to 133 (remaining are P/Invoke structs
and obsolete MAUI API usage)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-01 17:20:11 -05:00
parent 7b22d67920
commit c60453ea31
14 changed files with 58 additions and 23 deletions

View File

@@ -22,8 +22,7 @@ public class Easing
public static readonly Easing CubicInOut = new(v => public static readonly Easing CubicInOut = new(v =>
v < 0.5 ? 4.0 * v * v * v : 1.0 - Math.Pow(-2.0 * v + 2.0, 3.0) / 2.0); v < 0.5 ? 4.0 * v * v * v : 1.0 - Math.Pow(-2.0 * v + 2.0, 3.0) / 2.0);
public static readonly Easing BounceIn = new(v => 1.0 - BounceOut.Ease(1.0 - v)); // BounceOut must be declared before BounceIn since BounceIn references it
public static readonly Easing BounceOut = new(v => public static readonly Easing BounceOut = new(v =>
{ {
const double n1 = 7.5625; const double n1 = 7.5625;
@@ -38,6 +37,8 @@ public class Easing
return n1 * (v -= 2.625 / d1) * v + 0.984375; return n1 * (v -= 2.625 / d1) * v + 0.984375;
}); });
public static readonly Easing BounceIn = new(v => 1.0 - BounceOut.Ease(1.0 - v));
public static readonly Easing SpringIn = new(v => v * v * (2.70158 * v - 1.70158)); public static readonly Easing SpringIn = new(v => v * v * (2.70158 * v - 1.70158));
public static readonly Easing SpringOut = new(v => public static readonly Easing SpringOut = new(v =>

View File

@@ -188,7 +188,7 @@ public static class GestureManager
if (command != null && command.CanExecute(tapRecognizer.CommandParameter)) if (command != null && command.CanExecute(tapRecognizer.CommandParameter))
{ {
Console.WriteLine("[GestureManager] Executing Command"); Console.WriteLine("[GestureManager] Executing Command");
tapRecognizer.Command.Execute(tapRecognizer.CommandParameter); command.Execute(tapRecognizer.CommandParameter);
} }
result = true; result = true;
} }

View File

@@ -46,7 +46,7 @@ public static class LinuxProgramHost
ParseCommandLineOptions(args, options); ParseCommandLineOptions(args, options);
// Initialize GTK for WebView support // Initialize GTK for WebView support
GtkHostService.Instance.Initialize(options.Title, options.Width, options.Height); GtkHostService.Instance.Initialize(options.Title ?? "MAUI Application", options.Width, options.Height);
Console.WriteLine("[LinuxProgramHost] GTK initialized for WebView support"); Console.WriteLine("[LinuxProgramHost] GTK initialized for WebView support");
// Create Linux application // Create Linux application

View File

@@ -28,7 +28,7 @@ public static class GLibNative
public static uint IdleAdd(Func<bool> callback) public static uint IdleAdd(Func<bool> callback)
{ {
GSourceFunc wrapper = null; GSourceFunc wrapper = null!;
wrapper = delegate wrapper = delegate
{ {
bool flag = false; bool flag = false;
@@ -58,7 +58,7 @@ public static class GLibNative
public static uint TimeoutAdd(uint intervalMs, Func<bool> callback) public static uint TimeoutAdd(uint intervalMs, Func<bool> callback)
{ {
GSourceFunc wrapper = null; GSourceFunc wrapper = null!;
wrapper = delegate wrapper = delegate
{ {
bool flag = false; bool flag = false;

View File

@@ -41,7 +41,7 @@ public class AppInfoService : IAppInfo
{ {
try try
{ {
string environmentVariable = Environment.GetEnvironmentVariable("GTK_THEME"); var environmentVariable = Environment.GetEnvironmentVariable("GTK_THEME");
if (!string.IsNullOrEmpty(environmentVariable) && environmentVariable.Contains("dark", StringComparison.OrdinalIgnoreCase)) if (!string.IsNullOrEmpty(environmentVariable) && environmentVariable.Contains("dark", StringComparison.OrdinalIgnoreCase))
{ {
return AppTheme.Dark; return AppTheme.Dark;

View File

@@ -73,13 +73,13 @@ public class DeviceDisplayService : IDeviceDisplay
private double GetScaleFactor() private double GetScaleFactor()
{ {
string gdkScale = Environment.GetEnvironmentVariable("GDK_SCALE"); var gdkScale = Environment.GetEnvironmentVariable("GDK_SCALE");
if (!string.IsNullOrEmpty(gdkScale) && double.TryParse(gdkScale, out var result)) if (!string.IsNullOrEmpty(gdkScale) && double.TryParse(gdkScale, out var result))
{ {
return result; return result;
} }
string qtScale = Environment.GetEnvironmentVariable("QT_SCALE_FACTOR"); var qtScale = Environment.GetEnvironmentVariable("QT_SCALE_FACTOR");
if (!string.IsNullOrEmpty(qtScale) && double.TryParse(qtScale, out result)) if (!string.IsNullOrEmpty(qtScale) && double.TryParse(qtScale, out result))
{ {
return result; return result;

View File

@@ -69,6 +69,7 @@ public class EmailService : IEmail
private static string BuildMailtoUri(EmailMessage? message) private static string BuildMailtoUri(EmailMessage? message)
{ {
var sb = new StringBuilder("mailto:"); var sb = new StringBuilder("mailto:");
if (message == null) return sb.ToString();
// Add recipients // Add recipients
if (message.To?.Count > 0) if (message.To?.Count > 0)

View File

@@ -56,7 +56,19 @@ public class SystemThemeService
/// <summary> /// <summary>
/// System colors based on the current theme. /// System colors based on the current theme.
/// </summary> /// </summary>
public SystemColors Colors { get; private set; } public SystemColors Colors { get; private set; } = new SystemColors
{
Background = SKColors.White,
Surface = new SKColor(0xF5, 0xF5, 0xF5),
Primary = new SKColor(0x21, 0x96, 0xF3),
OnPrimary = SKColors.White,
Text = new SKColor(0x21, 0x21, 0x21),
TextSecondary = new SKColor(0x75, 0x75, 0x75),
Border = new SKColor(0xE0, 0xE0, 0xE0),
Divider = new SKColor(0xE0, 0xE0, 0xE0),
Error = new SKColor(0xF4, 0x43, 0x36),
Success = new SKColor(0x4C, 0xAF, 0x50)
};
private FileSystemWatcher? _settingsWatcher; private FileSystemWatcher? _settingsWatcher;

View File

@@ -101,7 +101,7 @@ public class SystemTrayService : IDisposable
_ = ShowAsync(); _ = ShowAsync();
} }
private async Task<bool> TryYadTray() private Task<bool> TryYadTray()
{ {
try try
{ {
@@ -118,7 +118,7 @@ public class SystemTrayService : IDisposable
}; };
_trayProcess = Process.Start(startInfo); _trayProcess = Process.Start(startInfo);
if (_trayProcess == null) return false; if (_trayProcess == null) return Task.FromResult(false);
// Start reading output for menu clicks // Start reading output for menu clicks
_ = Task.Run(async () => _ = Task.Run(async () =>
@@ -137,11 +137,11 @@ public class SystemTrayService : IDisposable
catch { } catch { }
}); });
return true; return Task.FromResult(true);
} }
catch catch
{ {
return false; return Task.FromResult(false);
} }
} }

View File

@@ -27,7 +27,6 @@ public class X11InputMethodService : IInputMethodService, IDisposable
private XIMProc? _preeditDoneCallback; private XIMProc? _preeditDoneCallback;
private XIMProc? _preeditDrawCallback; private XIMProc? _preeditDrawCallback;
private XIMProc? _preeditCaretCallback; private XIMProc? _preeditCaretCallback;
private XIMProc? _commitCallback;
public bool IsActive => _isActive; public bool IsActive => _isActive;
public string PreEditText => _preEditText; public string PreEditText => _preEditText;

View File

@@ -982,6 +982,7 @@ public class SkiaEditor : SkiaView
{ {
base.OnFocusLost(); base.OnFocusLost();
SkiaVisualStateManager.GoToState(this, SkiaVisualStateManager.CommonStates.Normal); SkiaVisualStateManager.GoToState(this, SkiaVisualStateManager.CommonStates.Normal);
Completed?.Invoke(this, EventArgs.Empty);
} }
#region Selection and Clipboard #region Selection and Clipboard

View File

@@ -84,7 +84,7 @@ public class SkiaImage : SkiaView
!_pendingSvgReload) !_pendingSvgReload)
{ {
_pendingSvgReload = true; _pendingSvgReload = true;
ReloadSvgDebounced(); _ = ReloadSvgDebounced();
} }
} }
} }
@@ -427,7 +427,7 @@ public class SkiaImage : SkiaView
{ {
_lastArrangedBounds = bounds; _lastArrangedBounds = bounds;
Console.WriteLine($"[SkiaImage] Arrange detected larger bounds: {width}x{height} vs loaded {_svgLoadedWidth}x{_svgLoadedHeight}"); Console.WriteLine($"[SkiaImage] Arrange detected larger bounds: {width}x{height} vs loaded {_svgLoadedWidth}x{_svgLoadedHeight}");
LoadSvgAtSizeAsync(_currentFilePath, width, height); _ = LoadSvgAtSizeAsync(_currentFilePath, width, height);
} }
} }
} }

View File

@@ -693,7 +693,7 @@ public class SkiaShell : SkiaLayoutView
} }
SetCurrentContent(root.Content); SetCurrentContent(root.Content);
Title = root.Title; Title = root.Title ?? string.Empty;
Invalidate(); Invalidate();
} }

View File

@@ -759,6 +759,11 @@ public class SkiaWebView : SkiaView
public void LoadHtml(string html, string? baseUrl = null) public void LoadHtml(string html, string? baseUrl = null)
{ {
Console.WriteLine($"[WebView] LoadHtml called, html length: {html?.Length ?? 0}"); Console.WriteLine($"[WebView] LoadHtml called, html length: {html?.Length ?? 0}");
if (string.IsNullOrEmpty(html))
{
Console.WriteLine("[WebView] Cannot load HTML - html is null or empty");
return;
}
if (!_isInitialized) Initialize(); if (!_isInitialized) Initialize();
if (_webView == IntPtr.Zero || _webkitLoadHtml == null) if (_webView == IntPtr.Zero || _webkitLoadHtml == null)
{ {
@@ -869,6 +874,7 @@ public class SkiaWebView : SkiaView
public void ShowNativeWindow() public void ShowNativeWindow()
{ {
if (_isEmbedded) return; // Already embedded
if (!_isInitialized) Initialize(); if (!_isInitialized) Initialize();
if (_gtkWindow == IntPtr.Zero) return; if (_gtkWindow == IntPtr.Zero) return;
@@ -918,7 +924,15 @@ public class SkiaWebView : SkiaView
if (gdkWindow != IntPtr.Zero) if (gdkWindow != IntPtr.Zero)
{ {
_gtkX11Window = gdk3_x11_window_get_xid(gdkWindow); _gtkX11Window = gdk3_x11_window_get_xid(gdkWindow);
Console.WriteLine($"[WebView] GTK X11 window: {_gtkX11Window}"); if (_gtkX11Window != IntPtr.Zero)
{
_isProperlyReparented = true;
Console.WriteLine($"[WebView] GTK X11 window: {_gtkX11Window} (reparented successfully)");
}
else
{
Console.WriteLine($"[WebView] GTK X11 window: failed to get XID");
}
} }
PositionUsingGtk(); PositionUsingGtk();
@@ -1073,13 +1087,20 @@ public class SkiaWebView : SkiaView
} }
catch { } catch { }
int offsetX = 0, offsetY = 0; // Track main window position changes
int screenX = destX + (int)Bounds.Left - offsetX; bool mainWindowMoved = destX != _lastMainX || destY != _lastMainY;
int screenY = destY + (int)Bounds.Top - offsetY; if (mainWindowMoved)
{
_lastMainX = destX;
_lastMainY = destY;
}
int screenX = destX + (int)Bounds.Left;
int screenY = destY + (int)Bounds.Top;
int width = Math.Max(100, (int)Bounds.Width); int width = Math.Max(100, (int)Bounds.Width);
int height = Math.Max(100, (int)Bounds.Height); int height = Math.Max(100, (int)Bounds.Height);
if (Math.Abs(screenX - _lastPosX) > 2 || Math.Abs(screenY - _lastPosY) > 2 || if (mainWindowMoved || Math.Abs(screenX - _lastPosX) > 2 || Math.Abs(screenY - _lastPosY) > 2 ||
Math.Abs(width - _lastWidth) > 2 || Math.Abs(height - _lastHeight) > 2) Math.Abs(width - _lastWidth) > 2 || Math.Abs(height - _lastHeight) > 2)
{ {
Console.WriteLine($"[WebView] Move to ({screenX}, {screenY}), size ({width}x{height}), mainWin=({destX},{destY}), bounds=({Bounds.Left},{Bounds.Top})"); Console.WriteLine($"[WebView] Move to ({screenX}, {screenY}), size ({width}x{height}), mainWin=({destX},{destY}), bounds=({Bounds.Left},{Bounds.Top})");