summaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorLCD 47 <lcd047@gmail.com>2020-01-16 18:20:21 +0200
committerCharles Pigott <charlespigott@googlemail.com>2020-02-15 19:38:25 +0000
commit7f693ce497d949b8f66e00a40f4477681ac71af1 (patch)
tree2682c08fdf23cd65161b4d22ba50919a9242d98a /src/os
parent87909855c885d110907fa0f4e39a81137ed206de (diff)
downloadopenttd-7f693ce497d949b8f66e00a40f4477681ac71af1.tar.xz
Fix: [SDL2] support pasting from clipboard on Linux
Diffstat (limited to 'src/os')
-rw-r--r--src/os/unix/unix.cpp17
1 files changed, 17 insertions, 0 deletions
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 <time.h>
#include <signal.h>
+#ifdef WITH_SDL2
+#include <SDL.h>
+#endif
+
#ifdef __APPLE__
#include <sys/mount.h>
#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