SDL: Only return current clipboard data under X11 (8dcb6)

From 8dcb6db82390681b5b00723804c87ce3738726e4 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 9 Oct 2025 11:36:22 -0700
Subject: [PATCH] Only return current clipboard data under X11

Fixes https://github.com/libsdl-org/SDL/issues/10192

(cherry picked from commit 9cf7cdf23a529bf2f6372ff14f7b4dd6d38d6c4a)
---
 src/video/x11/SDL_x11clipboard.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c
index 2cd42dc447188..6a4a1cec5b0e8 100644
--- a/src/video/x11/SDL_x11clipboard.c
+++ b/src/video/x11/SDL_x11clipboard.c
@@ -273,6 +273,11 @@ bool X11_SetClipboardData(SDL_VideoDevice *_this)
 void *X11_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *length)
 {
     SDL_VideoData *videodata = _this->internal;
+    if (!SDL_HasInternalClipboardData(_this, mime_type)) {
+        // This mime type wasn't advertised by the last selection owner.
+        // The atom might still have data, but it's stale, so ignore it.
+        return NULL;
+    }
     return GetSelectionData(_this, videodata->atoms.CLIPBOARD, mime_type, length);
 }