commit 5c889bf
Michael Forney
·
2019-09-03 22:04:02 +0000 UTC
parent 0d7d343
util: Add destroy_resource helper
13 files changed,
+28,
-90
+2,
-14
1@@ -60,16 +60,10 @@ offer_receive(struct wl_client *client, struct wl_resource *offer, const char *m
2 close(fd);
3 }
4
5-static void
6-offer_destroy(struct wl_client *client, struct wl_resource *offer)
7-{
8- wl_resource_destroy(offer);
9-}
10-
11 static const struct wl_data_offer_interface data_offer_impl = {
12 .accept = offer_accept,
13 .receive = offer_receive,
14- .destroy = offer_destroy,
15+ .destroy = destroy_resource,
16 };
17
18 static void
19@@ -82,15 +76,9 @@ source_offer(struct wl_client *client, struct wl_resource *source, const char *m
20 *destination = strdup(mime_type);
21 }
22
23-static void
24-source_destroy(struct wl_client *client, struct wl_resource *source)
25-{
26- wl_resource_destroy(source);
27-}
28-
29 static const struct wl_data_source_interface data_source_impl = {
30 .offer = source_offer,
31- .destroy = source_destroy,
32+ .destroy = destroy_resource,
33 };
34
35 static void
+2,
-8
1@@ -44,12 +44,6 @@ struct params {
2 bool created;
3 };
4
5-static void
6-destroy(struct wl_client *client, struct wl_resource *resource)
7-{
8- wl_resource_destroy(resource);
9-}
10-
11 static void
12 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)
13 {
14@@ -133,7 +127,7 @@ create(struct wl_client *client, struct wl_resource *resource,
15 }
16
17 static const struct zwp_linux_buffer_params_v1_interface params_impl = {
18- .destroy = destroy,
19+ .destroy = destroy_resource,
20 .add = add,
21 .create = create,
22 .create_immed = create_immed,
23@@ -174,7 +168,7 @@ error0:
24 }
25
26 static const struct zwp_linux_dmabuf_v1_interface dmabuf_impl = {
27- .destroy = destroy,
28+ .destroy = destroy_resource,
29 .create_params = create_params,
30 };
31
+1,
-7
1@@ -293,14 +293,8 @@ keyboard_set_focus(struct keyboard *keyboard, struct compositor_view *view)
2 input_focus_set(&keyboard->focus, view);
3 }
4
5-static void
6-release(struct wl_client *client, struct wl_resource *resource)
7-{
8- wl_resource_destroy(resource);
9-}
10-
11 static const struct wl_keyboard_interface keyboard_impl = {
12- .release = release,
13+ .release = destroy_resource,
14 };
15
16 static void
+1,
-7
1@@ -331,15 +331,9 @@ set_cursor(struct wl_client *client, struct wl_resource *resource,
2 }
3 }
4
5-static void
6-release(struct wl_client *client, struct wl_resource *resource)
7-{
8- wl_resource_destroy(resource);
9-}
10-
11 static const struct wl_pointer_interface pointer_impl = {
12 .set_cursor = set_cursor,
13- .release = release,
14+ .release = destroy_resource,
15 };
16
17 static void
+2,
-7
1@@ -1,14 +1,9 @@
2 #include "region.h"
3+#include "util.h"
4
5 #include <stdlib.h>
6 #include <wayland-server.h>
7
8-static void
9-destroy(struct wl_client *client, struct wl_resource *resource)
10-{
11- wl_resource_destroy(resource);
12-}
13-
14 static void
15 add(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
16 {
17@@ -27,7 +22,7 @@ subtract(struct wl_client *client, struct wl_resource *resource, int32_t x, int3
18 }
19
20 static const struct wl_region_interface region_impl = {
21- .destroy = destroy,
22+ .destroy = destroy_resource,
23 .add = add,
24 .subtract = subtract,
25 };
+1,
-7
1@@ -132,12 +132,6 @@ error0:
2 wl_resource_post_no_memory(resource);
3 }
4
5-static void
6-destroy(struct wl_client *client, struct wl_resource *resource)
7-{
8- wl_resource_destroy(resource);
9-}
10-
11 static void
12 resize(struct wl_client *client, struct wl_resource *resource, int32_t size)
13 {
14@@ -155,7 +149,7 @@ resize(struct wl_client *client, struct wl_resource *resource, int32_t size)
15
16 static const struct wl_shm_pool_interface shm_pool_impl = {
17 .create_buffer = create_buffer,
18- .destroy = destroy,
19+ .destroy = destroy_resource,
20 .resize = resize,
21 };
22
+3,
-8
1@@ -1,6 +1,6 @@
2 /* swc: libswc/subcompositor.c
3 *
4- * Copyright (c) 2015 Michael Forney
5+ * Copyright (c) 2015-2019 Michael Forney
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9@@ -25,15 +25,10 @@
10 #include "internal.h"
11 #include "subcompositor.h"
12 #include "subsurface.h"
13+#include "util.h"
14
15 static struct wl_global *global;
16
17-static void
18-destroy(struct wl_client *client, struct wl_resource *resource)
19-{
20- wl_resource_destroy(resource);
21-}
22-
23 static void
24 get_subsurface(struct wl_client *client, struct wl_resource *resource,
25 uint32_t id, struct wl_resource *surface_resource, struct wl_resource *parent_resource)
26@@ -49,7 +44,7 @@ get_subsurface(struct wl_client *client, struct wl_resource *resource,
27 }
28
29 static const struct wl_subcompositor_interface subcompositor_impl = {
30- .destroy = destroy,
31+ .destroy = destroy_resource,
32 .get_subsurface = get_subsurface,
33 };
34
+3,
-8
1@@ -1,6 +1,6 @@
2 /* swc: libswc/subsurface.c
3 *
4- * Copyright (c) 2015 Michael Forney
5+ * Copyright (c) 2015-2019 Michael Forney
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9@@ -22,16 +22,11 @@
10 */
11
12 #include "subsurface.h"
13+#include "util.h"
14
15 #include <stdlib.h>
16 #include <wayland-server.h>
17
18-static void
19-destroy(struct wl_client *client, struct wl_resource *resource)
20-{
21- wl_resource_destroy(resource);
22-}
23-
24 static void
25 set_position(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y)
26 {
27@@ -63,7 +58,7 @@ set_desync(struct wl_client *client, struct wl_resource *resource)
28 }
29
30 static const struct wl_subsurface_interface subsurface_impl = {
31- .destroy = destroy,
32+ .destroy = destroy_resource,
33 .set_position = set_position,
34 .place_above = place_above,
35 .place_below = place_below,
+1,
-7
1@@ -143,12 +143,6 @@ static const struct view_handler_impl view_handler_impl = {
2 .screens = handle_screens,
3 };
4
5-static void
6-destroy(struct wl_client *client, struct wl_resource *resource)
7-{
8- wl_resource_destroy(resource);
9-}
10-
11 static void
12 attach(struct wl_client *client, struct wl_resource *resource,
13 struct wl_resource *buffer_resource, int32_t x, int32_t y)
14@@ -280,7 +274,7 @@ set_buffer_scale(struct wl_client *client, struct wl_resource *surface, int32_t
15 }
16
17 static struct wl_surface_interface surface_impl = {
18- .destroy = destroy,
19+ .destroy = destroy_resource,
20 .attach = attach,
21 .damage = damage,
22 .frame = frame,
+6,
-0
1@@ -35,3 +35,9 @@ remove_resource(struct wl_resource *resource)
2 {
3 wl_list_remove(wl_resource_get_link(resource));
4 }
5+
6+void
7+destroy_resource(struct wl_client *client, struct wl_resource *resource)
8+{
9+ wl_resource_destroy(resource);
10+}
+1,
-0
1@@ -64,6 +64,7 @@
2 struct wl_resource;
3
4 void remove_resource(struct wl_resource *resource);
5+void destroy_resource(struct wl_client *client, struct wl_resource *resource);
6
7 static inline uint32_t
8 get_time(void)
+1,
-7
1@@ -29,14 +29,8 @@
2 #include <wld/wld.h>
3 #include <wld/pixman.h>
4
5-static void
6-destroy(struct wl_client *client, struct wl_resource *resource)
7-{
8- wl_resource_destroy(resource);
9-}
10-
11 static const struct wl_buffer_interface buffer_impl = {
12- .destroy = destroy,
13+ .destroy = destroy_resource,
14 };
15
16 struct wld_buffer *
+4,
-10
1@@ -51,12 +51,6 @@ struct xdg_toplevel {
2 struct xdg_surface *xdg_surface;
3 };
4
5-static void
6-destroy(struct wl_client *client, struct wl_resource *resource)
7-{
8- wl_resource_destroy(resource);
9-}
10-
11 /* xdg_positioner */
12 static void
13 destroy_positioner(struct wl_resource *resource)
14@@ -97,7 +91,7 @@ set_offset(struct wl_client *client, struct wl_resource *resource, int32_t x, in
15 }
16
17 static const struct xdg_positioner_interface positioner_impl = {
18- .destroy = destroy,
19+ .destroy = destroy_resource,
20 .set_size = set_size,
21 .set_anchor_rect = set_anchor_rect,
22 .set_anchor = set_anchor,
23@@ -321,7 +315,7 @@ set_minimized(struct wl_client *client, struct wl_resource *resource)
24 }
25
26 static const struct xdg_toplevel_interface toplevel_impl = {
27- .destroy = destroy,
28+ .destroy = destroy_resource,
29 .set_parent = set_parent,
30 .set_title = set_title,
31 .set_app_id = set_app_id,
32@@ -402,7 +396,7 @@ set_window_geometry(struct wl_client *client, struct wl_resource *resource, int3
33 }
34
35 static const struct xdg_surface_interface xdg_surface_impl = {
36- .destroy = destroy,
37+ .destroy = destroy_resource,
38 .get_toplevel = get_toplevel,
39 .get_popup = get_popup,
40 .ack_configure = ack_configure,
41@@ -501,7 +495,7 @@ pong(struct wl_client *client, struct wl_resource *resource, uint32_t serial)
42 }
43
44 static const struct xdg_wm_base_interface wm_base_impl = {
45- .destroy = destroy,
46+ .destroy = destroy_resource,
47 .create_positioner = create_positioner,
48 .get_xdg_surface = get_xdg_surface,
49 .pong = pong,