libweston: add set_output param for weston_touch_create_touch_device

Add the set_output function to weston_touch_device to allow touch binding
interfaces to re-assign the touch-to-output mapping.

Signed-off-by: liang zhou <liang.zhou@gehealthcare.com>
This commit is contained in:
liang zhou 2026-05-15 14:16:33 +08:00 committed by liang zhou
parent 3427788c40
commit 751a5a5f74
6 changed files with 30 additions and 5 deletions

View file

@ -869,6 +869,10 @@ enum weston_touch_mode {
WESTON_TOUCH_MODE_PREP_NORMAL
};
typedef void (*weston_touch_device_set_output_func_t)(
struct weston_touch_device *,
struct weston_output *);
/** Represents a physical touchscreen input device */
struct weston_touch_device {
char *syspath; /**< unique name */
@ -880,6 +884,10 @@ struct weston_touch_device {
void *backend_data; /**< backend-specific private */
const struct weston_touch_device_ops *ops;
/** Set touch to specific output */
weston_touch_device_set_output_func_t set_output;
struct weston_touch_device_matrix saved_calibration;
};

View file

@ -2255,7 +2255,7 @@ create_touch_device(struct wayland_input *input)
wl_proxy_get_id((struct wl_proxy *)input->parent.seat));
touch_device = weston_touch_create_touch_device(input->base.touch_state,
str, NULL, NULL);
str, NULL, NULL, NULL);
return touch_device;
}

View file

@ -129,13 +129,15 @@ remove_input_resource_from_timestamps(struct wl_resource *input_resource,
* \param syspath Unique device name.
* \param backend_data Backend private data if necessary.
* \param ops Calibration operations, or NULL for not able to run calibration.
* \param set_output Set output function.
* \return New touch device, or NULL on failure.
*/
WL_EXPORT struct weston_touch_device *
weston_touch_create_touch_device(struct weston_touch *touch,
const char *syspath,
void *backend_data,
const struct weston_touch_device_ops *ops)
const struct weston_touch_device_ops *ops,
weston_touch_device_set_output_func_t set_output)
{
struct weston_touch_device *device;
@ -161,6 +163,7 @@ weston_touch_create_touch_device(struct weston_touch *touch,
device->backend_data = backend_data;
device->ops = ops;
device->set_output = set_output;
device->aggregate = touch;
wl_list_insert(touch->device_list.prev, &device->link);

View file

@ -409,6 +409,18 @@ touch_set_calibration(struct weston_touch_device *device,
do_set_calibration(evdev_device, cal);
}
static void
touch_set_output(struct weston_touch_device *device,
struct weston_output *output)
{
struct evdev_device *evdev_device = device->backend_data;
if (!evdev_device || !output)
return;
evdev_device_set_output(evdev_device, output);
}
static const struct weston_touch_device_ops touch_calibration_ops = {
.get_output = touch_get_output,
.get_calibration_head_name = touch_get_calibration_head_name,
@ -432,7 +444,8 @@ create_touch_device(struct evdev_device *device)
touch_device = weston_touch_create_touch_device(device->seat->touch_state,
udev_device_get_syspath(udev_device),
device, ops);
device, ops,
touch_set_output);
udev_device_unref(udev_device);

View file

@ -480,7 +480,8 @@ struct weston_touch_device *
weston_touch_create_touch_device(struct weston_touch *touch,
const char *syspath,
void *backend_data,
const struct weston_touch_device_ops *ops);
const struct weston_touch_device_ops *ops,
weston_touch_device_set_output_func_t set_output);
void
weston_touch_device_destroy(struct weston_touch_device *device);

View file

@ -208,7 +208,7 @@ touch_device_add(struct weston_test *test)
snprintf(buf, sizeof buf, "test-touch-device-%d", i);
test->touch_device[i] = weston_touch_create_touch_device(
test->seat.touch_state, buf, NULL, NULL);
test->seat.touch_state, buf, NULL, NULL, NULL);
test->nr_touch_devices++;
}