diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-02-13 08:30:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-13 08:30:54 -0500 |
commit | 71cba94e73022d8cef8651055204a4706377ae11 (patch) | |
tree | 8ea1a2b6a0414fd7904824ffac330cd4e1e96ca2 /backend | |
parent | 3497e53516d96ad67b26115e2e06218f68e1114d (diff) | |
parent | c2e147401048aa53aebd52f1851b1da8c91043a3 (diff) |
Merge pull request #627 from emersion/wlr-signal-emit-safe
Remove wlr_backend.events.{output_remove,device_remove}
Diffstat (limited to 'backend')
30 files changed, 225 insertions, 238 deletions
diff --git a/backend/backend.c b/backend/backend.c index 98b94c5c..c67be617 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -1,17 +1,17 @@ -#include <wayland-server.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> #include <assert.h> +#include <errno.h> #include <libinput.h> -#include <wlr/backend/session.h> -#include <wlr/backend/interface.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <wayland-server.h> #include <wlr/backend/drm.h> +#include <wlr/backend/interface.h> #include <wlr/backend/libinput.h> +#include <wlr/backend/multi.h> +#include <wlr/backend/session.h> #include <wlr/backend/wayland.h> #include <wlr/backend/x11.h> -#include <wlr/backend/multi.h> #include <wlr/util/log.h> void wlr_backend_init(struct wlr_backend *backend, @@ -19,10 +19,8 @@ void wlr_backend_init(struct wlr_backend *backend, assert(backend); backend->impl = impl; wl_signal_init(&backend->events.destroy); - wl_signal_init(&backend->events.input_add); - wl_signal_init(&backend->events.input_remove); - wl_signal_init(&backend->events.output_add); - wl_signal_init(&backend->events.output_remove); + wl_signal_init(&backend->events.new_input); + wl_signal_init(&backend->events.new_output); } bool wlr_backend_start(struct wlr_backend *backend) { diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index 526b2731..29b5ccb1 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -1,8 +1,8 @@ -#include <stdlib.h> #include <gbm.h> +#include <stdlib.h> +#include <wlr/util/log.h> #include <xf86drm.h> #include <xf86drmMode.h> -#include <wlr/util/log.h> #include "backend/drm/drm.h" #include "backend/drm/iface.h" #include "backend/drm/util.h" diff --git a/backend/drm/backend.c b/backend/drm/backend.c index 3782817c..47dff227 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -1,18 +1,19 @@ -#include <unistd.h> -#include <stdlib.h> +#include <assert.h> +#include <errno.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> -#include <errno.h> -#include <assert.h> +#include <unistd.h> #include <wayland-server.h> -#include <xf86drm.h> -#include <wlr/backend/session.h> #include <wlr/backend/interface.h> +#include <wlr/backend/session.h> #include <wlr/interfaces/wlr_output.h> +#include <wlr/render/egl.h> #include <wlr/types/wlr_list.h> #include <wlr/util/log.h> -#include <wlr/render/egl.h> +#include <xf86drm.h> #include "backend/drm/drm.h" +#include "util/signal.h" static bool wlr_drm_backend_start(struct wlr_backend *backend) { struct wlr_drm_backend *drm = (struct wlr_drm_backend *)backend; @@ -34,7 +35,7 @@ static void wlr_drm_backend_destroy(struct wlr_backend *backend) { wlr_output_destroy(&conn->output); } - wl_signal_emit(&backend->events.destroy, backend); + wlr_signal_emit_safe(&backend->events.destroy, backend); wl_list_remove(&drm->display_destroy.link); wl_list_remove(&drm->session_signal.link); diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 56a78851..e60b7e1c 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -1,29 +1,30 @@ #include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <inttypes.h> -#include <errno.h> -#include <time.h> -#include <xf86drm.h> -#include <xf86drmMode.h> #include <drm_mode.h> #include <EGL/egl.h> #include <EGL/eglext.h> +#include <errno.h> #include <gbm.h> #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> +#include <inttypes.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> #include <wayland-server.h> #include <wayland-util.h> #include <wlr/backend/interface.h> #include <wlr/interfaces/wlr_output.h> -#include <wlr/util/log.h> -#include <wlr/render/matrix.h> -#include <wlr/render/gles2.h> #include <wlr/render.h> +#include <wlr/render/gles2.h> +#include <wlr/render/matrix.h> +#include <wlr/util/log.h> +#include <xf86drm.h> +#include <xf86drmMode.h> #include "backend/drm/drm.h" #include "backend/drm/iface.h" #include "backend/drm/util.h" +#include "util/signal.h" bool wlr_drm_check_features(struct wlr_drm_backend *drm) { if (drmSetClientCap(drm->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1)) { @@ -870,7 +871,8 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) { wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET; wlr_log(L_INFO, "Sending modesetting signal for '%s'", wlr_conn->output.name); - wl_signal_emit(&drm->backend.events.output_add, &wlr_conn->output); + wlr_signal_emit_safe(&drm->backend.events.new_output, + &wlr_conn->output); } else if (wlr_conn->state == WLR_DRM_CONN_CONNECTED && drm_conn->connection != DRM_MODE_CONNECTED) { wlr_log(L_INFO, "'%s' disconnected", wlr_conn->output.name); @@ -978,8 +980,6 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) { return; } - struct wlr_drm_backend *drm = (struct wlr_drm_backend *)conn->output.backend; - switch (conn->state) { case WLR_DRM_CONN_CONNECTED: case WLR_DRM_CONN_CLEANUP:; @@ -1013,8 +1013,8 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) { /* Fallthrough */ case WLR_DRM_CONN_NEEDS_MODESET: wlr_log(L_INFO, "Emitting destruction signal for '%s'", - conn->output.name); - wl_signal_emit(&drm->backend.events.output_remove, &conn->output); + conn->output.name); + wlr_signal_emit_safe(&conn->output.events.destroy, &conn->output); break; case WLR_DRM_CONN_DISCONNECTED: break; diff --git a/backend/drm/legacy.c b/backend/drm/legacy.c index eec8c642..88a01b89 100644 --- a/backend/drm/legacy.c +++ b/backend/drm/legacy.c @@ -1,7 +1,7 @@ #include <gbm.h> +#include <wlr/util/log.h> #include <xf86drm.h> #include <xf86drmMode.h> -#include <wlr/util/log.h> #include "backend/drm/drm.h" #include "backend/drm/iface.h" #include "backend/drm/util.h" diff --git a/backend/drm/properties.c b/backend/drm/properties.c index 153e845e..3d35beb5 100644 --- a/backend/drm/properties.c +++ b/backend/drm/properties.c @@ -2,9 +2,9 @@ #include <stddef.h> #include <stdint.h> #include <stdlib.h> +#include <wlr/util/log.h> #include <xf86drm.h> #include <xf86drmMode.h> -#include <wlr/util/log.h> #include "backend/drm/properties.h" /* diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index 80d3bd9a..f3e570f7 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -1,18 +1,16 @@ +#include <EGL/egl.h> +#include <EGL/eglext.h> +#include <gbm.h> +#include <GLES2/gl2.h> #include <stdbool.h> #include <stdlib.h> #include <unistd.h> - -#include <gbm.h> -#include <GLES2/gl2.h> -#include <EGL/egl.h> -#include <EGL/eglext.h> #include <wayland-util.h> - -#include <wlr/util/log.h> +#include <wlr/render.h> #include <wlr/render/egl.h> -#include <wlr/render/matrix.h> #include <wlr/render/gles2.h> -#include <wlr/render.h> +#include <wlr/render/matrix.h> +#include <wlr/util/log.h> #include "backend/drm/drm.h" #include "glapi.h" diff --git a/backend/drm/util.c b/backend/drm/util.c index 37d99aa8..41ba47d1 100644 --- a/backend/drm/util.c +++ b/backend/drm/util.c @@ -1,10 +1,10 @@ -#include <stdio.h> -#include <string.h> -#include <drm.h> #include <drm_mode.h> +#include <drm.h> #include <gbm.h> -#include "backend/drm/util.h" +#include <stdio.h> +#include <string.h> #include <wlr/util/log.h> +#include "backend/drm/util.h" int32_t calculate_refresh_rate(drmModeModeInfo *mode) { int32_t refresh = (mode->clock * 1000000LL / mode->htotal + diff --git a/backend/headless/backend.c b/backend/headless/backend.c index 0bf5ec28..663bc13b 100644 --- a/backend/headless/backend.c +++ b/backend/headless/backend.c @@ -1,9 +1,10 @@ +#include "util/signal.h" #include <stdlib.h> +#include <wlr/interfaces/wlr_input_device.h> +#include <wlr/interfaces/wlr_output.h> #include <wlr/render/egl.h> #include <wlr/render/gles2.h> #include <wlr/util/log.h> -#include <wlr/interfaces/wlr_output.h> -#include <wlr/interfaces/wlr_input_device.h> #include "backend/headless.h" #include "glapi.h" @@ -16,14 +17,14 @@ static bool backend_start(struct wlr_backend *wlr_backend) { wl_list_for_each(output, &backend->outputs, link) { wl_event_source_timer_update(output->frame_timer, output->frame_delay); wlr_output_update_enabled(&output->wlr_output, true); - wl_signal_emit(&backend->backend.events.output_add, + wlr_signal_emit_safe(&backend->backend.events.new_output, &output->wlr_output); } struct wlr_headless_input_device *input_device; wl_list_for_each(input_device, &backend->input_devices, wlr_input_device.link) { - wl_signal_emit(&backend->backend.events.input_add, + wlr_signal_emit_safe(&backend->backend.events.new_input, &input_device->wlr_input_device); } @@ -51,7 +52,7 @@ static void backend_destroy(struct wlr_backend *wlr_backend) { wlr_input_device_destroy(&input_device->wlr_input_device); } - wl_signal_emit(&wlr_backend->events.destroy, backend); + wlr_signal_emit_safe(&wlr_backend->events.destroy, backend); wlr_egl_finish(&backend->egl); free(backend); diff --git a/backend/headless/input_device.c b/backend/headless/input_device.c index 5c62e87f..ea335aff 100644 --- a/backend/headless/input_device.c +++ b/backend/headless/input_device.c @@ -1,17 +1,17 @@ #include <stdlib.h> #include <wlr/interfaces/wlr_input_device.h> -#include <wlr/interfaces/wlr_pointer.h> #include <wlr/interfaces/wlr_keyboard.h> -#include <wlr/interfaces/wlr_touch.h> -#include <wlr/interfaces/wlr_tablet_tool.h> +#include <wlr/interfaces/wlr_pointer.h> #include <wlr/interfaces/wlr_tablet_pad.h> +#include <wlr/interfaces/wlr_tablet_tool.h> +#include <wlr/interfaces/wlr_touch.h> #include <wlr/util/log.h> #include "backend/headless.h" +#include "util/signal.h" static void input_device_destroy(struct wlr_input_device *wlr_dev) { struct wlr_headless_input_device *device = (struct wlr_headless_input_device *)wlr_dev; - wl_signal_emit(&device->backend->backend.events.input_remove, wlr_dev); free(device); } @@ -88,7 +88,7 @@ struct wlr_input_device *wlr_headless_add_input_device( wl_list_insert(&backend->input_devices, &wlr_device->link); if (backend->started) { - wl_signal_emit(&backend->backend.events.input_add, wlr_device); + wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_device); } return wlr_device; diff --git a/backend/headless/output.c b/backend/headless/output.c index 507595a5..ba4a094e 100644 --- a/backend/headless/output.c +++ b/backend/headless/output.c @@ -1,10 +1,11 @@ -#include <stdlib.h> #include <EGL/egl.h> #include <EGL/eglext.h> #include <GLES2/gl2.h> +#include <stdlib.h> #include <wlr/interfaces/wlr_output.h> #include <wlr/util/log.h> #include "backend/headless.h" +#include "util/signal.h" static EGLSurface egl_create_surface(struct wlr_egl *egl, unsigned int width, unsigned int height) { @@ -136,7 +137,7 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend, if (backend->started) { wl_event_source_timer_update(output->frame_timer, output->frame_delay); wlr_output_update_enabled(wlr_output, true); - wl_signal_emit(&backend->backend.events.output_add, wlr_output); + wlr_signal_emit_safe(&backend->backend.events.new_output, wlr_output); } return wlr_output; diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c index 86477947..71fe0d93 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -1,10 +1,11 @@ -#include <stdlib.h> #include <assert.h> #include <libinput.h> -#include <wlr/backend/session.h> +#include <stdlib.h> #include <wlr/backend/interface.h> +#include <wlr/backend/session.h> #include <wlr/util/log.h> #include "backend/libinput.h" +#include "util/signal.h" static int wlr_libinput_open_restricted(const char *path, int flags, void *_backend) { @@ -106,13 +107,12 @@ 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_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); diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 758a9f25..603eed07 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -1,11 +1,12 @@ -#include <stdlib.h> #include <assert.h> #include <libinput.h> +#include <stdlib.h> +#include <wayland-util.h> #include <wlr/backend/session.h> #include <wlr/interfaces/wlr_input_device.h> #include <wlr/util/log.h> -#include <wayland-util.h> #include "backend/libinput.h" +#include "util/signal.h" struct wlr_input_device *get_appropriate_device( enum wlr_input_device_type desired_type, @@ -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.new_input, 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.new_input, 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.new_input, 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.new_input, 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.new_input, wlr_dev); } if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_GESTURE)) { // TODO @@ -178,7 +179,6 @@ 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_input_device_destroy(dev); } for (size_t i = 0; i < backend->wlr_device_lists.length; i++) { diff --git a/backend/libinput/keyboard.c b/backend/libinput/keyboard.c index 065d8ead..b44bc892 100644 --- a/backend/libinput/keyboard.c +++ b/backend/libinput/keyboard.c @@ -1,9 +1,9 @@ -#include <stdlib.h> #include <assert.h> #include <libinput.h> +#include <stdlib.h> #include <wlr/backend/session.h> -#include <wlr/types/wlr_input_device.h> #include <wlr/interfaces/wlr_keyboard.h> +#include <wlr/types/wlr_input_device.h> #include <wlr/util/log.h> #include "backend/libinput.h" @@ -57,7 +57,7 @@ void handle_keyboard_key(struct libinput_event *event, wlr_event.time_msec = usec_to_msec(libinput_event_keyboard_get_time_usec(kbevent)); wlr_event.keycode = libinput_event_keyboard_get_key(kbevent); - enum libinput_key_state state = + enum libinput_key_state state = libinput_event_keyboard_get_key_state(kbevent); switch (state) { case LIBINPUT_KEY_STATE_RELEASED: diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c index 13402ac2..8a31d312 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -1,11 +1,12 @@ -#include <stdlib.h> #include <assert.h> #include <libinput.h> +#include <stdlib.h> #include <wlr/backend/session.h> -#include <wlr/types/wlr_input_device.h> #include <wlr/interfaces/wlr_pointer.h> +#include <wlr/types/wlr_input_device.h> #include <wlr/util/log.h> #include "backend/libinput.h" +#include "util/signal.h" struct wlr_pointer *wlr_libinput_pointer_create( struct libinput_device *libinput_dev) { @@ -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); } } } diff --git a/backend/libinput/tablet_pad.c b/backend/libinput/tablet_pad.c index 7dac3b7c..70e4c677 100644 --- a/backend/libinput/tablet_pad.c +++ b/backend/libinput/tablet_pad.c @@ -1,11 +1,12 @@ -#include <stdlib.h> #include <assert.h> #include <libinput.h> +#include <stdlib.h> #include <wlr/backend/session.h> -#include <wlr/types/wlr_input_device.h> #include <wlr/interfaces/wlr_tablet_pad.h> +#include <wlr/types/wlr_input_device.h> #include <wlr/util/log.h> #include "backend/libinput.h" +#include "util/signal.h" struct wlr_tablet_pad *wlr_libinput_tablet_pad_create( struct libinput_device *libinput_dev) { @@ -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); } diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index 3d5fafc3..4e60367f 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -1,11 +1,12 @@ -#include <stdlib.h> #include <assert.h> #include <libinput.h> +#include <stdlib.h> #include <wlr/backend/session.h> -#include <wlr/types/wlr_input_device.h> #include <wlr/interfaces/wlr_tablet_tool.h> +#include <wlr/types/wlr_input_device.h> #include <wlr/util/log.h> #include "backend/libinput.h" +#include "util/signal.h" struct wlr_tablet_tool *wlr_libinput_tablet_tool_create( struct libinput_device *libinput_dev) { @@ -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); } diff --git a/backend/libinput/touch.c b/backend/libinput/touch.c index 0ba6ec86..2b87f9cd 100644 --- a/backend/libinput/touch.c +++ b/backend/libinput/touch.c @@ -1,11 +1,12 @@ -#include <stdlib.h> #include <assert.h> #include <libinput.h> +#include <stdlib.h> #include <wlr/backend/session.h> -#include <wlr/types/wlr_input_device.h> #include <wlr/interfaces/wlr_touch.h> +#include <wlr/types/wlr_input_device.h> #include <wlr/util/log.h> #include "backend/libinput.h" +#include "util/signal.h" struct wlr_touch *wlr_libinput_touch_create( struct libinput_device *libinput_dev) { @@ -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); } diff --git a/backend/meson.build b/backend/meson.build index beb3841c..bac43063 100644 --- a/backend/meson.build +++ b/backend/meson.build @@ -1,7 +1,5 @@ backend_files = files( 'backend.c', - 'session/direct-ipc.c', - 'session/session.c', 'drm/atomic.c', 'drm/backend.c', 'drm/drm.c', @@ -10,8 +8,8 @@ backend_files = files( 'drm/renderer.c', 'drm/util.c', 'headless/backend.c', - 'headless/output.c', 'headless/input_device.c', + 'headless/output.c', 'libinput/backend.c', 'libinput/events.c', 'libinput/keyboard.c', @@ -20,6 +18,8 @@ backend_files = files( 'libinput/tablet_tool.c', 'libinput/touch.c', 'multi/backend.c', + 'session/direct-ipc.c', + 'session/session.c', 'wayland/backend.c', 'wayland/output.c', 'wayland/registry.c', diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 78f5c63b..5cb3fbc5 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -4,17 +4,16 @@ #include <wlr/backend/interface.h> #include <wlr/backend/session.h> #include <wlr/util/log.h> -#include "backend/multi.h" #include "backend/drm/drm.h" +#include "backend/multi.h" +#include "util/signal.h" struct subbackend_state { struct wlr_backend *backend; struct wlr_backend *container; - struct wl_listener input_add; - struct wl_listener input_remove; - struct wl_listener output_add; - struct wl_listener output_remove; - struct wl_listener backend_destroy; + struct wl_listener new_input; + struct wl_listener new_output; + struct wl_listener destroy; struct wl_list link; }; @@ -31,11 +30,9 @@ static bool multi_backend_start(struct wlr_backend *wlr_backend) { } static void subbackend_state_destroy(struct subbackend_state *sub) { - wl_list_remove(&sub->input_add.link); - wl_list_remove(&sub->input_remove.link); - wl_list_remove(&sub->output_add.link); - wl_list_remove(&sub->output_remove.link); - wl_list_remove(&sub->backend_destroy.link); + wl_list_remove(&sub->new_input.link); + wl_list_remove(&sub->new_output.link); + wl_list_remove(&sub->destroy.link); wl_list_remove(&sub->link); free(sub); } @@ -51,7 +48,7 @@ static void multi_backend_destroy(struct wlr_backend *wlr_backend) { } // Destroy this backend only after removing all sub-backends - wl_signal_emit(&wlr_backend->events.destroy, backend); + wlr_signal_emit_safe(&wlr_backend->events.destroy, backend); free(backend); } @@ -117,34 +114,21 @@ bool wlr_backend_is_multi(struct wlr_backend *b) { return b->impl == &backend_impl; } -static void input_add_reemit(struct wl_listener *listener, void *data) { - struct subbackend_state *state = wl_container_of(listener, - state, input_add); - wl_signal_emit(&state->container->events.input_add, data); -} - -static void input_remove_reemit(struct wl_listener *listener, void *data) { +static void new_input_reemit(struct wl_listener *listener, void *data) { struct subbackend_state *state = wl_container_of(listener, - state, input_remove); - wl_signal_emit(&state->container->events.input_remove, data); + state, new_input); + wlr_signal_emit_safe(&state->container->events.new_input, data); } -static void output_add_reemit(struct wl_listener *listener, void *data) { +static void new_output_reemit(struct wl_listener *listener, void *data) { struct subbackend_state *state = wl_container_of(listener, - state, output_add); - wl_signal_emit(&state->container->events.output_add, data); -} - -static void output_remove_reemit(struct wl_listener *listener, void *data) { - struct subbackend_state *state = wl_container_of(listener, - state, output_remove); - wl_signal_emit(&state->container->events.output_remove, data); + state, new_output); + wlr_signal_emit_safe(&state->container->events.new_output, data); } static void handle_subbackend_destroy(struct wl_listener *listener, void *data) { - struct subbackend_state *state = wl_container_of(listener, - state, backend_destroy); + struct subbackend_state *state = wl_container_of(listener, state, destroy); subbackend_state_destroy(state); } @@ -179,22 +163,16 @@ void wlr_multi_backend_add(struct wlr_backend *_multi, sub->backend = backend; sub->container = &multi->backend; - wl_signal_add(&backend->events.destroy, &sub->backend_destroy); - sub->backend_destroy.notify = handle_subbackend_destroy; - - wl_signal_add(&backend->events.input_add, &sub->input_add); - sub->input_add.notify = input_add_reemit; - - wl_signal_add(&backend->events.input_remove, &sub->input_remove); - sub->input_remove.notify = input_remove_reemit; + wl_signal_add(&backend->events.destroy, &sub->destroy); + sub->destroy.notify = handle_subbackend_destroy; - wl_signal_add(&backend->events.output_add, &sub->output_add); - sub->output_add.notify = output_add_reemit; + wl_signal_add(&backend->events.new_input, &sub->new_input); + sub->new_input.notify = new_input_reemit; - wl_signal_add(&backend->events.output_remove, &sub->output_remove); - sub->output_remove.notify = output_remove_reemit; + wl_signal_add(&backend->events.new_output, &sub->new_output); + sub->new_output.notify = new_output_reemit; - wl_signal_emit(&multi->events.backend_add, backend); + wlr_signal_emit_safe(&multi->events.backend_add, backend); } void wlr_multi_backend_remove(struct wlr_backend *_multi, @@ -206,7 +184,7 @@ void wlr_multi_backend_remove(struct wlr_backend *_multi, multi_backend_get_subbackend(multi, backend); if (sub) { - wl_signal_emit(&multi->events.backend_remove, backend); + wlr_signal_emit_safe(&multi->events.backend_remove, backend); subbackend_state_destroy(sub); } } diff --git a/backend/session/direct-freebsd.c b/backend/session/direct-freebsd.c index c0621416..6e23bf1b 100644 --- a/backend/session/direct-freebsd.c +++ b/backend/session/direct-freebsd.c @@ -1,21 +1,22 @@ +#include <dev/evdev/input.h> #include <errno.h> -#include <stdlib.h> -#include <stdio.h> -#include <stdbool.h> -#include <unistd.h> +#include <fcntl.h> #include <signal.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/consio.h> #include <sys/ioctl.h> +#include <sys/kbio.h> #include <sys/stat.h> -#include <termios.h> -#include <fcntl.h> #include <sys/types.h> -#include <dev/evdev/input.h> -#include <sys/kbio.h> -#include <sys/consio.h> +#include <termios.h> +#include <unistd.h> #include <wayland-server.h> #include <wlr/backend/session/interface.h> #include <wlr/util/log.h> #include "backend/session/direct-ipc.h" +#include "util/signal.h" const struct session_impl session_direct; @@ -95,12 +96,12 @@ static int vt_handler(int signo, void *data) { if (session->base.active) { session->base.active = false; - wl_signal_emit(&session->base.session_signal, session); + wlr_signal_emit_safe(&session->base.session_signal, session); ioctl(session->tty_fd, VT_RELDISP, 1); } else { ioctl(session->tty_fd, VT_RELDISP, VT_ACKACQ); session->base.active = true; - wl_signal_emit(&session->base.session_signal, session); + wlr_signal_emit_safe(&session->base.session_signal, session); } return 1; diff --git a/backend/session/direct-ipc.c b/backend/session/direct-ipc.c index e7a169fa..6c69b70a 100644 --- a/backend/session/direct-ipc.c +++ b/backend/session/direct-ipc.c @@ -4,22 +4,22 @@ #define INPUT_MAJOR 0 #endif #include <errno.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <fcntl.h> -#include <unistd.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/wait.h> +#include <unistd.h> +#include <wlr/config.h> +#include <wlr/util/log.h> +#include <xf86drm.h> #ifdef __linux__ #include <sys/sysmacros.h> #include <linux/major.h> #endif -#include <xf86drm.h> -#include <wlr/config.h> -#include <wlr/util/log.h> #include "backend/session/direct-ipc.h" enum { DRM_MAJOR = 226 }; diff --git a/backend/session/direct.c b/backend/session/direct.c index 9d6cd36d..13a26d99 100644 --- a/backend/session/direct.c +++ b/backend/session/direct.c @@ -1,21 +1,22 @@ #define _POSIX_C_SOURCE 200809L #include <errno.h> -#include <stdlib.h> -#include <stdio.h> -#include <stdbool.h> -#include <unistd.h> +#include <linux/input.h> +#include <linux/kd.h> +#include <linux/major.h> +#include <linux/vt.h> #include <signal.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/sysmacros.h> -#include <linux/kd.h> -#include <linux/major.h> -#include <linux/input.h> -#include <linux/vt.h> +#include <unistd.h> #include <wayland-server.h> #include <wlr/backend/session/interface.h> #include <wlr/util/log.h> #include "backend/session/direct-ipc.h" +#include "util/signal.h" enum { DRM_MAJOR = 226 }; @@ -107,7 +108,7 @@ static int vt_handler(int signo, void *data) { if (session->base.active) { session->base.active = false; - wl_signal_emit(&session->base.session_signal, session); + wlr_signal_emit_safe(&session->base.session_signal, session); struct wlr_device *dev; wl_list_for_each(dev, &session->base.devices, link) { @@ -130,7 +131,7 @@ static int vt_handler(int signo, void *data) { } session->base.active = true; - wl_signal_emit(&session->base.session_signal, session); + wlr_signal_emit_safe(&session->base.session_signal, session); } return 1; diff --git a/backend/session/logind.c b/backend/session/logind.c index 1ece051f..f0ac1e93 100644 --- a/backend/session/logind.c +++ b/backend/session/logind.c @@ -1,25 +1,26 @@ #define _POSIX_C_SOURCE 200809L #include <assert.h> -#include <stdio.h> +#include <errno.h> +#include <fcntl.h> #include <stdbool.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <errno.h> -#include <unistd.h> -#include <sys/sysmacros.h> #include <sys/stat.h> -#include <fcntl.h> +#include <sys/sysmacros.h> +#include <unistd.h> #include <wayland-server.h> -#include <wlr/config.h> #include <wlr/backend/session/interface.h> +#include <wlr/config.h> #include <wlr/util/log.h> +#include "util/signal.h" #ifdef WLR_HAS_SYSTEMD #include <systemd/sd-bus.h> #include <systemd/sd-login.h> #elif defined(WLR_HAS_ELOGIND) #include <elogind/sd-bus.h> - #include <elogind/sd-login.h> + #include <elogind/sd-login.h> #endif enum { DRM_MAJOR = 226 }; @@ -250,7 +251,7 @@ static int pause_device(sd_bus_message *msg, void *userdata, sd_bus_error *ret_e if (major == DRM_MAJOR) { session->base.active = false; - wl_signal_emit(&session->base.session_signal, session); + wlr_signal_emit_safe(&session->base.session_signal, session); } if (strcmp(type, "pause") == 0) { @@ -286,7 +287,7 @@ static int resume_device(sd_bus_message *msg, void *userdata, sd_bus_error *ret_ if (!session->base.active) { session->base.active = true; - wl_signal_emit(&session->base.session_signal, session); + wlr_signal_emit_safe(&session->base.session_signal, session); } } diff --git a/backend/session/session.c b/backend/session/session.c index 2bbbd4ef..2d5d9776 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -1,18 +1,19 @@ #define _POSIX_C_SOURCE 200809L #include <assert.h> +#include <libudev.h> #include <stddef.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> -#include <libudev.h> #include <wayland-server.h> -#include <xf86drm.h> -#include <xf86drmMode.h> -#include <wlr/config.h> #include <wlr/backend/session.h> #include <wlr/backend/session/interface.h> +#include <wlr/config.h> #include <wlr/util/log.h> +#include <xf86drm.h> +#include <xf86drmMode.h> +#include "util/signal.h" extern const struct session_impl session_logind; extern const struct session_impl session_direct; @@ -49,7 +50,7 @@ static int udev_event(int fd, uint32_t mask, void *data) { wl_list_for_each(dev, &session->devices, link) { if (dev->dev == devnum) { - wl_signal_emit(&dev->signal, session); + wlr_signal_emit_safe(&dev->signal, session); break; } } diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index 458c9dd0..abb25df5 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -1,17 +1,18 @@ -#include <stdlib.h> -#include <stdint.h> #include <assert.h> -#include <limits.h> #include <EGL/egl.h> #include <EGL/eglext.h> +#include <limits.h> +#include <stdint.h> +#include <stdlib.h> #include <wayland-server.h> -#include <wlr/render/egl.h> -#include <wlr/render/gles2.h> #include <wlr/backend/interface.h> -#include <wlr/interfaces/wlr_output.h> #include <wlr/interfaces/wlr_input_device.h> +#include <wlr/interfaces/wlr_output.h> +#include <wlr/render/egl.h> +#include <wlr/render/gles2.h> #include <wlr/util/log.h> #include "backend/wayland.h" +#include "util/signal.h" #include "xdg-shell-unstable-v6-client-protocol.h" static int dispatch_events(int fd, uint32_t mask, void *data) { @@ -80,7 +81,7 @@ static void wlr_wl_backend_destroy(struct wlr_backend *wlr_backend) { wlr_input_device_destroy(input_device); } - wl_signal_emit(&wlr_backend->events.destroy, wlr_backend); + wlr_signal_emit_safe(&wlr_backend->events.destroy, wlr_backend); wl_list_remove(&backend->local_display_destroy.link); diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 0bbf6d42..fc40dea0 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -1,16 +1,17 @@ -#include <stdio.h> #include <assert.h> +#include <GLES2/gl2.h> #include <stdint.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <unistd.h> -#include <sys/types.h> #include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> #include <wayland-client.h> -#include <GLES2/gl2.h> #include <wlr/interfaces/wlr_output.h> #include <wlr/util/log.h> #include "backend/wayland.h" +#include "util/signal.h" #include "xdg-shell-unstable-v6-client-protocol.h" int os_create_anonymous_file(off_t size); @@ -338,7 +339,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) { wl_list_insert(&backend->outputs, &output->link); wlr_output_update_enabled(wlr_output, true); - wl_signal_emit(&backend->backend.events.output_add, wlr_output); + wlr_signal_emit_safe(&backend->backend.events.new_output, wlr_output); return wlr_output; error: diff --git a/backend/wayland/registry.c b/backend/wayland/registry.c index 0dec0ec5..4aa39f09 100644 --- a/backend/wayland/registry.c +++ b/backend/wayland/registry.c @@ -6,7 +6,6 @@ #include "backend/wayland.h" #include "xdg-shell-unstable-v6-client-protocol.h" - static void xdg_shell_handle_ping(void *data, struct zxdg_shell_v6 *shell, uint32_t serial) { zxdg_shell_v6_pong(shell, serial); diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index 37489678..b1f7cff6 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -1,16 +1,17 @@ #define _XOPEN_SOURCE 500 #include <assert.h> -#include <stdlib.h> #include <stdint.h> +#include <stdlib.h> #include <string.h> #include <wayland-client.h> -#include <wlr/interfaces/wlr_output.h> #include <wlr/interfaces/wlr_input_device.h> -#include <wlr/interfaces/wlr_pointer.h> #include <wlr/interfaces/wlr_keyboard.h> +#include <wlr/interfaces/wlr_output.h> +#include <wlr/interfaces/wlr_pointer.h> #include <wlr/interfaces/wlr_touch.h> #include <wlr/util/log.h> #include "backend/wayland.h" +#include "util/signal.h" static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, @@ -78,7 +79,7 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer, wlr_event.height_mm = layout_box.height; wlr_event.x_mm = transformed.x + wlr_output->lx - layout_box.x; wlr_event.y_mm = transformed.y + wlr_output->ly - layout_box.y; - wl_signal_emit(&dev->pointer->events.motion_absolute, &wlr_event); + wlr_signal_emit_safe(&dev->pointer->events.motion_absolute, &wlr_event); } static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer, @@ -91,7 +92,7 @@ static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer, wlr_event.button = button; wlr_event.state = state; wlr_event.time_msec = time; - wl_signal_emit(&dev->pointer->events.button, &wlr_event); + wlr_signal_emit_safe(&dev->pointer->events.button, &wlr_event); } static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer, @@ -106,7 +107,7 @@ static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer, wlr_event.orientation = axis; wlr_event.time_msec = time; wlr_event.source = wlr_wl_pointer->axis_source; - wl_signal_emit(&dev->pointer->events.axis, &wlr_event); + wlr_signal_emit_safe(&dev->pointer->events.axis, &wlr_event); } static void pointer_handle_frame(void *data, struct wl_pointer *wl_pointer) { @@ -192,9 +193,8 @@ static struct wl_keyboard_listener keyboard_listener = { .repeat_info = keyboard_handle_repeat_info }; -static void input_device_destroy(struct wlr_input_device *_dev) { - struct wlr_wl_input_device *dev = (struct wlr_wl_input_device *)_dev; - wl_signal_emit(&dev->backend->backend.events.input_remove, &dev->wlr_input_device); +static void input_device_destroy(struct wlr_input_device *wlr_dev) { + struct wlr_wl_input_device *dev = (struct wlr_wl_input_device *)wlr_dev; if (dev->resource) { wl_proxy_destroy(dev->resource); } @@ -256,7 +256,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat, wlr_device->pointer = &wlr_wl_pointer->wlr_pointer; wlr_pointer_init(wlr_device->pointer, NULL); wlr_wl_device->resource = wl_pointer; - wl_signal_emit(&backend->backend.events.input_add, wlr_device); + wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_device); backend->pointer = wl_pointer; } if ((caps & WL_SEAT_CAPABILITY_KEYBOARD)) { @@ -280,7 +280,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat, struct wl_keyboard *wl_keyboard = wl_seat_get_keyboard(wl_seat); wl_keyboard_add_listener(wl_keyboard, &keyboard_listener, wlr_device); wlr_wl_device->resource = wl_keyboard; - wl_signal_emit(&backend->backend.events.input_add, wlr_device); + wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_device); } } diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 411d0ef6..28a4fcac 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -1,28 +1,29 @@ #define _POSIX_C_SOURCE 200112L +#include <EGL/egl.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <time.h> -#include <EGL/egl.h> #include <wayland-server.h> -#include <xcb/xcb.h> -#include <xcb/glx.h> -#include <X11/Xlib-xcb.h> -#ifdef __linux__ -#include <linux/input-event-codes.h> -#elif __FreeBSD__ -#include <dev/evdev/input-event-codes.h> -#endif #include <wlr/backend/interface.h> #include <wlr/backend/x11.h> -#include <wlr/render/egl.h> -#include <wlr/render/gles2.h> -#include <wlr/interfaces/wlr_output.h> #include <wlr/interfaces/wlr_input_device.h> #include <wlr/interfaces/wlr_keyboard.h> +#include <wlr/interfaces/wlr_output.h> #include <wlr/interfaces/wlr_pointer.h> +#include <wlr/render/egl.h> +#include <wlr/render/gles2.h> #include <wlr/util/log.h> +#include <X11/Xlib-xcb.h> +#include <xcb/glx.h> +#include <xcb/xcb.h> +#ifdef __linux__ +#include <linux/input-event-codes.h> +#elif __FreeBSD__ +#include <dev/evdev/input-event-codes.h> +#endif #include "backend/x11.h" +#include "util/signal.h" static struct wlr_backend_impl backend_impl; static struct wlr_output_impl output_impl; @@ -77,7 +78,7 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e .orientation = WLR_AXIS_ORIENTATION_VERTICAL, .delta = delta, }; - wl_signal_emit(&x11->pointer.events.axis, &axis); + wlr_signal_emit_safe(&x11->pointer.events.axis, &axis); x11->time = ev->time; break; } @@ -96,7 +97,7 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED, }; - wl_signal_emit(&x11->pointer.events.button, &button); + wlr_signal_emit_safe(&x11->pointer.events.button, &button); } x11->time = ev->time; break; @@ -112,7 +113,7 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e .height_mm = output->wlr_output.height, }; - wl_signal_emit(&x11->pointer.events.motion_absolute, &abs); + wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &abs); x11->time = ev->time; break; } @@ -140,7 +141,7 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e .height_mm = output->wlr_output.height, }; - wl_signal_emit(&x11->pointer.events.motion_absolute, &abs); + wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &abs); break; } case XCB_GLX_DELETE_QUERIES_ARB: { @@ -229,9 +230,9 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) { xcb_flush(x11->xcb_conn); wlr_output_update_enabled(&output->wlr_output, true); - wl_signal_emit(&x11->backend.events.output_add, output); - wl_signal_emit(&x11->backend.events.input_add, &x11->keyboard_dev); - wl_signal_emit(&x11->backend.events.input_add, &x11->pointer_dev); + wlr_signal_emit_safe(&x11->backend.events.new_output, output); + wlr_signal_emit_safe(&x11->backend.events.new_input, &x11->keyboard_dev); + wlr_signal_emit_safe(&x11->backend.events.new_input, &x11->pointer_dev); wl_event_source_timer_update(x11->frame_timer, 16); @@ -248,8 +249,8 @@ static void wlr_x11_backend_destroy(struct wlr_backend *backend) { struct wlr_x11_output *output = &x11->output; wlr_output_destroy(&output->wlr_output); - wl_signal_emit(&backend->events.input_remove, &x11->pointer_dev); - wl_signal_emit(&backend->events.input_remove, &x11->keyboard_dev); + wlr_signal_emit_safe(&x11->pointer_dev.events.destroy, &x11->pointer_dev); + wlr_signal_emit_safe(&x11->keyboard_dev.events.destroy, &x11->keyboard_dev); // TODO probably need to use wlr_keyboard_destroy, but the devices need to // be malloced for that to work if (x11->keyboard_dev.keyboard->keymap) { @@ -259,7 +260,7 @@ static void wlr_x11_backend_destroy(struct wlr_backend *backend) { xkb_state_unref(x11->keyboard_dev.keyboard->xkb_state); } - wl_signal_emit(&backend->events.destroy, backend); + wlr_signal_emit_safe(&backend->events.destroy, backend); wl_list_remove(&x11->display_destroy.link); |