Wrap modifier_set_copy into event_data_copy

This commit is contained in:
Vftdan 2024-08-21 13:32:48 +02:00
parent 74f11849b3
commit 52b3b74e7b
3 changed files with 11 additions and 6 deletions

View File

@ -21,8 +21,7 @@ event_replicate(EventNode * source, size_t count)
}
replica->position = NULL;
replica->input_index = 0;
replica->data = source->data;
replica->data.modifiers = modifier_set_copy(source->data.modifiers);
replica->data = event_data_copy(source->data);
replica->prev = source;
replica->next = source->next;
source->next->prev = replica;
@ -39,8 +38,7 @@ event_create(const EventData * content)
return NULL;
}
if (content) {
event->data = *content;
event->data.modifiers = modifier_set_copy(content->modifiers);
event->data = event_data_copy(*content);
} else {
event->data.time = get_current_time();
}

View File

@ -49,4 +49,11 @@ EventNode * event_create(const EventData * content);
void event_destroy(EventNode * self);
void event_destroy_all();
__attribute__((unused)) inline static EventData
event_data_copy(EventData orig)
{
orig.modifiers = modifier_set_copy(orig.modifiers);
return orig;
}
#endif /* end of include guard: EVENTS_H_ */

View File

@ -69,6 +69,7 @@ trigger_new_window(WindowGraphNode * node, EventNode * base)
terminator->data.code = node->terminator_prototype.code;
terminator->data.modifiers = modifier_set_copy(node->terminator_prototype.modifiers);
terminator->data.payload = node->terminator_prototype.payload;
// Preserve ttl, priority, time
graph_node_broadcast_forward_event(&node->as_GraphNode, terminator);
}
}
@ -102,8 +103,7 @@ trigger_new_window(WindowGraphNode * node, EventNode * base)
if (!recipient) {
continue;
}
recipient->data = orig->data;
recipient->data.modifiers = modifier_set_copy(orig->data.modifiers);
recipient->data = event_data_copy(orig->data);
graph_node_broadcast_forward_event(&node->as_GraphNode, recipient);
}