mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-16 08:56:26 -05:00
Add wlr_signal_emit_safe
This commit is contained in:
parent
3497e53516
commit
5e58d46cc1
43 changed files with 265 additions and 182 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include <wlr/backend/session.h>
|
||||
#include <wlr/backend/interface.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/signal.h>
|
||||
#include "backend/libinput.h"
|
||||
|
||||
static int wlr_libinput_open_restricted(const char *path,
|
||||
|
|
@ -106,13 +107,13 @@ static void wlr_libinput_backend_destroy(struct wlr_backend *wlr_backend) {
|
|||
struct wl_list *wlr_devices = backend->wlr_device_lists.items[i];
|
||||
struct wlr_input_device *wlr_dev, *next;
|
||||
wl_list_for_each_safe(wlr_dev, next, wlr_devices, link) {
|
||||
wl_signal_emit(&backend->backend.events.input_remove, wlr_dev);
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_remove, wlr_dev);
|
||||
wlr_input_device_destroy(wlr_dev);
|
||||
}
|
||||
free(wlr_devices);
|
||||
}
|
||||
|
||||
wl_signal_emit(&wlr_backend->events.destroy, wlr_backend);
|
||||
wlr_signal_emit_safe(&wlr_backend->events.destroy, wlr_backend);
|
||||
|
||||
wl_list_remove(&backend->display_destroy.link);
|
||||
wl_list_remove(&backend->session_signal.link);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <wlr/interfaces/wlr_input_device.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wayland-util.h>
|
||||
#include <wlr/util/signal.h>
|
||||
#include "backend/libinput.h"
|
||||
|
||||
struct wlr_input_device *get_appropriate_device(
|
||||
|
|
@ -88,7 +89,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
free(wlr_dev);
|
||||
goto fail;
|
||||
}
|
||||
wl_signal_emit(&backend->backend.events.input_add, wlr_dev);
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_dev);
|
||||
}
|
||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_POINTER)) {
|
||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||
|
|
@ -101,7 +102,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
free(wlr_dev);
|
||||
goto fail;
|
||||
}
|
||||
wl_signal_emit(&backend->backend.events.input_add, wlr_dev);
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_dev);
|
||||
}
|
||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TOUCH)) {
|
||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||
|
|
@ -114,7 +115,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
free(wlr_dev);
|
||||
goto fail;
|
||||
}
|
||||
wl_signal_emit(&backend->backend.events.input_add, wlr_dev);
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_dev);
|
||||
}
|
||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TABLET_TOOL)) {
|
||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||
|
|
@ -127,7 +128,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
free(wlr_dev);
|
||||
goto fail;
|
||||
}
|
||||
wl_signal_emit(&backend->backend.events.input_add, wlr_dev);
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_dev);
|
||||
}
|
||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TABLET_PAD)) {
|
||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||
|
|
@ -140,7 +141,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
free(wlr_dev);
|
||||
goto fail;
|
||||
}
|
||||
wl_signal_emit(&backend->backend.events.input_add, wlr_dev);
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_add, wlr_dev);
|
||||
}
|
||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_GESTURE)) {
|
||||
// TODO
|
||||
|
|
@ -178,7 +179,7 @@ static void handle_device_removed(struct wlr_libinput_backend *backend,
|
|||
}
|
||||
struct wlr_input_device *dev, *tmp_dev;
|
||||
wl_list_for_each_safe(dev, tmp_dev, wlr_devices, link) {
|
||||
wl_signal_emit(&backend->backend.events.input_remove, dev);
|
||||
wlr_signal_emit_safe(&backend->backend.events.input_remove, dev);
|
||||
wlr_input_device_destroy(dev);
|
||||
}
|
||||
for (size_t i = 0; i < backend->wlr_device_lists.length; i++) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/interfaces/wlr_pointer.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/signal.h>
|
||||
#include "backend/libinput.h"
|
||||
|
||||
struct wlr_pointer *wlr_libinput_pointer_create(
|
||||
|
|
@ -35,7 +36,7 @@ void handle_pointer_motion(struct libinput_event *event,
|
|||
usec_to_msec(libinput_event_pointer_get_time_usec(pevent));
|
||||
wlr_event.delta_x = libinput_event_pointer_get_dx(pevent);
|
||||
wlr_event.delta_y = libinput_event_pointer_get_dy(pevent);
|
||||
wl_signal_emit(&wlr_dev->pointer->events.motion, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->pointer->events.motion, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_pointer_motion_abs(struct libinput_event *event,
|
||||
|
|
@ -55,7 +56,7 @@ void handle_pointer_motion_abs(struct libinput_event *event,
|
|||
wlr_event.x_mm = libinput_event_pointer_get_absolute_x(pevent);
|
||||
wlr_event.y_mm = libinput_event_pointer_get_absolute_y(pevent);
|
||||
libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
|
||||
wl_signal_emit(&wlr_dev->pointer->events.motion_absolute, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->pointer->events.motion_absolute, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_pointer_button(struct libinput_event *event,
|
||||
|
|
@ -81,7 +82,7 @@ void handle_pointer_button(struct libinput_event *event,
|
|||
wlr_event.state = WLR_BUTTON_RELEASED;
|
||||
break;
|
||||
}
|
||||
wl_signal_emit(&wlr_dev->pointer->events.button, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->pointer->events.button, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_pointer_axis(struct libinput_event *event,
|
||||
|
|
@ -128,7 +129,7 @@ void handle_pointer_axis(struct libinput_event *event,
|
|||
}
|
||||
wlr_event.delta = libinput_event_pointer_get_axis_value(
|
||||
pevent, axies[i]);
|
||||
wl_signal_emit(&wlr_dev->pointer->events.axis, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->pointer->events.axis, &wlr_event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/interfaces/wlr_tablet_pad.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/signal.h>
|
||||
#include "backend/libinput.h"
|
||||
|
||||
struct wlr_tablet_pad *wlr_libinput_tablet_pad_create(
|
||||
|
|
@ -41,7 +42,7 @@ void handle_tablet_pad_button(struct libinput_event *event,
|
|||
wlr_event.state = WLR_BUTTON_RELEASED;
|
||||
break;
|
||||
}
|
||||
wl_signal_emit(&wlr_dev->tablet_pad->events.button, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->tablet_pad->events.button, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_tablet_pad_ring(struct libinput_event *event,
|
||||
|
|
@ -67,7 +68,7 @@ void handle_tablet_pad_ring(struct libinput_event *event,
|
|||
wlr_event.source = WLR_TABLET_PAD_RING_SOURCE_FINGER;
|
||||
break;
|
||||
}
|
||||
wl_signal_emit(&wlr_dev->tablet_pad->events.ring, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->tablet_pad->events.ring, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_tablet_pad_strip(struct libinput_event *event,
|
||||
|
|
@ -93,5 +94,5 @@ void handle_tablet_pad_strip(struct libinput_event *event,
|
|||
wlr_event.source = WLR_TABLET_PAD_STRIP_SOURCE_FINGER;
|
||||
break;
|
||||
}
|
||||
wl_signal_emit(&wlr_dev->tablet_pad->events.strip, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->tablet_pad->events.strip, &wlr_event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/interfaces/wlr_tablet_tool.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/signal.h>
|
||||
#include "backend/libinput.h"
|
||||
|
||||
struct wlr_tablet_tool *wlr_libinput_tablet_tool_create(
|
||||
|
|
@ -72,7 +73,7 @@ void handle_tablet_tool_axis(struct libinput_event *event,
|
|||
}
|
||||
wlr_log(L_DEBUG, "Tablet tool axis event %d @ %f,%f",
|
||||
wlr_event.updated_axes, wlr_event.x_mm, wlr_event.y_mm);
|
||||
wl_signal_emit(&wlr_dev->tablet_tool->events.axis, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.axis, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_tablet_tool_proximity(struct libinput_event *event,
|
||||
|
|
@ -98,7 +99,7 @@ void handle_tablet_tool_proximity(struct libinput_event *event,
|
|||
handle_tablet_tool_axis(event, libinput_dev);
|
||||
break;
|
||||
}
|
||||
wl_signal_emit(&wlr_dev->tablet_tool->events.proximity, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.proximity, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_tablet_tool_tip(struct libinput_event *event,
|
||||
|
|
@ -124,7 +125,7 @@ void handle_tablet_tool_tip(struct libinput_event *event,
|
|||
wlr_event.state = WLR_TABLET_TOOL_TIP_DOWN;
|
||||
break;
|
||||
}
|
||||
wl_signal_emit(&wlr_dev->tablet_tool->events.tip, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.tip, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_tablet_tool_button(struct libinput_event *event,
|
||||
|
|
@ -151,5 +152,5 @@ void handle_tablet_tool_button(struct libinput_event *event,
|
|||
wlr_event.state = WLR_BUTTON_PRESSED;
|
||||
break;
|
||||
}
|
||||
wl_signal_emit(&wlr_dev->tablet_tool->events.button, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.button, &wlr_event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/interfaces/wlr_touch.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/signal.h>
|
||||
#include "backend/libinput.h"
|
||||
|
||||
struct wlr_touch *wlr_libinput_touch_create(
|
||||
|
|
@ -37,7 +38,7 @@ void handle_touch_down(struct libinput_event *event,
|
|||
wlr_event.x_mm = libinput_event_touch_get_x(tevent);
|
||||
wlr_event.y_mm = libinput_event_touch_get_y(tevent);
|
||||
libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
|
||||
wl_signal_emit(&wlr_dev->touch->events.down, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->touch->events.down, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_touch_up(struct libinput_event *event,
|
||||
|
|
@ -55,7 +56,7 @@ void handle_touch_up(struct libinput_event *event,
|
|||
wlr_event.time_msec =
|
||||
usec_to_msec(libinput_event_touch_get_time_usec(tevent));
|
||||
wlr_event.touch_id = libinput_event_touch_get_slot(tevent);
|
||||
wl_signal_emit(&wlr_dev->touch->events.up, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->touch->events.up, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_touch_motion(struct libinput_event *event,
|
||||
|
|
@ -76,7 +77,7 @@ void handle_touch_motion(struct libinput_event *event,
|
|||
wlr_event.x_mm = libinput_event_touch_get_x(tevent);
|
||||
wlr_event.y_mm = libinput_event_touch_get_y(tevent);
|
||||
libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
|
||||
wl_signal_emit(&wlr_dev->touch->events.motion, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->touch->events.motion, &wlr_event);
|
||||
}
|
||||
|
||||
void handle_touch_cancel(struct libinput_event *event,
|
||||
|
|
@ -94,5 +95,5 @@ void handle_touch_cancel(struct libinput_event *event,
|
|||
wlr_event.time_msec =
|
||||
usec_to_msec(libinput_event_touch_get_time_usec(tevent));
|
||||
wlr_event.touch_id = libinput_event_touch_get_slot(tevent);
|
||||
wl_signal_emit(&wlr_dev->touch->events.cancel, &wlr_event);
|
||||
wlr_signal_emit_safe(&wlr_dev->touch->events.cancel, &wlr_event);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue