Browse Source

Merge remote-tracking branch 'origin/master' into feature/pens-only-subscribe-when-needed

pull/7303/head
Nikita Tsukanov 5 years ago
parent
commit
bb24e5233f
  1. 5
      src/Avalonia.Base/Utilities/WeakEvent.cs
  2. 2
      src/Avalonia.Native/AvaloniaNativeMenuExporter.cs
  3. 28
      src/Avalonia.Native/WindowImplBase.cs
  4. 7
      src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs
  5. 6
      src/Web/Avalonia.Web.Blazor/AvaloniaView.razor.cs
  6. 8
      src/Web/Avalonia.Web.Blazor/RazorViewTopLevelImpl.cs

5
src/Avalonia.Base/Utilities/WeakEvent.cs

@ -49,6 +49,7 @@ public class WeakEvent<TSender, TEventArgs> : WeakEvent where TEventArgs : Event
{
private readonly WeakEvent<TSender, TEventArgs> _ev;
private readonly TSender _target;
private readonly Action _compact;
private WeakReference<IWeakEventSubscriber<TEventArgs>>?[] _data =
new WeakReference<IWeakEventSubscriber<TEventArgs>>[16];
@ -60,7 +61,7 @@ public class WeakEvent<TSender, TEventArgs> : WeakEvent where TEventArgs : Event
{
_ev = ev;
_target = target;
_compact = Compact;
_unsubscribe = ev._subscribe(target, OnEvent);
}
@ -110,7 +111,7 @@ public class WeakEvent<TSender, TEventArgs> : WeakEvent where TEventArgs : Event
if(_compactScheduled)
return;
_compactScheduled = true;
Dispatcher.UIThread.Post(Compact, DispatcherPriority.Background);
Dispatcher.UIThread.Post(_compact, DispatcherPriority.Background);
}
void Compact()

2
src/Avalonia.Native/AvaloniaNativeMenuExporter.cs

@ -131,7 +131,7 @@ namespace Avalonia.Native
};
quitItem.Click += (sender, args) =>
{
_applicationCommands.ShowAll();
(Application.Current.ApplicationLifetime as IControlledApplicationLifetime)?.Shutdown();
};
result.Add(quitItem);
}

28
src/Avalonia.Native/WindowImplBase.cs

@ -28,18 +28,18 @@ namespace Avalonia.Native
public string HandleDescriptor => "NSWindow";
public IntPtr NSView => _native.ObtainNSViewHandle();
public IntPtr NSView => _native?.ObtainNSViewHandle() ?? IntPtr.Zero;
public IntPtr NSWindow => _native.ObtainNSWindowHandle();
public IntPtr NSWindow => _native?.ObtainNSWindowHandle() ?? IntPtr.Zero;
public IntPtr GetNSViewRetained()
{
return _native.ObtainNSViewHandleRetained();
return _native?.ObtainNSViewHandleRetained() ?? IntPtr.Zero;
}
public IntPtr GetNSWindowRetained()
{
return _native.ObtainNSWindowHandleRetained();
return _native?.ObtainNSWindowHandleRetained() ?? IntPtr.Zero;
}
}
@ -260,7 +260,7 @@ namespace Avalonia.Native
public void Activate()
{
_native.Activate();
_native?.Activate();
}
public bool RawTextInputEvent(uint timeStamp, string text)
@ -322,7 +322,7 @@ namespace Avalonia.Native
public void Resize(Size clientSize, PlatformResizeReason reason)
{
_native.Resize(clientSize.Width, clientSize.Height, (AvnPlatformResizeReason)reason);
_native?.Resize(clientSize.Width, clientSize.Height, (AvnPlatformResizeReason)reason);
}
public IRenderer CreateRenderer(IRenderRoot root)
@ -367,14 +367,14 @@ namespace Avalonia.Native
public virtual void Show(bool activate, bool isDialog)
{
_native.Show(activate.AsComBool(), isDialog.AsComBool());
_native?.Show(activate.AsComBool(), isDialog.AsComBool());
}
public PixelPoint Position
{
get => _native.Position.ToAvaloniaPixelPoint();
set => _native.SetPosition(value.ToAvnPoint());
get => _native?.Position.ToAvaloniaPixelPoint() ?? default;
set => _native?.SetPosition(value.ToAvnPoint());
}
public Point PointToClient(PixelPoint point)
@ -389,12 +389,12 @@ namespace Avalonia.Native
public void Hide()
{
_native.Hide();
_native?.Hide();
}
public void BeginMoveDrag(PointerPressedEventArgs e)
{
_native.BeginMoveDrag();
_native?.BeginMoveDrag();
}
public Size MaxAutoSizeHint => Screen.AllScreens.Select(s => s.Bounds.Size.ToSize(1))
@ -402,7 +402,7 @@ namespace Avalonia.Native
public void SetTopmost(bool value)
{
_native.SetTopMost(value.AsComBool());
_native?.SetTopMost(value.AsComBool());
}
public double RenderScaling => _native?.Scaling ?? 1;
@ -438,7 +438,7 @@ namespace Avalonia.Native
public void SetMinMaxSize(Size minSize, Size maxSize)
{
_native.SetMinMaxSize(minSize.ToAvnSize(), maxSize.ToAvnSize());
_native?.SetMinMaxSize(minSize.ToAvnSize(), maxSize.ToAvnSize());
}
public void BeginResizeDrag(WindowEdge edge, PointerPressedEventArgs e)
@ -449,7 +449,7 @@ namespace Avalonia.Native
internal void BeginDraggingSession(AvnDragDropEffects effects, AvnPoint point, IAvnClipboard clipboard,
IAvnDndResultCallback callback, IntPtr sourceHandle)
{
_native.BeginDragAndDropOperation(effects, point, clipboard, callback, sourceHandle);
_native?.BeginDragAndDropOperation(effects, point, clipboard, callback, sourceHandle);
}
public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel)

7
src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs

@ -126,7 +126,12 @@ namespace Avalonia.Rendering.SceneGraph
while (node == null && visual.IsVisible)
{
visual = visual.VisualParent!;
var parent = visual.VisualParent;
if (parent is null)
return null;
visual = parent;
node = scene.FindNode(visual);
}

6
src/Web/Avalonia.Web.Blazor/AvaloniaView.razor.cs

@ -259,7 +259,11 @@ namespace Avalonia.Web.Blazor
_inputHelper.Hide();
_canvasHelper.SetCursor("default");
_topLevelImpl.SetCssCursor = _canvasHelper.SetCursor;
_topLevelImpl.SetCssCursor = x =>
{
_inputHelper.SetCursor(x);//macOS
_canvasHelper.SetCursor(x);//windows
};
Console.WriteLine("starting html canvas setup");
_interop = await SKHtmlCanvasInterop.ImportAsync(Js, _htmlCanvas, OnRenderFrame);

8
src/Web/Avalonia.Web.Blazor/RazorViewTopLevelImpl.cs

@ -127,15 +127,11 @@ namespace Avalonia.Web.Blazor
public void SetCursor(ICursorImpl cursor)
{
var cur = cursor as CssCursor;
var val = CssCursor.Default;
if (cur != null && cur.Value != null)
{
val = cur.Value;
}
var val = (cursor as CssCursor)?.Value ?? CssCursor.Default;
if (_currentCursor != val)
{
SetCssCursor?.Invoke(val);
_currentCursor = val;
}
}

Loading…
Cancel
Save