From 5e58d46cc1a90810e3ee76203cee8ca2f14fb462 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 12 Feb 2018 09:12:31 +0100 Subject: [PATCH 1/4] Add wlr_signal_emit_safe --- backend/drm/backend.c | 3 ++- backend/drm/drm.c | 5 ++-- backend/headless/backend.c | 7 +++--- backend/headless/input_device.c | 5 ++-- backend/headless/output.c | 3 ++- backend/libinput/backend.c | 5 ++-- backend/libinput/events.c | 13 +++++----- backend/libinput/pointer.c | 9 +++---- backend/libinput/tablet_pad.c | 7 +++--- backend/libinput/tablet_tool.c | 9 +++---- backend/libinput/touch.c | 9 +++---- backend/multi/backend.c | 15 ++++++------ backend/session/direct-freebsd.c | 5 ++-- backend/session/direct.c | 5 ++-- backend/session/logind.c | 7 +++--- backend/session/session.c | 3 ++- backend/wayland/backend.c | 3 ++- backend/wayland/output.c | 3 ++- backend/wayland/wl_seat.c | 13 +++++----- backend/x11/backend.c | 21 ++++++++-------- include/wlr/util/signal.h | 8 +++++++ render/gles2/texture.c | 3 ++- rootston/desktop.c | 3 ++- types/wlr_compositor.c | 3 ++- types/wlr_cursor.c | 25 +++++++++---------- types/wlr_data_device.c | 13 +++++----- types/wlr_gamma_control.c | 3 ++- types/wlr_idle.c | 3 ++- types/wlr_input_device.c | 3 ++- types/wlr_keyboard.c | 11 +++++---- types/wlr_output.c | 21 ++++++++-------- types/wlr_output_damage.c | 5 ++-- types/wlr_output_layout.c | 19 ++++++++------- types/wlr_primary_selection.c | 7 +++--- types/wlr_seat.c | 21 ++++++++-------- types/wlr_server_decoration.c | 7 +++--- types/wlr_surface.c | 9 +++---- types/wlr_wl_shell.c | 25 +++++++++---------- types/wlr_xdg_shell_v6.c | 25 +++++++++---------- util/meson.build | 1 + util/signal.c | 34 ++++++++++++++++++++++++++ xwayland/xwayland.c | 7 +++--- xwayland/xwm.c | 41 ++++++++++++++++---------------- 43 files changed, 265 insertions(+), 182 deletions(-) create mode 100644 include/wlr/util/signal.h create mode 100644 util/signal.c diff --git a/backend/drm/backend.c b/backend/drm/backend.c index 3782817c..4d09e078 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "backend/drm/drm.h" @@ -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..516eb405 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -870,7 +871,7 @@ 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.output_add, &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); @@ -1014,7 +1015,7 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) { 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); + wlr_signal_emit_safe(&drm->backend.events.output_remove, &conn->output); break; case WLR_DRM_CONN_DISCONNECTED: break; diff --git a/backend/headless/backend.c b/backend/headless/backend.c index 0bf5ec28..7832b00c 100644 --- a/backend/headless/backend.c +++ b/backend/headless/backend.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include "backend/headless.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.output_add, &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.input_add, &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..68e7ce24 100644 --- a/backend/headless/input_device.c +++ b/backend/headless/input_device.c @@ -6,12 +6,13 @@ #include #include #include +#include #include "backend/headless.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); + wlr_signal_emit_safe(&device->backend->backend.events.input_remove, wlr_dev); free(device); } @@ -88,7 +89,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.input_add, wlr_device); } return wlr_device; diff --git a/backend/headless/output.c b/backend/headless/output.c index 507595a5..eab983cc 100644 --- a/backend/headless/output.c +++ b/backend/headless/output.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "backend/headless.h" static EGLSurface egl_create_surface(struct wlr_egl *egl, unsigned int width, @@ -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.output_add, wlr_output); } return wlr_output; diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c index 86477947..dfbe1d20 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -4,6 +4,7 @@ #include #include #include +#include #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); diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 758a9f25..60088a40 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -5,6 +5,7 @@ #include #include #include +#include #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++) { diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c index 13402ac2..f80f4f84 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -5,6 +5,7 @@ #include #include #include +#include #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); } } } diff --git a/backend/libinput/tablet_pad.c b/backend/libinput/tablet_pad.c index 7dac3b7c..54315581 100644 --- a/backend/libinput/tablet_pad.c +++ b/backend/libinput/tablet_pad.c @@ -5,6 +5,7 @@ #include #include #include +#include #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); } diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index 3d5fafc3..2f28540b 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -5,6 +5,7 @@ #include #include #include +#include #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); } diff --git a/backend/libinput/touch.c b/backend/libinput/touch.c index 0ba6ec86..d496d792 100644 --- a/backend/libinput/touch.c +++ b/backend/libinput/touch.c @@ -5,6 +5,7 @@ #include #include #include +#include #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); } diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 78f5c63b..14f774d0 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "backend/multi.h" #include "backend/drm/drm.h" @@ -51,7 +52,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); } @@ -120,25 +121,25 @@ bool wlr_backend_is_multi(struct wlr_backend *b) { 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); + wlr_signal_emit_safe(&state->container->events.input_add, data); } static void input_remove_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); + wlr_signal_emit_safe(&state->container->events.input_remove, data); } static void output_add_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); + wlr_signal_emit_safe(&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); + wlr_signal_emit_safe(&state->container->events.output_remove, data); } static void handle_subbackend_destroy(struct wl_listener *listener, @@ -194,7 +195,7 @@ void wlr_multi_backend_add(struct wlr_backend *_multi, wl_signal_add(&backend->events.output_remove, &sub->output_remove); sub->output_remove.notify = output_remove_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 +207,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..fe4ff653 100644 --- a/backend/session/direct-freebsd.c +++ b/backend/session/direct-freebsd.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "backend/session/direct-ipc.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.c b/backend/session/direct.c index 9d6cd36d..245683ea 100644 --- a/backend/session/direct.c +++ b/backend/session/direct.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "backend/session/direct-ipc.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..f6150817 100644 --- a/backend/session/logind.c +++ b/backend/session/logind.c @@ -13,13 +13,14 @@ #include #include #include +#include #ifdef WLR_HAS_SYSTEMD #include #include #elif defined(WLR_HAS_ELOGIND) #include - #include + #include #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..4b81e230 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -13,6 +13,7 @@ #include #include #include +#include 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..2907057c 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "backend/wayland.h" #include "xdg-shell-unstable-v6-client-protocol.h" @@ -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..f2336549 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "backend/wayland.h" #include "xdg-shell-unstable-v6-client-protocol.h" @@ -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.output_add, wlr_output); return wlr_output; error: diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index 37489678..2018f449 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "backend/wayland.h" static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer, @@ -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) { @@ -194,7 +195,7 @@ static struct wl_keyboard_listener keyboard_listener = { 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); + wlr_signal_emit_safe(&dev->backend->backend.events.input_remove, &dev->wlr_input_device); if (dev->resource) { wl_proxy_destroy(dev->resource); } @@ -256,7 +257,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.input_add, wlr_device); backend->pointer = wl_pointer; } if ((caps & WL_SEAT_CAPABILITY_KEYBOARD)) { @@ -280,7 +281,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.input_add, wlr_device); } } diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 411d0ef6..2417810a 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "backend/x11.h" static struct wlr_backend_impl backend_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.output_add, output); + wlr_signal_emit_safe(&x11->backend.events.input_add, &x11->keyboard_dev); + wlr_signal_emit_safe(&x11->backend.events.input_add, &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(&backend->events.input_remove, &x11->pointer_dev); + wlr_signal_emit_safe(&backend->events.input_remove, &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); diff --git a/include/wlr/util/signal.h b/include/wlr/util/signal.h new file mode 100644 index 00000000..e13141d8 --- /dev/null +++ b/include/wlr/util/signal.h @@ -0,0 +1,8 @@ +#ifndef WLR_UTIL_SIGNAL_H +#define WLR_UTIL_SIGNAL_H + +#include + +void wlr_signal_emit_safe(struct wl_signal *signal, void *data); + +#endif diff --git a/render/gles2/texture.c b/render/gles2/texture.c index ff71cb08..54cee627 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "render/gles2.h" static struct pixel_format external_pixel_format = { @@ -271,7 +272,7 @@ static void gles2_texture_bind(struct wlr_texture *_texture) { static void gles2_texture_destroy(struct wlr_texture *_texture) { struct wlr_gles2_texture *texture = (struct wlr_gles2_texture *)_texture; - wl_signal_emit(&texture->wlr_texture.destroy_signal, &texture->wlr_texture); + wlr_signal_emit_safe(&texture->wlr_texture.destroy_signal, &texture->wlr_texture); if (texture->tex_id) { GL_CALL(glDeleteTextures(1, &texture->tex_id)); } diff --git a/rootston/desktop.c b/rootston/desktop.c index 91661c05..e9d66d5c 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "rootston/server.h" #include "rootston/seat.h" #include "rootston/xcursor.h" @@ -383,7 +384,7 @@ struct roots_subsurface *subsurface_create(struct roots_view *view, void view_finish(struct roots_view *view) { view_damage_whole(view); - wl_signal_emit(&view->events.destroy, view); + wlr_signal_emit_safe(&view->events.destroy, view); wl_list_remove(&view->new_subsurface.link); diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c index a4bd7a16..bab41b85 100644 --- a/types/wlr_compositor.c +++ b/types/wlr_compositor.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,7 @@ static void wl_compositor_create_surface(struct wl_client *client, wl_list_insert(&compositor->surfaces, wl_resource_get_link(surface_resource)); - wl_signal_emit(&compositor->events.new_surface, surface); + wlr_signal_emit_safe(&compositor->events.new_surface, surface); } static void wl_compositor_create_region(struct wl_client *client, diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index fd48c1b6..564ead46 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -325,7 +326,7 @@ static void handle_pointer_motion(struct wl_listener *listener, void *data) { struct wlr_event_pointer_motion *event = data; struct wlr_cursor_device *device = wl_container_of(listener, device, motion); - wl_signal_emit(&device->cursor->events.motion, event); + wlr_signal_emit_safe(&device->cursor->events.motion, event); } static void handle_pointer_motion_absolute(struct wl_listener *listener, @@ -333,62 +334,62 @@ static void handle_pointer_motion_absolute(struct wl_listener *listener, struct wlr_event_pointer_motion_absolute *event = data; struct wlr_cursor_device *device = wl_container_of(listener, device, motion_absolute); - wl_signal_emit(&device->cursor->events.motion_absolute, event); + wlr_signal_emit_safe(&device->cursor->events.motion_absolute, event); } static void handle_pointer_button(struct wl_listener *listener, void *data) { struct wlr_event_pointer_button *event = data; struct wlr_cursor_device *device = wl_container_of(listener, device, button); - wl_signal_emit(&device->cursor->events.button, event); + wlr_signal_emit_safe(&device->cursor->events.button, event); } static void handle_pointer_axis(struct wl_listener *listener, void *data) { struct wlr_event_pointer_axis *event = data; struct wlr_cursor_device *device = wl_container_of(listener, device, axis); - wl_signal_emit(&device->cursor->events.axis, event); + wlr_signal_emit_safe(&device->cursor->events.axis, event); } static void handle_touch_up(struct wl_listener *listener, void *data) { struct wlr_event_touch_up *event = data; struct wlr_cursor_device *device; device = wl_container_of(listener, device, touch_up); - wl_signal_emit(&device->cursor->events.touch_up, event); + wlr_signal_emit_safe(&device->cursor->events.touch_up, event); } static void handle_touch_down(struct wl_listener *listener, void *data) { struct wlr_event_touch_down *event = data; struct wlr_cursor_device *device; device = wl_container_of(listener, device, touch_down); - wl_signal_emit(&device->cursor->events.touch_down, event); + wlr_signal_emit_safe(&device->cursor->events.touch_down, event); } static void handle_touch_motion(struct wl_listener *listener, void *data) { struct wlr_event_touch_motion *event = data; struct wlr_cursor_device *device; device = wl_container_of(listener, device, touch_motion); - wl_signal_emit(&device->cursor->events.touch_motion, event); + wlr_signal_emit_safe(&device->cursor->events.touch_motion, event); } static void handle_touch_cancel(struct wl_listener *listener, void *data) { struct wlr_event_touch_cancel *event = data; struct wlr_cursor_device *device; device = wl_container_of(listener, device, touch_cancel); - wl_signal_emit(&device->cursor->events.touch_cancel, event); + wlr_signal_emit_safe(&device->cursor->events.touch_cancel, event); } static void handle_tablet_tool_tip(struct wl_listener *listener, void *data) { struct wlr_event_tablet_tool_tip *event = data; struct wlr_cursor_device *device; device = wl_container_of(listener, device, tablet_tool_tip); - wl_signal_emit(&device->cursor->events.tablet_tool_tip, event); + wlr_signal_emit_safe(&device->cursor->events.tablet_tool_tip, event); } static void handle_tablet_tool_axis(struct wl_listener *listener, void *data) { struct wlr_event_tablet_tool_axis *event = data; struct wlr_cursor_device *device; device = wl_container_of(listener, device, tablet_tool_axis); - wl_signal_emit(&device->cursor->events.tablet_tool_axis, event); + wlr_signal_emit_safe(&device->cursor->events.tablet_tool_axis, event); } static void handle_tablet_tool_button(struct wl_listener *listener, @@ -396,7 +397,7 @@ static void handle_tablet_tool_button(struct wl_listener *listener, struct wlr_event_tablet_tool_button *event = data; struct wlr_cursor_device *device; device = wl_container_of(listener, device, tablet_tool_button); - wl_signal_emit(&device->cursor->events.tablet_tool_button, event); + wlr_signal_emit_safe(&device->cursor->events.tablet_tool_button, event); } static void handle_tablet_tool_proximity(struct wl_listener *listener, @@ -404,7 +405,7 @@ static void handle_tablet_tool_proximity(struct wl_listener *listener, struct wlr_event_tablet_tool_proximity *event = data; struct wlr_cursor_device *device; device = wl_container_of(listener, device, tablet_tool_proximity); - wl_signal_emit(&device->cursor->events.tablet_tool_proximity, event); + wlr_signal_emit_safe(&device->cursor->events.tablet_tool_proximity, event); } static void handle_device_destroy(struct wl_listener *listener, void *data) { diff --git a/types/wlr_data_device.c b/types/wlr_data_device.c index d7e4aa14..ae3219f1 100644 --- a/types/wlr_data_device.c +++ b/types/wlr_data_device.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -290,7 +291,7 @@ static void seat_client_selection_data_source_destroy( seat->selection_data_source = NULL; - wl_signal_emit(&seat->events.selection, seat); + wlr_signal_emit_safe(&seat->events.selection, seat); } void wlr_seat_set_selection(struct wlr_seat *seat, @@ -321,7 +322,7 @@ void wlr_seat_set_selection(struct wlr_seat *seat, wlr_seat_client_send_selection(focused_client); } - wl_signal_emit(&seat->events.selection, seat); + wlr_signal_emit_safe(&seat->events.selection, seat); if (source) { seat->selection_data_source_destroy.notify = @@ -457,7 +458,7 @@ static void wlr_drag_end(struct wlr_drag *drag) { if (drag->icon) { drag->icon->mapped = false; wl_list_remove(&drag->icon_destroy.link); - wl_signal_emit(&drag->icon->events.map, drag->icon); + wlr_signal_emit_safe(&drag->icon->events.map, drag->icon); } free(drag); @@ -634,7 +635,7 @@ static void wlr_drag_icon_destroy(struct wlr_drag_icon *icon) { if (!icon) { return; } - wl_signal_emit(&icon->events.destroy, icon); + wlr_signal_emit_safe(&icon->events.destroy, icon); wlr_surface_set_role_committed(icon->surface, NULL, NULL); wl_list_remove(&icon->surface_destroy.link); wl_list_remove(&icon->seat_client_destroy.link); @@ -691,7 +692,7 @@ static struct wlr_drag_icon *wlr_drag_icon_create( icon->seat_client_destroy.notify = handle_drag_icon_seat_client_destroy; wl_list_insert(&client->seat->drag_icons, &icon->link); - wl_signal_emit(&client->seat->events.new_drag_icon, icon); + wlr_signal_emit_safe(&client->seat->events.new_drag_icon, icon); return icon; } @@ -941,7 +942,7 @@ void wlr_data_source_finish(struct wlr_data_source *source) { return; } - wl_signal_emit(&source->events.destroy, source); + wlr_signal_emit_safe(&source->events.destroy, source); char **p; wl_array_for_each(p, &source->mime_types) { diff --git a/types/wlr_gamma_control.c b/types/wlr_gamma_control.c index eb154b6b..f7644230 100644 --- a/types/wlr_gamma_control.c +++ b/types/wlr_gamma_control.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "gamma-control-protocol.h" static void resource_destroy(struct wl_client *client, @@ -15,7 +16,7 @@ static void gamma_control_destroy(struct wlr_gamma_control *gamma_control) { if (gamma_control == NULL) { return; } - wl_signal_emit(&gamma_control->events.destroy, gamma_control); + wlr_signal_emit_safe(&gamma_control->events.destroy, gamma_control); wl_list_remove(&gamma_control->output_destroy_listener.link); wl_resource_set_user_data(gamma_control->resource, NULL); wl_list_remove(&gamma_control->link); diff --git a/types/wlr_idle.c b/types/wlr_idle.c index f2cad42b..b30bb9d7 100644 --- a/types/wlr_idle.c +++ b/types/wlr_idle.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "idle-protocol.h" static void idle_timeout_destroy(struct wlr_idle_timeout *timer) { @@ -186,5 +187,5 @@ struct wlr_idle *wlr_idle_create(struct wl_display *display) { } void wlr_idle_notify_activity(struct wlr_idle *idle, struct wlr_seat *seat) { - wl_signal_emit(&idle->activity_notify, seat); + wlr_signal_emit_safe(&idle->activity_notify, seat); } diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index 7015dcba..468b93f9 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -10,6 +10,7 @@ #include #include #include +#include void wlr_input_device_init(struct wlr_input_device *dev, enum wlr_input_device_type type, @@ -29,7 +30,7 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) { return; } - wl_signal_emit(&dev->events.destroy, dev); + wlr_signal_emit_safe(&dev->events.destroy, dev); if (dev->_device) { switch (dev->type) { diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c index 29552eb4..9fac1843 100644 --- a/types/wlr_keyboard.c +++ b/types/wlr_keyboard.c @@ -7,6 +7,7 @@ #include #include #include +#include int os_create_anonymous_file(off_t size); @@ -110,7 +111,7 @@ void wlr_keyboard_notify_modifiers(struct wlr_keyboard *keyboard, bool updated = keyboard_modifier_update(keyboard); if (updated) { - wl_signal_emit(&keyboard->events.modifiers, keyboard); + wlr_signal_emit_safe(&keyboard->events.modifiers, keyboard); } } @@ -128,11 +129,11 @@ void wlr_keyboard_notify_key(struct wlr_keyboard *keyboard, bool updated = keyboard_modifier_update(keyboard); if (updated) { - wl_signal_emit(&keyboard->events.modifiers, keyboard); + wlr_signal_emit_safe(&keyboard->events.modifiers, keyboard); } keyboard_key_update(keyboard, event); - wl_signal_emit(&keyboard->events.key, event); + wlr_signal_emit_safe(&keyboard->events.key, event); } void wlr_keyboard_init(struct wlr_keyboard *kb, @@ -234,7 +235,7 @@ void wlr_keyboard_set_keymap(struct wlr_keyboard *kb, keyboard_modifier_update(kb); - wl_signal_emit(&kb->events.keymap, kb); + wlr_signal_emit_safe(&kb->events.keymap, kb); return; err: @@ -253,7 +254,7 @@ void wlr_keyboard_set_repeat_info(struct wlr_keyboard *kb, int32_t rate, } kb->repeat_info.rate = rate; kb->repeat_info.delay = delay; - wl_signal_emit(&kb->events.repeat_info, kb); + wlr_signal_emit_safe(&kb->events.repeat_info, kb); } uint32_t wlr_keyboard_get_modifiers(struct wlr_keyboard *kb) { diff --git a/types/wlr_output.c b/types/wlr_output.c index 5f7dca28..bf3ed6ae 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -13,6 +13,7 @@ #include #include #include +#include static void wl_output_send_to_resource(struct wl_resource *resource) { assert(resource); @@ -139,7 +140,7 @@ void wlr_output_update_enabled(struct wlr_output *output, bool enabled) { } output->enabled = enabled; - wl_signal_emit(&output->events.enable, output); + wlr_signal_emit_safe(&output->events.enable, output); } static void wlr_output_update_matrix(struct wlr_output *output) { @@ -193,7 +194,7 @@ void wlr_output_update_custom_mode(struct wlr_output *output, int32_t width, wlr_output_send_current_mode_to_resource(resource); } - wl_signal_emit(&output->events.mode, output); + wlr_signal_emit_safe(&output->events.mode, output); } void wlr_output_set_transform(struct wlr_output *output, @@ -207,7 +208,7 @@ void wlr_output_set_transform(struct wlr_output *output, wl_output_send_to_resource(resource); } - wl_signal_emit(&output->events.transform, output); + wlr_signal_emit_safe(&output->events.transform, output); } void wlr_output_set_position(struct wlr_output *output, int32_t lx, @@ -239,7 +240,7 @@ void wlr_output_set_scale(struct wlr_output *output, float scale) { wl_output_send_to_resource(resource); } - wl_signal_emit(&output->events.scale, output); + wlr_signal_emit_safe(&output->events.scale, output); } static void handle_display_destroy(struct wl_listener *listener, void *data) { @@ -284,8 +285,8 @@ void wlr_output_destroy(struct wlr_output *output) { wlr_output_destroy_global(output); wlr_output_set_fullscreen_surface(output, NULL); - wl_signal_emit(&output->backend->events.output_remove, output); - wl_signal_emit(&output->events.destroy, output); + wlr_signal_emit_safe(&output->backend->events.output_remove, output); + wlr_signal_emit_safe(&output->events.destroy, output); struct wlr_output_mode *mode, *tmp_mode; wl_list_for_each_safe(mode, tmp_mode, &output->modes, link) { @@ -471,7 +472,7 @@ bool wlr_output_swap_buffers(struct wlr_output *output, struct timespec *when, output->idle_frame = NULL; } - wl_signal_emit(&output->events.swap_buffers, damage); + wlr_signal_emit_safe(&output->events.swap_buffers, damage); int width, height; wlr_output_transformed_resolution(output, &width, &height); @@ -528,7 +529,7 @@ bool wlr_output_swap_buffers(struct wlr_output *output, struct timespec *when, void wlr_output_send_frame(struct wlr_output *output) { output->frame_pending = false; - wl_signal_emit(&output->events.frame, output); + wlr_signal_emit_safe(&output->events.frame, output); } static void schedule_frame_handle_idle_timer(void *data) { @@ -566,7 +567,7 @@ uint32_t wlr_output_get_gamma_size(struct wlr_output *output) { void wlr_output_update_needs_swap(struct wlr_output *output) { output->needs_swap = true; - wl_signal_emit(&output->events.needs_swap, output); + wlr_signal_emit_safe(&output->events.needs_swap, output); } static void output_damage_whole(struct wlr_output *output) { @@ -883,7 +884,7 @@ void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor) { return; } output_cursor_reset(cursor); - wl_signal_emit(&cursor->events.destroy, cursor); + wlr_signal_emit_safe(&cursor->events.destroy, cursor); if (cursor->output->hardware_cursor == cursor) { // If this cursor was the hardware cursor, disable it if (cursor->output->impl->set_cursor) { diff --git a/types/wlr_output_damage.c b/types/wlr_output_damage.c index 354314b6..2c6e24f0 100644 --- a/types/wlr_output_damage.c +++ b/types/wlr_output_damage.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -46,7 +47,7 @@ static void output_handle_frame(struct wl_listener *listener, void *data) { return; } - wl_signal_emit(&output_damage->events.frame, output_damage); + wlr_signal_emit_safe(&output_damage->events.frame, output_damage); } struct wlr_output_damage *wlr_output_damage_create(struct wlr_output *output) { @@ -85,7 +86,7 @@ void wlr_output_damage_destroy(struct wlr_output_damage *output_damage) { if (output_damage == NULL) { return; } - wl_signal_emit(&output_damage->events.destroy, output_damage); + wlr_signal_emit_safe(&output_damage->events.destroy, output_damage); wl_list_remove(&output_damage->output_destroy.link); wl_list_remove(&output_damage->output_mode.link); wl_list_remove(&output_damage->output_transform.link); diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index 46b0bd2a..ea8581b3 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -1,11 +1,12 @@ -#include -#include -#include -#include #include #include #include #include +#include +#include +#include +#include +#include struct wlr_output_layout_state { struct wlr_box _box; // should never be read directly, use the getter @@ -46,7 +47,7 @@ struct wlr_output_layout *wlr_output_layout_create() { static void wlr_output_layout_output_destroy( struct wlr_output_layout_output *l_output) { - wl_signal_emit(&l_output->events.destroy, l_output); + wlr_signal_emit_safe(&l_output->events.destroy, l_output); wl_list_remove(&l_output->state->mode.link); wl_list_remove(&l_output->state->scale.link); wl_list_remove(&l_output->state->transform.link); @@ -61,7 +62,7 @@ void wlr_output_layout_destroy(struct wlr_output_layout *layout) { return; } - wl_signal_emit(&layout->events.destroy, layout); + wlr_signal_emit_safe(&layout->events.destroy, layout); struct wlr_output_layout_output *l_output, *temp = NULL; wl_list_for_each_safe(l_output, temp, &layout->outputs, link) { @@ -129,7 +130,7 @@ static void wlr_output_layout_reconfigure(struct wlr_output_layout *layout) { wlr_output_set_position(l_output->output, l_output->x, l_output->y); } - wl_signal_emit(&layout->events.change, layout); + wlr_signal_emit_safe(&layout->events.change, layout); } static void handle_output_mode(struct wl_listener *listener, void *data) { @@ -204,7 +205,7 @@ void wlr_output_layout_add(struct wlr_output_layout *layout, l_output->state->auto_configured = false; wlr_output_layout_reconfigure(layout); wlr_output_create_global(output); - wl_signal_emit(&layout->events.add, l_output); + wlr_signal_emit_safe(&layout->events.add, l_output); } struct wlr_output_layout_output *wlr_output_layout_get( @@ -401,7 +402,7 @@ void wlr_output_layout_add_auto(struct wlr_output_layout *layout, l_output->state->auto_configured = true; wlr_output_layout_reconfigure(layout); wlr_output_create_global(output); - wl_signal_emit(&layout->events.add, l_output); + wlr_signal_emit_safe(&layout->events.add, l_output); } struct wlr_output *wlr_output_layout_get_center_output( diff --git a/types/wlr_primary_selection.c b/types/wlr_primary_selection.c index fafde669..7eb5d97a 100644 --- a/types/wlr_primary_selection.c +++ b/types/wlr_primary_selection.c @@ -7,6 +7,7 @@ #include #include #include +#include static void offer_handle_receive(struct wl_client *client, struct wl_resource *resource, const char *mime_type, int32_t fd) { @@ -195,7 +196,7 @@ static void seat_client_primary_selection_source_destroy( seat->primary_selection_source = NULL; - wl_signal_emit(&seat->events.primary_selection, seat); + wlr_signal_emit_safe(&seat->events.primary_selection, seat); } void wlr_seat_set_primary_selection(struct wlr_seat *seat, @@ -225,7 +226,7 @@ void wlr_seat_set_primary_selection(struct wlr_seat *seat, wlr_seat_client_send_primary_selection(focused_client); } - wl_signal_emit(&seat->events.primary_selection, seat); + wlr_signal_emit_safe(&seat->events.primary_selection, seat); if (source) { seat->primary_selection_source_destroy.notify = @@ -278,7 +279,7 @@ void wlr_primary_selection_source_finish( return; } - wl_signal_emit(&source->events.destroy, source); + wlr_signal_emit_safe(&source->events.destroy, source); char **p; wl_array_for_each(p, &source->mime_types) { diff --git a/types/wlr_seat.c b/types/wlr_seat.c index 79c4f6f6..b9d8b1b8 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -49,7 +50,7 @@ static void wl_pointer_set_cursor(struct wl_client *client, event->hotspot_x = hotspot_x; event->hotspot_y = hotspot_y; - wl_signal_emit(&seat_client->seat->events.request_set_cursor, event); + wlr_signal_emit_safe(&seat_client->seat->events.request_set_cursor, event); free(event); } @@ -177,7 +178,7 @@ static void wl_seat_get_touch(struct wl_client *client, static void wlr_seat_client_resource_destroy(struct wl_resource *seat_resource) { struct wlr_seat_client *client = wl_resource_get_user_data(seat_resource); - wl_signal_emit(&client->events.destroy, client); + wlr_signal_emit_safe(&client->events.destroy, client); if (client == client->seat->pointer_state.focused_client) { client->seat->pointer_state.focused_client = NULL; @@ -350,7 +351,7 @@ void wlr_seat_destroy(struct wlr_seat *seat) { return; } - wl_signal_emit(&seat->events.destroy, seat); + wlr_signal_emit_safe(&seat->events.destroy, seat); wl_list_remove(&seat->display_destroy.link); @@ -656,14 +657,14 @@ void wlr_seat_pointer_start_grab(struct wlr_seat *wlr_seat, assert(grab->seat); wlr_seat->pointer_state.grab = grab; - wl_signal_emit(&wlr_seat->events.pointer_grab_begin, grab); + wlr_signal_emit_safe(&wlr_seat->events.pointer_grab_begin, grab); } void wlr_seat_pointer_end_grab(struct wlr_seat *wlr_seat) { struct wlr_seat_pointer_grab *grab = wlr_seat->pointer_state.grab; if (grab != wlr_seat->pointer_state.default_grab) { wlr_seat->pointer_state.grab = wlr_seat->pointer_state.default_grab; - wl_signal_emit(&wlr_seat->events.pointer_grab_end, grab); + wlr_signal_emit_safe(&wlr_seat->events.pointer_grab_end, grab); if (grab->interface->cancel) { grab->interface->cancel(grab); } @@ -812,7 +813,7 @@ void wlr_seat_keyboard_start_grab(struct wlr_seat *wlr_seat, grab->seat = wlr_seat; wlr_seat->keyboard_state.grab = grab; - wl_signal_emit(&wlr_seat->events.keyboard_grab_begin, grab); + wlr_signal_emit_safe(&wlr_seat->events.keyboard_grab_begin, grab); } void wlr_seat_keyboard_end_grab(struct wlr_seat *wlr_seat) { @@ -820,7 +821,7 @@ void wlr_seat_keyboard_end_grab(struct wlr_seat *wlr_seat) { if (grab != wlr_seat->keyboard_state.default_grab) { wlr_seat->keyboard_state.grab = wlr_seat->keyboard_state.default_grab; - wl_signal_emit(&wlr_seat->events.keyboard_grab_end, grab); + wlr_signal_emit_safe(&wlr_seat->events.keyboard_grab_end, grab); if (grab->interface->cancel) { grab->interface->cancel(grab); } @@ -979,7 +980,7 @@ void wlr_seat_touch_start_grab(struct wlr_seat *wlr_seat, grab->seat = wlr_seat; wlr_seat->touch_state.grab = grab; - wl_signal_emit(&wlr_seat->events.touch_grab_begin, grab); + wlr_signal_emit_safe(&wlr_seat->events.touch_grab_begin, grab); } void wlr_seat_touch_end_grab(struct wlr_seat *wlr_seat) { @@ -987,7 +988,7 @@ void wlr_seat_touch_end_grab(struct wlr_seat *wlr_seat) { if (grab != wlr_seat->touch_state.default_grab) { wlr_seat->touch_state.grab = wlr_seat->touch_state.default_grab; - wl_signal_emit(&wlr_seat->events.touch_grab_end, grab); + wlr_signal_emit_safe(&wlr_seat->events.touch_grab_end, grab); if (grab->interface->cancel) { grab->interface->cancel(grab); } @@ -1003,7 +1004,7 @@ static void touch_point_clear_focus(struct wlr_touch_point *point) { } static void touch_point_destroy(struct wlr_touch_point *point) { - wl_signal_emit(&point->events.destroy, point); + wlr_signal_emit_safe(&point->events.destroy, point); touch_point_clear_focus(point); wl_list_remove(&point->surface_destroy.link); diff --git a/types/wlr_server_decoration.c b/types/wlr_server_decoration.c index 09909bb6..f648cce7 100644 --- a/types/wlr_server_decoration.c +++ b/types/wlr_server_decoration.c @@ -4,6 +4,7 @@ #include #include #include +#include static void server_decoration_handle_release(struct wl_client *client, struct wl_resource *resource) { @@ -18,14 +19,14 @@ static void server_decoration_handle_request_mode(struct wl_client *client, return; } decoration->mode = mode; - wl_signal_emit(&decoration->events.mode, decoration); + wlr_signal_emit_safe(&decoration->events.mode, decoration); org_kde_kwin_server_decoration_send_mode(decoration->resource, decoration->mode); } static void server_decoration_destroy( struct wlr_server_decoration *decoration) { - wl_signal_emit(&decoration->events.destroy, decoration); + wlr_signal_emit_safe(&decoration->events.destroy, decoration); wl_list_remove(&decoration->surface_destroy_listener.link); wl_resource_set_user_data(decoration->resource, NULL); wl_list_remove(&decoration->link); @@ -97,7 +98,7 @@ static void server_decoration_manager_handle_create(struct wl_client *client, org_kde_kwin_server_decoration_send_mode(decoration->resource, decoration->mode); - wl_signal_emit(&manager->events.new_decoration, decoration); + wlr_signal_emit_safe(&manager->events.new_decoration, decoration); } static const struct org_kde_kwin_server_decoration_manager_interface diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 045e3670..e430339b 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -395,7 +396,7 @@ static void wlr_surface_commit_pending(struct wlr_surface *surface) { } // TODO: add the invalid bitfield to this callback - wl_signal_emit(&surface->events.commit, surface); + wlr_signal_emit_safe(&surface->events.commit, surface); pixman_region32_clear(&surface->current->surface_damage); pixman_region32_clear(&surface->current->buffer_damage); @@ -559,7 +560,7 @@ static void wlr_surface_state_destroy(struct wlr_surface_state *state) { } void wlr_subsurface_destroy(struct wlr_subsurface *subsurface) { - wl_signal_emit(&subsurface->events.destroy, subsurface); + wlr_signal_emit_safe(&subsurface->events.destroy, subsurface); wlr_surface_state_destroy(subsurface->cached); @@ -578,7 +579,7 @@ void wlr_subsurface_destroy(struct wlr_subsurface *subsurface) { static void destroy_surface(struct wl_resource *resource) { struct wlr_surface *surface = wl_resource_get_user_data(resource); - wl_signal_emit(&surface->events.destroy, surface); + wlr_signal_emit_safe(&surface->events.destroy, surface); if (surface->subsurface) { wlr_subsurface_destroy(surface->subsurface); @@ -831,7 +832,7 @@ void wlr_surface_make_subsurface(struct wlr_surface *surface, surface->subsurface = subsurface; - wl_signal_emit(&parent->events.new_subsurface, subsurface); + wlr_signal_emit_safe(&parent->events.new_subsurface, subsurface); } diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index dd6514df..0c4e01fd 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -1,12 +1,13 @@ #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200809L #endif +#include #include #include #include +#include #include #include -#include #include static const char *wlr_wl_shell_surface_role = "wl-shell-surface"; @@ -123,7 +124,7 @@ static void shell_surface_protocol_move(struct wl_client *client, .serial = serial, }; - wl_signal_emit(&surface->events.request_move, &event); + wlr_signal_emit_safe(&surface->events.request_move, &event); } static struct wlr_wl_shell_popup_grab *shell_popup_grab_from_seat( @@ -187,7 +188,7 @@ static void shell_surface_protocol_resize(struct wl_client *client, .edges = edges, }; - wl_signal_emit(&surface->events.request_resize, &event); + wlr_signal_emit_safe(&surface->events.request_resize, &event); } static void shell_surface_set_state(struct wlr_wl_shell_surface *surface, @@ -200,7 +201,7 @@ static void shell_surface_set_state(struct wlr_wl_shell_surface *surface, shell_surface_destroy_popup_state(surface); surface->popup_state = popup_state; - wl_signal_emit(&surface->events.set_state, surface); + wlr_signal_emit_safe(&surface->events.set_state, surface); } static void shell_surface_protocol_set_toplevel(struct wl_client *client, @@ -221,7 +222,7 @@ static void shell_surface_popup_set_parent(struct wlr_wl_shell_surface *surface, if (parent) { wl_list_remove(&surface->popup_link); wl_list_insert(&parent->popups, &surface->popup_link); - wl_signal_emit(&parent->events.new_popup, surface); + wlr_signal_emit_safe(&parent->events.new_popup, surface); } } @@ -290,7 +291,7 @@ static void shell_surface_protocol_set_fullscreen(struct wl_client *client, .output = output, }; - wl_signal_emit(&surface->events.request_fullscreen, &event); + wlr_signal_emit_safe(&surface->events.request_fullscreen, &event); } static void shell_surface_protocol_set_popup(struct wl_client *client, @@ -368,7 +369,7 @@ static void shell_surface_protocol_set_maximized(struct wl_client *client, .output = output, }; - wl_signal_emit(&surface->events.request_maximize, &event); + wlr_signal_emit_safe(&surface->events.request_maximize, &event); } static void shell_surface_protocol_set_title(struct wl_client *client, @@ -384,7 +385,7 @@ static void shell_surface_protocol_set_title(struct wl_client *client, free(surface->title); surface->title = tmp; - wl_signal_emit(&surface->events.set_title, surface); + wlr_signal_emit_safe(&surface->events.set_title, surface); } static void shell_surface_protocol_set_class(struct wl_client *client, @@ -400,7 +401,7 @@ static void shell_surface_protocol_set_class(struct wl_client *client, free(surface->class); surface->class = tmp; - wl_signal_emit(&surface->events.set_class, surface); + wlr_signal_emit_safe(&surface->events.set_class, surface); } static const struct wl_shell_surface_interface shell_surface_impl = { @@ -417,7 +418,7 @@ static const struct wl_shell_surface_interface shell_surface_impl = { }; static void shell_surface_destroy(struct wlr_wl_shell_surface *surface) { - wl_signal_emit(&surface->events.destroy, surface); + wlr_signal_emit_safe(&surface->events.destroy, surface); shell_surface_destroy_popup_state(surface); wl_resource_set_user_data(surface->resource, NULL); @@ -457,7 +458,7 @@ static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface, wlr_surface_has_buffer(surface->surface) && surface->state != WLR_WL_SHELL_SURFACE_STATE_NONE) { surface->configured = true; - wl_signal_emit(&surface->shell->events.new_surface, surface); + wlr_signal_emit_safe(&surface->shell->events.new_surface, surface); } if (surface->popup_mapped && @@ -473,7 +474,7 @@ static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface, static int shell_surface_ping_timeout(void *user_data) { struct wlr_wl_shell_surface *surface = user_data; - wl_signal_emit(&surface->events.ping_timeout, surface); + wlr_signal_emit_safe(&surface->events.ping_timeout, surface); surface->ping_serial = 0; return 1; diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 5c820edc..b6eee875 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "xdg-shell-unstable-v6-protocol.h" static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel"; @@ -160,7 +161,7 @@ static struct wlr_xdg_popup_grab_v6 *xdg_shell_popup_grab_from_seat( static void xdg_surface_destroy(struct wlr_xdg_surface_v6 *surface) { // TODO: probably need to ungrab before this event - wl_signal_emit(&surface->events.destroy, surface); + wlr_signal_emit_safe(&surface->events.destroy, surface); if (surface->configure_idle) { wl_event_source_remove(surface->configure_idle); @@ -511,7 +512,7 @@ static void xdg_surface_get_popup(struct wl_client *client, &zxdg_popup_v6_implementation, surface, xdg_popup_resource_destroy); - wl_signal_emit(&parent->events.new_popup, surface->popup_state); + wlr_signal_emit_safe(&parent->events.new_popup, surface->popup_state); } @@ -582,7 +583,7 @@ static void xdg_toplevel_protocol_show_window_menu(struct wl_client *client, .y = y, }; - wl_signal_emit(&surface->events.request_show_window_menu, &event); + wlr_signal_emit_safe(&surface->events.request_show_window_menu, &event); } static void xdg_toplevel_protocol_move(struct wl_client *client, @@ -610,7 +611,7 @@ static void xdg_toplevel_protocol_move(struct wl_client *client, .serial = serial, }; - wl_signal_emit(&surface->events.request_move, &event); + wlr_signal_emit_safe(&surface->events.request_move, &event); } static void xdg_toplevel_protocol_resize(struct wl_client *client, @@ -639,7 +640,7 @@ static void xdg_toplevel_protocol_resize(struct wl_client *client, .edges = edges, }; - wl_signal_emit(&surface->events.request_resize, &event); + wlr_signal_emit_safe(&surface->events.request_resize, &event); } static void xdg_toplevel_protocol_set_max_size(struct wl_client *client, @@ -660,14 +661,14 @@ static void xdg_toplevel_protocol_set_maximized(struct wl_client *client, struct wl_resource *resource) { struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); surface->toplevel_state->next.maximized = true; - wl_signal_emit(&surface->events.request_maximize, surface); + wlr_signal_emit_safe(&surface->events.request_maximize, surface); } static void xdg_toplevel_protocol_unset_maximized(struct wl_client *client, struct wl_resource *resource) { struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); surface->toplevel_state->next.maximized = false; - wl_signal_emit(&surface->events.request_maximize, surface); + wlr_signal_emit_safe(&surface->events.request_maximize, surface); } static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client, @@ -687,7 +688,7 @@ static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client, .output = output, }; - wl_signal_emit(&surface->events.request_fullscreen, &event); + wlr_signal_emit_safe(&surface->events.request_fullscreen, &event); } static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client, @@ -702,13 +703,13 @@ static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client, .output = NULL, }; - wl_signal_emit(&surface->events.request_fullscreen, &event); + wlr_signal_emit_safe(&surface->events.request_fullscreen, &event); } static void xdg_toplevel_protocol_set_minimized(struct wl_client *client, struct wl_resource *resource) { struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); - wl_signal_emit(&surface->events.request_minimize, surface); + wlr_signal_emit_safe(&surface->events.request_minimize, surface); } static const struct zxdg_toplevel_v6_interface zxdg_toplevel_v6_implementation = @@ -1123,7 +1124,7 @@ static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface, if (surface->configured && !surface->added) { surface->added = true; - wl_signal_emit(&surface->client->shell->events.new_surface, surface); + wlr_signal_emit_safe(&surface->client->shell->events.new_surface, surface); } } @@ -1243,7 +1244,7 @@ static int wlr_xdg_client_v6_ping_timeout(void *user_data) { struct wlr_xdg_surface_v6 *surface; wl_list_for_each(surface, &client->surfaces, link) { - wl_signal_emit(&surface->events.ping_timeout, surface); + wlr_signal_emit_safe(&surface->events.ping_timeout, surface); } client->ping_serial = 0; diff --git a/util/meson.build b/util/meson.build index 34aa428b..adc52a53 100644 --- a/util/meson.build +++ b/util/meson.build @@ -4,6 +4,7 @@ lib_wlr_util = static_library( 'log.c', 'os-compatibility.c', 'region.c', + 'signal.c', ), include_directories: wlr_inc, dependencies: [wayland_server, pixman], diff --git a/util/signal.c b/util/signal.c new file mode 100644 index 00000000..91c4f571 --- /dev/null +++ b/util/signal.c @@ -0,0 +1,34 @@ +#include + +static void handle_noop(struct wl_listener *listener, void *data) { + // Do nothing +} + +void wlr_signal_emit_safe(struct wl_signal *signal, void *data) { + struct wl_listener cursor; + struct wl_listener end; + + /* Add two special markers: one cursor and one end marker. This way, we know + * that we've already called listeners on the left of the cursor and that we + * don't want to call listeners on the right of the end marker. The 'it' + * function can remove any element it wants from the list without troubles. + * wl_list_for_each_safe tries to be safe but it fails: it works fine + * if the current item is removed, but not if the next one is. */ + wl_list_insert(&signal->listener_list, &cursor.link); + cursor.notify = handle_noop; + wl_list_insert(signal->listener_list.prev, &end.link); + end.notify = handle_noop; + + while (cursor.link.next != &end.link) { + struct wl_list *pos = cursor.link.next; + struct wl_listener *l = wl_container_of(pos, l, link); + + wl_list_remove(&cursor.link); + wl_list_insert(pos, &cursor.link); + + l->notify(l, data); + } + + wl_list_remove(&cursor.link); + wl_list_remove(&end.link); +} diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index 6c700cc5..7c57b6c0 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -16,8 +16,9 @@ #include #include #include -#include "wlr/util/log.h" -#include "wlr/xwayland.h" +#include +#include +#include #include "sockets.h" #include "wlr/xwm.h" @@ -237,7 +238,7 @@ static int xserver_handle_ready(int signal_number, void *data) { snprintf(display_name, sizeof(display_name), ":%d", wlr_xwayland->display); setenv("DISPLAY", display_name, true); - wl_signal_emit(&wlr_xwayland->events.ready, wlr_xwayland); + wlr_signal_emit_safe(&wlr_xwayland->events.ready, wlr_xwayland); /* ready is a one-shot signal, fire and forget */ wl_signal_init(&wlr_xwayland->events.ready); diff --git a/xwayland/xwm.c b/xwayland/xwm.c index e59c6e66..86d8bde7 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -8,12 +8,13 @@ #include #include #include -#include "wlr/util/log.h" -#include "wlr/util/edges.h" -#include "wlr/types/wlr_surface.h" -#include "wlr/xwayland.h" -#include "wlr/xcursor.h" -#include "wlr/xwm.h" +#include +#include +#include +#include +#include +#include +#include #ifdef WLR_HAS_XCB_ICCCM #include @@ -210,7 +211,7 @@ static void xsurface_set_net_wm_state(struct wlr_xwayland_surface *xsurface) { static void wlr_xwayland_surface_destroy( struct wlr_xwayland_surface *xsurface) { - wl_signal_emit(&xsurface->events.destroy, xsurface); + wlr_signal_emit_safe(&xsurface->events.destroy, xsurface); if (xsurface == xsurface->xwm->focus_surface) { xwm_surface_activate(xsurface->xwm, NULL); @@ -266,7 +267,7 @@ static void read_surface_class(struct wlr_xwm *xwm, wlr_log(L_DEBUG, "XCB_ATOM_WM_CLASS: %s %s", surface->instance, surface->class); - wl_signal_emit(&surface->events.set_class, surface); + wlr_signal_emit_safe(&surface->events.set_class, surface); } static void read_surface_title(struct wlr_xwm *xwm, @@ -291,7 +292,7 @@ static void read_surface_title(struct wlr_xwm *xwm, } wlr_log(L_DEBUG, "XCB_ATOM_WM_NAME: %s", xsurface->title); - wl_signal_emit(&xsurface->events.set_title, xsurface); + wlr_signal_emit_safe(&xsurface->events.set_title, xsurface); } static void read_surface_parent(struct wlr_xwm *xwm, @@ -316,7 +317,7 @@ static void read_surface_parent(struct wlr_xwm *xwm, } wlr_log(L_DEBUG, "XCB_ATOM_WM_TRANSIENT_FOR: %p", xsurface->parent); - wl_signal_emit(&xsurface->events.set_parent, xsurface); + wlr_signal_emit_safe(&xsurface->events.set_parent, xsurface); } static void read_surface_pid(struct wlr_xwm *xwm, @@ -329,7 +330,7 @@ static void read_surface_pid(struct wlr_xwm *xwm, pid_t *pid = xcb_get_property_value(reply); xsurface->pid = *pid; wlr_log(L_DEBUG, "NET_WM_PID %d", xsurface->pid); - wl_signal_emit(&xsurface->events.set_pid, xsurface); + wlr_signal_emit_safe(&xsurface->events.set_pid, xsurface); } static void read_surface_window_type(struct wlr_xwm *xwm, @@ -352,7 +353,7 @@ static void read_surface_window_type(struct wlr_xwm *xwm, xsurface->window_type_len = atoms_len; wlr_log(L_DEBUG, "NET_WM_WINDOW_TYPE (%zu)", atoms_len); - wl_signal_emit(&xsurface->events.set_window_type, xsurface); + wlr_signal_emit_safe(&xsurface->events.set_window_type, xsurface); } static void read_surface_protocols(struct wlr_xwm *xwm, @@ -535,7 +536,7 @@ static void handle_surface_commit(struct wlr_surface *wlr_surface, if (!xsurface->added && wlr_surface_has_buffer(xsurface->surface) && xsurface->mapped) { - wl_signal_emit(&xsurface->xwm->xwayland->events.new_surface, xsurface); + wlr_signal_emit_safe(&xsurface->xwm->xwayland->events.new_surface, xsurface); xsurface->added = true; } } @@ -578,7 +579,7 @@ static void xwm_map_shell_surface(struct wlr_xwm *xwm, wl_signal_add(&surface->events.destroy, &xsurface->surface_destroy); xsurface->mapped = true; - wl_signal_emit(&xsurface->events.map_notify, xsurface); + wlr_signal_emit_safe(&xsurface->events.map_notify, xsurface); } static void xwm_handle_create_notify(struct wlr_xwm *xwm, @@ -626,7 +627,7 @@ static void xwm_handle_configure_request(struct wlr_xwm *xwm, wlr_event->width = ev->width; wlr_event->height = ev->height; - wl_signal_emit(&xsurface->events.request_configure, wlr_event); + wlr_signal_emit_safe(&xsurface->events.request_configure, wlr_event); free(wlr_event); } @@ -710,7 +711,7 @@ static void xwm_handle_unmap_notify(struct wlr_xwm *xwm, if (xsurface->mapped) { xsurface->mapped = false; - wl_signal_emit(&xsurface->events.unmap_notify, xsurface); + wlr_signal_emit_safe(&xsurface->events.unmap_notify, xsurface); } xsurface_set_wm_state(xsurface, ICCCM_WITHDRAWN_STATE); @@ -814,7 +815,7 @@ static void xwm_handle_net_wm_moveresize_message(struct wlr_xwm *xwm, switch (detail) { case _NET_WM_MOVERESIZE_MOVE: move_event.surface = xsurface; - wl_signal_emit(&xsurface->events.request_move, &move_event); + wlr_signal_emit_safe(&xsurface->events.request_move, &move_event); break; case _NET_WM_MOVERESIZE_SIZE_TOPLEFT: case _NET_WM_MOVERESIZE_SIZE_TOP: @@ -826,7 +827,7 @@ static void xwm_handle_net_wm_moveresize_message(struct wlr_xwm *xwm, case _NET_WM_MOVERESIZE_SIZE_LEFT: resize_event.surface = xsurface; resize_event.edges = net_wm_edges_to_wlr(detail); - wl_signal_emit(&xsurface->events.request_resize, &resize_event); + wlr_signal_emit_safe(&xsurface->events.request_resize, &resize_event); break; case _NET_WM_MOVERESIZE_CANCEL: // handled by the compositor @@ -904,7 +905,7 @@ static void xwm_handle_net_wm_state_message(struct wlr_xwm *xwm, xsurface->saved_height = xsurface->height; } - wl_signal_emit(&xsurface->events.request_fullscreen, xsurface); + wlr_signal_emit_safe(&xsurface->events.request_fullscreen, xsurface); } if (maximized != xsurface_is_maximized(xsurface)) { @@ -913,7 +914,7 @@ static void xwm_handle_net_wm_state_message(struct wlr_xwm *xwm, xsurface->saved_height = xsurface->height; } - wl_signal_emit(&xsurface->events.request_maximize, xsurface); + wlr_signal_emit_safe(&xsurface->events.request_maximize, xsurface); } } From 10ecf871f27ddd7170b6fb9ee7bd055b9cb3423c Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 12 Feb 2018 10:36:43 +0100 Subject: [PATCH 2/4] Remove wlr_backend.events.{output_remove,device_remove} --- backend/backend.c | 6 +- backend/drm/drm.c | 9 +- backend/headless/backend.c | 4 +- backend/headless/input_device.c | 3 +- backend/headless/output.c | 2 +- backend/libinput/backend.c | 1 - backend/libinput/events.c | 11 +- backend/multi/backend.c | 61 +++---- backend/wayland/output.c | 2 +- backend/wayland/wl_seat.c | 9 +- backend/x11/backend.c | 10 +- examples/support/shared.c | 274 +++++++++++++------------------- examples/support/shared.h | 12 +- include/rootston/desktop.h | 3 +- include/rootston/input.h | 3 +- include/rootston/keyboard.h | 1 + include/rootston/output.h | 4 +- include/rootston/seat.h | 3 + include/wlr/backend.h | 6 +- rootston/desktop.c | 7 +- rootston/input.c | 20 +-- rootston/output.c | 47 ++---- rootston/seat.c | 145 ++++++++--------- types/wlr_input_device.c | 1 - types/wlr_output.c | 1 - 25 files changed, 263 insertions(+), 382 deletions(-) diff --git a/backend/backend.c b/backend/backend.c index 98b94c5c..aec5781e 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -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/drm.c b/backend/drm/drm.c index 516eb405..7af242bc 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -871,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); - wlr_signal_emit_safe(&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); @@ -979,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:; @@ -1014,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); - wlr_signal_emit_safe(&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/headless/backend.c b/backend/headless/backend.c index 7832b00c..703dc8cd 100644 --- a/backend/headless/backend.c +++ b/backend/headless/backend.c @@ -17,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); - wlr_signal_emit_safe(&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) { - wlr_signal_emit_safe(&backend->backend.events.input_add, + wlr_signal_emit_safe(&backend->backend.events.new_input, &input_device->wlr_input_device); } diff --git a/backend/headless/input_device.c b/backend/headless/input_device.c index 68e7ce24..6b2bc4e7 100644 --- a/backend/headless/input_device.c +++ b/backend/headless/input_device.c @@ -12,7 +12,6 @@ static void input_device_destroy(struct wlr_input_device *wlr_dev) { struct wlr_headless_input_device *device = (struct wlr_headless_input_device *)wlr_dev; - wlr_signal_emit_safe(&device->backend->backend.events.input_remove, wlr_dev); free(device); } @@ -89,7 +88,7 @@ struct wlr_input_device *wlr_headless_add_input_device( wl_list_insert(&backend->input_devices, &wlr_device->link); if (backend->started) { - wlr_signal_emit_safe(&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 eab983cc..f31b7d37 100644 --- a/backend/headless/output.c +++ b/backend/headless/output.c @@ -137,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); - wlr_signal_emit_safe(&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 dfbe1d20..5b815a0c 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -107,7 +107,6 @@ 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) { - wlr_signal_emit_safe(&backend->backend.events.input_remove, wlr_dev); wlr_input_device_destroy(wlr_dev); } free(wlr_devices); diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 60088a40..4bcfa539 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -89,7 +89,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend, free(wlr_dev); goto fail; } - wlr_signal_emit_safe(&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, @@ -102,7 +102,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend, free(wlr_dev); goto fail; } - wlr_signal_emit_safe(&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, @@ -115,7 +115,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend, free(wlr_dev); goto fail; } - wlr_signal_emit_safe(&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, @@ -128,7 +128,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend, free(wlr_dev); goto fail; } - wlr_signal_emit_safe(&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, @@ -141,7 +141,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend, free(wlr_dev); goto fail; } - wlr_signal_emit_safe(&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 @@ -179,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) { - 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++) { diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 14f774d0..02738f59 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -11,11 +11,9 @@ 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; }; @@ -32,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); } @@ -118,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) { +static void new_input_reemit(struct wl_listener *listener, void *data) { struct subbackend_state *state = wl_container_of(listener, - state, input_add); - wlr_signal_emit_safe(&state->container->events.input_add, data); + state, new_input); + wlr_signal_emit_safe(&state->container->events.new_input, data); } -static void input_remove_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, input_remove); - wlr_signal_emit_safe(&state->container->events.input_remove, data); -} - -static void output_add_reemit(struct wl_listener *listener, void *data) { - struct subbackend_state *state = wl_container_of(listener, - state, output_add); - wlr_signal_emit_safe(&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); - wlr_signal_emit_safe(&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); } @@ -180,20 +163,14 @@ 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.destroy, &sub->destroy); + sub->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.new_input, &sub->new_input); + sub->new_input.notify = new_input_reemit; - wl_signal_add(&backend->events.input_remove, &sub->input_remove); - sub->input_remove.notify = input_remove_reemit; - - wl_signal_add(&backend->events.output_add, &sub->output_add); - sub->output_add.notify = output_add_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; wlr_signal_emit_safe(&multi->events.backend_add, backend); } diff --git a/backend/wayland/output.c b/backend/wayland/output.c index f2336549..b1cc6836 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -339,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); - wlr_signal_emit_safe(&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/wl_seat.c b/backend/wayland/wl_seat.c index 2018f449..18114119 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -193,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; - wlr_signal_emit_safe(&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); } @@ -257,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; - wlr_signal_emit_safe(&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)) { @@ -281,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; - wlr_signal_emit_safe(&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 2417810a..5608a2ea 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -230,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); - wlr_signal_emit_safe(&x11->backend.events.output_add, output); - wlr_signal_emit_safe(&x11->backend.events.input_add, &x11->keyboard_dev); - wlr_signal_emit_safe(&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); @@ -249,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); - wlr_signal_emit_safe(&backend->events.input_remove, &x11->pointer_dev); - wlr_signal_emit_safe(&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) { diff --git a/examples/support/shared.c b/examples/support/shared.c index 6cfaa6aa..c4f9288d 100644 --- a/examples/support/shared.c +++ b/examples/support/shared.c @@ -56,10 +56,24 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) { } } +static void keyboard_destroy_notify(struct wl_listener *listener, void *data) { + struct keyboard_state *kbstate = wl_container_of(listener, kbstate, destroy); + struct compositor_state *state = kbstate->compositor; + if (state->input_remove_cb) { + state->input_remove_cb(state, kbstate->device); + } + wl_list_remove(&kbstate->link); + wl_list_remove(&kbstate->destroy.link); + wl_list_remove(&kbstate->key.link); + free(kbstate); +} + static void keyboard_add(struct wlr_input_device *device, struct compositor_state *state) { struct keyboard_state *kbstate = calloc(sizeof(struct keyboard_state), 1); kbstate->device = device; kbstate->compositor = state; + kbstate->destroy.notify = keyboard_destroy_notify; + wl_signal_add(&device->events.destroy, &kbstate->destroy); kbstate->key.notify = keyboard_key_notify; wl_signal_add(&device->keyboard->events.key, &kbstate->key); wl_list_insert(&state->keyboards, &kbstate->link); @@ -117,17 +131,34 @@ static void pointer_axis_notify(struct wl_listener *listener, void *data) { } } +static void pointer_destroy_notify(struct wl_listener *listener, void *data) { + struct pointer_state *pstate = wl_container_of(listener, pstate, destroy); + struct compositor_state *state = pstate->compositor; + if (state->input_remove_cb) { + state->input_remove_cb(state, pstate->device); + } + wl_list_remove(&pstate->link); + wl_list_remove(&pstate->destroy.link); + wl_list_remove(&pstate->motion.link); + wl_list_remove(&pstate->motion_absolute.link); + wl_list_remove(&pstate->button.link); + wl_list_remove(&pstate->axis.link); + free(pstate); +} + static void pointer_add(struct wlr_input_device *device, struct compositor_state *state) { struct pointer_state *pstate = calloc(sizeof(struct pointer_state), 1); pstate->device = device; pstate->compositor = state; + pstate->destroy.notify = pointer_destroy_notify; + wl_signal_add(&device->events.destroy, &pstate->destroy); pstate->motion.notify = pointer_motion_notify; - pstate->motion_absolute.notify = pointer_motion_absolute_notify; - pstate->button.notify = pointer_button_notify; - pstate->axis.notify = pointer_axis_notify; wl_signal_add(&device->pointer->events.motion, &pstate->motion); + pstate->motion_absolute.notify = pointer_motion_absolute_notify; wl_signal_add(&device->pointer->events.motion_absolute, &pstate->motion_absolute); + pstate->button.notify = pointer_button_notify; wl_signal_add(&device->pointer->events.button, &pstate->button); + pstate->axis.notify = pointer_axis_notify; wl_signal_add(&device->pointer->events.axis, &pstate->axis); wl_list_insert(&state->pointers, &pstate->link); } @@ -166,17 +197,34 @@ static void touch_cancel_notify(struct wl_listener *listener, void *data) { } } +static void touch_destroy_notify(struct wl_listener *listener, void *data) { + struct touch_state *tstate = wl_container_of(listener, tstate, destroy); + struct compositor_state *state = tstate->compositor; + if (state->input_remove_cb) { + state->input_remove_cb(state, tstate->device); + } + wl_list_remove(&tstate->link); + wl_list_remove(&tstate->destroy.link); + wl_list_remove(&tstate->down.link); + wl_list_remove(&tstate->motion.link); + wl_list_remove(&tstate->up.link); + wl_list_remove(&tstate->cancel.link); + free(tstate); +} + static void touch_add(struct wlr_input_device *device, struct compositor_state *state) { struct touch_state *tstate = calloc(sizeof(struct touch_state), 1); tstate->device = device; tstate->compositor = state; + tstate->destroy.notify = touch_destroy_notify; + wl_signal_add(&device->events.destroy, &tstate->destroy); tstate->down.notify = touch_down_notify; - tstate->motion.notify = touch_motion_notify; - tstate->up.notify = touch_up_notify; - tstate->cancel.notify = touch_cancel_notify; wl_signal_add(&device->touch->events.down, &tstate->down); + tstate->motion.notify = touch_motion_notify; wl_signal_add(&device->touch->events.motion, &tstate->motion); + tstate->up.notify = touch_up_notify; wl_signal_add(&device->touch->events.up, &tstate->up); + tstate->cancel.notify = touch_cancel_notify; wl_signal_add(&device->touch->events.cancel, &tstate->cancel); wl_list_insert(&state->touch, &tstate->link); } @@ -205,18 +253,35 @@ static void tablet_tool_button_notify(struct wl_listener *listener, void *data) } } +static void tablet_tool_destroy_notify(struct wl_listener *listener, void *data) { + struct tablet_tool_state *tstate = wl_container_of(listener, tstate, destroy); + struct compositor_state *state = tstate->compositor; + if (state->input_remove_cb) { + state->input_remove_cb(state, tstate->device); + } + wl_list_remove(&tstate->link); + wl_list_remove(&tstate->destroy.link); + wl_list_remove(&tstate->axis.link); + wl_list_remove(&tstate->proximity.link); + //wl_list_remove(&tstate->tip.link); + wl_list_remove(&tstate->button.link); + free(tstate); +} + static void tablet_tool_add(struct wlr_input_device *device, struct compositor_state *state) { struct tablet_tool_state *tstate = calloc(sizeof(struct tablet_tool_state), 1); tstate->device = device; tstate->compositor = state; + tstate->destroy.notify = tablet_tool_destroy_notify; + wl_signal_add(&device->events.destroy, &tstate->destroy); tstate->axis.notify = tablet_tool_axis_notify; - tstate->proximity.notify = tablet_tool_proximity_notify; - //tstate->tip.notify = tablet_tool_tip_notify; - tstate->button.notify = tablet_tool_button_notify; wl_signal_add(&device->tablet_tool->events.axis, &tstate->axis); + tstate->proximity.notify = tablet_tool_proximity_notify; wl_signal_add(&device->tablet_tool->events.proximity, &tstate->proximity); + //tstate->tip.notify = tablet_tool_tip_notify; //wl_signal_add(&device->tablet_tool->events.tip, &tstate->tip); + tstate->button.notify = tablet_tool_button_notify; wl_signal_add(&device->tablet_tool->events.button, &tstate->button); wl_list_insert(&state->tablet_tools, &tstate->link); } @@ -229,19 +294,33 @@ static void tablet_pad_button_notify(struct wl_listener *listener, void *data) { } } +static void tablet_pad_destroy_notify(struct wl_listener *listener, void *data) { + struct tablet_pad_state *pstate = wl_container_of(listener, pstate, destroy); + struct compositor_state *state = pstate->compositor; + if (state->input_remove_cb) { + state->input_remove_cb(state, pstate->device); + } + wl_list_remove(&pstate->link); + wl_list_remove(&pstate->destroy.link); + wl_list_remove(&pstate->button.link); + free(pstate); +} + static void tablet_pad_add(struct wlr_input_device *device, struct compositor_state *state) { struct tablet_pad_state *pstate = calloc(sizeof(struct tablet_pad_state), 1); pstate->device = device; pstate->compositor = state; + pstate->destroy.notify = tablet_pad_destroy_notify; + wl_signal_add(&device->events.destroy, &pstate->destroy); pstate->button.notify = tablet_pad_button_notify; wl_signal_add(&device->tablet_pad->events.button, &pstate->button); wl_list_insert(&state->tablet_pads, &pstate->link); } -static void input_add_notify(struct wl_listener *listener, void *data) { +static void new_input_notify(struct wl_listener *listener, void *data) { struct wlr_input_device *device = data; - struct compositor_state *state = wl_container_of(listener, state, input_add); + struct compositor_state *state = wl_container_of(listener, state, new_input); switch (device->type) { case WLR_INPUT_DEVICE_KEYBOARD: keyboard_add(device, state); @@ -267,123 +346,6 @@ static void input_add_notify(struct wl_listener *listener, void *data) { } } -static void keyboard_remove(struct wlr_input_device *device, struct compositor_state *state) { - struct keyboard_state *kbstate = NULL, *_kbstate; - wl_list_for_each(_kbstate, &state->keyboards, link) { - if (_kbstate->device == device) { - kbstate = _kbstate; - break; - } - } - if (!kbstate) { - return; - } - wl_list_remove(&kbstate->link); - wl_list_remove(&kbstate->key.link); - free(kbstate); -} - -static void pointer_remove(struct wlr_input_device *device, struct compositor_state *state) { - struct pointer_state *pstate = NULL, *_pstate; - wl_list_for_each(_pstate, &state->pointers, link) { - if (_pstate->device == device) { - pstate = _pstate; - break; - } - } - if (!pstate) { - return; - } - wl_list_remove(&pstate->link); - wl_list_remove(&pstate->motion.link); - wl_list_remove(&pstate->motion_absolute.link); - wl_list_remove(&pstate->button.link); - wl_list_remove(&pstate->axis.link); - free(pstate); -} - -static void touch_remove(struct wlr_input_device *device, struct compositor_state *state) { - struct touch_state *tstate = NULL, *_tstate; - wl_list_for_each(_tstate, &state->touch, link) { - if (_tstate->device == device) { - tstate = _tstate; - break; - } - } - if (!tstate) { - return; - } - wl_list_remove(&tstate->link); - wl_list_remove(&tstate->down.link); - wl_list_remove(&tstate->motion.link); - wl_list_remove(&tstate->up.link); - wl_list_remove(&tstate->cancel.link); - free(tstate); -} - -static void tablet_tool_remove(struct wlr_input_device *device, struct compositor_state *state) { - struct tablet_tool_state *tstate = NULL, *_tstate; - wl_list_for_each(_tstate, &state->tablet_tools, link) { - if (_tstate->device == device) { - tstate = _tstate; - break; - } - } - if (!tstate) { - return; - } - wl_list_remove(&tstate->link); - wl_list_remove(&tstate->axis.link); - wl_list_remove(&tstate->proximity.link); - //wl_list_remove(&tstate->tip.link); - wl_list_remove(&tstate->button.link); - free(tstate); -} - -static void tablet_pad_remove(struct wlr_input_device *device, struct compositor_state *state) { - struct tablet_pad_state *pstate = NULL, *_pstate; - wl_list_for_each(_pstate, &state->tablet_pads, link) { - if (_pstate->device ==device) { - pstate = _pstate; - break; - } - } - if (!pstate) { - return; - } - wl_list_remove(&pstate->button.link); - free(pstate); -} - -static void input_remove_notify(struct wl_listener *listener, void *data) { - struct wlr_input_device *device = data; - struct compositor_state *state = wl_container_of(listener, state, input_remove); - - if (state->input_remove_cb) { - state->input_remove_cb(state, device); - } - - switch (device->type) { - case WLR_INPUT_DEVICE_KEYBOARD: - keyboard_remove(device, state); - break; - case WLR_INPUT_DEVICE_POINTER: - pointer_remove(device, state); - break; - case WLR_INPUT_DEVICE_TOUCH: - touch_remove(device, state); - break; - case WLR_INPUT_DEVICE_TABLET_TOOL: - tablet_tool_remove(device, state); - break; - case WLR_INPUT_DEVICE_TABLET_PAD: - tablet_pad_remove(device, state); - break; - default: - break; - } -} - static void output_frame_notify(struct wl_listener *listener, void *data) { struct output_state *output = wl_container_of(listener, output, frame); struct compositor_state *compositor = output->compositor; @@ -407,9 +369,21 @@ static void output_resolution_notify(struct wl_listener *listener, void *data) { } } -static void output_add_notify(struct wl_listener *listener, void *data) { +static void output_destroy_notify(struct wl_listener *listener, void *data) { + struct output_state *ostate = wl_container_of(listener, ostate, destroy); + struct compositor_state *state = ostate->compositor; + if (state->output_remove_cb) { + state->output_remove_cb(ostate); + } + wl_list_remove(&ostate->link); + wl_list_remove(&ostate->frame.link); + wl_list_remove(&ostate->resolution.link); + free(ostate); +} + +static void new_output_notify(struct wl_listener *listener, void *data) { struct wlr_output *output = data; - struct compositor_state *state = wl_container_of(listener, state, output_add); + struct compositor_state *state = wl_container_of(listener, state, new_output); wlr_log(L_DEBUG, "Output '%s' added", output->name); wlr_log(L_DEBUG, "%s %s %"PRId32"mm x %"PRId32"mm", output->make, output->model, output->phys_width, output->phys_height); @@ -422,9 +396,11 @@ static void output_add_notify(struct wl_listener *listener, void *data) { clock_gettime(CLOCK_MONOTONIC, &ostate->last_frame); ostate->output = output; ostate->compositor = state; + ostate->destroy.notify = output_destroy_notify; + wl_signal_add(&output->events.destroy, &ostate->destroy); ostate->frame.notify = output_frame_notify; - ostate->resolution.notify = output_resolution_notify; wl_signal_add(&output->events.frame, &ostate->frame); + ostate->resolution.notify = output_resolution_notify; wl_signal_add(&output->events.mode, &ostate->resolution); wl_list_insert(&state->outputs, &ostate->link); if (state->output_add_cb) { @@ -432,28 +408,6 @@ static void output_add_notify(struct wl_listener *listener, void *data) { } } -static void output_remove_notify(struct wl_listener *listener, void *data) { - struct wlr_output *output = data; - struct compositor_state *state = wl_container_of(listener, state, output_remove); - struct output_state *ostate = NULL, *_ostate; - wl_list_for_each(_ostate, &state->outputs, link) { - if (_ostate->output == output) { - ostate = _ostate; - break; - } - } - if (!ostate) { - return; // We are unfamiliar with this output - } - if (state->output_remove_cb) { - state->output_remove_cb(ostate); - } - wl_list_remove(&ostate->link); - wl_list_remove(&ostate->frame.link); - wl_list_remove(&ostate->resolution.link); - free(ostate); -} - void compositor_init(struct compositor_state *state) { state->display = wl_display_create(); state->event_loop = wl_display_get_event_loop(state->display); @@ -463,23 +417,19 @@ void compositor_init(struct compositor_state *state) { wl_list_init(&state->touch); wl_list_init(&state->tablet_tools); wl_list_init(&state->tablet_pads); - state->input_add.notify = input_add_notify; - state->input_remove.notify = input_remove_notify; - wl_list_init(&state->outputs); - state->output_add.notify = output_add_notify; - state->output_remove.notify = output_remove_notify; struct wlr_backend *wlr = wlr_backend_autocreate(state->display); if (!wlr) { exit(1); } - wl_signal_add(&wlr->events.input_add, &state->input_add); - wl_signal_add(&wlr->events.input_remove, &state->input_remove); - wl_signal_add(&wlr->events.output_add, &state->output_add); - wl_signal_add(&wlr->events.output_remove, &state->output_remove); state->backend = wlr; + wl_signal_add(&wlr->events.new_input, &state->new_input); + state->new_input.notify = new_input_notify; + wl_signal_add(&wlr->events.new_output, &state->new_output); + state->new_output.notify = new_output_notify; + clock_gettime(CLOCK_MONOTONIC, &state->last_frame); const char *socket = wl_display_add_socket_auto(state->display); diff --git a/examples/support/shared.h b/examples/support/shared.h index 014b709e..8cdea301 100644 --- a/examples/support/shared.h +++ b/examples/support/shared.h @@ -15,6 +15,7 @@ struct output_state { struct compositor_state *compositor; struct wlr_output *output; + struct wl_listener destroy; struct wl_listener frame; struct wl_listener resolution; struct timespec last_frame; @@ -25,6 +26,7 @@ struct output_state { struct keyboard_state { struct compositor_state *compositor; struct wlr_input_device *device; + struct wl_listener destroy; struct wl_listener key; struct wl_list link; void *data; @@ -33,6 +35,7 @@ struct keyboard_state { struct pointer_state { struct compositor_state *compositor; struct wlr_input_device *device; + struct wl_listener destroy; struct wl_listener motion; struct wl_listener motion_absolute; struct wl_listener button; @@ -44,6 +47,7 @@ struct pointer_state { struct touch_state { struct compositor_state *compositor; struct wlr_input_device *device; + struct wl_listener destroy; struct wl_listener down; struct wl_listener up; struct wl_listener motion; @@ -55,6 +59,7 @@ struct touch_state { struct tablet_tool_state { struct compositor_state *compositor; struct wlr_input_device *device; + struct wl_listener destroy; struct wl_listener axis; struct wl_listener proximity; struct wl_listener tip; @@ -66,6 +71,7 @@ struct tablet_tool_state { struct tablet_pad_state { struct compositor_state *compositor; struct wlr_input_device *device; + struct wl_listener destroy; struct wl_listener button; struct wl_list link; void *data; @@ -122,12 +128,10 @@ struct compositor_state { struct wl_list touch; struct wl_list tablet_tools; struct wl_list tablet_pads; - struct wl_listener input_add; - struct wl_listener input_remove; + struct wl_listener new_input; struct timespec last_frame; - struct wl_listener output_add; - struct wl_listener output_remove; + struct wl_listener new_output; struct wl_list outputs; void *data; diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index 1232121a..a2121701 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -39,8 +39,7 @@ struct roots_desktop { struct wlr_primary_selection_device_manager *primary_selection_device_manager; struct wlr_idle *idle; - struct wl_listener output_add; - struct wl_listener output_remove; + struct wl_listener new_output; struct wl_listener layout_change; struct wl_listener xdg_shell_v6_surface; struct wl_listener wl_shell_surface; diff --git a/include/rootston/input.h b/include/rootston/input.h index 726dda24..d05cbb0a 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -13,8 +13,7 @@ struct roots_input { struct roots_config *config; struct roots_server *server; - struct wl_listener input_add; - struct wl_listener input_remove; + struct wl_listener new_input; struct wl_list seats; }; diff --git a/include/rootston/keyboard.h b/include/rootston/keyboard.h index 39650d7c..4548f4a7 100644 --- a/include/rootston/keyboard.h +++ b/include/rootston/keyboard.h @@ -13,6 +13,7 @@ struct roots_keyboard { struct roots_keyboard_config *config; struct wl_list link; + struct wl_listener device_destroy; struct wl_listener keyboard_key; struct wl_listener keyboard_modifiers; diff --git a/include/rootston/output.h b/include/rootston/output.h index 7f42904f..8396e7c5 100644 --- a/include/rootston/output.h +++ b/include/rootston/output.h @@ -18,11 +18,11 @@ struct roots_output { struct timespec last_frame; struct wlr_output_damage *damage; + struct wl_listener destroy; struct wl_listener frame; }; -void output_add_notify(struct wl_listener *listener, void *data); -void output_remove_notify(struct wl_listener *listener, void *data); +void handle_new_output(struct wl_listener *listener, void *data); struct roots_view; struct roots_drag_icon; diff --git a/include/rootston/seat.h b/include/rootston/seat.h index 0047522c..cd819076 100644 --- a/include/rootston/seat.h +++ b/include/rootston/seat.h @@ -56,18 +56,21 @@ struct roots_drag_icon { struct roots_pointer { struct roots_seat *seat; struct wlr_input_device *device; + struct wl_listener device_destroy; struct wl_list link; }; struct roots_touch { struct roots_seat *seat; struct wlr_input_device *device; + struct wl_listener device_destroy; struct wl_list link; }; struct roots_tablet_tool { struct roots_seat *seat; struct wlr_input_device *device; + struct wl_listener device_destroy; struct wl_listener axis; struct wl_listener proximity; struct wl_listener tip; diff --git a/include/wlr/backend.h b/include/wlr/backend.h index d4b1f773..00dc9fdc 100644 --- a/include/wlr/backend.h +++ b/include/wlr/backend.h @@ -12,10 +12,8 @@ struct wlr_backend { struct { struct wl_signal destroy; - struct wl_signal input_add; - struct wl_signal input_remove; - struct wl_signal output_add; - struct wl_signal output_remove; + struct wl_signal new_input; + struct wl_signal new_output; } events; }; diff --git a/rootston/desktop.c b/rootston/desktop.c index e9d66d5c..753a85e5 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -622,11 +622,8 @@ struct roots_desktop *desktop_create(struct roots_server *server, wl_list_init(&desktop->views); wl_list_init(&desktop->outputs); - desktop->output_add.notify = output_add_notify; - wl_signal_add(&server->backend->events.output_add, &desktop->output_add); - desktop->output_remove.notify = output_remove_notify; - wl_signal_add(&server->backend->events.output_remove, - &desktop->output_remove); + desktop->new_output.notify = handle_new_output; + wl_signal_add(&server->backend->events.new_output, &desktop->new_output); desktop->server = server; desktop->config = config; diff --git a/rootston/input.c b/rootston/input.c index 74ce59d0..a0da2531 100644 --- a/rootston/input.c +++ b/rootston/input.c @@ -40,9 +40,9 @@ struct roots_seat *input_get_seat(struct roots_input *input, char *name) { return seat; } -static void input_add_notify(struct wl_listener *listener, void *data) { +static void handle_new_input(struct wl_listener *listener, void *data) { struct wlr_input_device *device = data; - struct roots_input *input = wl_container_of(listener, input, input_add); + struct roots_input *input = wl_container_of(listener, input, new_input); char *seat_name = ROOTS_CONFIG_DEFAULT_SEAT_NAME; struct roots_device_config *dc = @@ -74,16 +74,6 @@ static void input_add_notify(struct wl_listener *listener, void *data) { } } -static void input_remove_notify(struct wl_listener *listener, void *data) { - struct wlr_input_device *device = data; - struct roots_input *input = wl_container_of(listener, input, input_remove); - - struct roots_seat *seat; - wl_list_for_each(seat, &input->seats, link) { - roots_seat_remove_device(seat, device); - } -} - struct roots_input *input_create(struct roots_server *server, struct roots_config *config) { wlr_log(L_DEBUG, "Initializing roots input"); @@ -99,10 +89,8 @@ struct roots_input *input_create(struct roots_server *server, wl_list_init(&input->seats); - input->input_add.notify = input_add_notify; - wl_signal_add(&server->backend->events.input_add, &input->input_add); - input->input_remove.notify = input_remove_notify; - wl_signal_add(&server->backend->events.input_remove, &input->input_remove); + input->new_input.notify = handle_new_input; + wl_signal_add(&server->backend->events.new_input, &input->new_input); return input; } diff --git a/rootston/output.c b/rootston/output.c index fce875da..bd2ec18d 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -644,9 +644,22 @@ static void set_mode(struct wlr_output *output, } } -void output_add_notify(struct wl_listener *listener, void *data) { +static void output_handle_destroy(struct wl_listener *listener, void *data) { + struct roots_output *output = wl_container_of(listener, output, destroy); + + // TODO: cursor + //example_config_configure_cursor(sample->config, sample->cursor, + // sample->compositor); + + wl_list_remove(&output->link); + wl_list_remove(&output->destroy.link); + wl_list_remove(&output->frame.link); + free(output); +} + +void handle_new_output(struct wl_listener *listener, void *data) { struct roots_desktop *desktop = wl_container_of(listener, desktop, - output_add); + new_output); struct wlr_output *wlr_output = data; struct roots_input *input = desktop->server->input; struct roots_config *config = desktop->config; @@ -670,6 +683,8 @@ void output_add_notify(struct wl_listener *listener, void *data) { output->damage = wlr_output_damage_create(wlr_output); + output->destroy.notify = output_handle_destroy; + wl_signal_add(&wlr_output->events.destroy, &output->destroy); output->frame.notify = output_damage_handle_frame; wl_signal_add(&output->damage->events.frame, &output->frame); @@ -699,31 +714,3 @@ void output_add_notify(struct wl_listener *listener, void *data) { output_damage_whole(output); } - -void output_remove_notify(struct wl_listener *listener, void *data) { - struct wlr_output *wlr_output = data; - struct roots_desktop *desktop = - wl_container_of(listener, desktop, output_remove); - - struct roots_output *output = NULL, *_output; - wl_list_for_each(_output, &desktop->outputs, link) { - if (_output->wlr_output == wlr_output) { - output = _output; - break; - } - } - if (!output) { - return; // We are unfamiliar with this output - } - - wlr_output_layout_remove(desktop->layout, output->wlr_output); - - // TODO: cursor - //example_config_configure_cursor(sample->config, sample->cursor, - // sample->compositor); - - wl_list_remove(&output->link); - wl_list_remove(&output->frame.link); - wlr_output_damage_destroy(output->damage); - free(output); -} diff --git a/rootston/seat.c b/rootston/seat.c index 45e42d7d..0c9867ec 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -404,6 +404,17 @@ static void seat_update_capabilities(struct roots_seat *seat) { } } +static void handle_keyboard_destroy(struct wl_listener *listener, void *data) { + struct roots_keyboard *keyboard = + wl_container_of(listener, keyboard, device_destroy); + struct roots_seat *seat = keyboard->seat; + roots_keyboard_destroy(keyboard); + wl_list_remove(&keyboard->device_destroy.link); + wl_list_remove(&keyboard->keyboard_key.link); + wl_list_remove(&keyboard->keyboard_modifiers.link); + seat_update_capabilities(seat); +} + static void seat_add_keyboard(struct roots_seat *seat, struct wlr_input_device *device) { assert(device->type == WLR_INPUT_DEVICE_KEYBOARD); @@ -418,10 +429,11 @@ static void seat_add_keyboard(struct roots_seat *seat, wl_list_insert(&seat->keyboards, &keyboard->link); + keyboard->device_destroy.notify = handle_keyboard_destroy; + wl_signal_add(&keyboard->device->events.destroy, &keyboard->device_destroy); keyboard->keyboard_key.notify = handle_keyboard_key; wl_signal_add(&keyboard->device->keyboard->events.key, &keyboard->keyboard_key); - keyboard->keyboard_modifiers.notify = handle_keyboard_modifiers; wl_signal_add(&keyboard->device->keyboard->events.modifiers, &keyboard->keyboard_modifiers); @@ -429,6 +441,19 @@ static void seat_add_keyboard(struct roots_seat *seat, wlr_seat_set_keyboard(seat->seat, device); } +static void handle_pointer_destroy(struct wl_listener *listener, void *data) { + struct roots_pointer *pointer = + wl_container_of(listener, pointer, device_destroy); + struct roots_seat *seat = pointer->seat; + + wl_list_remove(&pointer->link); + wlr_cursor_detach_input_device(seat->cursor->cursor, pointer->device); + wl_list_remove(&pointer->device_destroy.link); + free(pointer); + + seat_update_capabilities(seat); +} + static void seat_add_pointer(struct roots_seat *seat, struct wlr_input_device *device) { struct roots_pointer *pointer = calloc(sizeof(struct roots_pointer), 1); @@ -441,10 +466,27 @@ static void seat_add_pointer(struct roots_seat *seat, pointer->device = device; pointer->seat = seat; wl_list_insert(&seat->pointers, &pointer->link); + + pointer->device_destroy.notify = handle_pointer_destroy; + wl_signal_add(&pointer->device->events.destroy, &pointer->device_destroy); + wlr_cursor_attach_input_device(seat->cursor->cursor, device); roots_seat_configure_cursor(seat); } +static void handle_touch_destroy(struct wl_listener *listener, void *data) { + struct roots_pointer *touch = + wl_container_of(listener, touch, device_destroy); + struct roots_seat *seat = touch->seat; + + wl_list_remove(&touch->link); + wlr_cursor_detach_input_device(seat->cursor->cursor, touch->device); + wl_list_remove(&touch->device_destroy.link); + free(touch); + + seat_update_capabilities(seat); +} + static void seat_add_touch(struct roots_seat *seat, struct wlr_input_device *device) { struct roots_touch *touch = calloc(sizeof(struct roots_touch), 1); @@ -457,6 +499,10 @@ static void seat_add_touch(struct roots_seat *seat, touch->device = device; touch->seat = seat; wl_list_insert(&seat->touch, &touch->link); + + touch->device_destroy.notify = handle_touch_destroy; + wl_signal_add(&touch->device->events.destroy, &touch->device_destroy); + wlr_cursor_attach_input_device(seat->cursor->cursor, device); roots_seat_configure_cursor(seat); } @@ -466,6 +512,20 @@ static void seat_add_tablet_pad(struct roots_seat *seat, // TODO } +static void handle_tablet_tool_destroy(struct wl_listener *listener, + void *data) { + struct roots_pointer *tablet_tool = + wl_container_of(listener, tablet_tool, device_destroy); + struct roots_seat *seat = tablet_tool->seat; + + wl_list_remove(&tablet_tool->link); + wlr_cursor_detach_input_device(seat->cursor->cursor, tablet_tool->device); + wl_list_remove(&tablet_tool->device_destroy.link); + free(tablet_tool); + + seat_update_capabilities(seat); +} + static void seat_add_tablet_tool(struct roots_seat *seat, struct wlr_input_device *device) { struct roots_tablet_tool *tablet_tool = @@ -479,6 +539,11 @@ static void seat_add_tablet_tool(struct roots_seat *seat, tablet_tool->device = device; tablet_tool->seat = seat; wl_list_insert(&seat->tablet_tools, &tablet_tool->link); + + tablet_tool->device_destroy.notify = handle_tablet_tool_destroy; + wl_signal_add(&tablet_tool->device->events.destroy, + &tablet_tool->device_destroy); + wlr_cursor_attach_input_device(seat->cursor->cursor, device); roots_seat_configure_cursor(seat); } @@ -506,84 +571,6 @@ void roots_seat_add_device(struct roots_seat *seat, seat_update_capabilities(seat); } -static void seat_remove_keyboard(struct roots_seat *seat, - struct wlr_input_device *device) { - struct roots_keyboard *keyboard; - wl_list_for_each(keyboard, &seat->keyboards, link) { - if (keyboard->device == device) { - roots_keyboard_destroy(keyboard); - return; - } - } -} - -static void seat_remove_pointer(struct roots_seat *seat, - struct wlr_input_device *device) { - struct roots_pointer *pointer; - wl_list_for_each(pointer, &seat->pointers, link) { - if (pointer->device == device) { - wl_list_remove(&pointer->link); - wlr_cursor_detach_input_device(seat->cursor->cursor, device); - free(pointer); - return; - } - } -} - -static void seat_remove_touch(struct roots_seat *seat, - struct wlr_input_device *device) { - struct roots_touch *touch; - wl_list_for_each(touch, &seat->touch, link) { - if (touch->device == device) { - wl_list_remove(&touch->link); - wlr_cursor_detach_input_device(seat->cursor->cursor, device); - free(touch); - return; - } - } -} - -static void seat_remove_tablet_pad(struct roots_seat *seat, - struct wlr_input_device *device) { - // TODO -} - -static void seat_remove_tablet_tool(struct roots_seat *seat, - struct wlr_input_device *device) { - struct roots_tablet_tool *tablet_tool; - wl_list_for_each(tablet_tool, &seat->tablet_tools, link) { - if (tablet_tool->device == device) { - wl_list_remove(&tablet_tool->link); - wlr_cursor_detach_input_device(seat->cursor->cursor, device); - free(tablet_tool); - return; - } - } -} - -void roots_seat_remove_device(struct roots_seat *seat, - struct wlr_input_device *device) { - switch (device->type) { - case WLR_INPUT_DEVICE_KEYBOARD: - seat_remove_keyboard(seat, device); - break; - case WLR_INPUT_DEVICE_POINTER: - seat_remove_pointer(seat, device); - break; - case WLR_INPUT_DEVICE_TOUCH: - seat_remove_touch(seat, device); - break; - case WLR_INPUT_DEVICE_TABLET_PAD: - seat_remove_tablet_pad(seat, device); - break; - case WLR_INPUT_DEVICE_TABLET_TOOL: - seat_remove_tablet_tool(seat, device); - break; - } - - seat_update_capabilities(seat); -} - void roots_seat_configure_xcursor(struct roots_seat *seat) { const char *cursor_theme = NULL; struct roots_cursor_config *cc = diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index 468b93f9..f88b7197 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -59,7 +59,6 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) { if (dev->impl && dev->impl->destroy) { dev->impl->destroy(dev); } else { - wl_list_remove(&dev->events.destroy.listener_list); free(dev); } } diff --git a/types/wlr_output.c b/types/wlr_output.c index bf3ed6ae..bac8b7ce 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -285,7 +285,6 @@ void wlr_output_destroy(struct wlr_output *output) { wlr_output_destroy_global(output); wlr_output_set_fullscreen_surface(output, NULL); - wlr_signal_emit_safe(&output->backend->events.output_remove, output); wlr_signal_emit_safe(&output->events.destroy, output); struct wlr_output_mode *mode, *tmp_mode; From 36ead80cd19b4c1773b894750ecf7fcec63f9b9b Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 12 Feb 2018 19:45:58 +0100 Subject: [PATCH 3/4] Make wlr_signal_emit_safe private --- backend/drm/backend.c | 2 +- backend/drm/drm.c | 2 +- backend/headless/backend.c | 2 +- backend/headless/input_device.c | 2 +- backend/headless/output.c | 2 +- backend/libinput/backend.c | 2 +- backend/libinput/events.c | 2 +- backend/libinput/pointer.c | 2 +- backend/libinput/tablet_pad.c | 2 +- backend/libinput/tablet_tool.c | 2 +- backend/libinput/touch.c | 2 +- backend/multi/backend.c | 2 +- backend/session/direct-freebsd.c | 2 +- backend/session/direct.c | 2 +- backend/session/logind.c | 2 +- backend/session/session.c | 2 +- backend/wayland/backend.c | 2 +- backend/wayland/output.c | 2 +- backend/wayland/wl_seat.c | 2 +- backend/x11/backend.c | 2 +- include/{wlr => }/util/signal.h | 0 render/gles2/texture.c | 2 +- rootston/desktop.c | 3 +-- types/wlr_compositor.c | 2 +- types/wlr_cursor.c | 2 +- types/wlr_data_device.c | 2 +- types/wlr_gamma_control.c | 2 +- types/wlr_idle.c | 2 +- types/wlr_input_device.c | 2 +- types/wlr_keyboard.c | 2 +- types/wlr_output.c | 2 +- types/wlr_output_damage.c | 2 +- types/wlr_output_layout.c | 2 +- types/wlr_primary_selection.c | 2 +- types/wlr_seat.c | 2 +- types/wlr_server_decoration.c | 2 +- types/wlr_surface.c | 2 +- types/wlr_wl_shell.c | 2 +- types/wlr_xdg_shell_v6.c | 2 +- util/signal.c | 2 +- xwayland/xwayland.c | 2 +- xwayland/xwm.c | 2 +- 42 files changed, 41 insertions(+), 42 deletions(-) rename include/{wlr => }/util/signal.h (100%) diff --git a/backend/drm/backend.c b/backend/drm/backend.c index 4d09e078..682e8c85 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include "util/signal.h" #include #include "backend/drm/drm.h" diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 7af242bc..5189ec90 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include "util/signal.h" #include #include #include diff --git a/backend/headless/backend.c b/backend/headless/backend.c index 703dc8cd..a79e4af8 100644 --- a/backend/headless/backend.c +++ b/backend/headless/backend.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include "util/signal.h" #include #include #include "backend/headless.h" diff --git a/backend/headless/input_device.c b/backend/headless/input_device.c index 6b2bc4e7..5d7ca34b 100644 --- a/backend/headless/input_device.c +++ b/backend/headless/input_device.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/headless.h" static void input_device_destroy(struct wlr_input_device *wlr_dev) { diff --git a/backend/headless/output.c b/backend/headless/output.c index f31b7d37..63f0b6b4 100644 --- a/backend/headless/output.c +++ b/backend/headless/output.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/headless.h" static EGLSurface egl_create_surface(struct wlr_egl *egl, unsigned int width, diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c index 5b815a0c..1ec73009 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/libinput.h" static int wlr_libinput_open_restricted(const char *path, diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 4bcfa539..248b8213 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/libinput.h" struct wlr_input_device *get_appropriate_device( diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c index f80f4f84..560e95b5 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/libinput.h" struct wlr_pointer *wlr_libinput_pointer_create( diff --git a/backend/libinput/tablet_pad.c b/backend/libinput/tablet_pad.c index 54315581..e8ffc6dd 100644 --- a/backend/libinput/tablet_pad.c +++ b/backend/libinput/tablet_pad.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/libinput.h" struct wlr_tablet_pad *wlr_libinput_tablet_pad_create( diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index 2f28540b..0f2ea70a 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/libinput.h" struct wlr_tablet_tool *wlr_libinput_tablet_tool_create( diff --git a/backend/libinput/touch.c b/backend/libinput/touch.c index d496d792..fb2b8e3f 100644 --- a/backend/libinput/touch.c +++ b/backend/libinput/touch.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/libinput.h" struct wlr_touch *wlr_libinput_touch_create( diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 02738f59..1005e6b7 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/multi.h" #include "backend/drm/drm.h" diff --git a/backend/session/direct-freebsd.c b/backend/session/direct-freebsd.c index fe4ff653..ceaae2be 100644 --- a/backend/session/direct-freebsd.c +++ b/backend/session/direct-freebsd.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/session/direct-ipc.h" const struct session_impl session_direct; diff --git a/backend/session/direct.c b/backend/session/direct.c index 245683ea..1f60ed23 100644 --- a/backend/session/direct.c +++ b/backend/session/direct.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/session/direct-ipc.h" enum { DRM_MAJOR = 226 }; diff --git a/backend/session/logind.c b/backend/session/logind.c index f6150817..b2206e15 100644 --- a/backend/session/logind.c +++ b/backend/session/logind.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include "util/signal.h" #ifdef WLR_HAS_SYSTEMD #include diff --git a/backend/session/session.c b/backend/session/session.c index 4b81e230..ac55a191 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include "util/signal.h" extern const struct session_impl session_logind; extern const struct session_impl session_direct; diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index 2907057c..60c8ede9 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/wayland.h" #include "xdg-shell-unstable-v6-client-protocol.h" diff --git a/backend/wayland/output.c b/backend/wayland/output.c index b1cc6836..fed4c63a 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/wayland.h" #include "xdg-shell-unstable-v6-client-protocol.h" diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index 18114119..f6328106 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/wayland.h" static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer, diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 5608a2ea..2715b366 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include "util/signal.h" #include "backend/x11.h" static struct wlr_backend_impl backend_impl; diff --git a/include/wlr/util/signal.h b/include/util/signal.h similarity index 100% rename from include/wlr/util/signal.h rename to include/util/signal.h diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 54cee627..a594f23e 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include "util/signal.h" #include "render/gles2.h" static struct pixel_format external_pixel_format = { diff --git a/rootston/desktop.c b/rootston/desktop.c index 753a85e5..68da45e0 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -16,7 +16,6 @@ #include #include #include -#include #include "rootston/server.h" #include "rootston/seat.h" #include "rootston/xcursor.h" @@ -384,7 +383,7 @@ struct roots_subsurface *subsurface_create(struct roots_view *view, void view_finish(struct roots_view *view) { view_damage_whole(view); - wlr_signal_emit_safe(&view->events.destroy, view); + wl_signal_emit(&view->events.destroy, view); wl_list_remove(&view->new_subsurface.link); diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c index bab41b85..bd56b0fb 100644 --- a/types/wlr_compositor.c +++ b/types/wlr_compositor.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include "util/signal.h" #include #include #include diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index 564ead46..4f3d8727 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include "util/signal.h" #include #include #include diff --git a/types/wlr_data_device.c b/types/wlr_data_device.c index ae3219f1..7153dd53 100644 --- a/types/wlr_data_device.c +++ b/types/wlr_data_device.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include "util/signal.h" #include #include diff --git a/types/wlr_gamma_control.c b/types/wlr_gamma_control.c index f7644230..214dfd21 100644 --- a/types/wlr_gamma_control.c +++ b/types/wlr_gamma_control.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include "util/signal.h" #include "gamma-control-protocol.h" static void resource_destroy(struct wl_client *client, diff --git a/types/wlr_idle.c b/types/wlr_idle.c index b30bb9d7..1976004f 100644 --- a/types/wlr_idle.c +++ b/types/wlr_idle.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include "util/signal.h" #include "idle-protocol.h" static void idle_timeout_destroy(struct wlr_idle_timeout *timer) { diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index f88b7197..372b3a7b 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include "util/signal.h" void wlr_input_device_init(struct wlr_input_device *dev, enum wlr_input_device_type type, diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c index 9fac1843..6f09d599 100644 --- a/types/wlr_keyboard.c +++ b/types/wlr_keyboard.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include "util/signal.h" int os_create_anonymous_file(off_t size); diff --git a/types/wlr_output.c b/types/wlr_output.c index bac8b7ce..7dcf4c78 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include "util/signal.h" static void wl_output_send_to_resource(struct wl_resource *resource) { assert(resource); diff --git a/types/wlr_output_damage.c b/types/wlr_output_damage.c index 2c6e24f0..c231a900 100644 --- a/types/wlr_output_damage.c +++ b/types/wlr_output_damage.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include "util/signal.h" #include #include #include diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index ea8581b3..ea7b81c5 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include "util/signal.h" #include #include #include diff --git a/types/wlr_primary_selection.c b/types/wlr_primary_selection.c index 7eb5d97a..45d71f19 100644 --- a/types/wlr_primary_selection.c +++ b/types/wlr_primary_selection.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include "util/signal.h" static void offer_handle_receive(struct wl_client *client, struct wl_resource *resource, const char *mime_type, int32_t fd) { diff --git a/types/wlr_seat.c b/types/wlr_seat.c index b9d8b1b8..3ad4d81d 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include "util/signal.h" #include #include diff --git a/types/wlr_server_decoration.c b/types/wlr_server_decoration.c index f648cce7..ffa0477c 100644 --- a/types/wlr_server_decoration.c +++ b/types/wlr_server_decoration.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include "util/signal.h" static void server_decoration_handle_release(struct wl_client *client, struct wl_resource *resource) { diff --git a/types/wlr_surface.c b/types/wlr_surface.c index e430339b..b761bab5 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include "util/signal.h" #include #include #include diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 0c4e01fd..e9d52cc9 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include "util/signal.h" #include #include #include diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index b6eee875..30870d3b 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include "util/signal.h" #include "xdg-shell-unstable-v6-protocol.h" static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel"; diff --git a/util/signal.c b/util/signal.c index 91c4f571..39618465 100644 --- a/util/signal.c +++ b/util/signal.c @@ -1,4 +1,4 @@ -#include +#include "util/signal.h" static void handle_noop(struct wl_listener *listener, void *data) { // Do nothing diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index 7c57b6c0..74555edb 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include "util/signal.h" #include "sockets.h" #include "wlr/xwm.h" diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 86d8bde7..425188c7 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include "util/signal.h" #include #include #include From c2e147401048aa53aebd52f1851b1da8c91043a3 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 12 Feb 2018 21:29:23 +0100 Subject: [PATCH 4/4] Reformat all #include directives --- backend/backend.c | 16 +++++----- backend/drm/atomic.c | 4 +-- backend/drm/backend.c | 18 ++++++------ backend/drm/drm.c | 24 +++++++-------- backend/drm/legacy.c | 2 +- backend/drm/properties.c | 2 +- backend/drm/renderer.c | 18 +++++------- backend/drm/util.c | 8 ++--- backend/headless/backend.c | 6 ++-- backend/headless/input_device.c | 8 ++--- backend/headless/output.c | 4 +-- backend/libinput/backend.c | 6 ++-- backend/libinput/events.c | 6 ++-- backend/libinput/keyboard.c | 6 ++-- backend/libinput/pointer.c | 6 ++-- backend/libinput/tablet_pad.c | 6 ++-- backend/libinput/tablet_tool.c | 6 ++-- backend/libinput/touch.c | 6 ++-- backend/meson.build | 6 ++-- backend/multi/backend.c | 4 +-- backend/session/direct-freebsd.c | 26 ++++++++-------- backend/session/direct-ipc.c | 10 +++---- backend/session/direct.c | 18 ++++++------ backend/session/logind.c | 12 ++++---- backend/session/session.c | 8 ++--- backend/wayland/backend.c | 14 ++++----- backend/wayland/output.c | 10 +++---- backend/wayland/registry.c | 1 - backend/wayland/wl_seat.c | 8 ++--- backend/x11/backend.c | 26 ++++++++-------- include/backend/drm/drm.h | 10 +++---- include/backend/drm/iface.h | 3 +- include/backend/drm/renderer.h | 6 ++-- include/backend/drm/util.h | 2 +- include/backend/headless.h | 2 +- include/backend/libinput.h | 3 +- include/backend/multi.h | 2 +- include/backend/wayland.h | 10 +++---- include/backend/x11.h | 8 ++--- include/render/gles2.h | 10 +++---- include/rootston/config.h | 7 +++-- include/rootston/cursor.h | 4 +-- include/rootston/desktop.h | 21 ++++++------- include/rootston/input.h | 11 +++---- include/rootston/keyboard.h | 4 +-- include/rootston/output.h | 6 ++-- include/rootston/seat.h | 5 ++-- include/rootston/server.h | 5 ++-- include/rootston/view.h | 4 +-- include/rootston/xcursor.h | 4 +-- include/util/os-compatibility.h | 7 ++--- include/util/signal.h | 4 +-- include/wlr/backend/drm.h | 2 +- include/wlr/backend/libinput.h | 2 +- include/wlr/backend/multi.h | 5 ---- include/wlr/backend/session.h | 4 +-- include/wlr/backend/wayland.h | 2 +- include/wlr/interfaces/wlr_keyboard.h | 2 +- include/wlr/interfaces/wlr_output.h | 2 +- include/wlr/render.h | 2 +- include/wlr/render/egl.h | 6 ++-- include/wlr/render/gles2.h | 2 +- include/wlr/render/interface.h | 2 +- include/wlr/types/wlr_cursor.h | 6 ++-- include/wlr/types/wlr_keyboard.h | 4 +-- include/wlr/types/wlr_list.h | 6 ++-- include/wlr/types/wlr_output.h | 4 +-- include/wlr/types/wlr_output_damage.h | 2 +- include/wlr/types/wlr_output_layout.h | 4 +-- include/wlr/types/wlr_pointer.h | 4 +-- include/wlr/types/wlr_primary_selection.h | 2 +- include/wlr/types/wlr_screenshooter.h | 5 ++-- include/wlr/types/wlr_seat.h | 5 ++-- include/wlr/types/wlr_surface.h | 7 +++-- include/wlr/types/wlr_tablet_pad.h | 4 +-- include/wlr/types/wlr_tablet_tool.h | 4 +-- include/wlr/types/wlr_touch.h | 2 +- include/wlr/types/wlr_xdg_shell_v6.h | 2 +- include/wlr/xwayland.h | 2 +- include/wlr/xwm.h | 6 ++-- meson.build | 36 +++++++++++------------ protocol/meson.build | 4 +-- render/egl.c | 4 +-- render/gles2/renderer.c | 6 ++-- render/gles2/shaders.c | 2 +- render/gles2/texture.c | 8 ++--- render/gles2/util.c | 4 +-- render/matrix.c | 4 +-- render/meson.build | 2 +- render/wlr_renderer.c | 2 +- render/wlr_texture.c | 2 +- rootston/config.c | 10 +++---- rootston/cursor.c | 10 +++---- rootston/desktop.c | 10 +++---- rootston/input.c | 4 +-- rootston/keyboard.c | 8 ++--- rootston/main.c | 2 +- rootston/meson.build | 2 +- rootston/output.c | 14 ++++----- rootston/seat.c | 10 +++---- rootston/wl_shell.c | 4 +-- rootston/xdg_shell_v6.c | 4 +-- rootston/xwayland.c | 4 +-- types/meson.build | 4 +-- types/wlr_box.c | 2 +- types/wlr_compositor.c | 6 ++-- types/wlr_cursor.c | 12 ++++---- types/wlr_data_device.c | 6 ++-- types/wlr_gamma_control.c | 2 +- types/wlr_idle.c | 2 +- types/wlr_input_device.c | 6 ++-- types/wlr_keyboard.c | 4 +-- types/wlr_list.c | 4 +-- types/wlr_output.c | 6 ++-- types/wlr_output_damage.c | 6 ++-- types/wlr_output_layout.c | 12 ++++---- types/wlr_pointer.c | 2 +- types/wlr_primary_selection.c | 6 ++-- types/wlr_region.c | 6 ++-- types/wlr_screenshooter.c | 4 +-- types/wlr_seat.c | 6 ++-- types/wlr_server_decoration.c | 4 +-- types/wlr_surface.c | 8 ++--- types/wlr_tablet_pad.c | 2 +- types/wlr_tablet_tool.c | 2 +- types/wlr_touch.c | 2 +- types/wlr_wl_shell.c | 8 ++--- types/wlr_xdg_shell_v6.c | 4 +-- util/log.c | 2 +- util/os-compatibility.c | 10 +++---- util/region.c | 2 +- xcursor/meson.build | 2 +- xcursor/wlr_xcursor.c | 6 ++-- xcursor/xcursor.c | 4 +-- xwayland/selection.c | 16 +++++----- xwayland/sockets.c | 16 +++++----- xwayland/xwayland.c | 16 +++++----- xwayland/xwm.c | 16 +++++----- 138 files changed, 449 insertions(+), 456 deletions(-) diff --git a/backend/backend.c b/backend/backend.c index aec5781e..c67be617 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -1,17 +1,17 @@ -#include -#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include +#include +#include #include +#include #include +#include +#include #include #include -#include #include void wlr_backend_init(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 #include +#include +#include #include #include -#include #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 682e8c85..47dff227 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -1,19 +1,19 @@ -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #include -#include -#include #include +#include #include +#include #include #include -#include "util/signal.h" -#include +#include #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; diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 5189ec90..e60b7e1c 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -1,30 +1,30 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include +#include #include #include #include +#include +#include +#include +#include +#include #include #include #include #include -#include -#include "util/signal.h" -#include -#include #include +#include +#include +#include +#include +#include #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)) { 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 +#include #include #include -#include #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 #include #include +#include #include #include -#include #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 +#include +#include +#include #include #include #include - -#include -#include -#include -#include #include - -#include -#include -#include -#include #include +#include +#include +#include +#include #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 +#include +#include #include #include -#include -#include -#include -#include "backend/drm/util.h" #include +#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 a79e4af8..663bc13b 100644 --- a/backend/headless/backend.c +++ b/backend/headless/backend.c @@ -1,10 +1,10 @@ +#include "util/signal.h" #include +#include +#include #include #include #include -#include "util/signal.h" -#include -#include #include "backend/headless.h" #include "glapi.h" diff --git a/backend/headless/input_device.c b/backend/headless/input_device.c index 5d7ca34b..ea335aff 100644 --- a/backend/headless/input_device.c +++ b/backend/headless/input_device.c @@ -1,13 +1,13 @@ #include #include -#include #include -#include -#include +#include #include +#include +#include #include -#include "util/signal.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 = diff --git a/backend/headless/output.c b/backend/headless/output.c index 63f0b6b4..ba4a094e 100644 --- a/backend/headless/output.c +++ b/backend/headless/output.c @@ -1,11 +1,11 @@ -#include #include #include #include +#include #include #include -#include "util/signal.h" #include "backend/headless.h" +#include "util/signal.h" static EGLSurface egl_create_surface(struct wlr_egl *egl, unsigned int width, unsigned int height) { diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c index 1ec73009..71fe0d93 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -1,11 +1,11 @@ -#include #include #include -#include +#include #include +#include #include -#include "util/signal.h" #include "backend/libinput.h" +#include "util/signal.h" static int wlr_libinput_open_restricted(const char *path, int flags, void *_backend) { diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 248b8213..603eed07 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -1,12 +1,12 @@ -#include #include #include +#include +#include #include #include #include -#include -#include "util/signal.h" #include "backend/libinput.h" +#include "util/signal.h" struct wlr_input_device *get_appropriate_device( enum wlr_input_device_type desired_type, 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 #include #include +#include #include -#include #include +#include #include #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 560e95b5..8a31d312 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -1,12 +1,12 @@ -#include #include #include +#include #include -#include #include +#include #include -#include "util/signal.h" #include "backend/libinput.h" +#include "util/signal.h" struct wlr_pointer *wlr_libinput_pointer_create( struct libinput_device *libinput_dev) { diff --git a/backend/libinput/tablet_pad.c b/backend/libinput/tablet_pad.c index e8ffc6dd..70e4c677 100644 --- a/backend/libinput/tablet_pad.c +++ b/backend/libinput/tablet_pad.c @@ -1,12 +1,12 @@ -#include #include #include +#include #include -#include #include +#include #include -#include "util/signal.h" #include "backend/libinput.h" +#include "util/signal.h" struct wlr_tablet_pad *wlr_libinput_tablet_pad_create( struct libinput_device *libinput_dev) { diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index 0f2ea70a..4e60367f 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -1,12 +1,12 @@ -#include #include #include +#include #include -#include #include +#include #include -#include "util/signal.h" #include "backend/libinput.h" +#include "util/signal.h" struct wlr_tablet_tool *wlr_libinput_tablet_tool_create( struct libinput_device *libinput_dev) { diff --git a/backend/libinput/touch.c b/backend/libinput/touch.c index fb2b8e3f..2b87f9cd 100644 --- a/backend/libinput/touch.c +++ b/backend/libinput/touch.c @@ -1,12 +1,12 @@ -#include #include #include +#include #include -#include #include +#include #include -#include "util/signal.h" #include "backend/libinput.h" +#include "util/signal.h" struct wlr_touch *wlr_libinput_touch_create( struct libinput_device *libinput_dev) { 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 1005e6b7..5cb3fbc5 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -4,9 +4,9 @@ #include #include #include -#include "util/signal.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; diff --git a/backend/session/direct-freebsd.c b/backend/session/direct-freebsd.c index ceaae2be..6e23bf1b 100644 --- a/backend/session/direct-freebsd.c +++ b/backend/session/direct-freebsd.c @@ -1,22 +1,22 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include #include #include -#include "util/signal.h" #include "backend/session/direct-ipc.h" +#include "util/signal.h" const struct session_impl session_direct; 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 +#include #include #include #include -#include -#include #include #include #include #include +#include +#include +#include +#include #ifdef __linux__ #include #include #endif -#include -#include -#include #include "backend/session/direct-ipc.h" enum { DRM_MAJOR = 226 }; diff --git a/backend/session/direct.c b/backend/session/direct.c index 1f60ed23..13a26d99 100644 --- a/backend/session/direct.c +++ b/backend/session/direct.c @@ -1,22 +1,22 @@ #define _POSIX_C_SOURCE 200809L #include -#include -#include -#include -#include +#include +#include +#include +#include #include +#include +#include +#include #include #include #include -#include -#include -#include -#include +#include #include #include #include -#include "util/signal.h" #include "backend/session/direct-ipc.h" +#include "util/signal.h" enum { DRM_MAJOR = 226 }; diff --git a/backend/session/logind.c b/backend/session/logind.c index b2206e15..f0ac1e93 100644 --- a/backend/session/logind.c +++ b/backend/session/logind.c @@ -1,17 +1,17 @@ #define _POSIX_C_SOURCE 200809L #include -#include +#include +#include #include +#include #include #include -#include -#include -#include #include -#include +#include +#include #include -#include #include +#include #include #include "util/signal.h" diff --git a/backend/session/session.c b/backend/session/session.c index ac55a191..2d5d9776 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -1,18 +1,18 @@ #define _POSIX_C_SOURCE 200809L #include +#include #include #include #include #include #include -#include #include -#include -#include -#include #include #include +#include #include +#include +#include #include "util/signal.h" extern const struct session_impl session_logind; diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index 60c8ede9..abb25df5 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -1,18 +1,18 @@ -#include -#include #include -#include #include #include +#include +#include +#include #include +#include +#include +#include #include #include -#include -#include -#include #include -#include "util/signal.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) { diff --git a/backend/wayland/output.c b/backend/wayland/output.c index fed4c63a..fc40dea0 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -1,17 +1,17 @@ -#include #include +#include #include +#include #include #include -#include -#include #include +#include +#include #include -#include #include #include -#include "util/signal.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); 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 f6328106..b1f7cff6 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -1,17 +1,17 @@ #define _XOPEN_SOURCE 500 #include -#include #include +#include #include #include -#include #include -#include #include +#include +#include #include #include -#include "util/signal.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, diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 2715b366..28a4fcac 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -1,29 +1,29 @@ #define _POSIX_C_SOURCE 200112L +#include #include #include #include #include -#include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #ifdef __linux__ #include #elif __FreeBSD__ #include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "util/signal.h" #include "backend/x11.h" +#include "util/signal.h" static struct wlr_backend_impl backend_impl; static struct wlr_output_impl output_impl; diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index 12530da6..65db04ef 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -1,19 +1,17 @@ #ifndef BACKEND_DRM_DRM_H #define BACKEND_DRM_DRM_H +#include +#include #include #include #include #include -#include -#include -#include #include - -#include #include +#include #include - +#include #include "iface.h" #include "properties.h" #include "renderer.h" diff --git a/include/backend/drm/iface.h b/include/backend/drm/iface.h index 15cdf1ab..ef0e7bf8 100644 --- a/include/backend/drm/iface.h +++ b/include/backend/drm/iface.h @@ -1,10 +1,9 @@ #ifndef BACKEND_DRM_IFACE_H #define BACKEND_DRM_IFACE_H +#include #include #include - -#include #include #include diff --git a/include/backend/drm/renderer.h b/include/backend/drm/renderer.h index bf0165bc..a56a8673 100644 --- a/include/backend/drm/renderer.h +++ b/include/backend/drm/renderer.h @@ -1,12 +1,10 @@ #ifndef BACKEND_DRM_RENDERER_H #define BACKEND_DRM_RENDERER_H -#include -#include - #include #include - +#include +#include #include struct wlr_drm_backend; diff --git a/include/backend/drm/util.h b/include/backend/drm/util.h index 6818b4db..25da858f 100644 --- a/include/backend/drm/util.h +++ b/include/backend/drm/util.h @@ -2,9 +2,9 @@ #define BACKEND_DRM_UTIL_H #include +#include #include #include -#include // Calculates a more accurate refresh rate (mHz) than what mode itself provides int32_t calculate_refresh_rate(drmModeModeInfo *mode); diff --git a/include/backend/headless.h b/include/backend/headless.h index f9805bcc..e130bae1 100644 --- a/include/backend/headless.h +++ b/include/backend/headless.h @@ -1,8 +1,8 @@ #ifndef BACKEND_HEADLESS_H #define BACKEND_HEADLESS_H -#include #include +#include struct wlr_headless_backend { struct wlr_backend backend; diff --git a/include/backend/libinput.h b/include/backend/libinput.h index 6ec718c6..f828c310 100644 --- a/include/backend/libinput.h +++ b/include/backend/libinput.h @@ -1,10 +1,11 @@ #ifndef BACKEND_LIBINPUT_H #define BACKEND_LIBINPUT_H + #include #include -#include #include #include +#include #include struct wlr_libinput_backend { diff --git a/include/backend/multi.h b/include/backend/multi.h index 3363c608..c57c48f3 100644 --- a/include/backend/multi.h +++ b/include/backend/multi.h @@ -1,10 +1,10 @@ #ifndef BACKEND_MULTI_H #define BACKEND_MULTI_H +#include #include #include #include -#include struct wlr_multi_backend { struct wlr_backend backend; diff --git a/include/backend/wayland.h b/include/backend/wayland.h index 78a88f29..16c8e13b 100644 --- a/include/backend/wayland.h +++ b/include/backend/wayland.h @@ -3,13 +3,13 @@ #include #include -#include #include -#include -#include -#include -#include +#include #include +#include +#include +#include +#include struct wlr_wl_backend { struct wlr_backend backend; diff --git a/include/backend/x11.h b/include/backend/x11.h index fee39eac..c5f258c0 100644 --- a/include/backend/x11.h +++ b/include/backend/x11.h @@ -1,11 +1,11 @@ -#ifndef WLR_X11_H -#define WLR_X11_H +#ifndef BACKEND_X11_H +#define BACKEND_X11_H #include -#include -#include #include #include +#include +#include struct wlr_x11_backend; diff --git a/include/render/gles2.h b/include/render/gles2.h index 0b7032cc..797c5293 100644 --- a/include/render/gles2.h +++ b/include/render/gles2.h @@ -1,13 +1,13 @@ #ifndef RENDER_GLES2_H #define RENDER_GLES2_H -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include #include #include #include diff --git a/include/rootston/config.h b/include/rootston/config.h index 05f23b75..9926d9c2 100644 --- a/include/rootston/config.h +++ b/include/rootston/config.h @@ -1,7 +1,8 @@ -#ifndef _ROOTSTON_CONFIG_H -#define _ROOTSTON_CONFIG_H -#include +#ifndef ROOTSTON_CONFIG_H +#define ROOTSTON_CONFIG_H + #include +#include #define ROOTS_CONFIG_DEFAULT_SEAT_NAME "seat0" diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h index 90d54c12..a1a466c2 100644 --- a/include/rootston/cursor.h +++ b/include/rootston/cursor.h @@ -1,5 +1,5 @@ -#ifndef _ROOTSTON_CURSOR_H -#define _ROOTSTON_CURSOR_H +#ifndef ROOTSTON_CURSOR_H +#define ROOTSTON_CURSOR_H #include "rootston/seat.h" diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index a2121701..6572b242 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -1,22 +1,23 @@ -#ifndef _ROOTSTON_DESKTOP_H -#define _ROOTSTON_DESKTOP_H +#ifndef ROOTSTON_DESKTOP_H +#define ROOTSTON_DESKTOP_H + #include #include #include -#include -#include #include -#include -#include -#include #include +#include +#include +#include +#include #include #include -#include -#include -#include "rootston/view.h" +#include +#include +#include #include "rootston/config.h" #include "rootston/output.h" +#include "rootston/view.h" struct roots_desktop { struct wl_list views; // roots_view::link diff --git a/include/rootston/input.h b/include/rootston/input.h index d05cbb0a..4395a0f7 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -1,13 +1,14 @@ -#ifndef _ROOTSTON_INPUT_H -#define _ROOTSTON_INPUT_H +#ifndef ROOTSTON_INPUT_H +#define ROOTSTON_INPUT_H + #include -#include #include +#include #include -#include "rootston/cursor.h" #include "rootston/config.h" -#include "rootston/view.h" +#include "rootston/cursor.h" #include "rootston/server.h" +#include "rootston/view.h" struct roots_input { struct roots_config *config; diff --git a/include/rootston/keyboard.h b/include/rootston/keyboard.h index 4548f4a7..0140389a 100644 --- a/include/rootston/keyboard.h +++ b/include/rootston/keyboard.h @@ -1,5 +1,5 @@ -#ifndef _ROOTSTON_KEYBOARD_H -#define _ROOTSTON_KEYBOARD_H +#ifndef ROOTSTON_KEYBOARD_H +#define ROOTSTON_KEYBOARD_H #include #include "rootston/input.h" diff --git a/include/rootston/output.h b/include/rootston/output.h index 8396e7c5..9682e4f5 100644 --- a/include/rootston/output.h +++ b/include/rootston/output.h @@ -1,8 +1,8 @@ -#ifndef _ROOTSTON_OUTPUT_H -#define _ROOTSTON_OUTPUT_H +#ifndef ROOTSTON_OUTPUT_H +#define ROOTSTON_OUTPUT_H -#include #include +#include #include #include diff --git a/include/rootston/seat.h b/include/rootston/seat.h index cd819076..cc0293b5 100644 --- a/include/rootston/seat.h +++ b/include/rootston/seat.h @@ -1,5 +1,6 @@ -#ifndef _ROOTSTON_SEAT_H -#define _ROOTSTON_SEAT_H +#ifndef ROOTSTON_SEAT_H +#define ROOTSTON_SEAT_H + #include #include "rootston/input.h" #include "rootston/keyboard.h" diff --git a/include/rootston/server.h b/include/rootston/server.h index 0c26ea92..5f35dd90 100644 --- a/include/rootston/server.h +++ b/include/rootston/server.h @@ -1,11 +1,12 @@ #ifndef _ROOTSTON_SERVER_H #define _ROOTSTON_SERVER_H + #include -#include #include #include -#include +#include #include +#include #ifdef WLR_HAS_XWAYLAND #include #endif diff --git a/include/rootston/view.h b/include/rootston/view.h index f6968c7a..b61ac330 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -1,5 +1,5 @@ -#ifndef _ROOTSTON_VIEW_H -#define _ROOTSTON_VIEW_H +#ifndef ROOTSTON_VIEW_H +#define ROOTSTON_VIEW_H #include #include diff --git a/include/rootston/xcursor.h b/include/rootston/xcursor.h index a7d2b960..f78489a4 100644 --- a/include/rootston/xcursor.h +++ b/include/rootston/xcursor.h @@ -1,5 +1,5 @@ -#ifndef _ROOTSTON_XCURSOR_H -#define _ROOTSTON_XCURSOR_H +#ifndef ROOTSTON_XCURSOR_H +#define ROOTSTON_XCURSOR_H #include diff --git a/include/util/os-compatibility.h b/include/util/os-compatibility.h index b2ec2db9..2038025e 100644 --- a/include/util/os-compatibility.h +++ b/include/util/os-compatibility.h @@ -1,12 +1,9 @@ -#ifndef _WLR_UTIL_OS_COMPATIBILITY_H -#define _WLR_UTIL_OS_COMPATIBILITY_H +#ifndef UTIL_OS_COMPATIBILITY_H +#define UTIL_OS_COMPATIBILITY_H int os_fd_set_cloexec(int fd); - int set_cloexec_or_close(int fd); - int create_tmpfile_cloexec(char *tmpname); - int os_create_anonymous_file(off_t size); #endif diff --git a/include/util/signal.h b/include/util/signal.h index e13141d8..cc6cb525 100644 --- a/include/util/signal.h +++ b/include/util/signal.h @@ -1,5 +1,5 @@ -#ifndef WLR_UTIL_SIGNAL_H -#define WLR_UTIL_SIGNAL_H +#ifndef UTIL_SIGNAL_H +#define UTIL_SIGNAL_H #include diff --git a/include/wlr/backend/drm.h b/include/wlr/backend/drm.h index 133e4f69..90460647 100644 --- a/include/wlr/backend/drm.h +++ b/include/wlr/backend/drm.h @@ -2,8 +2,8 @@ #define WLR_BACKEND_DRM_H #include -#include #include +#include #include struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, diff --git a/include/wlr/backend/libinput.h b/include/wlr/backend/libinput.h index af873628..c7cfe894 100644 --- a/include/wlr/backend/libinput.h +++ b/include/wlr/backend/libinput.h @@ -3,8 +3,8 @@ #include #include -#include #include +#include #include struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display, diff --git a/include/wlr/backend/multi.h b/include/wlr/backend/multi.h index d9914efc..2dee7403 100644 --- a/include/wlr/backend/multi.h +++ b/include/wlr/backend/multi.h @@ -5,17 +5,12 @@ #include struct wlr_backend *wlr_multi_backend_create(struct wl_display *display); - void wlr_multi_backend_add(struct wlr_backend *multi, struct wlr_backend *backend); - void wlr_multi_backend_remove(struct wlr_backend *multi, struct wlr_backend *backend); - bool wlr_backend_is_multi(struct wlr_backend *backend); - struct wlr_session *wlr_multi_get_session(struct wlr_backend *base); - bool wlr_multi_is_empty(struct wlr_backend *backend); #endif diff --git a/include/wlr/backend/session.h b/include/wlr/backend/session.h index 3242a13f..7ff9691f 100644 --- a/include/wlr/backend/session.h +++ b/include/wlr/backend/session.h @@ -1,10 +1,10 @@ #ifndef WLR_BACKEND_SESSION_H #define WLR_BACKEND_SESSION_H -#include -#include #include +#include #include +#include struct session_impl; diff --git a/include/wlr/backend/wayland.h b/include/wlr/backend/wayland.h index f89a6383..e28ffff5 100644 --- a/include/wlr/backend/wayland.h +++ b/include/wlr/backend/wayland.h @@ -1,12 +1,12 @@ #ifndef WLR_BACKEND_WAYLAND_H #define WLR_BACKEND_WAYLAND_H +#include #include #include #include #include #include -#include /** * Creates a new wlr_wl_backend. This backend will be created with no outputs; diff --git a/include/wlr/interfaces/wlr_keyboard.h b/include/wlr/interfaces/wlr_keyboard.h index 570f5721..6960ea87 100644 --- a/include/wlr/interfaces/wlr_keyboard.h +++ b/include/wlr/interfaces/wlr_keyboard.h @@ -1,8 +1,8 @@ #ifndef WLR_INTERFACES_WLR_KEYBOARD_H #define WLR_INTERFACES_WLR_KEYBOARD_H -#include #include +#include struct wlr_keyboard_impl { void (*destroy)(struct wlr_keyboard *keyboard); diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h index a01f8901..5edd1ae1 100644 --- a/include/wlr/interfaces/wlr_output.h +++ b/include/wlr/interfaces/wlr_output.h @@ -2,9 +2,9 @@ #define WLR_INTERFACES_WLR_OUTPUT_H #include +#include #include #include -#include struct wlr_output_impl { void (*enable)(struct wlr_output *output, bool enable); diff --git a/include/wlr/render.h b/include/wlr/render.h index ccc66d36..3743482b 100644 --- a/include/wlr/render.h +++ b/include/wlr/render.h @@ -1,9 +1,9 @@ #ifndef WLR_RENDER_H #define WLR_RENDER_H -#include #include #include +#include #include #include #include diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h index 1facc6b8..97a28016 100644 --- a/include/wlr/render/egl.h +++ b/include/wlr/render/egl.h @@ -1,10 +1,10 @@ -#ifndef WLR_EGL_H -#define WLR_EGL_H +#ifndef WLR_RENDER_EGL_H +#define WLR_RENDER_EGL_H -#include #include #include #include +#include #include struct wlr_egl { diff --git a/include/wlr/render/gles2.h b/include/wlr/render/gles2.h index 25e760d5..a924a065 100644 --- a/include/wlr/render/gles2.h +++ b/include/wlr/render/gles2.h @@ -1,8 +1,8 @@ #ifndef WLR_RENDER_GLES2_H #define WLR_RENDER_GLES2_H -#include #include +#include struct wlr_egl; struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend); diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index b8e99898..b989e399 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -1,10 +1,10 @@ #ifndef WLR_RENDER_INTERFACE_H #define WLR_RENDER_INTERFACE_H -#include #include #include #include +#include #include #include #include diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h index e072ca05..da010972 100644 --- a/include/wlr/types/wlr_cursor.h +++ b/include/wlr/types/wlr_cursor.h @@ -2,10 +2,10 @@ #define WLR_TYPES_WLR_CURSOR_H #include -#include -#include -#include #include +#include +#include +#include struct wlr_cursor_state; diff --git a/include/wlr/types/wlr_keyboard.h b/include/wlr/types/wlr_keyboard.h index c67cc4c2..ed0427e8 100644 --- a/include/wlr/types/wlr_keyboard.h +++ b/include/wlr/types/wlr_keyboard.h @@ -1,9 +1,9 @@ #ifndef WLR_TYPES_WLR_KEYBOARD_H #define WLR_TYPES_WLR_KEYBOARD_H -#include -#include #include +#include +#include #include #include diff --git a/include/wlr/types/wlr_list.h b/include/wlr/types/wlr_list.h index 78a30995..23bf53b7 100644 --- a/include/wlr/types/wlr_list.h +++ b/include/wlr/types/wlr_list.h @@ -1,8 +1,8 @@ -#ifndef WLR_UTIL_LIST_H -#define WLR_UTIL_LIST_H +#ifndef WLR_TYPES_WLR_LIST_H +#define WLR_TYPES_WLR_LIST_H -#include #include +#include struct wlr_list { size_t capacity; diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 8eed06fe..5c2ffee0 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -1,11 +1,11 @@ #ifndef WLR_TYPES_WLR_OUTPUT_H #define WLR_TYPES_WLR_OUTPUT_H +#include #include #include -#include -#include #include +#include struct wlr_output_mode { uint32_t flags; // enum wl_output_mode diff --git a/include/wlr/types/wlr_output_damage.h b/include/wlr/types/wlr_output_damage.h index 52cbce78..6682f942 100644 --- a/include/wlr/types/wlr_output_damage.h +++ b/include/wlr/types/wlr_output_damage.h @@ -1,8 +1,8 @@ #ifndef WLR_TYPES_WLR_OUTPUT_DAMAGE_H #define WLR_TYPES_WLR_OUTPUT_DAMAGE_H -#include #include +#include #include /** diff --git a/include/wlr/types/wlr_output_layout.h b/include/wlr/types/wlr_output_layout.h index 9187b377..7dd2b16a 100644 --- a/include/wlr/types/wlr_output_layout.h +++ b/include/wlr/types/wlr_output_layout.h @@ -1,10 +1,10 @@ #ifndef WLR_TYPES_WLR_OUTPUT_LAYOUT_H #define WLR_TYPES_WLR_OUTPUT_LAYOUT_H +#include +#include #include #include -#include -#include struct wlr_output_layout_state; diff --git a/include/wlr/types/wlr_pointer.h b/include/wlr/types/wlr_pointer.h index 3a6d2175..e7ac9b46 100644 --- a/include/wlr/types/wlr_pointer.h +++ b/include/wlr/types/wlr_pointer.h @@ -1,9 +1,9 @@ #ifndef WLR_TYPES_WLR_POINTER_H #define WLR_TYPES_WLR_POINTER_H -#include -#include #include +#include +#include struct wlr_pointer_impl; diff --git a/include/wlr/types/wlr_primary_selection.h b/include/wlr/types/wlr_primary_selection.h index da3c096a..78f23ad6 100644 --- a/include/wlr/types/wlr_primary_selection.h +++ b/include/wlr/types/wlr_primary_selection.h @@ -1,8 +1,8 @@ #ifndef WLR_TYPES_WLR_PRIMARY_SELECTION_H #define WLR_TYPES_WLR_PRIMARY_SELECTION_H -#include #include +#include struct wlr_primary_selection_device_manager { struct wl_global *global; diff --git a/include/wlr/types/wlr_screenshooter.h b/include/wlr/types/wlr_screenshooter.h index cfe7742d..680d86f0 100644 --- a/include/wlr/types/wlr_screenshooter.h +++ b/include/wlr/types/wlr_screenshooter.h @@ -1,5 +1,6 @@ -#ifndef _WLR_SCREENSHOOTER_H -#define _WLR_SCREENSHOOTER_H +#ifndef WLR_TYPES_WLR_SCREENSHOOTER_H +#define WLR_TYPES_WLR_SCREENSHOOTER_H + #include struct wlr_screenshooter { diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index ffdabd98..b03cab6e 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -1,10 +1,11 @@ #ifndef WLR_TYPES_WLR_SEAT_H #define WLR_TYPES_WLR_SEAT_H + #include -#include +#include #include #include -#include +#include /** * Contains state for a single client's bound wl_seat resource and can be used diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index 50316abc..998b5ae5 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -1,9 +1,10 @@ #ifndef WLR_TYPES_WLR_SURFACE_H #define WLR_TYPES_WLR_SURFACE_H -#include -#include -#include + #include +#include +#include +#include #include #include diff --git a/include/wlr/types/wlr_tablet_pad.h b/include/wlr/types/wlr_tablet_pad.h index 51a65dd1..e70db516 100644 --- a/include/wlr/types/wlr_tablet_pad.h +++ b/include/wlr/types/wlr_tablet_pad.h @@ -1,9 +1,9 @@ #ifndef WLR_TYPES_WLR_TABLET_PAD_H #define WLR_TYPES_WLR_TABLET_PAD_H -#include -#include #include +#include +#include /* * NOTE: the wlr tablet pad implementation does not currently support tablets diff --git a/include/wlr/types/wlr_tablet_tool.h b/include/wlr/types/wlr_tablet_tool.h index c6984d4d..59e49ef8 100644 --- a/include/wlr/types/wlr_tablet_tool.h +++ b/include/wlr/types/wlr_tablet_tool.h @@ -1,9 +1,9 @@ #ifndef WLR_TYPES_TABLET_TOOL_H #define WLR_TYPES_TABLET_TOOL_H -#include -#include #include +#include +#include struct wlr_tablet_tool_impl; diff --git a/include/wlr/types/wlr_touch.h b/include/wlr/types/wlr_touch.h index 2925fd01..8ea293eb 100644 --- a/include/wlr/types/wlr_touch.h +++ b/include/wlr/types/wlr_touch.h @@ -1,8 +1,8 @@ #ifndef WLR_TYPES_WLR_TOUCH_H #define WLR_TYPES_WLR_TOUCH_H -#include #include +#include struct wlr_touch_impl; diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index c7b1a24b..7dc746ce 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -1,9 +1,9 @@ #ifndef WLR_TYPES_WLR_XDG_SHELL_V6_H #define WLR_TYPES_WLR_XDG_SHELL_V6_H +#include #include #include -#include struct wlr_xdg_shell_v6 { struct wl_global *wl_global; diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index c0135943..ad7ceb83 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -1,8 +1,8 @@ #ifndef WLR_XWAYLAND_H #define WLR_XWAYLAND_H -#include #include +#include #include #include #include diff --git a/include/wlr/xwm.h b/include/wlr/xwm.h index 35c43b18..242ff9cc 100644 --- a/include/wlr/xwm.h +++ b/include/wlr/xwm.h @@ -1,9 +1,9 @@ -#ifndef XWAYLAND_INTERNALS_H -#define XWAYLAND_INTERNALS_H +#ifndef WLR_XWM_H +#define WLR_XWM_H -#include #include #include +#include enum atom_name { WL_SURFACE_ID, diff --git a/meson.build b/meson.build index 6c8a3a8b..1cf7781a 100644 --- a/meson.build +++ b/meson.build @@ -157,16 +157,16 @@ wlroots = declare_dependency( summary = [ - '', - '----------------', - 'wlroots @0@'.format(meson.project_version()), - '', - ' libcap: @0@'.format(conf_data.get('WLR_HAS_LIBCAP', false)), - ' systemd: @0@'.format(conf_data.get('WLR_HAS_SYSTEMD', false)), - ' elogind: @0@'.format(conf_data.get('WLR_HAS_ELOGIND', false)), - ' xwayland: @0@'.format(conf_data.get('WLR_HAS_XWAYLAND', false)), - '----------------', - '' + '', + '----------------', + 'wlroots @0@'.format(meson.project_version()), + '', + ' libcap: @0@'.format(conf_data.get('WLR_HAS_LIBCAP', false)), + ' systemd: @0@'.format(conf_data.get('WLR_HAS_SYSTEMD', false)), + ' elogind: @0@'.format(conf_data.get('WLR_HAS_ELOGIND', false)), + ' xwayland: @0@'.format(conf_data.get('WLR_HAS_XWAYLAND', false)), + '----------------', + '' ] message('\n'.join(summary)) @@ -195,18 +195,18 @@ if git.found() etags = find_program('etags', required: false) if etags.found() and all_files.length() > 0 custom_target('etags', - build_by_default: true, - input: all_files, - output: 'TAGS', - command: [etags.path(), '-o', 'TAGS'] + all_files) + build_by_default: true, + input: all_files, + output: 'TAGS', + command: [etags.path(), '-o', 'TAGS'] + all_files) endif ctags = find_program('ctags', required: false) if ctags.found() and all_files.length() > 0 custom_target('ctags', - build_by_default: true, - input: all_files, - output: 'tags', - command: [ctags.path(), '-o', 'tags'] + all_files) + build_by_default: true, + input: all_files, + output: 'tags', + command: [ctags.path(), '-o', 'tags'] + all_files) endif endif diff --git a/protocol/meson.build b/protocol/meson.build index 6e9f4125..0db7c03c 100644 --- a/protocol/meson.build +++ b/protocol/meson.build @@ -24,18 +24,18 @@ protocols = [ [wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'], 'gamma-control.xml', 'gtk-primary-selection.xml', + 'idle.xml', 'screenshooter.xml', 'server-decoration.xml', - 'idle.xml', ] client_protocols = [ [wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'], 'gamma-control.xml', 'gtk-primary-selection.xml', + 'idle.xml', 'screenshooter.xml', 'server-decoration.xml', - 'idle.xml', ] wl_protos_src = [] diff --git a/render/egl.c b/render/egl.c index 328726ba..f1208a72 100644 --- a/render/egl.c +++ b/render/egl.c @@ -1,10 +1,10 @@ #include -#include #include #include #include -#include +#include #include +#include #include "glapi.h" // Extension documentation diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index f57e9dae..81a932e6 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -1,10 +1,10 @@ -#include -#include #include #include #include -#include +#include +#include #include +#include #include #include #include diff --git a/render/gles2/shaders.c b/render/gles2/shaders.c index ff6fba9c..46a10248 100644 --- a/render/gles2/shaders.c +++ b/render/gles2/shaders.c @@ -1,5 +1,5 @@ -#include "render/gles2.h" #include +#include "render/gles2.h" // Colored quads const GLchar quad_vertex_src[] = diff --git a/render/gles2/texture.c b/render/gles2/texture.c index a594f23e..688a51d8 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -1,17 +1,17 @@ -#include -#include #include #include #include -#include +#include +#include #include +#include #include #include #include #include #include -#include "util/signal.h" #include "render/gles2.h" +#include "util/signal.h" static struct pixel_format external_pixel_format = { .wl_format = 0, diff --git a/render/gles2/util.c b/render/gles2/util.c index 9498a1cd..c291f533 100644 --- a/render/gles2/util.c +++ b/render/gles2/util.c @@ -1,6 +1,6 @@ -#include -#include #include +#include +#include #include #include "render/gles2.h" diff --git a/render/matrix.c b/render/matrix.c index fa45dd04..d5d7f49d 100644 --- a/render/matrix.c +++ b/render/matrix.c @@ -1,9 +1,9 @@ -#include #include +#include #include +#include #include #include -#include /* Obtains the index for the given row/column */ static inline int mind(int row, int col) { diff --git a/render/meson.build b/render/meson.build index 309e83cd..1a5a85b8 100644 --- a/render/meson.build +++ b/render/meson.build @@ -10,12 +10,12 @@ lib_wlr_render = static_library( 'wlr_render', files( 'egl.c', - 'matrix.c', 'gles2/pixel_format.c', 'gles2/renderer.c', 'gles2/shaders.c', 'gles2/texture.c', 'gles2/util.c', + 'matrix.c', 'wlr_renderer.c', 'wlr_texture.c', ), diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index c8f06a64..fa6c6fc3 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -1,5 +1,5 @@ -#include #include +#include #include void wlr_renderer_init(struct wlr_renderer *renderer, diff --git a/render/wlr_texture.c b/render/wlr_texture.c index 4ce86bdd..a82a16b2 100644 --- a/render/wlr_texture.c +++ b/render/wlr_texture.c @@ -1,5 +1,5 @@ -#include #include +#include #include void wlr_texture_init(struct wlr_texture *texture, diff --git a/rootston/config.c b/rootston/config.c index 26cbd12d..e63efc0b 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -2,20 +2,20 @@ #define _POSIX_C_SOURCE 200809L #endif #include -#include -#include #include +#include +#include #include #include -#include #include +#include #include -#include #include +#include #include "rootston/config.h" +#include "rootston/ini.h" #include "rootston/input.h" #include "rootston/keyboard.h" -#include "rootston/ini.h" static void usage(const char *name, int ret) { fprintf(stderr, diff --git a/rootston/cursor.c b/rootston/cursor.c index ab32a5de..aa94daeb 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -1,16 +1,16 @@ #define _XOPEN_SOURCE 700 -#include #include +#include +#include +#include +#include #ifdef __linux__ #include #elif __FreeBSD__ #include #endif -#include -#include -#include -#include "rootston/xcursor.h" #include "rootston/cursor.h" +#include "rootston/xcursor.h" struct roots_cursor *roots_cursor_create(struct roots_seat *seat) { struct roots_cursor *cursor = calloc(1, sizeof(struct roots_cursor)); diff --git a/rootston/desktop.c b/rootston/desktop.c index 68da45e0..80ccbc25 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -1,25 +1,25 @@ #define _POSIX_C_SOURCE 199309L #include -#include -#include #include +#include +#include #include #include #include #include #include #include +#include #include #include -#include #include #include #include #include -#include "rootston/server.h" #include "rootston/seat.h" -#include "rootston/xcursor.h" +#include "rootston/server.h" #include "rootston/view.h" +#include "rootston/xcursor.h" void view_get_box(const struct roots_view *view, struct wlr_box *box) { box->x = view->x; diff --git a/rootston/input.c b/rootston/input.c index a0da2531..657b0946 100644 --- a/rootston/input.c +++ b/rootston/input.c @@ -1,16 +1,16 @@ #include #include #include +#include #include #include #include #include -#include -#include "rootston/server.h" #include "rootston/config.h" #include "rootston/input.h" #include "rootston/keyboard.h" #include "rootston/seat.h" +#include "rootston/server.h" static const char *device_type(enum wlr_input_device_type type) { switch (type) { diff --git a/rootston/keyboard.c b/rootston/keyboard.c index ddf541b4..6ec90c31 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -1,18 +1,18 @@ #include +#include #include #include #include -#include #include -#include -#include #include #include +#include +#include #include #include #include "rootston/input.h" -#include "rootston/seat.h" #include "rootston/keyboard.h" +#include "rootston/seat.h" static ssize_t pressed_keysyms_index(xkb_keysym_t *pressed_keysyms, xkb_keysym_t keysym) { diff --git a/rootston/main.c b/rootston/main.c index 3273c53f..5450ade2 100644 --- a/rootston/main.c +++ b/rootston/main.c @@ -3,10 +3,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include "rootston/config.h" diff --git a/rootston/meson.build b/rootston/meson.build index 973f93a4..a53812e3 100644 --- a/rootston/meson.build +++ b/rootston/meson.build @@ -8,8 +8,8 @@ sources = [ 'main.c', 'output.c', 'seat.c', - 'xdg_shell_v6.c', 'wl_shell.c', + 'xdg_shell_v6.c', ] if get_option('enable_xwayland') sources += ['xwayland.c'] diff --git a/rootston/output.c b/rootston/output.c index bd2ec18d..1ea4412e 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -1,18 +1,18 @@ #define _POSIX_C_SOURCE 200809L -#include -#include -#include #include -#include +#include +#include +#include +#include #include +#include #include #include -#include #include #include -#include "rootston/server.h" -#include "rootston/output.h" #include "rootston/config.h" +#include "rootston/output.h" +#include "rootston/server.h" typedef void (*surface_iterator_func_t)(struct wlr_surface *surface, double lx, double ly, float rotation, void *data); diff --git a/rootston/seat.c b/rootston/seat.c index 0c9867ec..38c26628 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -3,14 +3,14 @@ #include #include #include +#include #include #include -#include -#include "rootston/xcursor.h" -#include "rootston/input.h" -#include "rootston/seat.h" -#include "rootston/keyboard.h" #include "rootston/cursor.h" +#include "rootston/input.h" +#include "rootston/keyboard.h" +#include "rootston/seat.h" +#include "rootston/xcursor.h" static void handle_keyboard_key(struct wl_listener *listener, void *data) { struct roots_keyboard *keyboard = diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index 267e2cf5..44a65cf5 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -1,14 +1,14 @@ #include -#include #include +#include #include #include #include #include #include #include "rootston/desktop.h" -#include "rootston/server.h" #include "rootston/input.h" +#include "rootston/server.h" static void popup_destroy(struct roots_view_child *child) { assert(child->destroy == popup_destroy); diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 9bd6f76a..8e6674ab 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -1,14 +1,14 @@ #include -#include #include +#include #include #include #include #include #include #include "rootston/desktop.h" -#include "rootston/server.h" #include "rootston/input.h" +#include "rootston/server.h" static void popup_destroy(struct roots_view_child *child) { assert(child->destroy == popup_destroy); diff --git a/rootston/xwayland.c b/rootston/xwayland.c index 36be9793..e9e0d5e0 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -1,12 +1,12 @@ #include -#include #include +#include #include #include #include #include -#include #include +#include #include "rootston/server.h" #include "rootston/server.h" diff --git a/types/meson.build b/types/meson.build index 9f37cc86..2731f9bc 100644 --- a/types/meson.build +++ b/types/meson.build @@ -1,18 +1,18 @@ lib_wlr_types = static_library( 'wlr_types', files( - 'wlr_data_device.c', 'wlr_box.c', 'wlr_compositor.c', 'wlr_cursor.c', + 'wlr_data_device.c', 'wlr_gamma_control.c', 'wlr_idle.c', 'wlr_input_device.c', 'wlr_keyboard.c', 'wlr_list.c', - 'wlr_output.c', 'wlr_output_damage.c', 'wlr_output_layout.c', + 'wlr_output.c', 'wlr_pointer.c', 'wlr_primary_selection.c', 'wlr_region.c', diff --git a/types/wlr_box.c b/types/wlr_box.c index 33031858..2ea743d0 100644 --- a/types/wlr_box.c +++ b/types/wlr_box.c @@ -1,7 +1,7 @@ #include -#include #include #include +#include #include #include #include diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c index bd56b0fb..925e0019 100644 --- a/types/wlr_compositor.c +++ b/types/wlr_compositor.c @@ -1,11 +1,11 @@ #include #include #include +#include +#include +#include #include #include "util/signal.h" -#include -#include -#include static void destroy_surface_listener(struct wl_listener *listener, void *data) { wl_list_remove(wl_resource_get_link(data)); diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index 4f3d8727..20acebf1 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -1,13 +1,13 @@ -#include -#include #include #include +#include +#include +#include +#include +#include +#include #include #include "util/signal.h" -#include -#include -#include -#include struct wlr_cursor_device { struct wlr_cursor *cursor; diff --git a/types/wlr_data_device.c b/types/wlr_data_device.c index 7153dd53..b8ef820b 100644 --- a/types/wlr_data_device.c +++ b/types/wlr_data_device.c @@ -1,14 +1,14 @@ #define _XOPEN_SOURCE 700 +#include #include #include #include -#include #include #include +#include +#include #include #include "util/signal.h" -#include -#include #define ALL_ACTIONS (WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY | \ WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE | \ diff --git a/types/wlr_gamma_control.c b/types/wlr_gamma_control.c index 214dfd21..861427bd 100644 --- a/types/wlr_gamma_control.c +++ b/types/wlr_gamma_control.c @@ -4,8 +4,8 @@ #include #include #include -#include "util/signal.h" #include "gamma-control-protocol.h" +#include "util/signal.h" static void resource_destroy(struct wl_client *client, struct wl_resource *resource) { diff --git a/types/wlr_idle.c b/types/wlr_idle.c index 1976004f..9eddc42b 100644 --- a/types/wlr_idle.c +++ b/types/wlr_idle.c @@ -4,8 +4,8 @@ #include #include #include -#include "util/signal.h" #include "idle-protocol.h" +#include "util/signal.h" static void idle_timeout_destroy(struct wlr_idle_timeout *timer) { wl_list_remove(&timer->input_listener.link); diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index 372b3a7b..65d4b1d6 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -2,13 +2,13 @@ #include #include #include -#include #include #include #include -#include -#include #include +#include +#include +#include #include #include "util/signal.h" diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c index 6f09d599..5c0699ff 100644 --- a/types/wlr_keyboard.c +++ b/types/wlr_keyboard.c @@ -1,11 +1,11 @@ +#include #include #include #include #include -#include #include -#include #include +#include #include #include "util/signal.h" diff --git a/types/wlr_list.c b/types/wlr_list.c index 565a155b..2be0912a 100644 --- a/types/wlr_list.c +++ b/types/wlr_list.c @@ -1,8 +1,8 @@ +#include +#include #include #include -#include #include -#include #include #include diff --git a/types/wlr_output.c b/types/wlr_output.c index 7dcf4c78..504d0209 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -5,13 +5,13 @@ #include #include #include +#include +#include +#include #include #include #include -#include #include -#include -#include #include #include "util/signal.h" diff --git a/types/wlr_output_damage.c b/types/wlr_output_damage.c index c231a900..b3636c37 100644 --- a/types/wlr_output_damage.c +++ b/types/wlr_output_damage.c @@ -1,11 +1,11 @@ -#include #include +#include #include #include -#include "util/signal.h" #include -#include #include +#include +#include "util/signal.h" static void output_handle_destroy(struct wl_listener *listener, void *data) { struct wlr_output_damage *output_damage = diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index ea7b81c5..db0389bd 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -1,12 +1,12 @@ -#include -#include -#include #include +#include +#include +#include +#include +#include +#include #include #include "util/signal.h" -#include -#include -#include struct wlr_output_layout_state { struct wlr_box _box; // should never be read directly, use the getter diff --git a/types/wlr_pointer.c b/types/wlr_pointer.c index 04100e56..bc9efd8c 100644 --- a/types/wlr_pointer.c +++ b/types/wlr_pointer.c @@ -1,8 +1,8 @@ #include #include #include -#include #include +#include void wlr_pointer_init(struct wlr_pointer *pointer, struct wlr_pointer_impl *impl) { diff --git a/types/wlr_primary_selection.c b/types/wlr_primary_selection.c index 45d71f19..28fe63c1 100644 --- a/types/wlr_primary_selection.c +++ b/types/wlr_primary_selection.c @@ -1,9 +1,9 @@ #define _XOPEN_SOURCE 700 -#include -#include -#include #include #include +#include +#include +#include #include #include #include diff --git a/types/wlr_region.c b/types/wlr_region.c index fdf23ad2..322088b5 100644 --- a/types/wlr_region.c +++ b/types/wlr_region.c @@ -1,8 +1,8 @@ -#include -#include #include -#include #include +#include +#include +#include static void region_add(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) { diff --git a/types/wlr_screenshooter.c b/types/wlr_screenshooter.c index 74f9f602..04757fb6 100644 --- a/types/wlr_screenshooter.c +++ b/types/wlr_screenshooter.c @@ -2,10 +2,10 @@ #include #include #include -#include #include -#include +#include #include +#include #include #include "screenshooter-protocol.h" diff --git a/types/wlr_seat.c b/types/wlr_seat.c index 3ad4d81d..d60e0e0d 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -4,12 +4,12 @@ #include #include #include -#include +#include #include +#include +#include #include #include "util/signal.h" -#include -#include static void resource_destroy(struct wl_client *client, struct wl_resource *resource) { diff --git a/types/wlr_server_decoration.c b/types/wlr_server_decoration.c index ffa0477c..556193e2 100644 --- a/types/wlr_server_decoration.c +++ b/types/wlr_server_decoration.c @@ -1,8 +1,8 @@ #include -#include #include -#include +#include #include +#include #include #include "util/signal.h" diff --git a/types/wlr_surface.c b/types/wlr_surface.c index b761bab5..c47565c4 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -1,13 +1,13 @@ #include #include #include +#include +#include +#include +#include #include #include #include "util/signal.h" -#include -#include -#include -#include static void wlr_surface_state_reset_buffer(struct wlr_surface_state *state) { if (state->buffer) { diff --git a/types/wlr_tablet_pad.c b/types/wlr_tablet_pad.c index 07f9da10..3d25d685 100644 --- a/types/wlr_tablet_pad.c +++ b/types/wlr_tablet_pad.c @@ -1,8 +1,8 @@ #include #include #include -#include #include +#include void wlr_tablet_pad_init(struct wlr_tablet_pad *pad, struct wlr_tablet_pad_impl *impl) { diff --git a/types/wlr_tablet_tool.c b/types/wlr_tablet_tool.c index a396bb02..f46a5434 100644 --- a/types/wlr_tablet_tool.c +++ b/types/wlr_tablet_tool.c @@ -1,8 +1,8 @@ #include #include #include -#include #include +#include void wlr_tablet_tool_init(struct wlr_tablet_tool *tool, struct wlr_tablet_tool_impl *impl) { diff --git a/types/wlr_touch.c b/types/wlr_touch.c index 5db653e7..ba7ffac7 100644 --- a/types/wlr_touch.c +++ b/types/wlr_touch.c @@ -1,8 +1,8 @@ #include #include #include -#include #include +#include void wlr_touch_init(struct wlr_touch *touch, struct wlr_touch_impl *impl) { diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index e9d52cc9..85749ddd 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -1,14 +1,14 @@ #ifndef _POSIX_C_SOURCE #define _POSIX_C_SOURCE 200809L #endif -#include #include +#include +#include #include -#include -#include "util/signal.h" #include #include -#include +#include +#include "util/signal.h" static const char *wlr_wl_shell_surface_role = "wl-shell-surface"; diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 30870d3b..eb18f022 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -6,9 +6,9 @@ #include #include #include -#include -#include #include +#include +#include #include #include "util/signal.h" #include "xdg-shell-unstable-v6-protocol.h" diff --git a/util/log.c b/util/log.c index e0b6a132..327402e6 100644 --- a/util/log.c +++ b/util/log.c @@ -3,9 +3,9 @@ #include #include #include -#include #include #include +#include #include static bool colored = true; diff --git a/util/os-compatibility.c b/util/os-compatibility.c index 98aeab3d..bd3067d2 100644 --- a/util/os-compatibility.c +++ b/util/os-compatibility.c @@ -24,13 +24,13 @@ */ #define _XOPEN_SOURCE 700 -#include -#include -#include -#include #include -#include +#include #include +#include +#include +#include +#include #include "util/os-compatibility.h" int os_fd_set_cloexec(int fd) { diff --git a/util/region.c b/util/region.c index 1bde0cb8..88e38fd2 100644 --- a/util/region.c +++ b/util/region.c @@ -1,5 +1,5 @@ -#include #include +#include #include void wlr_region_scale(pixman_region32_t *dst, pixman_region32_t *src, diff --git a/xcursor/meson.build b/xcursor/meson.build index afaab915..31040a92 100644 --- a/xcursor/meson.build +++ b/xcursor/meson.build @@ -1,8 +1,8 @@ lib_wlr_xcursor = static_library( 'wlr_xcursor', files( - 'xcursor.c', 'wlr_xcursor.c', + 'xcursor.c', ), include_directories: wlr_inc, dependencies: [egl] # header required via include/wlr/render.h diff --git a/xcursor/wlr_xcursor.c b/xcursor/wlr_xcursor.c index 2d1a38b5..7fcdbb6f 100644 --- a/xcursor/wlr_xcursor.c +++ b/xcursor/wlr_xcursor.c @@ -24,12 +24,12 @@ */ #define _XOPEN_SOURCE 500 -#include -#include +#include #include #include -#include #include +#include +#include #include "xcursor/xcursor.h" static void wlr_xcursor_destroy(struct wlr_xcursor *cursor) { diff --git a/xcursor/xcursor.c b/xcursor/xcursor.c index 8dc35a7c..32711105 100644 --- a/xcursor/xcursor.c +++ b/xcursor/xcursor.c @@ -24,11 +24,11 @@ */ #define _DEFAULT_SOURCE -#include "xcursor/xcursor.h" +#include #include #include #include -#include +#include "xcursor/xcursor.h" /* * From libXcursor/include/X11/extensions/Xcursor.h diff --git a/xwayland/selection.c b/xwayland/selection.c index 060c0baf..ffcde4d0 100644 --- a/xwayland/selection.c +++ b/xwayland/selection.c @@ -1,14 +1,14 @@ #define _XOPEN_SOURCE 700 -#include -#include -#include #include -#include #include -#include "wlr/util/log.h" -#include "wlr/types/wlr_data_device.h" -#include "wlr/types/wlr_primary_selection.h" -#include "wlr/xwm.h" +#include +#include +#include +#include +#include +#include +#include +#include static const size_t incr_chunk_size = 64 * 1024; diff --git a/xwayland/sockets.c b/xwayland/sockets.c index 2119056d..1e943b1d 100644 --- a/xwayland/sockets.c +++ b/xwayland/sockets.c @@ -3,19 +3,19 @@ // for SOCK_CLOEXEC #define __BSD_VISIBLE 1 #endif -#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include +#include #include +#include +#include #include -#include -#include "wlr/util/log.h" +#include +#include #include "sockets.h" static const char *lock_fmt = "/tmp/.X%d-lock"; diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index 74555edb..1d935180 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -4,23 +4,23 @@ // for SOCK_CLOEXEC #define __BSD_VISIBLE 1 #endif -#include -#include -#include +#include #include #include +#include +#include +#include #include #include #include #include -#include -#include +#include #include -#include #include -#include "util/signal.h" +#include +#include #include "sockets.h" -#include "wlr/xwm.h" +#include "util/signal.h" #ifdef __FreeBSD__ static inline int clearenv(void) { diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 425188c7..10bc2e30 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -3,18 +3,18 @@ #endif #include #include -#include -#include -#include -#include #include -#include -#include -#include "util/signal.h" #include -#include +#include +#include #include +#include #include +#include +#include +#include +#include +#include "util/signal.h" #ifdef WLR_HAS_XCB_ICCCM #include