diff --git a/JavaApp/libs_caciocavallo/cacio-androidnw-1.10-SNAPSHOT.jar b/JavaApp/libs_caciocavallo/cacio-androidnw-1.10-SNAPSHOT.jar index 4fdaa9c7..fa2db2a1 100644 Binary files a/JavaApp/libs_caciocavallo/cacio-androidnw-1.10-SNAPSHOT.jar and b/JavaApp/libs_caciocavallo/cacio-androidnw-1.10-SNAPSHOT.jar differ diff --git a/JavaApp/libs_caciocavallo/cacio-shared-1.10-SNAPSHOT.jar b/JavaApp/libs_caciocavallo/cacio-shared-1.10-SNAPSHOT.jar index a7129ca1..5171bec5 100644 Binary files a/JavaApp/libs_caciocavallo/cacio-shared-1.10-SNAPSHOT.jar and b/JavaApp/libs_caciocavallo/cacio-shared-1.10-SNAPSHOT.jar differ diff --git a/JavaApp/libs_caciocavallo17/cacio-shared-1.18-SNAPSHOT.jar b/JavaApp/libs_caciocavallo17/cacio-shared-1.18-SNAPSHOT.jar index 0d4859d2..39d65c52 100644 Binary files a/JavaApp/libs_caciocavallo17/cacio-shared-1.18-SNAPSHOT.jar and b/JavaApp/libs_caciocavallo17/cacio-shared-1.18-SNAPSHOT.jar differ diff --git a/JavaApp/libs_caciocavallo17/cacio-tta-1.18-SNAPSHOT.jar b/JavaApp/libs_caciocavallo17/cacio-tta-1.18-SNAPSHOT.jar index 91bc6420..59f113b1 100644 Binary files a/JavaApp/libs_caciocavallo17/cacio-tta-1.18-SNAPSHOT.jar and b/JavaApp/libs_caciocavallo17/cacio-tta-1.18-SNAPSHOT.jar differ diff --git a/Natives/environ.h b/Natives/environ.h index bb3a9a8b..d189d654 100644 --- a/Natives/environ.h +++ b/Natives/environ.h @@ -27,6 +27,9 @@ typedef void GLFW_invoke_Scroll_func(void* window, double xoffset, double yoffse typedef void GLFW_invoke_WindowPos_func(void* window, int x, int y); typedef void GLFW_invoke_WindowSize_func(void* window, int width, int height); +jclass class_CTCClipboard; +jmethodID method_SystemClipboardDataReceived; + //struct pojav_environ_s { //struct ANativeWindow* pojavWindow; //render_window_t* mainWindowBundle; diff --git a/Natives/input_bridge_v3.m b/Natives/input_bridge_v3.m index e73346d9..a9f4ebab 100644 --- a/Natives/input_bridge_v3.m +++ b/Natives/input_bridge_v3.m @@ -95,7 +95,29 @@ hooked_ProcessImpl_forkAndExec(JNIEnv *env, jobject process, jint mode, jbyteArr } // Part of awt_bridge +void CTCClipboard_nQuerySystemClipboard(JNIEnv *env, jclass clazz) { + if(method_SystemClipboardDataReceived == NULL) { + class_CTCClipboard = (*env)->NewGlobalRef(env, clazz); + method_SystemClipboardDataReceived = (*env)->GetStaticMethodID(env, clazz, "systemClipboardDataReceived", "(Ljava/lang/String;Ljava/lang/String;)V"); } + // From Java_net_kdt_pojavlaunch_AWTInputBridge_nativeClipboardReceived + // Note: we cannot use main_queue here as it will cause deadlock + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + JNIEnv *env; + (*runtimeJavaVMPtr)->AttachCurrentThread(runtimeJavaVMPtr, &env, NULL); + const char* mimeChars = "text/plain"; + (*env)->CallStaticVoidMethod(env, class_CTCClipboard, method_SystemClipboardDataReceived, + UIKit_accessClipboard(env, CLIPBOARD_PASTE, NULL), + (*env)->NewStringUTF(env, mimeChars)); + (*runtimeJavaVMPtr)->DetachCurrentThread(runtimeJavaVMPtr); + }); +} + +void CTCClipboard_nPutClipboardData(JNIEnv* env, jclass clazz, jstring clipboardData, jstring clipboardDataMime) { + // TODO: handle non-text data(?) + UIKit_accessClipboard(env, CLIPBOARD_COPY, clipboardData); +} + void CTCDesktopPeer_openGlobal(JNIEnv *env, jclass clazz, jstring path) { const char* stringChars = (*env)->GetStringUTFChars(env, path, NULL); openURLGlobal(@(stringChars)); @@ -118,6 +140,19 @@ void registerOpenHandler() { }; (*runtimeJNIEnvPtr)->RegisterNatives(runtimeJNIEnvPtr, cls, forkAndExecMethod, 1); + // Register CTCClipboard natives + cls = (*runtimeJNIEnvPtr)->FindClass(runtimeJNIEnvPtr, "net/java/openjdk/cacio/ctc/CTCClipboard"); + if ((*runtimeJNIEnvPtr)->ExceptionOccurred(runtimeJNIEnvPtr)) { + // Java 17 + (*runtimeJNIEnvPtr)->ExceptionClear(runtimeJNIEnvPtr); + cls = (*runtimeJNIEnvPtr)->FindClass(runtimeJNIEnvPtr, "com/github/caciocavallosilano/cacio/ctc/CTCClipboard"); + } + JNINativeMethod clipboardMethods[] = { + {"nQuerySystemClipboard", "()V", (void *)&CTCClipboard_nQuerySystemClipboard}, + {"nPutClipboardData", "(Ljava/lang/String;Ljava/lang/String;)V", (void *)&CTCClipboard_nPutClipboardData} + }; + (*runtimeJNIEnvPtr)->RegisterNatives(runtimeJNIEnvPtr, cls, clipboardMethods, 2); + // Register CTCDesktopPeer natives cls = (*runtimeJNIEnvPtr)->FindClass(runtimeJNIEnvPtr, "net/java/openjdk/cacio/ctc/CTCDesktopPeer"); if ((*runtimeJNIEnvPtr)->ExceptionOccurred(runtimeJNIEnvPtr)) { diff --git a/Natives/ios_uikit_bridge.h b/Natives/ios_uikit_bridge.h index 74f99df0..86300b96 100644 --- a/Natives/ios_uikit_bridge.h +++ b/Natives/ios_uikit_bridge.h @@ -2,6 +2,9 @@ #import #include "jni.h" +#define CLIPBOARD_COPY 2000 +#define CLIPBOARD_PASTE 2001 + UIViewController* tmpRootVC; void showDialog(NSString* title, NSString* message); diff --git a/Natives/ios_uikit_bridge.m b/Natives/ios_uikit_bridge.m index 04d1022e..cdf947dc 100644 --- a/Natives/ios_uikit_bridge.m +++ b/Natives/ios_uikit_bridge.m @@ -10,9 +10,6 @@ #include "ios_uikit_bridge.h" #include "utils.h" -#define CLIPBOARD_COPY 2000 -#define CLIPBOARD_PASTE 2001 - jclass class_CTCScreen; jmethodID method_GetRGB;