{"id":21837175,"url":"https://github.com/x9void/waylandsharp","last_synced_at":"2025-04-14T09:50:55.284Z","repository":{"id":37242429,"uuid":"505606756","full_name":"X9VoiD/WaylandSharp","owner":"X9VoiD","description":"C# Source Generator for Wayland","archived":false,"fork":false,"pushed_at":"2024-11-22T14:57:57.000Z","size":132,"stargazers_count":22,"open_issues_count":6,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-27T23:06:10.769Z","etag":null,"topics":["csharp","source-generator","wayland"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/X9VoiD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-20T21:44:51.000Z","updated_at":"2025-02-06T00:52:06.000Z","dependencies_parsed_at":"2023-02-01T00:16:29.607Z","dependency_job_id":null,"html_url":"https://github.com/X9VoiD/WaylandSharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X9VoiD%2FWaylandSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X9VoiD%2FWaylandSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X9VoiD%2FWaylandSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/X9VoiD%2FWaylandSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/X9VoiD","download_url":"https://codeload.github.com/X9VoiD/WaylandSharp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248859499,"owners_count":21173336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","source-generator","wayland"],"created_at":"2024-11-27T20:44:31.857Z","updated_at":"2025-04-14T09:50:55.255Z","avatar_url":"https://github.com/X9VoiD.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WaylandSharp\n\nAn incremental source generator to automatically create bindings to Wayland\nusing given protocol xml files.\n\u003e `wayland.xml` should always be included to the list.\n\n## Compatibility\n\n| .NET Version | Compatibility |\n| ------------ | ------------- |\n| .NET | (6.0 and above) :heavy_check_mark: |\n| .NET Standard | :x: |\n| .NET Framework | :x: |\n\n## Getting started\n\nInstall WaylandSharp nuget package.\n```sh\ndotnet add package WaylandSharp\n```\n\nGrab `wayland.xml` from [freedesktop.org](https://gitlab.freedesktop.org/wayland/wayland/-/blob/main/protocol/wayland.xml). Drop the file into your project.\n\nAdd the following to your `.csproj`:\n```xml\n\u003cItemGroup\u003e\n    \u003cCompilerVisibleItemMetadata Include=\"AdditionalFiles\" MetadataName=\"WaylandProtocol\" /\u003e\n    \u003cAdditionalFiles Include=\"wayland.xml\" WaylandProtocol=\"client\" /\u003e\n    \u003c!-- Add additional protocol files with more AdditionalFiles tags --\u003e\n\u003c/ItemGroup\u003e\n```\n\n\u003e No support for generating server-side bindings yet.\n\nBenefit! :bread:\n\n\n\n## Quick Guide\n\nConnection to a wayland display server can be established by calling:\n```cs\nWlDisplay.Connect(string);\n```\n\nGlobal objects can be retrieved by creating a registry object and listening for\n`Global` event\n```cs\nusing wlDisplay = WlDisplay.Connect();\nusing wlRegistry = wlDisplay.GetRegistry();\n\nwlRegistry.Global += (_, e) =\u003e\n{\n    Console.WriteLine($\"{e.Name}:{e.Interface}:{e.Version}\");\n};\n\nwlDisplay.Roundtrip();\n```\n\nEither a `WlDisplay.Roundtrip()` or `WlDisplay.Dispatch()` is required to\ngenerate event invocations. In this case, `Global` event will occur upon calling\n`Roundtrip()`.\n\nAs described in Wayland's [official docs](https://wayland.freedesktop.org/docs/html/apb.html#Client-classwl__display),\n`WlDisplay.Roundtrip()` dispatches all currently pending events. If no events\nare pending, the function returns 0, otherwise it returns the number of pending\nevents that were processed. This internally calls `Sync` and waits for the\nserver's callback before returning.\n\nOn the other hand, `Dispatch` will block until there are events to process,\nas such, it will never return 0. It is useful for setting up an event loop, like\nin this example below.\n\n```cs\nwhile (someWlDisplayInstance.Dispatch() != -1)\n{\n    // intentionally empty\n}\n```\n\nBinding to global objects are done by using the data received from\n`GlobalEventArgs`, specifically `Name` (a unique `uint` given by the server\nfor this instance of global object), `Interface` (the contract used), and\n`Version` and passing it as the arguments of `WlRegistry.Bind()`.\n\nAs an example, assuming that the user wants to bind to a `wl_output`\n\n```cs\nwlRegistry.Global += (_, e) =\u003e\n{\n    if (e.Interface == WlInterface.WlOutput.Name)\n    {\n        // Passing a version is optional, it'll use the version specified in\n        // the protocol xml by default.\n        using var wlOutput = wlRegistry.Bind\u003cWlOutput\u003e(e.Name, e.Interface);\n\n        // do something about wlOutput here.\n    }\n};\n```\n\n\u003e A helper function will be introduced in the future to help shorten this\nspecific pattern.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx9void%2Fwaylandsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fx9void%2Fwaylandsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx9void%2Fwaylandsharp/lists"}