aboutsummaryrefslogtreecommitdiff
path: root/xwayland/selection
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-07-11 17:54:08 +0200
committerSimon Ser <contact@emersion.fr>2023-07-11 20:16:17 +0200
commitfe06e5f49a12174ceeb5e307bf5c3d7f623177d5 (patch)
tree40984fb21cd0cbf6be531206a86167298ab2d537 /xwayland/selection
parentc2c536de034cc27d3a15001cc478f5a327b8f910 (diff)
Use wl_container_of() instead of casts
This slightly improves type safety. The culprits were found with: git grep -E '\([a-z0-9_ ]+ \*\)\W?[a-z]'
Diffstat (limited to 'xwayland/selection')
-rw-r--r--xwayland/selection/incoming.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/xwayland/selection/incoming.c b/xwayland/selection/incoming.c
index 791eb5cf..755ce16c 100644
--- a/xwayland/selection/incoming.c
+++ b/xwayland/selection/incoming.c
@@ -257,7 +257,8 @@ bool data_source_is_xwayland(
static struct x11_data_source *data_source_from_wlr_data_source(
struct wlr_data_source *wlr_source) {
assert(data_source_is_xwayland(wlr_source));
- return (struct x11_data_source *)wlr_source;
+ struct x11_data_source *source = wl_container_of(wlr_source, source, base);
+ return source;
}
static void data_source_send(struct wlr_data_source *wlr_source,
@@ -299,8 +300,7 @@ bool primary_selection_source_is_xwayland(
static void primary_selection_source_send(
struct wlr_primary_selection_source *wlr_source,
const char *mime_type, int fd) {
- struct x11_primary_selection_source *source =
- (struct x11_primary_selection_source *)wlr_source;
+ struct x11_primary_selection_source *source = wl_container_of(wlr_source, source, base);
struct wlr_xwm_selection *selection = source->selection;
source_send(selection, &wlr_source->mime_types, &source->mime_types_atoms,
@@ -309,8 +309,7 @@ static void primary_selection_source_send(
static void primary_selection_source_destroy(
struct wlr_primary_selection_source *wlr_source) {
- struct x11_primary_selection_source *source =
- (struct x11_primary_selection_source *)wlr_source;
+ struct x11_primary_selection_source *source = wl_container_of(wlr_source, source, base);
wl_array_release(&source->mime_types_atoms);
free(source);
}