wayland: Check the origin of clipboard offers before forwarding them to the client

Wayland compositors may send recursive clipboard offers to the client, which need to be filtered out to avoid clearing local data. Previously this was worked around with a hack, but this caused the ownership flag to be set incorrectly, which broke some clients.

This introduces a metadata MIME type of application/x-sdl3-source-id to be sent with SDL3 selection offers, which contains a string that is a unique identifier for the instance, and can be used to detect if a received selection offer is originating from the same instance that generated it.

If DBus is available, the unique identifier string is the unique name of the connection, otherwise, the process ID is used.
This commit is contained in:
Frank Praznik
2025-04-18 12:57:53 -04:00
parent 23a7a74133
commit 86b3369491
6 changed files with 180 additions and 67 deletions

View File

@@ -47,6 +47,7 @@ typedef struct SDL_DBusContext
dbus_bool_t (*bus_register)(DBusConnection *, DBusError *);
void (*bus_add_match)(DBusConnection *, const char *, DBusError *);
void (*bus_remove_match)(DBusConnection *, const char *, DBusError *);
const char *(*bus_get_unique_name)(DBusConnection *);
DBusConnection *(*connection_open_private)(const char *, DBusError *);
void (*connection_set_exit_on_disconnect)(DBusConnection *, dbus_bool_t);
dbus_bool_t (*connection_get_is_connected)(DBusConnection *);