Give an example of a simple program that uses the wayland interface
- User
Give an example of a simple program that uses the wayland interface
Assistant
Certainly! Here's a simple Wayland program that displays a window with a text message:
#include <stdlib.h> #include <stdio.h> #include <wayland-client.h> struct my_data { struct wl_display *display; struct wl_surface *surface; struct wl_shell_surface *shell_surface; struct wl_shell *shell; }; static const struct wl_interface wl_shell_surface_interfaces[] = { WL_SHELL_SURFACE_INTERFACE, WL_SURFACE_INTERFACE, WL_COMPOSITE_SURFACE_INTERFACE, }; static const struct wl_composite_interface composite_interface = { composite_add = NULL, composite_destroy = NULL, composite_get_subsurface = NULL, composite_move = NULL, composite_resize = NULL, composite_activate = NULL, composite_deactivate = NULL, }; static void handle_shell_surface_destroy(void *data, struct wl_shell_surface *shell_surface) { struct my_data *d = data; wl_surface_destroy(d->surface); } static void handle_globals(void *data, struct zwp_shell_surface_manager *manager, uint32_t id, struct wl_resource *resource) { struct my_data *d = data; d->shell = wl_resource_get_pointer(resource); wl_resource_destroy(resource); } static void handle_surface(void *data, struct wl_client *client, uint32_t id, struct wl_resource *resource) { struct my_data *d = data; d->surface = wl_resource_get_pointer(resource); wl_resource_destroy(resource); d->shell_surface = wl_shell_surface_get(d->surface); wl_shell_surface_set_user_data
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.