From 4cbc8385cedddcbb13d7f8862fd7431d098c0468 Mon Sep 17 00:00:00 2001 From: Kirill Primak Date: Sat, 3 Jun 2023 20:10:22 +0300 Subject: [PATCH] pointer: store the output instead of its name In cases where the value is actually valid, the input device lives just as long as the output, so it's easier to provide the output itself instead for making a compositor find it by the name. --- backend/wayland/pointer.c | 2 +- backend/x11/output.c | 2 +- include/wlr/types/wlr_pointer.h | 2 +- types/wlr_pointer.c | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/wayland/pointer.c b/backend/wayland/pointer.c index 4ce233e52..5762d1ec3 100644 --- a/backend/wayland/pointer.c +++ b/backend/wayland/pointer.c @@ -454,7 +454,7 @@ void create_pointer(struct wlr_wl_seat *seat, struct wlr_wl_output *output) { snprintf(name, sizeof(name), "wayland-pointer-%s", seat->name); wlr_pointer_init(&pointer->wlr_pointer, &wl_pointer_impl, name); - pointer->wlr_pointer.output_name = strdup(output->wlr_output.name); + pointer->wlr_pointer.output = &output->wlr_output; pointer->seat = seat; pointer->output = output; diff --git a/backend/x11/output.c b/backend/x11/output.c index 517ea85be..9fe94abdd 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -598,7 +598,7 @@ struct wlr_output *wlr_x11_output_create(struct wlr_backend *backend) { wlr_output_update_enabled(wlr_output, true); wlr_pointer_init(&output->pointer, &x11_pointer_impl, "x11-pointer"); - output->pointer.output_name = strdup(wlr_output->name); + output->pointer.output = wlr_output; wlr_touch_init(&output->touch, &x11_touch_impl, "x11-touch"); output->touch.output_name = strdup(wlr_output->name); diff --git a/include/wlr/types/wlr_pointer.h b/include/wlr/types/wlr_pointer.h index 16aed1dc7..144f49220 100644 --- a/include/wlr/types/wlr_pointer.h +++ b/include/wlr/types/wlr_pointer.h @@ -21,7 +21,7 @@ struct wlr_pointer { const struct wlr_pointer_impl *impl; - char *output_name; + struct wlr_output *output; struct { struct wl_signal motion; // struct wlr_pointer_motion_event diff --git a/types/wlr_pointer.c b/types/wlr_pointer.c index be505b6c4..50bb47fec 100644 --- a/types/wlr_pointer.c +++ b/types/wlr_pointer.c @@ -36,6 +36,4 @@ void wlr_pointer_init(struct wlr_pointer *pointer, void wlr_pointer_finish(struct wlr_pointer *pointer) { wlr_input_device_finish(&pointer->base); - - free(pointer->output_name); }