|
@@ -33,11 +33,12 @@
|
|
|
|
|
|
#include "SDL_waylandvideo.h"
|
|
|
#include "SDL_waylanddatamanager.h"
|
|
|
+#include "primary-selection-unstable-v1-client-protocol.h"
|
|
|
|
|
|
/* FIXME: This is arbitrary, but we want this to be less than a frame because
|
|
|
* any longer can potentially spin an infinite loop of PumpEvents (!)
|
|
|
*/
|
|
|
-#define PIPE_MS_TIMEOUT 10
|
|
|
+#define PIPE_MS_TIMEOUT 14
|
|
|
|
|
|
static ssize_t
|
|
|
write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos)
|
|
@@ -53,7 +54,7 @@ write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos)
|
|
|
ready = SDL_IOReady(fd, SDL_IOR_WRITE, PIPE_MS_TIMEOUT);
|
|
|
|
|
|
sigemptyset(&sig_set);
|
|
|
- sigaddset(&sig_set, SIGPIPE);
|
|
|
+ sigaddset(&sig_set, SIGPIPE);
|
|
|
|
|
|
#if SDL_THREADS_DISABLED
|
|
|
sigprocmask(SIG_BLOCK, &sig_set, &old_sig_set);
|
|
@@ -97,7 +98,7 @@ read_pipe(int fd, void** buffer, size_t* total_length, SDL_bool null_terminate)
|
|
|
size_t pos = 0;
|
|
|
|
|
|
ready = SDL_IOReady(fd, SDL_IOR_READ, PIPE_MS_TIMEOUT);
|
|
|
-
|
|
|
+
|
|
|
if (ready == 0) {
|
|
|
bytes_read = SDL_SetError("Pipe timeout");
|
|
|
} else if (ready < 0) {
|
|
@@ -120,8 +121,8 @@ read_pipe(int fd, void** buffer, size_t* total_length, SDL_bool null_terminate)
|
|
|
output_buffer = SDL_malloc(new_buffer_length);
|
|
|
} else {
|
|
|
output_buffer = SDL_realloc(*buffer, new_buffer_length);
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
if (output_buffer == NULL) {
|
|
|
bytes_read = SDL_OutOfMemory();
|
|
|
} else {
|
|
@@ -130,7 +131,7 @@ read_pipe(int fd, void** buffer, size_t* total_length, SDL_bool null_terminate)
|
|
|
if (null_terminate == SDL_TRUE) {
|
|
|
SDL_memset((Uint8*)output_buffer + (new_buffer_length - 1), 0, 1);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
*buffer = output_buffer;
|
|
|
}
|
|
|
}
|
|
@@ -160,28 +161,28 @@ Wayland_convert_mime_type(const char *mime_type)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return found;
|
|
|
}
|
|
|
|
|
|
static SDL_MimeDataList*
|
|
|
-mime_data_list_find(struct wl_list* list,
|
|
|
+mime_data_list_find(struct wl_list* list,
|
|
|
const char* mime_type)
|
|
|
{
|
|
|
SDL_MimeDataList *found = NULL;
|
|
|
|
|
|
SDL_MimeDataList *mime_list = NULL;
|
|
|
- wl_list_for_each(mime_list, list, link) {
|
|
|
+ wl_list_for_each(mime_list, list, link) {
|
|
|
if (SDL_strcmp(mime_list->mime_type, mime_type) == 0) {
|
|
|
found = mime_list;
|
|
|
break;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
return found;
|
|
|
}
|
|
|
|
|
|
static int
|
|
|
-mime_data_list_add(struct wl_list* list,
|
|
|
+mime_data_list_add(struct wl_list* list,
|
|
|
const char* mime_type,
|
|
|
const void* buffer, size_t length)
|
|
|
{
|
|
@@ -216,7 +217,7 @@ mime_data_list_add(struct wl_list* list,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (mime_data != NULL && buffer != NULL && length > 0) {
|
|
|
if (mime_data->data != NULL) {
|
|
|
SDL_free(mime_data->data);
|
|
@@ -233,31 +234,25 @@ mime_data_list_add(struct wl_list* list,
|
|
|
static void
|
|
|
mime_data_list_free(struct wl_list *list)
|
|
|
{
|
|
|
- SDL_MimeDataList *mime_data = NULL;
|
|
|
+ SDL_MimeDataList *mime_data = NULL;
|
|
|
SDL_MimeDataList *next = NULL;
|
|
|
|
|
|
wl_list_for_each_safe(mime_data, next, list, link) {
|
|
|
if (mime_data->data != NULL) {
|
|
|
SDL_free(mime_data->data);
|
|
|
- }
|
|
|
+ }
|
|
|
if (mime_data->mime_type != NULL) {
|
|
|
SDL_free(mime_data->mime_type);
|
|
|
}
|
|
|
- SDL_free(mime_data);
|
|
|
- }
|
|
|
+ SDL_free(mime_data);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-ssize_t
|
|
|
-Wayland_data_source_send(SDL_WaylandDataSource *source,
|
|
|
- const char *mime_type, int fd)
|
|
|
+static ssize_t
|
|
|
+Wayland_source_send(SDL_MimeDataList *mime_data, const char *mime_type, int fd)
|
|
|
{
|
|
|
size_t written_bytes = 0;
|
|
|
ssize_t status = 0;
|
|
|
- SDL_MimeDataList *mime_data = NULL;
|
|
|
-
|
|
|
- mime_type = Wayland_convert_mime_type(mime_type);
|
|
|
- mime_data = mime_data_list_find(&source->mimes,
|
|
|
- mime_type);
|
|
|
|
|
|
if (mime_data == NULL || mime_data->data == NULL) {
|
|
|
status = SDL_SetError("Invalid mime type");
|
|
@@ -271,15 +266,49 @@ Wayland_data_source_send(SDL_WaylandDataSource *source,
|
|
|
return status;
|
|
|
}
|
|
|
|
|
|
+ssize_t
|
|
|
+Wayland_data_source_send(SDL_WaylandDataSource *source,
|
|
|
+ const char *mime_type, int fd)
|
|
|
+{
|
|
|
+ SDL_MimeDataList *mime_data = NULL;
|
|
|
+
|
|
|
+ mime_type = Wayland_convert_mime_type(mime_type);
|
|
|
+ mime_data = mime_data_list_find(&source->mimes,
|
|
|
+ mime_type);
|
|
|
+
|
|
|
+ return Wayland_source_send(mime_data, mime_type, fd);
|
|
|
+}
|
|
|
+
|
|
|
+ssize_t
|
|
|
+Wayland_primary_selection_source_send(SDL_WaylandPrimarySelectionSource *source,
|
|
|
+ const char *mime_type, int fd)
|
|
|
+{
|
|
|
+ SDL_MimeDataList *mime_data = NULL;
|
|
|
+
|
|
|
+ mime_type = Wayland_convert_mime_type(mime_type);
|
|
|
+ mime_data = mime_data_list_find(&source->mimes,
|
|
|
+ mime_type);
|
|
|
+
|
|
|
+ return Wayland_source_send(mime_data, mime_type, fd);
|
|
|
+}
|
|
|
+
|
|
|
int Wayland_data_source_add_data(SDL_WaylandDataSource *source,
|
|
|
const char *mime_type,
|
|
|
const void *buffer,
|
|
|
- size_t length)
|
|
|
+ size_t length)
|
|
|
+{
|
|
|
+ return mime_data_list_add(&source->mimes, mime_type, buffer, length);
|
|
|
+}
|
|
|
+
|
|
|
+int Wayland_primary_selection_source_add_data(SDL_WaylandPrimarySelectionSource *source,
|
|
|
+ const char *mime_type,
|
|
|
+ const void *buffer,
|
|
|
+ size_t length)
|
|
|
{
|
|
|
return mime_data_list_add(&source->mimes, mime_type, buffer, length);
|
|
|
}
|
|
|
|
|
|
-SDL_bool
|
|
|
+SDL_bool
|
|
|
Wayland_data_source_has_mime(SDL_WaylandDataSource *source,
|
|
|
const char *mime_type)
|
|
|
{
|
|
@@ -291,7 +320,47 @@ Wayland_data_source_has_mime(SDL_WaylandDataSource *source,
|
|
|
return found;
|
|
|
}
|
|
|
|
|
|
-void*
|
|
|
+SDL_bool
|
|
|
+Wayland_primary_selection_source_has_mime(SDL_WaylandPrimarySelectionSource *source,
|
|
|
+ const char *mime_type)
|
|
|
+{
|
|
|
+ SDL_bool found = SDL_FALSE;
|
|
|
+
|
|
|
+ if (source != NULL) {
|
|
|
+ found = mime_data_list_find(&source->mimes, mime_type) != NULL;
|
|
|
+ }
|
|
|
+ return found;
|
|
|
+}
|
|
|
+
|
|
|
+static void*
|
|
|
+Wayland_source_get_data(SDL_MimeDataList *mime_data,
|
|
|
+ size_t *length,
|
|
|
+ SDL_bool null_terminate)
|
|
|
+{
|
|
|
+ void *buffer = NULL;
|
|
|
+
|
|
|
+ if (mime_data != NULL && mime_data->length > 0) {
|
|
|
+ size_t buffer_length = mime_data->length;
|
|
|
+
|
|
|
+ if (null_terminate == SDL_TRUE) {
|
|
|
+ ++buffer_length;
|
|
|
+ }
|
|
|
+ buffer = SDL_malloc(buffer_length);
|
|
|
+ if (buffer == NULL) {
|
|
|
+ *length = SDL_OutOfMemory();
|
|
|
+ } else {
|
|
|
+ *length = mime_data->length;
|
|
|
+ SDL_memcpy(buffer, mime_data->data, mime_data->length);
|
|
|
+ if (null_terminate) {
|
|
|
+ *((Uint8 *)buffer + mime_data->length) = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return buffer;
|
|
|
+}
|
|
|
+
|
|
|
+void*
|
|
|
Wayland_data_source_get_data(SDL_WaylandDataSource *source,
|
|
|
size_t *length, const char* mime_type,
|
|
|
SDL_bool null_terminate)
|
|
@@ -304,23 +373,26 @@ Wayland_data_source_get_data(SDL_WaylandDataSource *source,
|
|
|
SDL_SetError("Invalid data source");
|
|
|
} else {
|
|
|
mime_data = mime_data_list_find(&source->mimes, mime_type);
|
|
|
- if (mime_data != NULL && mime_data->length > 0) {
|
|
|
- size_t buffer_length = mime_data->length;
|
|
|
+ buffer = Wayland_source_get_data(mime_data, length, null_terminate);
|
|
|
+ }
|
|
|
|
|
|
- if (null_terminate == SDL_TRUE) {
|
|
|
- ++buffer_length;
|
|
|
- }
|
|
|
- buffer = SDL_malloc(buffer_length);
|
|
|
- if (buffer == NULL) {
|
|
|
- *length = SDL_OutOfMemory();
|
|
|
- } else {
|
|
|
- *length = mime_data->length;
|
|
|
- SDL_memcpy(buffer, mime_data->data, mime_data->length);
|
|
|
- if (null_terminate) {
|
|
|
- *((Uint8 *)buffer + mime_data->length) = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ return buffer;
|
|
|
+}
|
|
|
+
|
|
|
+void*
|
|
|
+Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSource *source,
|
|
|
+ size_t *length, const char* mime_type,
|
|
|
+ SDL_bool null_terminate)
|
|
|
+{
|
|
|
+ SDL_MimeDataList *mime_data = NULL;
|
|
|
+ void *buffer = NULL;
|
|
|
+ *length = 0;
|
|
|
+
|
|
|
+ if (source == NULL) {
|
|
|
+ SDL_SetError("Invalid primary selection source");
|
|
|
+ } else {
|
|
|
+ mime_data = mime_data_list_find(&source->mimes, mime_type);
|
|
|
+ buffer = Wayland_source_get_data(mime_data, length, null_terminate);
|
|
|
}
|
|
|
|
|
|
return buffer;
|
|
@@ -340,13 +412,27 @@ Wayland_data_source_destroy(SDL_WaylandDataSource *source)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void*
|
|
|
+void
|
|
|
+Wayland_primary_selection_source_destroy(SDL_WaylandPrimarySelectionSource *source)
|
|
|
+{
|
|
|
+ if (source != NULL) {
|
|
|
+ SDL_WaylandPrimarySelectionDevice *primary_selection_device = (SDL_WaylandPrimarySelectionDevice *) source->primary_selection_device;
|
|
|
+ if (primary_selection_device && (primary_selection_device->selection_source == source)) {
|
|
|
+ primary_selection_device->selection_source = NULL;
|
|
|
+ }
|
|
|
+ zwp_primary_selection_source_v1_destroy(source->source);
|
|
|
+ mime_data_list_free(&source->mimes);
|
|
|
+ SDL_free(source);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void*
|
|
|
Wayland_data_offer_receive(SDL_WaylandDataOffer *offer,
|
|
|
size_t *length, const char* mime_type,
|
|
|
SDL_bool null_terminate)
|
|
|
{
|
|
|
SDL_WaylandDataDevice *data_device = NULL;
|
|
|
-
|
|
|
+
|
|
|
int pipefd[2];
|
|
|
void *buffer = NULL;
|
|
|
*length = 0;
|
|
@@ -364,22 +450,59 @@ Wayland_data_offer_receive(SDL_WaylandDataOffer *offer,
|
|
|
WAYLAND_wl_display_flush(data_device->video_data->display);
|
|
|
|
|
|
close(pipefd[1]);
|
|
|
-
|
|
|
+
|
|
|
while (read_pipe(pipefd[0], &buffer, length, null_terminate) > 0);
|
|
|
close(pipefd[0]);
|
|
|
}
|
|
|
return buffer;
|
|
|
}
|
|
|
|
|
|
-int
|
|
|
+void*
|
|
|
+Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer *offer,
|
|
|
+ size_t *length, const char* mime_type,
|
|
|
+ SDL_bool null_terminate)
|
|
|
+{
|
|
|
+ SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL;
|
|
|
+
|
|
|
+ int pipefd[2];
|
|
|
+ void *buffer = NULL;
|
|
|
+ *length = 0;
|
|
|
+
|
|
|
+ if (offer == NULL) {
|
|
|
+ SDL_SetError("Invalid data offer");
|
|
|
+ } else if ((primary_selection_device = offer->primary_selection_device) == NULL) {
|
|
|
+ SDL_SetError("Primary selection device not initialized");
|
|
|
+ } else if (pipe2(pipefd, O_CLOEXEC|O_NONBLOCK) == -1) {
|
|
|
+ SDL_SetError("Could not read pipe");
|
|
|
+ } else {
|
|
|
+ zwp_primary_selection_offer_v1_receive(offer->offer, mime_type, pipefd[1]);
|
|
|
+
|
|
|
+ /* TODO: Needs pump and flush? */
|
|
|
+ WAYLAND_wl_display_flush(primary_selection_device->video_data->display);
|
|
|
+
|
|
|
+ close(pipefd[1]);
|
|
|
+
|
|
|
+ while (read_pipe(pipefd[0], &buffer, length, null_terminate) > 0);
|
|
|
+ close(pipefd[0]);
|
|
|
+ }
|
|
|
+ return buffer;
|
|
|
+}
|
|
|
+
|
|
|
+int
|
|
|
Wayland_data_offer_add_mime(SDL_WaylandDataOffer *offer,
|
|
|
const char* mime_type)
|
|
|
{
|
|
|
return mime_data_list_add(&offer->mimes, mime_type, NULL, 0);
|
|
|
}
|
|
|
|
|
|
+int
|
|
|
+Wayland_primary_selection_offer_add_mime(SDL_WaylandPrimarySelectionOffer *offer,
|
|
|
+ const char* mime_type)
|
|
|
+{
|
|
|
+ return mime_data_list_add(&offer->mimes, mime_type, NULL, 0);
|
|
|
+}
|
|
|
|
|
|
-SDL_bool
|
|
|
+SDL_bool
|
|
|
Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer,
|
|
|
const char *mime_type)
|
|
|
{
|
|
@@ -391,6 +514,18 @@ Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer,
|
|
|
return found;
|
|
|
}
|
|
|
|
|
|
+SDL_bool
|
|
|
+Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOffer *offer,
|
|
|
+ const char *mime_type)
|
|
|
+{
|
|
|
+ SDL_bool found = SDL_FALSE;
|
|
|
+
|
|
|
+ if (offer != NULL) {
|
|
|
+ found = mime_data_list_find(&offer->mimes, mime_type) != NULL;
|
|
|
+ }
|
|
|
+ return found;
|
|
|
+}
|
|
|
+
|
|
|
void
|
|
|
Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer)
|
|
|
{
|
|
@@ -401,6 +536,16 @@ Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void
|
|
|
+Wayland_primary_selection_offer_destroy(SDL_WaylandPrimarySelectionOffer *offer)
|
|
|
+{
|
|
|
+ if (offer != NULL) {
|
|
|
+ zwp_primary_selection_offer_v1_destroy(offer->offer);
|
|
|
+ mime_data_list_free(&offer->mimes);
|
|
|
+ SDL_free(offer);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
int
|
|
|
Wayland_data_device_clear_selection(SDL_WaylandDataDevice *data_device)
|
|
|
{
|
|
@@ -416,6 +561,22 @@ Wayland_data_device_clear_selection(SDL_WaylandDataDevice *data_device)
|
|
|
return status;
|
|
|
}
|
|
|
|
|
|
+int
|
|
|
+Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySelectionDevice *primary_selection_device)
|
|
|
+{
|
|
|
+ int status = 0;
|
|
|
+
|
|
|
+ if (primary_selection_device == NULL || primary_selection_device->primary_selection_device == NULL) {
|
|
|
+ status = SDL_SetError("Invalid Primary Selection Device");
|
|
|
+ } else if (primary_selection_device->selection_source != NULL) {
|
|
|
+ zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device,
|
|
|
+ NULL, 0);
|
|
|
+ Wayland_primary_selection_source_destroy(primary_selection_device->selection_source);
|
|
|
+ primary_selection_device->selection_source = NULL;
|
|
|
+ }
|
|
|
+ return status;
|
|
|
+}
|
|
|
+
|
|
|
int
|
|
|
Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device,
|
|
|
SDL_WaylandDataSource *source)
|
|
@@ -433,7 +594,7 @@ Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device,
|
|
|
|
|
|
wl_list_for_each(mime_data, &(source->mimes), link) {
|
|
|
wl_data_source_offer(source->source,
|
|
|
- mime_data->mime_type);
|
|
|
+ mime_data->mime_type);
|
|
|
|
|
|
/* TODO - Improve system for multiple mime types to same data */
|
|
|
for (index = 0; index < MIME_LIST_SIZE; ++index) {
|
|
@@ -443,9 +604,9 @@ Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device,
|
|
|
}
|
|
|
}
|
|
|
/* */
|
|
|
-
|
|
|
+
|
|
|
++num_offers;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
if (num_offers == 0) {
|
|
|
Wayland_data_device_clear_selection(data_device);
|
|
@@ -455,7 +616,7 @@ Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device,
|
|
|
if (data_device->selection_serial != 0) {
|
|
|
wl_data_device_set_selection(data_device->data_device,
|
|
|
source->source,
|
|
|
- data_device->selection_serial);
|
|
|
+ data_device->selection_serial);
|
|
|
}
|
|
|
if (data_device->selection_source != NULL) {
|
|
|
Wayland_data_source_destroy(data_device->selection_source);
|
|
@@ -468,6 +629,58 @@ Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device,
|
|
|
return status;
|
|
|
}
|
|
|
|
|
|
+int
|
|
|
+Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDevice *primary_selection_device,
|
|
|
+ SDL_WaylandPrimarySelectionSource *source)
|
|
|
+{
|
|
|
+ int status = 0;
|
|
|
+ size_t num_offers = 0;
|
|
|
+ size_t index = 0;
|
|
|
+
|
|
|
+ if (primary_selection_device == NULL) {
|
|
|
+ status = SDL_SetError("Invalid Primary Selection Device");
|
|
|
+ } else if (source == NULL) {
|
|
|
+ status = SDL_SetError("Invalid source");
|
|
|
+ } else {
|
|
|
+ SDL_MimeDataList *mime_data = NULL;
|
|
|
+
|
|
|
+ wl_list_for_each(mime_data, &(source->mimes), link) {
|
|
|
+ zwp_primary_selection_source_v1_offer(source->source,
|
|
|
+ mime_data->mime_type);
|
|
|
+
|
|
|
+ /* TODO - Improve system for multiple mime types to same data */
|
|
|
+ for (index = 0; index < MIME_LIST_SIZE; ++index) {
|
|
|
+ if (SDL_strcmp(mime_conversion_list[index][1], mime_data->mime_type) == 0) {
|
|
|
+ zwp_primary_selection_source_v1_offer(source->source,
|
|
|
+ mime_conversion_list[index][0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /* */
|
|
|
+
|
|
|
+ ++num_offers;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (num_offers == 0) {
|
|
|
+ Wayland_primary_selection_device_clear_selection(primary_selection_device);
|
|
|
+ status = SDL_SetError("No mime data");
|
|
|
+ } else {
|
|
|
+ /* Only set if there is a valid serial if not set it later */
|
|
|
+ if (primary_selection_device->selection_serial != 0) {
|
|
|
+ zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device,
|
|
|
+ source->source,
|
|
|
+ primary_selection_device->selection_serial);
|
|
|
+ }
|
|
|
+ if (primary_selection_device->selection_source != NULL) {
|
|
|
+ Wayland_primary_selection_source_destroy(primary_selection_device->selection_source);
|
|
|
+ }
|
|
|
+ primary_selection_device->selection_source = source;
|
|
|
+ source->primary_selection_device = primary_selection_device;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return status;
|
|
|
+}
|
|
|
+
|
|
|
int
|
|
|
Wayland_data_device_set_serial(SDL_WaylandDataDevice *data_device,
|
|
|
uint32_t serial)
|
|
@@ -481,13 +694,35 @@ Wayland_data_device_set_serial(SDL_WaylandDataDevice *data_device,
|
|
|
&& data_device->selection_source != NULL) {
|
|
|
wl_data_device_set_selection(data_device->data_device,
|
|
|
data_device->selection_source->source,
|
|
|
- serial);
|
|
|
+ data_device->selection_serial);
|
|
|
}
|
|
|
|
|
|
data_device->selection_serial = serial;
|
|
|
}
|
|
|
|
|
|
- return status;
|
|
|
+ return status;
|
|
|
+}
|
|
|
+
|
|
|
+int
|
|
|
+Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevice *primary_selection_device,
|
|
|
+ uint32_t serial)
|
|
|
+{
|
|
|
+ int status = -1;
|
|
|
+ if (primary_selection_device != NULL) {
|
|
|
+ status = 0;
|
|
|
+
|
|
|
+ /* If there was no serial and there is a pending selection set it now. */
|
|
|
+ if (primary_selection_device->selection_serial == 0
|
|
|
+ && primary_selection_device->selection_source != NULL) {
|
|
|
+ zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device,
|
|
|
+ primary_selection_device->selection_source->source,
|
|
|
+ primary_selection_device->selection_serial);
|
|
|
+ }
|
|
|
+
|
|
|
+ primary_selection_device->selection_serial = serial;
|
|
|
+ }
|
|
|
+
|
|
|
+ return status;
|
|
|
}
|
|
|
|
|
|
#endif /* SDL_VIDEO_DRIVER_WAYLAND */
|