Skip to content

Commit

Permalink
Update to Avalonia@e621edbe (Apr 30 2023) (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpobst committed Jul 12, 2023
1 parent 7fa6688 commit e561bd8
Show file tree
Hide file tree
Showing 18 changed files with 187 additions and 89 deletions.
2 changes: 2 additions & 0 deletions build/update-avalonia.csx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ CopyFile ("Avalonia.Base/Platform/PlatformColorValues.cs", "PlatformColorValues.
CopyFile ("Avalonia.Base/Platform/PlatformHandle.cs", "PlatformHandle.cs");
CopyFile ("Avalonia.Base/Point.cs", "Point.cs");
CopyFile ("Avalonia.Base/Input/Pointer.cs", "Pointer.cs");
CopyFile ("Avalonia.Base/Metadata/PrivateApiAttribute.cs", "PrivateApiAttribute.cs");
CopyFile ("Shared/RawEventGrouping.cs", "RawEventGrouper.cs");
CopyFile ("Avalonia.Base/Input/Raw/RawInputEventArgs.cs", "RawInputEventArgs.cs");
CopyFile ("Avalonia.Base/Input/Raw/RawKeyEventArgs.cs", "RawKeyEventArgs.cs");
Expand Down Expand Up @@ -134,6 +135,7 @@ CopyFile ("Avalonia.Base/Platform/ICursorFactory.cs", "ICursorFactory.cs");
CopyFile ("Avalonia.Base/Platform/ICursorImpl.cs", "ICursorImpl.cs");
CopyFile ("Avalonia.Controls/WindowTransparencyLevel.cs", "WindowTransparencyLevel.cs");
CopyFile ("Avalonia.Controls/WindowClosingEventArgs.cs", "WindowClosingEventArgs.cs");
CopyFile ("Avalonia.Controls/WindowResizedEventArgs.cs", "WindowResizedEventArgs.cs");
CopyFile ("Avalonia.Controls/AcrylicPlatformCompensationLevels.cs", "AcrylicPlatformCompensationLevels.cs");

// Mac Backend
Expand Down
3 changes: 2 additions & 1 deletion src/Modern.WindowKit/Avalonia.Mac/PopupImpl.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Modern.WindowKit.Controls;
using Modern.WindowKit.Controls.Primitives.PopupPositioning;
using Modern.WindowKit.Mac.Interop;
using Modern.WindowKit.Platform;
Expand Down Expand Up @@ -29,7 +30,7 @@ public PopupImpl(IAvaloniaNativeFactory factory,
private void MoveResize(PixelPoint position, Size size, double scaling)
{
Position = position;
Resize(size, PlatformResizeReason.Layout);
Resize(size, WindowResizeReason.Layout);
//TODO: We ignore the scaling override for now
}

Expand Down
8 changes: 4 additions & 4 deletions src/Modern.WindowKit/Avalonia.Mac/WindowImplBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void Init(IAvnWindowBase window, IAvnScreens screens)
var monitor = Screen.AllScreens.OrderBy(x => x.Scaling)
.FirstOrDefault(m => m.Bounds.Contains(Position));

Resize(new Size(monitor.WorkingArea.Width * 0.75d, monitor.WorkingArea.Height * 0.7d), PlatformResizeReason.Layout);
Resize(new Size(monitor.WorkingArea.Width * 0.75d, monitor.WorkingArea.Height * 0.7d), WindowResizeReason.Layout);
}

public IAvnWindowBase Native => _native;
Expand Down Expand Up @@ -160,7 +160,7 @@ public ILockedFramebuffer Lock()
public Action LostFocus { get; set; }

public Action<Rect> Paint { get; set; }

Check warning on line 162 in src/Modern.WindowKit/Avalonia.Mac/WindowImplBase.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Nullability of reference types in type of parameter 'value' of 'void WindowBaseImpl.Paint.set' doesn't match implicitly implemented member 'void ITopLevelImpl.Paint.set' (possibly because of nullability attributes).
public Action<Size, PlatformResizeReason> Resized { get; set; }
public Action<Size, WindowResizeReason> Resized { get; set; }
public Action Closed { get; set; }
public IMouseDevice MouseDevice => _mouse;
public abstract IPopupImpl CreatePopup();
Expand Down Expand Up @@ -211,7 +211,7 @@ void IAvnWindowBaseEvents.Resized(AvnSize* size, AvnPlatformResizeReason reason)
{
var s = new Size(size->Width, size->Height);
_parent._savedLogicalSize = s;
_parent.Resized?.Invoke(s, (PlatformResizeReason)reason);
_parent.Resized?.Invoke(s, (WindowResizeReason)reason);
}
}

Expand Down Expand Up @@ -360,7 +360,7 @@ public void RawMouseEvent(AvnRawMouseEventType type, uint timeStamp, AvnInputMod
}
}

public void Resize(Size clientSize, PlatformResizeReason reason)
public void Resize(Size clientSize, WindowResizeReason reason)
{
_native?.Resize(clientSize.Width, clientSize.Height, (AvnPlatformResizeReason)reason);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Modern.WindowKit/Avalonia.Win32/PopupImpl.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Modern.WindowKit.Controls;
using Modern.WindowKit.Controls.Primitives.PopupPositioning;
using Modern.WindowKit.Platform;
using Modern.WindowKit.Win32.Interop;
Expand Down Expand Up @@ -135,7 +136,7 @@ private PopupImpl(IWindowBaseImpl parent, bool dummy)
private void MoveResize(PixelPoint position, Size size, double scaling)
{
Move(position);
Resize(size, PlatformResizeReason.Layout);
Resize(size, WindowResizeReason.Layout);
//TODO: We ignore the scaling override for now
}

Expand Down
6 changes: 3 additions & 3 deletions src/Modern.WindowKit/Avalonia.Win32/WindowImpl.AppWndProc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam,
_scaling = dpi / 96.0;
ScalingChanged?.Invoke(_scaling);

using (SetResizeReason(PlatformResizeReason.DpiChange))
using (SetResizeReason(WindowResizeReason.DpiChange))
{
SetWindowPos(hWnd,
IntPtr.Zero,
Expand Down Expand Up @@ -611,7 +611,7 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam,


case WindowsMessage.WM_ENTERSIZEMOVE:
_resizeReason = PlatformResizeReason.User;
_resizeReason = WindowResizeReason.User;
break;

case WindowsMessage.WM_SIZE:
Expand Down Expand Up @@ -658,7 +658,7 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam,
}

case WindowsMessage.WM_EXITSIZEMOVE:
_resizeReason = PlatformResizeReason.Unspecified;
_resizeReason = WindowResizeReason.Unspecified;
break;

case WindowsMessage.WM_MOVE:
Expand Down
14 changes: 7 additions & 7 deletions src/Modern.WindowKit/Avalonia.Win32/WindowImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal partial class WindowImpl : IWindowImpl //, EglGlPlatformSurface.IEglWin
private double _extendTitleBarHint = -1;
private readonly bool _isUsingComposition;
private readonly IBlurHost? _blurHost;
private PlatformResizeReason _resizeReason;
private WindowResizeReason _resizeReason;
private MOUSEMOVEPOINT _lastWmMousePoint;

#if USE_MANAGED_DRAG
Expand Down Expand Up @@ -200,7 +200,7 @@ private IInputRoot Owner

public Action<Rect>? Paint { get; set; }

public Action<Size, PlatformResizeReason>? Resized { get; set; }
public Action<Size, WindowResizeReason>? Resized { get; set; }

public Action<double>? ScalingChanged { get; set; }

Expand Down Expand Up @@ -588,7 +588,7 @@ public void SetMinMaxSize(Size minSize, Size maxSize)
//public IRenderer CreateRenderer(IRenderRoot root) =>
// new CompositingRenderer(root, Win32Platform.Compositor, () => Surfaces);

public void Resize(Size value, PlatformResizeReason reason)
public void Resize(Size value, WindowResizeReason reason)
{
if (WindowState != WindowState.Normal)
return;
Expand Down Expand Up @@ -1053,7 +1053,7 @@ private void ExtendClientArea()
_offScreenMargin = new Thickness();
_extendedMargins = new Thickness();

Resize(new Size(rcWindow.Width / RenderScaling, rcWindow.Height / RenderScaling), PlatformResizeReason.Layout);
Resize(new Size(rcWindow.Width / RenderScaling, rcWindow.Height / RenderScaling), WindowResizeReason.Layout);

unsafe
{
Expand Down Expand Up @@ -1462,7 +1462,7 @@ public void SetExtendClientAreaTitleBarHeightHint(double titleBarHeight)
/// <inheritdoc/>
public AcrylicPlatformCompensationLevels AcrylicCompensationLevels { get; } = new AcrylicPlatformCompensationLevels(1, 0.8, 0);

private ResizeReasonScope SetResizeReason(PlatformResizeReason reason)
private ResizeReasonScope SetResizeReason(WindowResizeReason reason)
{
var old = _resizeReason;
_resizeReason = reason;
Expand All @@ -1487,9 +1487,9 @@ private struct WindowProperties
private struct ResizeReasonScope : IDisposable
{
private readonly WindowImpl _owner;
private readonly PlatformResizeReason _restore;
private readonly WindowResizeReason _restore;

public ResizeReasonScope(WindowImpl owner, PlatformResizeReason restore)
public ResizeReasonScope(WindowImpl owner, WindowResizeReason restore)
{
_owner = owner;
_restore = restore;
Expand Down
14 changes: 7 additions & 7 deletions src/Modern.WindowKit/Avalonia.X11/X11Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public double RenderScaling
public IEnumerable<object> Surfaces { get; }
public Action<RawInputEventArgs>? Input { get; set; }
public Action<Rect>? Paint { get; set; }
public Action<Size, PlatformResizeReason>? Resized { get; set; }
public Action<Size, WindowResizeReason>? Resized { get; set; }
//TODO
public Action<double>? ScalingChanged { get; set; }
public Action? Deactivated { get; set; }
Expand Down Expand Up @@ -509,7 +509,7 @@ private void OnEvent(ref XEvent ev)
UpdateImePosition();
if (changedSize && !updatedSizeViaScaling && !_popup)
Resized?.Invoke(ClientSize, PlatformResizeReason.Unspecified);
Resized?.Invoke(ClientSize, WindowResizeReason.Unspecified);
}, DispatcherPriority.Layout);
if (_useRenderWindow)
Expand Down Expand Up @@ -590,7 +590,7 @@ private bool UpdateScaling(bool skipResize = false)
UpdateImePosition();
SetMinMaxSize(_scaledMinMaxSize.minSize, _scaledMinMaxSize.maxSize);
if(!skipResize)
Resize(oldScaledSize, true, PlatformResizeReason.DpiChange);
Resize(oldScaledSize, true, WindowResizeReason.DpiChange);
return true;
}

Expand Down Expand Up @@ -642,7 +642,7 @@ private void OnPropertyChange(IntPtr atom, bool hasValue)
{
// Occurs once the window has been mapped, which is the earliest the extents
// can be retrieved, so invoke event to force update of TopLevel.FrameSize.
Resized?.Invoke(ClientSize, PlatformResizeReason.Unspecified);
Resized?.Invoke(ClientSize, WindowResizeReason.Unspecified);
}

if (atom == _x11.Atoms._NET_WM_STATE)
Expand Down Expand Up @@ -959,19 +959,19 @@ public void SetSystemDecorations(SystemDecorations enabled)
}


public void Resize(Size clientSize, PlatformResizeReason reason) => Resize(clientSize, false, reason);
public void Resize(Size clientSize, WindowResizeReason reason) => Resize(clientSize, false, reason);
public void Move(PixelPoint point) => Position = point;
private void MoveResize(PixelPoint position, Size size, double scaling)
{
Move(position);
_scalingOverride = scaling;
UpdateScaling(true);
Resize(size, true, PlatformResizeReason.Layout);
Resize(size, true, WindowResizeReason.Layout);
}

private PixelSize ToPixelSize(Size size) => new PixelSize((int)(size.Width * RenderScaling), (int)(size.Height * RenderScaling));

private void Resize(Size clientSize, bool force, PlatformResizeReason reason)
private void Resize(Size clientSize, bool force, WindowResizeReason reason)
{
if (!force && clientSize == ClientSize)
return;
Expand Down
45 changes: 22 additions & 23 deletions src/Modern.WindowKit/Dispatcher.Invoke.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -118,11 +117,11 @@ public void Invoke(Action callback, DispatcherPriority priority, CancellationTok
}

/// <summary>
/// Executes the specified Func<TResult> synchronously on the
/// Executes the specified Func&lt;TResult&gt; synchronously on the
/// thread that the Dispatcher was created on.
/// </summary>
/// <param name="callback">
/// A Func<TResult> delegate to invoke through the dispatcher.
/// A Func&lt;TResult&gt; delegate to invoke through the dispatcher.
/// </param>
/// <returns>
/// The return value from the delegate being invoked.
Expand All @@ -136,11 +135,11 @@ public TResult Invoke<TResult>(Func<TResult> callback)
}

/// <summary>
/// Executes the specified Func<TResult> synchronously on the
/// Executes the specified Func&lt;TResult&gt; synchronously on the
/// thread that the Dispatcher was created on.
/// </summary>
/// <param name="callback">
/// A Func<TResult> delegate to invoke through the dispatcher.
/// A Func&lt;TResult&gt; delegate to invoke through the dispatcher.
/// </param>
/// <param name="priority">
/// The priority that determines in what order the specified
Expand All @@ -156,11 +155,11 @@ public TResult Invoke<TResult>(Func<TResult> callback, DispatcherPriority priori
}

/// <summary>
/// Executes the specified Func<TResult> synchronously on the
/// Executes the specified Func&lt;TResult&gt; synchronously on the
/// thread that the Dispatcher was created on.
/// </summary>
/// <param name="callback">
/// A Func<TResult> delegate to invoke through the dispatcher.
/// A Func&lt;TResult&gt; delegate to invoke through the dispatcher.
/// </param>
/// <param name="priority">
/// The priority that determines in what order the specified
Expand All @@ -183,11 +182,11 @@ public TResult Invoke<TResult>(Func<TResult> callback, DispatcherPriority priori
}

/// <summary>
/// Executes the specified Func<TResult> synchronously on the
/// Executes the specified Func&lt;TResult&gt; synchronously on the
/// thread that the Dispatcher was created on.
/// </summary>
/// <param name="callback">
/// A Func<TResult> delegate to invoke through the dispatcher.
/// A Func&lt;TResult&gt; delegate to invoke through the dispatcher.
/// </param>
/// <param name="priority">
/// The priority that determines in what order the specified
Expand Down Expand Up @@ -317,11 +316,11 @@ public DispatcherOperation InvokeAsync(Action callback, DispatcherPriority prior
}

/// <summary>
/// Executes the specified Func<TResult> asynchronously on the
/// Executes the specified Func&lt;TResult&gt; asynchronously on the
/// thread that the Dispatcher was created on.
/// </summary>
/// <param name="callback">
/// A Func<TResult> delegate to invoke through the dispatcher.
/// A Func&lt;TResult&gt; delegate to invoke through the dispatcher.
/// </param>
/// <returns>
/// An operation representing the queued delegate to be invoked.
Expand All @@ -335,11 +334,11 @@ public DispatcherOperation<TResult> InvokeAsync<TResult>(Func<TResult> callback)
}

/// <summary>
/// Executes the specified Func<TResult> asynchronously on the
/// Executes the specified Func&lt;TResult&gt; asynchronously on the
/// thread that the Dispatcher was created on.
/// </summary>
/// <param name="callback">
/// A Func<TResult> delegate to invoke through the dispatcher.
/// A Func&lt;TResult&gt; delegate to invoke through the dispatcher.
/// </param>
/// <param name="priority">
/// The priority that determines in what order the specified
Expand All @@ -355,11 +354,11 @@ public DispatcherOperation<TResult> InvokeAsync<TResult>(Func<TResult> callback,
}

/// <summary>
/// Executes the specified Func<TResult> asynchronously on the
/// Executes the specified Func&lt;TResult&gt; asynchronously on the
/// thread that the Dispatcher was created on.
/// </summary>
/// <param name="callback">
/// A Func<TResult> delegate to invoke through the dispatcher.
/// A Func&lt;TResult&gt; delegate to invoke through the dispatcher.
/// </param>
/// <param name="priority">
/// The priority that determines in what order the specified
Expand Down Expand Up @@ -479,7 +478,7 @@ internal void InvokeAsyncImpl(DispatcherOperation operation, CancellationToken c
// operation has already started when the timeout expires,
// we still wait for it to complete. This is different
// than simply waiting on the operation with a timeout
// because we are the ones queueing the dispatcher
// because we are the ones queuing the dispatcher
// operation, not the caller. We can't leave the operation
// in a state that it might execute if we return that it did not
// invoke.
Expand All @@ -492,12 +491,12 @@ internal void InvokeAsyncImpl(DispatcherOperation operation, CancellationToken c

// Old async semantics return from Wait without
// throwing an exception if the operation was aborted.
// There is no need to test the timout condition, since
// There is no need to test the timeout condition, since
// the old async semantics would just return the result,
// which would be null.

// This should not block because either the operation
// is using the old async sematics, or the operation
// is using the old async semantics, or the operation
// completed successfully.
result = operation.GetResult();
}
Expand Down Expand Up @@ -543,11 +542,11 @@ public void Post(Action action, DispatcherPriority priority = default)
}

/// <summary>
/// Executes the specified Func<Task> asynchronously on the
/// Executes the specified Func&lt;Task&gt; asynchronously on the
/// thread that the Dispatcher was created on
/// </summary>
/// <param name="callback">
/// A Func<Task> delegate to invoke through the dispatcher.
/// A Func&lt;Task&gt; delegate to invoke through the dispatcher.
/// </param>
/// <param name="priority">
/// The priority that determines in what order the specified
Expand All @@ -564,11 +563,11 @@ public Task InvokeAsync(Func<Task> callback, DispatcherPriority priority = defau
}

/// <summary>
/// Executes the specified Func<Task<TResult>> asynchronously on the
/// Executes the specified Func&lt;Task&lt;TResult&gt;&gt; asynchronously on the
/// thread that the Dispatcher was created on
/// </summary>
/// <param name="callback">
/// A Func<Task<TResult>> delegate to invoke through the dispatcher.
/// <param name="action">
/// A Func&lt;Task&lt;TResult&gt;&gt; delegate to invoke through the dispatcher.
/// </param>
/// <param name="priority">
/// The priority that determines in what order the specified
Expand Down
2 changes: 2 additions & 0 deletions src/Modern.WindowKit/ICursorFactory.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Modern.WindowKit.Input;
using Modern.WindowKit.Metadata;

#nullable enable

namespace Modern.WindowKit.Platform
{
[PrivateApi]
public interface ICursorFactory
{
ICursorImpl GetCursor(StandardCursorType cursorType);
Expand Down
Loading

0 comments on commit e561bd8

Please sign in to comment.