SDL: tests: Add clipboard clearing functionality to testclipboard

From 7fe81f789fb5bab65318488e923b950dc7fedea8 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Mon, 22 Dec 2025 09:04:33 -0500
Subject: [PATCH] tests: Add clipboard clearing functionality to testclipboard

Use Alt+C/P to clear the clipboard/primary selection in testclipboard.
---
 test/testclipboard.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/test/testclipboard.c b/test/testclipboard.c
index a991a8b343028..40dc12276a859 100644
--- a/test/testclipboard.c
+++ b/test/testclipboard.c
@@ -61,11 +61,18 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
         if (event->key.key == SDLK_ESCAPE) {
             return SDL_APP_SUCCESS;
         }
-        if (event->key.key == SDLK_C && event->key.mod & SDL_KMOD_CTRL) {
-            SDL_SetClipboardData(ClipboardDataCallback, NULL, NULL, mime_types, SDL_arraysize(mime_types));
-            break;
-        } else if (event->key.key == SDLK_P && event->key.mod & SDL_KMOD_CTRL) {
-            SDL_SetPrimarySelectionText("SDL Primary Selection Text!");
+        if (event->key.key == SDLK_C) {
+            if (event->key.mod & SDL_KMOD_CTRL) {
+                SDL_SetClipboardData(ClipboardDataCallback, NULL, NULL, mime_types, SDL_arraysize(mime_types));
+            } else if (event->key.mod & SDL_KMOD_ALT) {
+                SDL_ClearClipboardData();
+            }
+        } else if (event->key.key == SDLK_P) {
+            if (event->key.mod & SDL_KMOD_CTRL) {
+                SDL_SetPrimarySelectionText("SDL Primary Selection Text!");
+            } else if (event->key.mod & SDL_KMOD_ALT) {
+                SDL_SetPrimarySelectionText(NULL);
+            }
         }
         break;
 
@@ -188,9 +195,9 @@ SDL_AppResult SDL_AppIterate(void *appstate)
     SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
     float x = 4.0f;
     float y = 4.0f;
-    SDL_RenderDebugText(renderer, x, y, "Press Ctrl+C to copy content to the clipboard");
+    SDL_RenderDebugText(renderer, x, y, "Press Ctrl+C to copy content to the clipboard (Alt+C to clear)");
     y += SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * 2;
-    SDL_RenderDebugText(renderer, x, y, "Press Ctrl+P to set the primary selection text");
+    SDL_RenderDebugText(renderer, x, y, "Press Ctrl+P to set the primary selection text (Alt+P to clear)");
     y += SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * 2;
     SDL_RenderDebugText(renderer, x, y, "Clipboard contents:");
     x += SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * 2;