wayland: Fix memory leaks

This commit is contained in:
Cameron Gutman authored and Frank Praznik committed 2024-09-18 20:44:26 -04:00
1 parent 46ee6a3848
commit e239295491
1 file changed
+18 -2
+18 -2
View File
@@ -260,12 +260,25 @@ static SDL_bool keyboard_repeat_key_is_set(SDL_WaylandKeyboardRepeat *repeat_inf
return repeat_info->is_initialized && repeat_info->is_key_down && key == repeat_info->key; return repeat_info->is_initialized && repeat_info->is_key_down && key == repeat_info->key;
} }
static void sync_done_handler(void *data, struct wl_callback *callback, uint32_t callback_data)
{
/* Nothing to do, just destroy the callback */
wl_callback_destroy(callback);
}
static struct wl_callback_listener sync_listener = {
sync_done_handler
};
void Wayland_SendWakeupEvent(_THIS, SDL_Window *window) void Wayland_SendWakeupEvent(_THIS, SDL_Window *window)
{ {
SDL_VideoData *d = _this->driverdata; SDL_VideoData *d = _this->driverdata;
/* TODO: Maybe use a pipe to avoid the compositor roundtrip? */ /* Queue a sync event to unblock the event queue fd if it's empty and being waited on.
wl_display_sync(d->display); * TODO: Maybe use a pipe to avoid the compositor roundtrip?
*/
struct wl_callback *cb = wl_display_sync(d->display);
wl_callback_add_listener(cb, &sync_listener, NULL);
WAYLAND_wl_display_flush(d->display); WAYLAND_wl_display_flush(d->display);
} }
@@ -2537,6 +2550,9 @@ void Wayland_display_destroy_input(SDL_VideoData *d)
if (input->primary_selection_device->selection_offer) { if (input->primary_selection_device->selection_offer) {
Wayland_primary_selection_offer_destroy(input->primary_selection_device->selection_offer); Wayland_primary_selection_offer_destroy(input->primary_selection_device->selection_offer);
} }
if (input->primary_selection_device->primary_selection_device) {
zwp_primary_selection_device_v1_destroy(input->primary_selection_device->primary_selection_device);
}
SDL_free(input->primary_selection_device); SDL_free(input->primary_selection_device);
} }