From 11ccbe650699e393dbbc28a0f1c76fce8be65a75 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sat, 22 Nov 2025 01:24:06 +0200 Subject: [PATCH] ports/SDL2: Add clipboard support --- .../patches/0001-add-banan_os-support.patch | 139 ++++++++++++++++-- 1 file changed, 123 insertions(+), 16 deletions(-) diff --git a/ports/SDL2/patches/0001-add-banan_os-support.patch b/ports/SDL2/patches/0001-add-banan_os-support.patch index effc7308..6efe4382 100644 --- a/ports/SDL2/patches/0001-add-banan_os-support.patch +++ b/ports/SDL2/patches/0001-add-banan_os-support.patch @@ -1,6 +1,6 @@ diff -ruN SDL2-2.32.8/cmake/sdlplatform.cmake SDL2-2.32.8-banan_os/cmake/sdlplatform.cmake --- SDL2-2.32.8/cmake/sdlplatform.cmake 2024-08-14 13:35:43.000000000 +0300 -+++ SDL2-2.32.8-banan_os/cmake/sdlplatform.cmake 2025-08-06 02:07:18.347821313 +0300 ++++ SDL2-2.32.8-banan_os/cmake/sdlplatform.cmake 2025-11-22 00:45:00.922311100 +0200 @@ -28,6 +28,8 @@ set(SDL_CMAKE_PLATFORM AIX) elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*") @@ -12,7 +12,7 @@ diff -ruN SDL2-2.32.8/cmake/sdlplatform.cmake SDL2-2.32.8-banan_os/cmake/sdlplat endif() diff -ruN SDL2-2.32.8/CMakeLists.txt SDL2-2.32.8-banan_os/CMakeLists.txt --- SDL2-2.32.8/CMakeLists.txt 2025-06-03 02:00:39.000000000 +0300 -+++ SDL2-2.32.8-banan_os/CMakeLists.txt 2025-08-06 02:19:44.864415796 +0300 ++++ SDL2-2.32.8-banan_os/CMakeLists.txt 2025-11-22 00:45:00.923441418 +0200 @@ -14,7 +14,7 @@ set(SDL2_SUBPROJECT ON) endif() @@ -55,7 +55,7 @@ diff -ruN SDL2-2.32.8/CMakeLists.txt SDL2-2.32.8-banan_os/CMakeLists.txt + file(GLOB VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/banan_os/*.cpp) + list(APPEND SOURCE_FILES ${VIDEO_SOURCES}) + set(HAVE_SDL_VIDEO TRUE) -+ list(APPEND EXTRA_LIBS gui input) ++ list(APPEND EXTRA_LIBS gui input clipboard) + + if(SDL_OPENGL) + set(SDL_VIDEO_OPENGL 1) @@ -91,7 +91,7 @@ diff -ruN SDL2-2.32.8/CMakeLists.txt SDL2-2.32.8-banan_os/CMakeLists.txt file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/riscos/*.c) diff -ruN SDL2-2.32.8/include/SDL_config.h.cmake SDL2-2.32.8-banan_os/include/SDL_config.h.cmake --- SDL2-2.32.8/include/SDL_config.h.cmake 2025-01-01 17:47:53.000000000 +0200 -+++ SDL2-2.32.8-banan_os/include/SDL_config.h.cmake 2025-08-06 02:01:21.085539504 +0300 ++++ SDL2-2.32.8-banan_os/include/SDL_config.h.cmake 2025-11-22 00:45:00.924001549 +0200 @@ -307,6 +307,7 @@ #cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND @SDL_AUDIO_DRIVER_FUSIONSOUND@ #cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC @SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC@ @@ -110,7 +110,7 @@ diff -ruN SDL2-2.32.8/include/SDL_config.h.cmake SDL2-2.32.8-banan_os/include/SD #cmakedefine SDL_VIDEO_DRIVER_DIRECTFB @SDL_VIDEO_DRIVER_DIRECTFB@ diff -ruN SDL2-2.32.8/include/SDL_platform.h SDL2-2.32.8-banan_os/include/SDL_platform.h --- SDL2-2.32.8/include/SDL_platform.h 2025-01-01 17:47:53.000000000 +0200 -+++ SDL2-2.32.8-banan_os/include/SDL_platform.h 2025-08-06 02:01:21.085701327 +0300 ++++ SDL2-2.32.8-banan_os/include/SDL_platform.h 2025-11-22 00:45:00.924303894 +0200 @@ -36,6 +36,10 @@ #undef __HAIKU__ #define __HAIKU__ 1 @@ -124,7 +124,7 @@ diff -ruN SDL2-2.32.8/include/SDL_platform.h SDL2-2.32.8-banan_os/include/SDL_pl #define __BSDI__ 1 diff -ruN SDL2-2.32.8/src/audio/banan_os/SDL_banan_os_audio.cpp SDL2-2.32.8-banan_os/src/audio/banan_os/SDL_banan_os_audio.cpp --- SDL2-2.32.8/src/audio/banan_os/SDL_banan_os_audio.cpp 1970-01-01 02:00:00.000000000 +0200 -+++ SDL2-2.32.8-banan_os/src/audio/banan_os/SDL_banan_os_audio.cpp 2025-08-06 02:01:21.085876490 +0300 ++++ SDL2-2.32.8-banan_os/src/audio/banan_os/SDL_banan_os_audio.cpp 2025-11-22 00:45:00.924702550 +0200 @@ -0,0 +1,150 @@ +/* + Simple DirectMedia Layer @@ -278,7 +278,7 @@ diff -ruN SDL2-2.32.8/src/audio/banan_os/SDL_banan_os_audio.cpp SDL2-2.32.8-bana +#endif diff -ruN SDL2-2.32.8/src/audio/banan_os/SDL_banan_os_audio.h SDL2-2.32.8-banan_os/src/audio/banan_os/SDL_banan_os_audio.h --- SDL2-2.32.8/src/audio/banan_os/SDL_banan_os_audio.h 1970-01-01 02:00:00.000000000 +0200 -+++ SDL2-2.32.8-banan_os/src/audio/banan_os/SDL_banan_os_audio.h 2025-08-06 02:01:21.085937043 +0300 ++++ SDL2-2.32.8-banan_os/src/audio/banan_os/SDL_banan_os_audio.h 2025-11-22 00:45:00.924820303 +0200 @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer @@ -316,7 +316,7 @@ diff -ruN SDL2-2.32.8/src/audio/banan_os/SDL_banan_os_audio.h SDL2-2.32.8-banan_ +}; diff -ruN SDL2-2.32.8/src/audio/SDL_audio.c SDL2-2.32.8-banan_os/src/audio/SDL_audio.c --- SDL2-2.32.8/src/audio/SDL_audio.c 2025-01-01 17:47:53.000000000 +0200 -+++ SDL2-2.32.8-banan_os/src/audio/SDL_audio.c 2025-08-06 02:01:21.086082872 +0300 ++++ SDL2-2.32.8-banan_os/src/audio/SDL_audio.c 2025-11-22 00:45:00.925178591 +0200 @@ -87,6 +87,9 @@ #ifdef SDL_AUDIO_DRIVER_HAIKU &HAIKUAUDIO_bootstrap, @@ -329,7 +329,7 @@ diff -ruN SDL2-2.32.8/src/audio/SDL_audio.c SDL2-2.32.8-banan_os/src/audio/SDL_a #endif diff -ruN SDL2-2.32.8/src/audio/SDL_sysaudio.h SDL2-2.32.8-banan_os/src/audio/SDL_sysaudio.h --- SDL2-2.32.8/src/audio/SDL_sysaudio.h 2025-01-01 17:47:53.000000000 +0200 -+++ SDL2-2.32.8-banan_os/src/audio/SDL_sysaudio.h 2025-08-06 02:01:21.086309718 +0300 ++++ SDL2-2.32.8-banan_os/src/audio/SDL_sysaudio.h 2025-11-22 00:45:00.925759535 +0200 @@ -196,6 +196,7 @@ extern AudioBootStrap WINMM_bootstrap; extern AudioBootStrap PAUDIO_bootstrap; @@ -340,7 +340,7 @@ diff -ruN SDL2-2.32.8/src/audio/SDL_sysaudio.h SDL2-2.32.8-banan_os/src/audio/SD extern AudioBootStrap DUMMYAUDIO_bootstrap; diff -ruN SDL2-2.32.8/src/misc/banan_os/SDL_sysurl.cpp SDL2-2.32.8-banan_os/src/misc/banan_os/SDL_sysurl.cpp --- SDL2-2.32.8/src/misc/banan_os/SDL_sysurl.cpp 1970-01-01 02:00:00.000000000 +0200 -+++ SDL2-2.32.8-banan_os/src/misc/banan_os/SDL_sysurl.cpp 2025-08-06 02:01:21.086457363 +0300 ++++ SDL2-2.32.8-banan_os/src/misc/banan_os/SDL_sysurl.cpp 2025-11-22 00:45:00.926117334 +0200 @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer @@ -372,9 +372,111 @@ diff -ruN SDL2-2.32.8/src/misc/banan_os/SDL_sysurl.cpp SDL2-2.32.8-banan_os/src/ + +/* vi: set ts=4 sw=4 expandtab: */ + +diff -ruN SDL2-2.32.8/src/video/banan_os/SDL_banan_os_clipboard.cpp SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_clipboard.cpp +--- SDL2-2.32.8/src/video/banan_os/SDL_banan_os_clipboard.cpp 1970-01-01 02:00:00.000000000 +0200 ++++ SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_clipboard.cpp 2025-11-22 01:10:01.840984523 +0200 +@@ -0,0 +1,51 @@ ++/* ++ Simple DirectMedia Layer ++ Copyright (C) 1997-2025 Sam Lantinga ++ ++ This software is provided 'as-is', without any express or implied ++ warranty. In no event will the authors be held liable for any damages ++ arising from the use of this software. ++ ++ Permission is granted to anyone to use this software for any purpose, ++ including commercial applications, and to alter it and redistribute it ++ freely, subject to the following restrictions: ++ ++ 1. The origin of this software must not be misrepresented; you must not ++ claim that you wrote the original software. If you use this software ++ in a product, an acknowledgment in the product documentation would be ++ appreciated but is not required. ++ 2. Altered source versions must be plainly marked as such, and must not be ++ misrepresented as being the original software. ++ 3. This notice may not be removed or altered from any source distribution. ++*/ ++#include "../../SDL_internal.h" ++ ++#ifdef SDL_VIDEO_DRIVER_BANANOS ++ ++#include "SDL_banan_os_clipboard.h" ++ ++#include ++ ++int BANANOS_SetClipboardText(_THIS, const char *text) { ++ if (LibClipboard::Clipboard::set_clipboard_text(text).is_error()) ++ return -1; ++ return 0; ++} ++ ++char *BANANOS_GetClipboardText(_THIS) { ++ auto text_or_error = LibClipboard::Clipboard::get_clipboard_text(); ++ if (text_or_error.is_error()) ++ return NULL; ++ return SDL_strdup(text_or_error.value().data()); ++} ++ ++SDL_bool BANANOS_HasClipboardText(_THIS) { ++ auto text_or_error = LibClipboard::Clipboard::get_clipboard_text(); ++ if (text_or_error.is_error()) ++ return SDL_FALSE; ++ return text_or_error.value().empty() ? SDL_FALSE : SDL_TRUE; ++} ++ ++#endif /* SDL_VIDEO_DRIVER_BANANOS */ ++ ++/* vi: set ts=4 sw=4 expandtab: */ +diff -ruN SDL2-2.32.8/src/video/banan_os/SDL_banan_os_clipboard.h SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_clipboard.h +--- SDL2-2.32.8/src/video/banan_os/SDL_banan_os_clipboard.h 1970-01-01 02:00:00.000000000 +0200 ++++ SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_clipboard.h 2025-11-22 01:10:16.932880273 +0200 +@@ -0,0 +1,43 @@ ++/* ++ Simple DirectMedia Layer ++ Copyright (C) 1997-2025 Sam Lantinga ++ ++ This software is provided 'as-is', without any express or implied ++ warranty. In no event will the authors be held liable for any damages ++ arising from the use of this software. ++ ++ Permission is granted to anyone to use this software for any purpose, ++ including commercial applications, and to alter it and redistribute it ++ freely, subject to the following restrictions: ++ ++ 1. The origin of this software must not be misrepresented; you must not ++ claim that you wrote the original software. If you use this software ++ in a product, an acknowledgment in the product documentation would be ++ appreciated but is not required. ++ 2. Altered source versions must be plainly marked as such, and must not be ++ misrepresented as being the original software. ++ 3. This notice may not be removed or altered from any source distribution. ++*/ ++ ++#ifndef SDL_BANANOS_CLIPBOARD_H ++#define SDL_BANANOS_CLIPBOARD_H ++ ++#include "../../SDL_internal.h" ++ ++#include "../SDL_sysvideo.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++extern int BANANOS_SetClipboardText(_THIS, const char *text); ++extern char *BANANOS_GetClipboardText(_THIS); ++extern SDL_bool BANANOS_HasClipboardText(_THIS); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif ++ ++/* vi: set ts=4 sw=4 expandtab: */ diff -ruN SDL2-2.32.8/src/video/banan_os/SDL_banan_os_message_box.cpp SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_message_box.cpp --- SDL2-2.32.8/src/video/banan_os/SDL_banan_os_message_box.cpp 1970-01-01 02:00:00.000000000 +0200 -+++ SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_message_box.cpp 2025-08-06 02:01:21.086557935 +0300 ++++ SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_message_box.cpp 2025-11-22 00:45:00.926337964 +0200 @@ -0,0 +1,60 @@ +/* + Simple DirectMedia Layer @@ -438,7 +540,7 @@ diff -ruN SDL2-2.32.8/src/video/banan_os/SDL_banan_os_message_box.cpp SDL2-2.32. +/* vi: set ts=4 sw=4 expandtab: */ diff -ruN SDL2-2.32.8/src/video/banan_os/SDL_banan_os_message_box.h SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_message_box.h --- SDL2-2.32.8/src/video/banan_os/SDL_banan_os_message_box.h 1970-01-01 02:00:00.000000000 +0200 -+++ SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_message_box.h 2025-08-06 02:01:21.086603053 +0300 ++++ SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_message_box.h 2025-11-22 00:45:00.926434625 +0200 @@ -0,0 +1,45 @@ +/* + Simple DirectMedia Layer @@ -487,8 +589,8 @@ diff -ruN SDL2-2.32.8/src/video/banan_os/SDL_banan_os_message_box.h SDL2-2.32.8- +/* vi: set ts=4 sw=4 expandtab: */ diff -ruN SDL2-2.32.8/src/video/banan_os/SDL_banan_os_video.cpp SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_video.cpp --- SDL2-2.32.8/src/video/banan_os/SDL_banan_os_video.cpp 1970-01-01 02:00:00.000000000 +0200 -+++ SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_video.cpp 2025-08-21 02:32:59.649175565 +0300 -@@ -0,0 +1,724 @@ ++++ SDL2-2.32.8-banan_os/src/video/banan_os/SDL_banan_os_video.cpp 2025-11-22 01:08:26.204647073 +0200 +@@ -0,0 +1,729 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga @@ -518,6 +620,7 @@ diff -ruN SDL2-2.32.8/src/video/banan_os/SDL_banan_os_video.cpp SDL2-2.32.8-bana +#include "../../events/SDL_events_c.h" +} + ++#include "SDL_banan_os_clipboard.h" +#include "SDL_banan_os_message_box.h" + +#include @@ -1199,6 +1302,10 @@ diff -ruN SDL2-2.32.8/src/video/banan_os/SDL_banan_os_video.cpp SDL2-2.32.8-bana + device->GL_MakeCurrent = BANANOS_GL_MakeCurrent; + device->GL_SwapWindow = BANANOS_GL_SwapWindow; + ++ device->SetClipboardText = BANANOS_SetClipboardText; ++ device->GetClipboardText = BANANOS_GetClipboardText; ++ device->HasClipboardText = BANANOS_HasClipboardText; ++ + device->free = BANANOS_free; + + return device; @@ -1215,7 +1322,7 @@ diff -ruN SDL2-2.32.8/src/video/banan_os/SDL_banan_os_video.cpp SDL2-2.32.8-bana +/* vi: set ts=4 sw=4 expandtab: */ diff -ruN SDL2-2.32.8/src/video/SDL_sysvideo.h SDL2-2.32.8-banan_os/src/video/SDL_sysvideo.h --- SDL2-2.32.8/src/video/SDL_sysvideo.h 2025-05-20 00:24:41.000000000 +0300 -+++ SDL2-2.32.8-banan_os/src/video/SDL_sysvideo.h 2025-08-06 02:01:21.086873550 +0300 ++++ SDL2-2.32.8-banan_os/src/video/SDL_sysvideo.h 2025-11-22 00:45:00.927152737 +0200 @@ -462,6 +462,7 @@ extern VideoBootStrap WINDOWS_bootstrap; extern VideoBootStrap WINRT_bootstrap; @@ -1226,7 +1333,7 @@ diff -ruN SDL2-2.32.8/src/video/SDL_sysvideo.h SDL2-2.32.8-banan_os/src/video/SD extern VideoBootStrap Android_bootstrap; diff -ruN SDL2-2.32.8/src/video/SDL_video.c SDL2-2.32.8-banan_os/src/video/SDL_video.c --- SDL2-2.32.8/src/video/SDL_video.c 2025-05-20 00:24:41.000000000 +0300 -+++ SDL2-2.32.8-banan_os/src/video/SDL_video.c 2025-08-06 02:01:21.087224294 +0300 ++++ SDL2-2.32.8-banan_os/src/video/SDL_video.c 2025-11-22 00:45:00.928264617 +0200 @@ -96,6 +96,9 @@ #ifdef SDL_VIDEO_DRIVER_HAIKU &HAIKU_bootstrap,