static void set_selection(struct wl_client * client, struct wl_resource * resource, struct wl_resource * data_source, uint32_t serial) { struct data_device * data_device = wl_resource_get_user_data(resource); /* Check if this data source is already the current selection. */ if (data_source == data_device->selection) return; if (data_device->selection) { wl_data_source_send_cancelled(data_device->selection); wl_list_remove(&data_device->selection_destroy_listener.link); } data_device->selection = data_source; if (data_source) { wl_resource_add_destroy_listener (data_source, &data_device->selection_destroy_listener); } swc_send_event(&data_device->event_signal, DATA_DEVICE_EVENT_SELECTION_CHANGED, NULL); }
static void meta_wayland_data_device_set_selection (MetaWaylandDataDevice *data_device, MetaWaylandDataSource *source, guint32 serial) { MetaWaylandSeat *seat = wl_container_of (data_device, seat, data_device); struct wl_resource *data_device_resource, *offer; struct wl_client *focus_client; if (data_device->selection_data_source && data_device->selection_serial - serial < UINT32_MAX / 2) return; if (data_device->selection_data_source) { wl_data_source_send_cancelled (data_device->selection_data_source->resource); wl_list_remove (&data_device->selection_data_source_listener.link); data_device->selection_data_source = NULL; } data_device->selection_data_source = source; data_device->selection_serial = serial; focus_client = meta_wayland_keyboard_get_focus_client (&seat->keyboard); if (focus_client) { data_device_resource = wl_resource_find_for_client (&data_device->resource_list, focus_client); if (data_device_resource) { if (data_device->selection_data_source) { offer = meta_wayland_data_source_send_offer (data_device->selection_data_source, data_device_resource); wl_data_device_send_selection (data_device_resource, offer); } else { wl_data_device_send_selection (data_device_resource, NULL); } } } if (source) { data_device->selection_data_source_listener.notify = destroy_selection_data_source; wl_resource_add_destroy_listener (source->resource, &data_device->selection_data_source_listener); } }
static void client_source_cancel(struct wl_data_source *source) { wl_data_source_send_cancelled(&source->resource); }