update SDL3 to 3.2.6.

This commit is contained in:
Sasha Szpakowski
2025-03-02 14:42:35 -04:00
parent 3582488fbc
commit 30709de450
407 changed files with 20390 additions and 5388 deletions
+28 -7
View File
@@ -41,12 +41,12 @@ static const void *ClipboardDataCallback(void *userdata, const char *mime_type,
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_Log("Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
if (!SDL_CreateWindowAndRenderer("testclipboard", 640, 480, 0, &window, &renderer)) {
SDL_Log("Couldn't create window and renderer: %s\n", SDL_GetError());
SDL_Log("Couldn't create window and renderer: %s", SDL_GetError());
return SDL_APP_FAILURE;
}
return SDL_APP_CONTINUE;
@@ -63,18 +63,20 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
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!");
}
break;
case SDL_EVENT_CLIPBOARD_UPDATE:
if (event->clipboard.num_mime_types > 0) {
int i;
SDL_Log("Clipboard updated:\n");
SDL_Log("Clipboard updated:");
for (i = 0; event->clipboard.mime_types[i]; ++i) {
SDL_Log(" %s\n", event->clipboard.mime_types[i]);
SDL_Log(" %s", event->clipboard.mime_types[i]);
}
} else {
SDL_Log("Clipboard cleared\n");
SDL_Log("Clipboard cleared");
}
break;
@@ -99,6 +101,15 @@ static float PrintClipboardText(float x, float y, const char *mime_type)
return 0.0f;
}
static float PrintPrimarySelectionText(float x, float y)
{
if (SDL_HasPrimarySelectionText()) {
SDL_RenderDebugText(renderer, x, y, SDL_GetPrimarySelectionText());
return SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE + 2.0f;
}
return 0.0f;
}
static float PrintClipboardImage(float x, float y, const char *mime_type)
{
/* We don't actually need to read this data each frame, but this is a simple example */
@@ -134,7 +145,7 @@ static float PrintClipboardImage(float x, float y, const char *mime_type)
return 0.0f;
}
static void PrintClipboardContents(float x, float y)
static float PrintClipboardContents(float x, float y)
{
char **clipboard_mime_types = SDL_GetClipboardMimeTypes(NULL);
if (clipboard_mime_types) {
@@ -152,6 +163,8 @@ static void PrintClipboardContents(float x, float y)
}
SDL_free(clipboard_mime_types);
}
return y;
}
SDL_AppResult SDL_AppIterate(void *appstate)
@@ -164,10 +177,18 @@ SDL_AppResult SDL_AppIterate(void *appstate)
float y = 4.0f;
SDL_RenderDebugText(renderer, x, y, "Press Ctrl+C to copy content to the clipboard");
y += SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * 2;
SDL_RenderDebugText(renderer, x, y, "Press Ctrl+P to set the primary selection text");
y += SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * 2;
SDL_RenderDebugText(renderer, x, y, "Clipboard contents:");
x += SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * 2;
y += SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE + 2;
PrintClipboardContents(x, y);
y = PrintClipboardContents(x, y);
if (SDL_HasPrimarySelectionText()) {
x = 4.0f;
SDL_RenderDebugText(renderer, x, y, "Primary selection text contents:");
y += SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE + 2;
PrintPrimarySelectionText(x + SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * 2, y);
}
SDL_RenderPresent(renderer);