// There are two cases when sel->offer is NULL
// 1. No one owns the selection
// 2. We own the selection (we'll just access the register directly)
- if (offer == NULL || offer->from_vim)
+ if (offer == NULL || sel->source != NULL)
{
// Selection event is from us, so we are the source client. Therefore
// ignore it. Or the selection is cleared, so set sel->offer to NULL
vwl_data_source_add_listener(sel->source, &vwl_data_source_listener, sel);
// Advertise mime types
- vwl_data_source_offer(sel->source, wayland_vim_special_mime);
for (int i = 0; i < (int)ARRAY_LENGTH(supported_mimes); i++)
vwl_data_source_offer(sel->source, supported_mimes[i]);
// Wayland display name for global connection (ex. wayland-0). Can be NULL
EXTERN char *wayland_display_name INIT(= NULL);
-// Special mime type used to identify selection events that came from us setting
-// the selection. Is in format of "application/x-vim-instance-<pid>" where <pid>
-// is the PID of the Vim process. Set in main.c
-//
-// This is more reliable than just checking if our data source is non-NULL, as
-// that may be subject to data races in the Wayland protocol.
-EXTERN char wayland_vim_special_mime[
- sizeof("application/x-vim-instance-") + NUMBUFLEN - 1]; // Includes NUL
-
// Don't connect to Wayland compositor if TRUE
EXTERN int wayland_no_connect INIT(= FALSE);
if (!gui.in_use)
# endif
{
- sprintf(wayland_vim_special_mime, "application/x-vim-instance-%ld",
- mch_get_pid());
-
if (wayland_init_connection(wayland_display_name) == OK)
{
TIME_MSG("connected to Wayland display");
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 2089,
/**/
2088,
/**/
const char *mime_type) \
{ \
vwl_data_offer_T *self = data; \
- if (STRCMP(mime_type, wayland_vim_special_mime) == 0) \
- self->from_vim = true; \
- else if (!self->from_vim && \
- self->listener->offer(self->data, self, mime_type)) \
+ if (self->listener->offer(self->data, self, mime_type)) \
{ \
char *mime = (char *)vim_strsave((char_u *)mime_type); \
if (ga_grow(&self->mime_types, 1) == FAIL) \
void *data; // Should be same as parent data
// device.
garray_T mime_types;
- bool from_vim; // If offer came from us setting the
- // selection.
const vwl_data_offer_listener_T *listener;
vwl_data_protocol_T protocol;