From 7f693ce497d949b8f66e00a40f4477681ac71af1 Mon Sep 17 00:00:00 2001 From: LCD 47 Date: Thu, 16 Jan 2020 18:20:21 +0200 Subject: Fix: [SDL2] support pasting from clipboard on Linux --- src/os/unix/unix.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/os') diff --git a/src/os/unix/unix.cpp b/src/os/unix/unix.cpp index dc54badbd..e4e1d687c 100644 --- 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 -- cgit v1.2.3-70-g09d2