Add wlr_signal_emit_safe

This commit is contained in:
emersion 2018-02-12 09:12:31 +01:00
parent 3497e53516
commit 5e58d46cc1
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
43 changed files with 265 additions and 182 deletions

View file

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <wayland-server.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_region.h>
#include <wlr/types/wlr_compositor.h>
@ -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,

View file

@ -3,6 +3,7 @@
#include <assert.h>
#include <limits.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
#include <wayland-server.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
@ -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) {

View file

@ -6,6 +6,7 @@
#include <unistd.h>
#include <wayland-server.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_data_device.h>
@ -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) {

View file

@ -4,6 +4,7 @@
#include <wlr/types/wlr_gamma_control.h>
#include <wlr/types/wlr_output.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
#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);

View file

@ -4,6 +4,7 @@
#include <wayland-server.h>
#include <wlr/types/wlr_idle.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
#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);
}

View file

@ -10,6 +10,7 @@
#include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/interfaces/wlr_tablet_pad.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
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) {

View file

@ -7,6 +7,7 @@
#include <wlr/types/wlr_keyboard.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
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) {

View file

@ -13,6 +13,7 @@
#include <wlr/render/matrix.h>
#include <wlr/render.h>
#include <wlr/util/region.h>
#include <wlr/util/signal.h>
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) {

View file

@ -2,6 +2,7 @@
#include <stddef.h>
#include <time.h>
#include <wayland-server.h>
#include <wlr/util/signal.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_damage.h>
@ -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);

View file

@ -1,11 +1,12 @@
#include <wlr/util/log.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_box.h>
#include <limits.h>
#include <float.h>
#include <stdlib.h>
#include <assert.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_box.h>
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(

View file

@ -7,6 +7,7 @@
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
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) {

View file

@ -7,6 +7,7 @@
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_primary_selection.h>
@ -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);

View file

@ -4,6 +4,7 @@
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_server_decoration.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
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

View file

@ -3,6 +3,7 @@
#include <wayland-server.h>
#include <wlr/util/log.h>
#include <wlr/util/region.h>
#include <wlr/util/signal.h>
#include <wlr/render/interface.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/render/egl.h>
@ -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);
}

View file

@ -1,12 +1,13 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#include <stdlib.h>
#include <assert.h>
#include <wayland-server.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_wl_shell.h>
#include <stdlib.h>
#include <wayland-server-protocol.h>
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;

View file

@ -10,6 +10,7 @@
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/util/log.h>
#include <wlr/util/signal.h>
#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;