swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit 5c889bf5af72abd78a5f01baf060a09c5f1b8e3c
parent 0d7d34367619a971d39cd14b22f52f80af71143b
Author: Michael Forney <mforney@mforney.org>
Date:   Tue,  3 Sep 2019 15:04:02 -0700

util: Add destroy_resource helper

Diffstat:
Mlibswc/data.c | 16++--------------
Mlibswc/dmabuf.c | 10++--------
Mlibswc/keyboard.c | 8+-------
Mlibswc/pointer.c | 8+-------
Mlibswc/region.c | 9++-------
Mlibswc/shm.c | 8+-------
Mlibswc/subcompositor.c | 11+++--------
Mlibswc/subsurface.c | 11+++--------
Mlibswc/surface.c | 8+-------
Mlibswc/util.c | 6++++++
Mlibswc/util.h | 1+
Mlibswc/wayland_buffer.c | 8+-------
Mlibswc/xdg_shell.c | 14++++----------
13 files changed, 28 insertions(+), 90 deletions(-)

diff --git a/libswc/data.c b/libswc/data.c @@ -60,16 +60,10 @@ offer_receive(struct wl_client *client, struct wl_resource *offer, const char *m close(fd); } -static void -offer_destroy(struct wl_client *client, struct wl_resource *offer) -{ - wl_resource_destroy(offer); -} - static const struct wl_data_offer_interface data_offer_impl = { .accept = offer_accept, .receive = offer_receive, - .destroy = offer_destroy, + .destroy = destroy_resource, }; static void @@ -82,15 +76,9 @@ source_offer(struct wl_client *client, struct wl_resource *source, const char *m *destination = strdup(mime_type); } -static void -source_destroy(struct wl_client *client, struct wl_resource *source) -{ - wl_resource_destroy(source); -} - static const struct wl_data_source_interface data_source_impl = { .offer = source_offer, - .destroy = source_destroy, + .destroy = destroy_resource, }; static void diff --git a/libswc/dmabuf.c b/libswc/dmabuf.c @@ -45,12 +45,6 @@ struct params { }; static void -destroy(struct wl_client *client, struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - -static void add(struct wl_client *client, struct wl_resource *resource, int32_t fd, uint32_t i, uint32_t offset, uint32_t stride, uint32_t modifier_hi, uint32_t modifier_lo) { struct params *params = wl_resource_get_user_data(resource); @@ -133,7 +127,7 @@ create(struct wl_client *client, struct wl_resource *resource, } static const struct zwp_linux_buffer_params_v1_interface params_impl = { - .destroy = destroy, + .destroy = destroy_resource, .add = add, .create = create, .create_immed = create_immed, @@ -174,7 +168,7 @@ error0: } static const struct zwp_linux_dmabuf_v1_interface dmabuf_impl = { - .destroy = destroy, + .destroy = destroy_resource, .create_params = create_params, }; diff --git a/libswc/keyboard.c b/libswc/keyboard.c @@ -293,14 +293,8 @@ keyboard_set_focus(struct keyboard *keyboard, struct compositor_view *view) input_focus_set(&keyboard->focus, view); } -static void -release(struct wl_client *client, struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - static const struct wl_keyboard_interface keyboard_impl = { - .release = release, + .release = destroy_resource, }; static void diff --git a/libswc/pointer.c b/libswc/pointer.c @@ -331,15 +331,9 @@ set_cursor(struct wl_client *client, struct wl_resource *resource, } } -static void -release(struct wl_client *client, struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - static const struct wl_pointer_interface pointer_impl = { .set_cursor = set_cursor, - .release = release, + .release = destroy_resource, }; static void diff --git a/libswc/region.c b/libswc/region.c @@ -1,15 +1,10 @@ #include "region.h" +#include "util.h" #include <stdlib.h> #include <wayland-server.h> static void -destroy(struct wl_client *client, struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - -static void add(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) { struct region *region = wl_resource_get_user_data(resource); @@ -27,7 +22,7 @@ subtract(struct wl_client *client, struct wl_resource *resource, int32_t x, int3 } static const struct wl_region_interface region_impl = { - .destroy = destroy, + .destroy = destroy_resource, .add = add, .subtract = subtract, }; diff --git a/libswc/shm.c b/libswc/shm.c @@ -133,12 +133,6 @@ error0: } static void -destroy(struct wl_client *client, struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - -static void resize(struct wl_client *client, struct wl_resource *resource, int32_t size) { struct pool *pool = wl_resource_get_user_data(resource); @@ -155,7 +149,7 @@ resize(struct wl_client *client, struct wl_resource *resource, int32_t size) static const struct wl_shm_pool_interface shm_pool_impl = { .create_buffer = create_buffer, - .destroy = destroy, + .destroy = destroy_resource, .resize = resize, }; diff --git a/libswc/subcompositor.c b/libswc/subcompositor.c @@ -1,6 +1,6 @@ /* swc: libswc/subcompositor.c * - * Copyright (c) 2015 Michael Forney + * Copyright (c) 2015-2019 Michael Forney * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,16 +25,11 @@ #include "internal.h" #include "subcompositor.h" #include "subsurface.h" +#include "util.h" static struct wl_global *global; static void -destroy(struct wl_client *client, struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - -static void get_subsurface(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource, struct wl_resource *parent_resource) { @@ -49,7 +44,7 @@ get_subsurface(struct wl_client *client, struct wl_resource *resource, } static const struct wl_subcompositor_interface subcompositor_impl = { - .destroy = destroy, + .destroy = destroy_resource, .get_subsurface = get_subsurface, }; diff --git a/libswc/subsurface.c b/libswc/subsurface.c @@ -1,6 +1,6 @@ /* swc: libswc/subsurface.c * - * Copyright (c) 2015 Michael Forney + * Copyright (c) 2015-2019 Michael Forney * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,17 +22,12 @@ */ #include "subsurface.h" +#include "util.h" #include <stdlib.h> #include <wayland-server.h> static void -destroy(struct wl_client *client, struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - -static void set_position(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y) { /* TODO: Implement. */ @@ -63,7 +58,7 @@ set_desync(struct wl_client *client, struct wl_resource *resource) } static const struct wl_subsurface_interface subsurface_impl = { - .destroy = destroy, + .destroy = destroy_resource, .set_position = set_position, .place_above = place_above, .place_below = place_below, diff --git a/libswc/surface.c b/libswc/surface.c @@ -144,12 +144,6 @@ static const struct view_handler_impl view_handler_impl = { }; static void -destroy(struct wl_client *client, struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - -static void attach(struct wl_client *client, struct wl_resource *resource, struct wl_resource *buffer_resource, int32_t x, int32_t y) { @@ -280,7 +274,7 @@ set_buffer_scale(struct wl_client *client, struct wl_resource *surface, int32_t } static struct wl_surface_interface surface_impl = { - .destroy = destroy, + .destroy = destroy_resource, .attach = attach, .damage = damage, .frame = frame, diff --git a/libswc/util.c b/libswc/util.c @@ -35,3 +35,9 @@ remove_resource(struct wl_resource *resource) { wl_list_remove(wl_resource_get_link(resource)); } + +void +destroy_resource(struct wl_client *client, struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} diff --git a/libswc/util.h b/libswc/util.h @@ -64,6 +64,7 @@ struct wl_resource; void remove_resource(struct wl_resource *resource); +void destroy_resource(struct wl_client *client, struct wl_resource *resource); static inline uint32_t get_time(void) diff --git a/libswc/wayland_buffer.c b/libswc/wayland_buffer.c @@ -29,14 +29,8 @@ #include <wld/wld.h> #include <wld/pixman.h> -static void -destroy(struct wl_client *client, struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - static const struct wl_buffer_interface buffer_impl = { - .destroy = destroy, + .destroy = destroy_resource, }; struct wld_buffer * diff --git a/libswc/xdg_shell.c b/libswc/xdg_shell.c @@ -51,12 +51,6 @@ struct xdg_toplevel { struct xdg_surface *xdg_surface; }; -static void -destroy(struct wl_client *client, struct wl_resource *resource) -{ - wl_resource_destroy(resource); -} - /* xdg_positioner */ static void destroy_positioner(struct wl_resource *resource) @@ -97,7 +91,7 @@ set_offset(struct wl_client *client, struct wl_resource *resource, int32_t x, in } static const struct xdg_positioner_interface positioner_impl = { - .destroy = destroy, + .destroy = destroy_resource, .set_size = set_size, .set_anchor_rect = set_anchor_rect, .set_anchor = set_anchor, @@ -321,7 +315,7 @@ set_minimized(struct wl_client *client, struct wl_resource *resource) } static const struct xdg_toplevel_interface toplevel_impl = { - .destroy = destroy, + .destroy = destroy_resource, .set_parent = set_parent, .set_title = set_title, .set_app_id = set_app_id, @@ -402,7 +396,7 @@ set_window_geometry(struct wl_client *client, struct wl_resource *resource, int3 } static const struct xdg_surface_interface xdg_surface_impl = { - .destroy = destroy, + .destroy = destroy_resource, .get_toplevel = get_toplevel, .get_popup = get_popup, .ack_configure = ack_configure, @@ -501,7 +495,7 @@ pong(struct wl_client *client, struct wl_resource *resource, uint32_t serial) } static const struct xdg_wm_base_interface wm_base_impl = { - .destroy = destroy, + .destroy = destroy_resource, .create_positioner = create_positioner, .get_xdg_surface = get_xdg_surface, .pong = pong,