I'm trying to create a simple window using Wayland and EGL, and I've found that I need xdg_shell
or wl_shell
to do it.
But if I print every global Wayland registries:
#include <cstdio>
#include <wayland-client.h>
void registry_global(
void* data, struct wl_registry* wl_registry, uint32_t name, const char* interface, uint32_t version
) {
puts(interface);
}
void registry_global_remove(void* data, struct wl_registry* wl_registry, uint32_t name) {}
wl_registry_listener registry_listener{®istry_global, ®istry_global_remove};
int main() {
auto display = wl_display_connect(nullptr);
if (!display) throw;
auto registry = wl_display_get_registry(display);
if (!registry) throw;
wl_registry_add_listener(registry, ®istry_listener, nullptr);
wl_display_roundtrip(display);
wl_display_disconnect(display);
return 0;
}
It prints wl_compositor
or wl_shm
, but not xdg_shell
or wl_shell
. Am I missing something in my system?
Below is my system's graphics information.
Graphics:
Device-1: NVIDIA GP106 [GeForce GTX 1060 6GB] driver: nvidia v: 555.58.02
Device-2: AMD Raphael driver: amdgpu v: kernel
Display: wayland server: X.org v: 1.21.1.13 with: Xwayland v: 24.1.1
compositor: kwin_wayland driver: X: loaded: amdgpu,nvidia
unloaded: modesetting dri: radeonsi gpu: nvidia,amdgpu
resolution: 1920x1080
API: EGL v: 1.5 drivers: nvidia,radeonsi,swrast,zink
platforms: gbm,wayland,x11,surfaceless,device
API: OpenGL v: 4.6.0 compat-v: 4.5 vendor: nvidia mesa v: 555.58.02
renderer: NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2
API: Vulkan v: 1.3.279 drivers: nvidia surfaces: xcb,xlib,wayland
After two days of going down the rabbit hole about wayland, I finally found the answer: I'm using KDE as my desktop environment, in which case I just need to install the plasma-wayland-protocols
package, generate the headers and source files with wayland-scanner
, and create a shell via org_kde_plasma_shell
.
It's been a while since Wayland came out, and I'm really curious why there's no practical information/tutorial about it. I found this information literally by pure luck...