WaylandSharpest 1.27.2
dotnet add package WaylandSharpest --version 1.27.2
NuGet\Install-Package WaylandSharpest -Version 1.27.2
<PackageReference Include="WaylandSharpest" Version="1.27.2" />
<PackageVersion Include="WaylandSharpest" Version="1.27.2" />
<PackageReference Include="WaylandSharpest" />
paket add WaylandSharpest --version 1.27.2
#r "nuget: WaylandSharpest, 1.27.2"
#:package WaylandSharpest@1.27.2
#addin nuget:?package=WaylandSharpest&version=1.27.2
#tool nuget:?package=WaylandSharpest&version=1.27.2
WaylandSharpest
WaylandSharpest, the sharpest of Wayland.
This is (another) .NET binding for libwayland, with a Roslyn source generator that turns wayland-protocol XML into idiomatic C# APIs.
Consuming protocols
Add the package and drop protocol XML into a wayland-protocols/ folder next to your project fil, where they will be picked up automatically, or declare items explicitly:
<ItemGroup>
<PackageReference Include="WaylandSharpest" Version="..." />
<WaylandProtocol Include="protocol/xdg-shell.xml" WaylandNamespace="My.Protocols" />
</ItemGroup>
The Generated code lands in your project's root namespace unless overridden with WaylandNamespace. References to interfaces from other protocols resolve against protocol XML in the same project first, then against referenced assemblies via the [WaylandProxy]/[WaylandResource] attributes.
Client example
using var display = WlDisplay.Connect();
using var registry = display.GetRegistry();
WlCompositor? compositor = null;
registry.Global += (_, e) =>
{
if (e.Interface == "wl_compositor")
compositor = registry.Bind<WlCompositor>(e.Name, e.Version);
};
display.Roundtrip();
using var surface = compositor!.CreateSurface();
surface.Commit();
There are no finalizers; Wayland objects must be destroyed from the dispatch thread, so leaks are your responsibility.
Server example
using var server = WlServerDisplay.Create();
var socket = server.AddSocketAuto();
using var global = server.CreateGlobal(WlCompositor.Interface, 6, (client, version, id) =>
{
var compositor = new WlCompositorResource(client, version, id);
compositor.CreateSurface += (_, e) => new WlSurfaceResource(client, version, e.Id);
});
server.Run();
Building and testing
dotnet build
dotnet test
# run the sample
weston --backend=headless --socket=demo &
WAYLAND_DISPLAY=demo dotnet run --project samples/ShmWindow
Regenerating the raw bindings after updating the wayland submodule requires the ClangSharpPInvokeGenerator dotnet tool and clang:
dotnet tool install --global ClangSharpPInvokeGenerator
eng/generate-native.sh
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.