Browse Source

[X11] Set WM_CLASS property (default to entry assembly name)

#2369
pull/2416/head
Nikita Tsukanov 7 years ago
parent
commit
d505a41fd3
  1. 5
      src/Avalonia.X11/X11Platform.cs
  2. 12
      src/Avalonia.X11/X11Window.cs

5
src/Avalonia.X11/X11Platform.cs

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Avalonia.Controls;
using Avalonia.Controls.Platform;
using Avalonia.Input;
@ -24,6 +25,7 @@ namespace Avalonia.X11
public X11Info Info { get; private set; }
public IX11Screens X11Screens { get; private set; }
public IScreenImpl Screens { get; private set; }
public X11PlatformOptions Options { get; private set; }
public void Initialize(X11PlatformOptions options)
{
XInitThreads();
@ -63,6 +65,8 @@ namespace Avalonia.X11
else
GlxGlPlatformFeature.TryInitialize(Info);
}
Options = options;
}
public IntPtr DeferredDisplay { get; set; }
@ -91,6 +95,7 @@ namespace Avalonia
{
public bool UseEGL { get; set; }
public bool UseGpu { get; set; } = true;
public string WmClass { get; set; } = Assembly.GetEntryAssembly()?.GetName()?.Name ?? "AvaloniaApplication";
}
public static class AvaloniaX11PlatformExtensions
{

12
src/Avalonia.X11/X11Window.cs

@ -128,6 +128,8 @@ namespace Avalonia.X11
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);
var surfaces = new List<object>
{
@ -873,6 +875,16 @@ namespace Avalonia.X11
}
}
public void SetWmClass(string wmClass)
{
var data = Encoding.ASCII.GetBytes(wmClass);
fixed (void* pdata = data)
{
XChangeProperty(_x11.Display, _handle, _x11.Atoms.XA_WM_CLASS, _x11.Atoms.XA_STRING, 8,
PropertyMode.Replace, pdata, data.Length);
}
}
public void SetMinMaxSize(Size minSize, Size maxSize)
{
_scaledMinMaxSize = (minSize, maxSize);

Loading…
Cancel
Save