Skip to content

Commit

Permalink
merge release/0.10.18 - Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 401bc52
Author: Dan Walmsley <[email protected]>
Date:   Mon Aug 15 14:29:34 2022 +0100

    bump version.

commit 62a5ee1
Author: Max Katz <[email protected]>
Date:   Sat Aug 13 03:34:22 2022 -0400

    Merge pull request AvaloniaUI#8739 from AvaloniaUI/update-skia

    Update SkiaSharp
    # Conflicts:
    #	build/HarfBuzzSharp.props

commit 0ac982f
Merge: 9f50abd 96187d7
Author: Dan Walmsley <[email protected]>
Date:   Mon Aug 15 13:39:20 2022 +0100

    Merge pull request AvaloniaUI#8753 from AvaloniaUI/fix-listBoxTests-stable

    Fix ListBoxTests on stable

commit 96187d7
Author: Takoooooo <[email protected]>
Date:   Mon Aug 15 15:20:34 2022 +0300

    Fix ListBoxTests.

commit 9f50abd
Author: Dan Walmsley <[email protected]>
Date:   Mon Mar 7 16:54:24 2022 +0000

    Merge pull request AvaloniaUI#7755 from AvaloniaUI/fixes/win32-can-resize

    Fixes/win32 can resize

commit ff86693
Author: Max Katz <[email protected]>
Date:   Thu Aug 11 19:30:58 2022 -0400

    Merge pull request AvaloniaUI#8728 from jp2masa/gl-control-render-rect

    Fixed OpenGlControlBase render rect

commit 7627db1
Author: Max Katz <[email protected]>
Date:   Sat Aug 6 05:28:31 2022 -0400

    Merge pull request AvaloniaUI#8683 from AvaloniaUI/stop-transition-if-it-was-cancelled

    Stop TransitioningContentControl if it was cancelled

commit 7eb0a48
Author: Max Katz <[email protected]>
Date:   Sun Aug 7 02:52:50 2022 -0400

    Merge pull request AvaloniaUI#8569 from hez2010/visual-fixes

    Avoid crashing when fail to create OpenGL context

commit 5f9c852
Author: Dan Walmsley <[email protected]>
Date:   Tue Aug 9 18:38:40 2022 +0100

    Merge pull request AvaloniaUI#8574 from AvaloniaUI/fixes/win32-consistent-minimize-restore-window-size

    Win32: Retain window position and size when docked and then minimized and restored.
    # Conflicts:
    #	tests/Avalonia.IntegrationTests.Appium/WindowTests.cs

commit 46d83d1
Author: Dan Walmsley <[email protected]>
Date:   Tue Aug 9 17:09:06 2022 +0100

    Merge pull request AvaloniaUI#8618 from AvaloniaUI/fixes/macos-dont-reopen-hidden-window

    macos: Don't reopen hidden window when parent clicked.
    # Conflicts:
    #	tests/Avalonia.IntegrationTests.Appium/WindowTests_MacOS.cs

commit d758481
Merge: 765c4d7 7b33526
Author: Max Katz <[email protected]>
Date:   Tue Aug 9 01:29:08 2022 -0400

    Merge pull request AvaloniaUI#8699 from timunie/fix/backport_GH_7778

    Backport PR 7778

commit 7b33526
Author: Tim <[email protected]>
Date:   Mon Aug 8 11:24:12 2022 +0200

    Backport PR 7778

commit 765c4d7
Author: Tako <[email protected]>
Date:   Wed Aug 3 18:44:47 2022 +0300

    Merge pull request AvaloniaUI#8655 from AvaloniaUI/use-correct-toggleModifier-for-treeView-on-macOS-with-multiselection

    Use correct ToggleModifier in TreeView multiselection on MacOS

commit fb607cc
Author: Steven Kirk <[email protected]>
Date:   Wed Aug 3 17:05:21 2022 +0200

    Merge pull request AvaloniaUI#8637 from AvaloniaUI/use-correct-toggleModifier-for-listBox-on-macOS-with-multiselection

    Use correct ToggleModifier in ListBox multiselection on MacOS.

commit fcada17
Author: Steven Kirk <[email protected]>
Date:   Wed Aug 3 18:24:46 2022 +0200

    Added AvaloniaLocator.GetRequiredService.

commit 50f02de
Author: Max Katz <[email protected]>
Date:   Tue Jul 26 23:06:08 2022 -0400

    Merge pull request AvaloniaUI#8604 from AvaloniaUI/feature/tray-icon-non-mandatory

    Don't throw exceptions for missing windowing platform since it's actually not mandatory for TrayIcon

commit dfabf4d
Author: Max Katz <[email protected]>
Date:   Sat Jul 30 13:56:36 2022 -0400

    Merge pull request AvaloniaUI#8599 from jinek/fixes/scene-hittest-exclusive

    Scene hittest now uses exclusive `Rect.Contains`. Fixes https://githu…

commit 1628b20
Author: Nikita Tsukanov <[email protected]>
Date:   Tue Jul 26 13:52:23 2022 +0300

    Merge pull request AvaloniaUI#8597 from AvaloniaUI/feature/x11-wmclass-spec

    Set WM_CLASS property according to ICCCM spec

commit d2f8fe6
Author: Jumar Macato <[email protected]>
Date:   Fri Jul 15 21:04:07 2022 +0800

    Merge pull request AvaloniaUI#8520 from timunie/fix/DataGrid_LastColumnIsClipped

    fix: RowDesiredWidth was missing the RowHeaderWidth

commit 2d2cd97
Author: Max Katz <[email protected]>
Date:   Thu Jul 28 12:04:17 2022 -0400

    Backport proper exception handling in win32 system dialogs

commit 7fb8c01
Author: Nikita Tsukanov <[email protected]>
Date:   Tue Jul 26 16:41:15 2022 +0300

    Merge pull request AvaloniaUI#8601 from AvaloniaUI/fixes/7773-skia-stream-workaround

    Workaround for SkiaSharp broken image decoding.

commit e975100
Author: Dan Walmsley <[email protected]>
Date:   Mon Jul 18 15:38:27 2022 +0100

    Merge pull request AvaloniaUI#8538 from AvaloniaUI/feature/expose-gtk-thread-invoke

    Introduced GtkInteropHelper.RunOnGlibThread, fixed demos
    # Conflicts:
    #	samples/ControlCatalog.NetCore/NativeControls/Gtk/EmbedSample.Gtk.cs
    #	samples/ControlCatalog.NetCore/NativeControls/Gtk/GtkHelper.cs

# Conflicts:
#	build/SharedVersion.props
  • Loading branch information
donandren committed Mar 15, 2023
1 parent eb746f9 commit 1a2be02
Show file tree
Hide file tree
Showing 36 changed files with 704 additions and 467 deletions.
6 changes: 3 additions & 3 deletions build/HarfBuzzSharp.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="HarfBuzzSharp" Version="2.8.2-preview.178" />
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2-preview.178" />
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="2.8.2-preview.178"/>
<PackageReference Include="HarfBuzzSharp" Version="2.8.2.1-preview.108" />
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.1-preview.108" />
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="2.8.2.1-preview.108" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion build/SharedVersion.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Product>Avalonia</Product>
<Version>0.10.17</Version>
<Version>0.10.18</Version>
<Copyright>Copyright 2022 &#169; The AvaloniaUI Project</Copyright>
<PackageProjectUrl>https://avaloniaui.net</PackageProjectUrl>
<RepositoryUrl>https://github.com/AvaloniaUI/Avalonia/</RepositoryUrl>
Expand Down
6 changes: 3 additions & 3 deletions build/SkiaSharp.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="SkiaSharp" Version="2.88.1-preview.1" />
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.1-preview.1" />
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.1-preview.1" />
<PackageReference Include="SkiaSharp" Version="2.88.1-preview.108" />
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.1-preview.108" />
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.1-preview.108" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion native/Avalonia.Native/src/OSX/WindowImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
{
if(Window != nullptr)
{
if (![Window isMiniaturized])
if ([Window isVisible] && ![Window isMiniaturized])
{
if(IsDialog())
{
Expand Down
1 change: 1 addition & 0 deletions samples/IntegrationTestApp/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private void RestoreAll()

foreach (var window in lifetime.Windows)
{
window.Show();
if (window.WindowState == WindowState.Minimized)
window.WindowState = WindowState.Normal;
}
Expand Down
3 changes: 2 additions & 1 deletion samples/IntegrationTestApp/ShowWindowTest.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
x:Class="IntegrationTestApp.ShowWindowTest"
Name="SecondaryWindow"
Title="Show Window Test">
<Grid ColumnDefinitions="Auto,Auto" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<Grid ColumnDefinitions="Auto,Auto" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<Label Grid.Column="0" Grid.Row="1">Client Size</Label>
<TextBox Name="ClientSize" Grid.Column="1" Grid.Row="1" IsReadOnly="True"
Text="{Binding ClientSize, Mode=OneWay}"/>
Expand Down Expand Up @@ -31,5 +31,6 @@
<ComboBoxItem>Maximized</ComboBoxItem>
<ComboBoxItem>Fullscreen</ComboBoxItem>
</ComboBox>
<Button Name="HideButton" Grid.Row="8" Command="{Binding $parent[Window].Hide}">Hide</Button>
</Grid>
</Window>
10 changes: 10 additions & 0 deletions src/Avalonia.Base/AvaloniaLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ public static class LocatorExtensions
{
return (T?) resolver.GetService(typeof (T));
}

public static object GetRequiredService(this IAvaloniaDependencyResolver resolver, Type t)
{
return resolver.GetService(t) ?? throw new InvalidOperationException($"Unable to locate '{t}'.");
}

public static T GetRequiredService<T>(this IAvaloniaDependencyResolver resolver)
{
return (T?)resolver.GetService(typeof(T)) ?? throw new InvalidOperationException($"Unable to locate '{typeof(T)}'.");
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected override Size ArrangeOverride(Size finalSize)

OwningGrid.OnFillerColumnWidthNeeded(finalSize.Width);

double rowDesiredWidth = OwningGrid.ColumnsInternal.VisibleEdgedColumnsWidth + OwningGrid.ColumnsInternal.FillerColumn.FillerWidth;
double rowDesiredWidth = OwningGrid.RowHeadersDesiredWidth + OwningGrid.ColumnsInternal.VisibleEdgedColumnsWidth + OwningGrid.ColumnsInternal.FillerColumn.FillerWidth;
double topEdge = -OwningGrid.NegVerticalOffset;
foreach (Control element in OwningGrid.DisplayData.GetScrollingElements())
{
Expand Down
3 changes: 2 additions & 1 deletion src/Avalonia.Controls/ListBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Avalonia.Controls.Selection;
using Avalonia.Controls.Templates;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.VisualTree;

namespace Avalonia.Controls
Expand Down Expand Up @@ -157,7 +158,7 @@ protected override void OnPointerPressed(PointerPressedEventArgs e)
e.Source,
true,
e.KeyModifiers.HasAllFlags(KeyModifiers.Shift),
e.KeyModifiers.HasAllFlags(KeyModifiers.Control),
e.KeyModifiers.HasAllFlags(AvaloniaLocator.Current.GetRequiredService<PlatformHotkeyConfiguration>().CommandModifiers),
point.Properties.IsRightButtonPressed);
}
}
Expand Down
13 changes: 2 additions & 11 deletions src/Avalonia.Controls/Platform/PlatformManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,8 @@ public static void SetDesignerScalingFactor(double factor)
{
}

public static ITrayIconImpl? CreateTrayIcon()
{
var platform = AvaloniaLocator.Current.GetService<IWindowingPlatform>();

if (platform == null)
{
throw new Exception("Could not CreateTrayIcon(): IWindowingPlatform is not registered.");
}

return s_designerMode ? null : platform.CreateTrayIcon();
}
public static ITrayIconImpl? CreateTrayIcon() =>
s_designerMode ? null : AvaloniaLocator.Current.GetService<IWindowingPlatform>()?.CreateTrayIcon();


public static IWindowImpl CreateWindow()
Expand Down
10 changes: 8 additions & 2 deletions src/Avalonia.Controls/TransitioningContentControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,19 @@ private async void UpdateContentWithTransition(object? content)

_lastTransitionCts?.Cancel();
_lastTransitionCts = new CancellationTokenSource();
var localToken = _lastTransitionCts.Token;

if (PageTransition != null)
await PageTransition.Start(this, null, true, _lastTransitionCts.Token);
await PageTransition.Start(this, null, true, localToken);

if (localToken.IsCancellationRequested)
{
return;
}

CurrentContent = content;

if (PageTransition != null)
await PageTransition.Start(null, this, true, _lastTransitionCts.Token);
await PageTransition.Start(null, this, true, localToken);
}
}
2 changes: 1 addition & 1 deletion src/Avalonia.Controls/TreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ protected override void OnPointerPressed(PointerPressedEventArgs e)
e.Source,
true,
e.KeyModifiers.HasAllFlags(KeyModifiers.Shift),
e.KeyModifiers.HasAllFlags(KeyModifiers.Control),
e.KeyModifiers.HasAllFlags(AvaloniaLocator.Current.GetRequiredService<PlatformHotkeyConfiguration>().CommandModifiers),
point.Properties.IsRightButtonPressed);
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/Avalonia.OpenGL/Controls/OpenGlControlBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public sealed override void Render(DrawingContext context)
_attachment.Present();
}

context.DrawImage(_bitmap, new Rect(_bitmap.Size), Bounds);
context.DrawImage(_bitmap, new Rect(_bitmap.Size), new Rect(Bounds.Size));
base.Render(context);
}

Expand Down Expand Up @@ -148,6 +148,13 @@ private bool EnsureInitializedCore()
return false;
}

if (_context == null)
{
Logger.TryGet(LogEventLevel.Error, "OpenGL")?.Log("OpenGlControlBase",
"Unable to initialize OpenGL: unable to create additional OpenGL context.");
return false;
}

GlVersion = _context.Version;
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public override bool HitTest(Point p)
if (Material != null)
{
var rect = Rect.Rect;
return rect.Contains(p);
return rect.ContainsExclusive(p);
}
}

Expand Down
31 changes: 31 additions & 0 deletions src/Avalonia.Visuals/Rendering/SceneGraph/GeometryBoundsHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using Avalonia.Media;
using Avalonia.Utilities;

namespace Avalonia.Rendering.SceneGraph;

internal static class GeometryBoundsHelper
{
/// <summary>
/// Calculates the bounds of a given geometry with respect to the pens <see cref="IPen.LineCap"/>
/// </summary>
/// <param name="originalBounds">The calculated bounds without <see cref="IPen.LineCap"/>s</param>
/// <param name="pen">The pen with information about the <see cref="IPen.LineCap"/>s</param>
/// <returns></returns>
public static Rect CalculateBoundsWithLineCaps(this Rect originalBounds, IPen? pen)
{
if (pen is null || MathUtilities.IsZero(pen.Thickness)) return originalBounds;

switch (pen.LineCap)
{
case PenLineCap.Flat:
return originalBounds;
case PenLineCap.Round:
return originalBounds.Inflate(pen.Thickness / 2);
case PenLineCap.Square:
return originalBounds.Inflate(pen.Thickness);
default:
throw new ArgumentOutOfRangeException();
}
}
}
2 changes: 1 addition & 1 deletion src/Avalonia.Visuals/Rendering/SceneGraph/GeometryNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public GeometryNode(Matrix transform,
IPen pen,
IGeometryImpl geometry,
IDictionary<IVisual, Scene> childScenes = null)
: base(geometry.GetRenderBounds(pen), transform)
: base(geometry.GetRenderBounds(pen).CalculateBoundsWithLineCaps(pen), transform)
{
Transform = transform;
Brush = brush?.ToImmutable();
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Visuals/Rendering/SceneGraph/GlyphRunNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ internal bool Equals(Matrix transform, IBrush foreground, GlyphRun glyphRun)
}

/// <inheritdoc/>
public override bool HitTest(Point p) => Bounds.Contains(p);
public override bool HitTest(Point p) => Bounds.ContainsExclusive(p);
}
}
2 changes: 1 addition & 1 deletion src/Avalonia.Visuals/Rendering/SceneGraph/ImageNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public override void Render(IDrawingContextImpl context)
}

/// <inheritdoc/>
public override bool HitTest(Point p) => Bounds.Contains(p);
public override bool HitTest(Point p) => Bounds.ContainsExclusive(p);

public override void Dispose()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ public override bool HitTest(Point p)
if (Brush != null)
{
var rect = Rect.Rect.Inflate((Pen?.Thickness / 2) ?? 0);
return rect.Contains(p);
return rect.ContainsExclusive(p);
}
else
{
var borderRect = Rect.Rect.Inflate((Pen?.Thickness / 2) ?? 0);
var emptyRect = Rect.Rect.Deflate((Pen?.Thickness / 2) ?? 0);
return borderRect.Contains(p) && !emptyRect.Contains(p);
return borderRect.ContainsExclusive(p) && !emptyRect.ContainsExclusive(p);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Visuals/Rendering/SceneGraph/Scene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ private bool FilterAndClip(IVisualNode node, ref Rect? clip)
if (node.ClipToBounds)
{
clip = clip == null ? node.ClipBounds : clip.Value.Intersect(node.ClipBounds);
clipped = !clip.Value.Contains(_point);
clipped = !clip.Value.ContainsExclusive(_point);
}

if (node.GeometryClip != null)
Expand Down
15 changes: 15 additions & 0 deletions src/Avalonia.X11/Interop/GtkInteropHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.ComponentModel;
using System.Threading.Tasks;

namespace Avalonia.X11.Interop;

public class GtkInteropHelper
{
public static async Task<T> RunOnGlibThread<T>(Func<T> cb)
{
if (!await NativeDialogs.Gtk.StartGtk().ConfigureAwait(false))
throw new Win32Exception("Unable to initialize GTK");
return await NativeDialogs.Glib.RunOnGlibThread(cb).ConfigureAwait(false);
}
}
27 changes: 24 additions & 3 deletions src/Avalonia.X11/NativeDialogs/Gtk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.Threading;
using System.Threading.Tasks;
using Avalonia.Platform.Interop;
using JetBrains.Annotations;

// ReSharper disable IdentifierTypo
namespace Avalonia.X11.NativeDialogs
{
Expand Down Expand Up @@ -247,10 +249,19 @@ public static extern void

public static IntPtr GetForeignWindow(IntPtr xid) => gdk_x11_window_foreign_new_for_display(s_display, xid);

static object s_startGtkLock = new();
static Task<bool> s_startGtkTask;

public static Task<bool> StartGtk()
{
var tcs = new TaskCompletionSource<bool>();
new Thread(() =>
return StartGtkCore();
lock (s_startGtkLock)
return s_startGtkTask ??= StartGtkCore();
}

private static void GtkThread(TaskCompletionSource<bool> tcs)
{
try
{
try
{
Expand Down Expand Up @@ -284,7 +295,17 @@ public static Task<bool> StartGtk()
tcs.SetResult(true);
while (true)
gtk_main_iteration();
}) {Name = "GTK3THREAD", IsBackground = true}.Start();
}
catch
{
tcs.SetResult(false);
}
}

private static Task<bool> StartGtkCore()
{
var tcs = new TaskCompletionSource<bool>();
new Thread(() => GtkThread(tcs)) {Name = "GTK3THREAD", IsBackground = true}.Start();
return tcs.Task;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Avalonia.X11/X11Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ public class X11PlatformOptions
// and sometimes attempts to use GLX might cause a segfault
"llvmpipe"
};
public string WmClass { get; set; } = Assembly.GetEntryAssembly()?.GetName()?.Name ?? "AvaloniaApplication";

public string WmClass { get; set; } = Assembly.GetEntryAssembly()?.GetName()?.Name;

/// <summary>
/// Enables multitouch support. The default value is true.
Expand Down
23 changes: 17 additions & 6 deletions src/Avalonia.X11/X11Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ public X11Window(AvaloniaX11Platform platform, IWindowImpl popupParent)
XChangeProperty(_x11.Display, _handle, _x11.Atoms._NET_WM_WINDOW_TYPE, _x11.Atoms.XA_ATOM,
32, PropertyMode.Replace, new[] {_x11.Atoms._NET_WM_WINDOW_TYPE_NORMAL}, 1);

if (platform.Options.WmClass != null)
SetWmClass(platform.Options.WmClass);
SetWmClass(_platform.Options.WmClass);

var surfaces = new List<object>
{
Expand Down Expand Up @@ -1068,12 +1067,24 @@ public void SetTitle(string title)

public void SetWmClass(string wmClass)
{
var data = Encoding.ASCII.GetBytes(wmClass);
fixed (void* pdata = data)
// See https://tronche.com/gui/x/icccm/sec-4.html#WM_CLASS
// We don't actually parse the application's command line, so we only use RESOURCE_NAME and argv[0]
var appId = Environment.GetEnvironmentVariable("RESOURCE_NAME")
?? Process.GetCurrentProcess().ProcessName;

var encodedAppId = Encoding.ASCII.GetBytes(appId);
var encodedWmClass = Encoding.ASCII.GetBytes(wmClass ?? appId);

var hint = XAllocClassHint();
fixed(byte* pAppId = encodedAppId)
fixed (byte* pWmClass = encodedWmClass)
{
XChangeProperty(_x11.Display, _handle, _x11.Atoms.XA_WM_CLASS, _x11.Atoms.XA_STRING, 8,
PropertyMode.Replace, pdata, data.Length);
hint->res_name = pAppId;
hint->res_class = pWmClass;
XSetClassHint(_x11.Display, _handle, hint);
}

XFree(hint);
}

public void SetMinMaxSize(Size minSize, Size maxSize)
Expand Down
Loading

0 comments on commit 1a2be02

Please sign in to comment.