[colobot] 239/390: Implemented the OSX clipboard using the AppKit API
Didier Raboud
odyx at moszumanska.debian.org
Fri Jun 12 14:21:50 UTC 2015
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch upstream/latest
in repository colobot.
commit 7bb12511d9efc65253a7927fdeae1bd69266c632
Author: MBlanc <manuel.blanc at estudiante.uam.es>
Date: Tue Dec 9 14:50:06 2014 +0100
Implemented the OSX clipboard using the AppKit API
The X11 dependency is no longer needed on OSX, and has been removed
---
CMakeLists.txt | 6 +-----
lib/clipboard/CMakeLists.txt | 3 +++
lib/clipboard/src/clipboardOSX.m | 24 ++++++++++++++++++++++++
src/CMakeLists.txt | 2 +-
4 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 89a6371..e11acf8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -256,12 +256,8 @@ include("${colobot_SOURCE_DIR}/cmake/msys.cmake")
##
# Clipboard support needs X11 libraries
##
-if(PLATFORM_GNU OR PLATFORM_MACOSX)
+if(PLATFORM_GNU)
find_package(X11 REQUIRED)
- if(PLATFORM_MACOSX)
- # Add the includes for X11
- include_directories("/opt/X11/include")
- endif()
endif()
diff --git a/lib/clipboard/CMakeLists.txt b/lib/clipboard/CMakeLists.txt
index 7999cc1..ff9157e 100644
--- a/lib/clipboard/CMakeLists.txt
+++ b/lib/clipboard/CMakeLists.txt
@@ -7,6 +7,9 @@ add_definitions(-DLIB_COMPILE=1)
if(PLATFORM_WINDOWS)
set(CLIPBOARD_SRC src/clipboardWin32.c)
+elseif(PLATFORM_MACOSX)
+ set(CMAKE_CXX_FLAGS "-fobjc-arc")
+ set(CLIPBOARD_SRC src/clipboardOSX.m)
else()
set(CLIPBOARD_SRC src/clipboardX11.c)
endif()
diff --git a/lib/clipboard/src/clipboardOSX.m b/lib/clipboard/src/clipboardOSX.m
new file mode 100644
index 0000000..893dba8
--- /dev/null
+++ b/lib/clipboard/src/clipboardOSX.m
@@ -0,0 +1,24 @@
+
+#include <stdbool.h>
+#include <string.h>
+
+#include <AppKit/AppKit.h>
+
+char *widgetGetClipboardText()
+{
+ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
+ NSString *myString = [pasteboard stringForType:NSPasteboardTypeString];
+
+ if (myString == nil || [myString length] == 0) return NULL;
+
+ return strdup([myString UTF8String]);
+}
+
+bool widgetSetClipboardText(const char *text)
+{
+ NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
+ [pasteboard clearContents];
+
+ NSString *stringFromUTFString = [[NSString alloc] initWithUTF8String:text];
+ return [pasteboard setString:stringFromUTFString forType:NSStringPboardType];
+}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 613d92a..013c4e0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -35,7 +35,7 @@ elseif(PLATFORM_LINUX)
set(PLATFORM_LIBS "-lrt -lX11")
elseif(PLATFORM_MACOSX)
find_library(LIBINTL_LIBRARY NAMES intl libintl )
- set(PLATFORM_LIBS ${LIBINTL_LIBRARY} ${X11_X11_LIB})
+ set(PLATFORM_LIBS ${LIBINTL_LIBRARY})
endif()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list