# HG changeset patch # User LCD 47 # Date 2020-01-16 16:20:21 # Node ID 4ef53c5b9862d25f2eadc39ae0dd2a76f3c5f2eb # Parent 3c3570951af9f5f739b8711fd4ab4fb62e3e143b Fix: [SDL2] support pasting from clipboard on Linux diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp --- a/src/os/unix/unix.cpp +++ b/src/os/unix/unix.cpp @@ -24,6 +24,10 @@ #include #include +#ifdef WITH_SDL2 +#include +#endif + #ifdef __APPLE__ #include #elif (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) || defined(__GLIBC__) @@ -266,6 +270,19 @@ int CDECL main(int argc, char *argv[]) #ifndef WITH_COCOA bool GetClipboardContents(char *buffer, const char *last) { +#ifdef WITH_SDL2 + if (SDL_HasClipboardText() == SDL_FALSE) { + return false; + } + + char *clip = SDL_GetClipboardText(); + if (clip != NULL) { + strecpy(buffer, clip, last); + SDL_free(clip); + return true; + } +#endif + return false; } #endif