From a9c988b2a9f01c0038517ca3a283e3a036eec243 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 23 May 2023 14:36:25 -0700
Subject: [PATCH] Fixed building on 32-bit Linux
---
src/video/x11/SDL_x11clipboard.c | 9 +++++++--
src/video/x11/SDL_x11events.c | 6 +++---
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c
index a61a4565633a..2b3c0b3d0744 100644
--- a/src/video/x11/SDL_x11clipboard.c
+++ b/src/video/x11/SDL_x11clipboard.c
@@ -41,13 +41,15 @@ static void *X11_ClipboardTextCallback(size_t *length, const char *mime_type, vo
{
void *data = NULL;
SDL_bool valid_mime_type = SDL_FALSE;
+ size_t i;
+
*length = 0;
if (userdata == NULL) {
return data;
}
- for (size_t i = 0; i < TEXT_MIME_TYPES_LEN; ++i) {
+ for (i = 0; i < TEXT_MIME_TYPES_LEN; ++i) {
if (SDL_strcmp(mime_type, text_mime_types[i]) == 0) {
valid_mime_type = SDL_TRUE;
break;
@@ -163,6 +165,7 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, size_
Atom selection;
Atom seln_type;
int seln_format;
+ unsigned long count;
unsigned long overflow;
Uint64 waitStart;
Uint64 waitElapsed;
@@ -170,6 +173,7 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, size_
void *data = NULL;
unsigned char *src = NULL;
Atom XA_MIME = X11_XInternAtom(display, mime_type, False);
+
*length = 0;
/* Get the window that holds the selection */
@@ -216,8 +220,9 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, size_
}
if (X11_XGetWindowProperty(display, owner, selection, 0, INT_MAX / 4, False,
- XA_MIME, &seln_type, &seln_format, length, &overflow, &src) == Success) {
+ XA_MIME, &seln_type, &seln_format, &count, &overflow, &src) == Success) {
if (seln_type == XA_MIME) {
+ *length = (size_t)count;
data = CloneDataBuffer(src, length, nullterminate);
}
X11_XFree(src);
diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c
index df058f67d714..cc2f8564efa7 100644
--- a/src/video/x11/SDL_x11events.c
+++ b/src/video/x11/SDL_x11events.c
@@ -628,8 +628,8 @@ static void X11_HandleClipboardEvent(SDL_VideoDevice *_this, const XEvent *xeven
const XSelectionRequestEvent *req = &xevent->xselectionrequest;
XEvent sevent;
int mime_formats;
- unsigned long nbytes;
unsigned char *seln_data;
+ size_t seln_length = 0;
Atom XA_TARGETS = X11_XInternAtom(display, "TARGETS", 0);
SDLX11_ClipboardData *clipboard;
@@ -685,11 +685,11 @@ static void X11_HandleClipboardEvent(SDL_VideoDevice *_this, const XEvent *xeven
}
/* FIXME: We don't support the X11 INCR protocol for large clipboards. Do we want that? */
- seln_data = clipboard->callback(&nbytes, mime_type, clipboard->userdata);
+ seln_data = clipboard->callback(&seln_length, mime_type, clipboard->userdata);
if (seln_data != NULL) {
X11_XChangeProperty(display, req->requestor, req->property,
req->target, 8, PropModeReplace,
- seln_data, nbytes);
+ seln_data, seln_length);
sevent.xselection.property = req->property;
sevent.xselection.target = req->target;
}