代码拉取完成,页面将自动刷新
#include <stdio.h>
#include <string.h>
#include <wayland-client.h>
struct wl_compositor *compositor;
struct wl_shm *shm;
struct wl_shell *shell;
void registry_global_handler
(
void *data,
struct wl_registry *registry,
uint32_t name,
const char *interface,
uint32_t version
) {
if (strcmp(interface, "wl_compositor") == 0) {
compositor = wl_registry_bind(registry, name,
&wl_compositor_interface, 3);
} else if (strcmp(interface, "wl_shm") == 0) {
shm = wl_registry_bind(registry, name,
&wl_shm_interface, 1);
} else if (strcmp(interface, "wl_shell") == 0) {
shell = wl_registry_bind(registry, name,
&wl_shell_interface, 1);
}
}
void registry_global_remove_handler
(
void *data,
struct wl_registry *registry,
uint32_t name
) {}
const struct wl_registry_listener registry_listener = {
.global = registry_global_handler,
.global_remove = registry_global_remove_handler
};
int main(void)
{
struct wl_display *display = wl_display_connect(NULL);
struct wl_registry *registry = wl_display_get_registry(display);
wl_registry_add_listener(registry, ®istry_listener, NULL);
// wait for the "initial" set of globals to appear
wl_display_roundtrip(display);
// all our objects should be ready!
if (compositor && shm && shell) {
printf("Got them all!\n");
} else {
printf("Some required globals unavailable\n");
return 1;
}
while (1) {
wl_display_dispatch(display);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。