fixes: add implementation

This commit is contained in:
Kirill Primak 2024-05-12 11:53:09 +03:00 committed by Simon Ser
parent 7392b3313a
commit 812675ba34
4 changed files with 100 additions and 6 deletions

View file

@ -0,0 +1,28 @@
/*
* This an unstable interface of wlroots. No guarantees are made regarding the
* future consistency of this API.
*/
#ifndef WLR_USE_UNSTABLE
#error "Add -DWLR_USE_UNSTABLE to enable unstable wlroots features"
#endif
#ifndef WLR_TYPES_WLR_FIXES_H
#define WLR_TYPES_WLR_FIXES_H
#include <wayland-server-core.h>
struct wlr_fixes {
struct wl_global *global;
struct {
struct wl_signal destroy;
} events;
struct {
struct wl_listener display_destroy;
} WLR_PRIVATE;
};
struct wlr_fixes *wlr_fixes_create(struct wl_display *display, uint32_t version);
#endif

View file

@ -86,7 +86,7 @@ internal_features = {
internal_config = configuration_data() internal_config = configuration_data()
wayland_kwargs = { wayland_kwargs = {
'version': '>=1.23.1', 'version': '>=1.24.0',
'fallback': 'wayland', 'fallback': 'wayland',
'default_options': [ 'default_options': [
'tests=false', 'tests=false',

View file

@ -39,19 +39,20 @@ wlr_files += files(
'buffer/resource.c', 'buffer/resource.c',
'wlr_alpha_modifier_v1.c', 'wlr_alpha_modifier_v1.c',
'wlr_color_management_v1.c', 'wlr_color_management_v1.c',
'wlr_color_representation_v1.c',
'wlr_compositor.c', 'wlr_compositor.c',
'wlr_content_type_v1.c', 'wlr_content_type_v1.c',
'wlr_cursor_shape_v1.c',
'wlr_cursor.c', 'wlr_cursor.c',
'wlr_cursor_shape_v1.c',
'wlr_damage_ring.c', 'wlr_damage_ring.c',
'wlr_data_control_v1.c', 'wlr_data_control_v1.c',
'wlr_drm.c', 'wlr_drm.c',
'wlr_export_dmabuf_v1.c', 'wlr_export_dmabuf_v1.c',
'wlr_foreign_toplevel_management_v1.c',
'wlr_color_representation_v1.c',
'wlr_ext_image_copy_capture_v1.c',
'wlr_ext_foreign_toplevel_list_v1.c',
'wlr_ext_data_control_v1.c', 'wlr_ext_data_control_v1.c',
'wlr_ext_foreign_toplevel_list_v1.c',
'wlr_ext_image_copy_capture_v1.c',
'wlr_fixes.c',
'wlr_foreign_toplevel_management_v1.c',
'wlr_fractional_scale_v1.c', 'wlr_fractional_scale_v1.c',
'wlr_gamma_control_v1.c', 'wlr_gamma_control_v1.c',
'wlr_idle_inhibit_v1.c', 'wlr_idle_inhibit_v1.c',

65
types/wlr_fixes.c Normal file
View file

@ -0,0 +1,65 @@
#include <assert.h>
#include <wayland-server-protocol.h>
#include <stdlib.h>
#include <wlr/types/wlr_fixes.h>
#define FIXES_VERSION 1
static void fixes_destroy(struct wl_client *client, struct wl_resource *resource) {
wl_resource_destroy(resource);
}
static void fixes_destroy_registry(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *registry) {
wl_resource_destroy(registry);
}
static const struct wl_fixes_interface fixes_impl = {
.destroy = fixes_destroy,
.destroy_registry = fixes_destroy_registry,
};
static void fixes_bind(struct wl_client *wl_client, void *data, uint32_t version, uint32_t id) {
struct wlr_fixes *fixes = data;
struct wl_resource *resource = wl_resource_create(wl_client, &wl_fixes_interface, version, id);
if (resource == NULL) {
wl_client_post_no_memory(wl_client);
return;
}
wl_resource_set_implementation(resource, &fixes_impl, fixes, NULL);
}
static void fixes_handle_display_destroy(struct wl_listener *listener, void *data) {
struct wlr_fixes *fixes = wl_container_of(listener, fixes, display_destroy);
wl_signal_emit_mutable(&fixes->events.destroy, NULL);
assert(wl_list_empty(&fixes->events.destroy.listener_list));
wl_list_remove(&fixes->display_destroy.link);
wl_global_destroy(fixes->global);
free(fixes);
}
struct wlr_fixes *wlr_fixes_create(struct wl_display *display, uint32_t version) {
assert(version <= FIXES_VERSION);
struct wlr_fixes *fixes = calloc(1, sizeof(*fixes));
if (fixes == NULL) {
return NULL;
}
fixes->global = wl_global_create(display, &wl_fixes_interface, version, fixes, fixes_bind);
if (fixes->global == NULL) {
free(fixes);
return NULL;
}
wl_signal_init(&fixes->events.destroy);
fixes->display_destroy.notify = fixes_handle_display_destroy;
wl_display_add_destroy_listener(display, &fixes->display_destroy);
return fixes;
}