diff --git a/.gitmodules b/.gitmodules index ce51cf579..b0d496bc5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,15 @@ [submodule "app/src/main/jni/wayland"] path = app/src/main/jni/wayland url = https://gitlab.freedesktop.org/wayland/wayland +[submodule "x11-client-experimental/src/main/cpp/libxcb"] + path = x11-client-experimental/src/main/cpp/libxcb + url = https://gitlab.freedesktop.org/xorg/lib/libxcb +[submodule "x11-client-experimental/src/main/cpp/xorgproto"] + path = x11-client-experimental/src/main/cpp/xorgproto + url = https://gitlab.freedesktop.org/xorg/proto/xorgproto +[submodule "x11-client-experimental/src/main/cpp/xcbproto"] + path = x11-client-experimental/src/main/cpp/xcbproto + url = https://gitlab.freedesktop.org/xorg/proto/xcbproto +[submodule "x11-client-experimental/src/main/cpp/libXau"] + path = x11-client-experimental/src/main/cpp/libXau + url = https://gitlab.freedesktop.org/xorg/lib/libxau diff --git a/app/build.gradle b/app/build.gradle index 2b3e0435e..e68fc7c7a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -90,7 +90,6 @@ dependencies { //noinspection GradleDependency implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation project(path: ':common') testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test:runner:1.5.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' diff --git a/common/src/main/aidl/com/termux/x11/common/ITermuxX11Internal.aidl b/app/src/main/aidl/com/termux/x11/ITermuxX11Internal.aidl similarity index 85% rename from common/src/main/aidl/com/termux/x11/common/ITermuxX11Internal.aidl rename to app/src/main/aidl/com/termux/x11/ITermuxX11Internal.aidl index 588394563..d3c4aa868 100644 --- a/common/src/main/aidl/com/termux/x11/common/ITermuxX11Internal.aidl +++ b/app/src/main/aidl/com/termux/x11/ITermuxX11Internal.aidl @@ -1,4 +1,4 @@ -package com.termux.x11.common; +package com.termux.x11; // This interface is used by utility on termux side. interface ITermuxX11Internal { diff --git a/app/src/main/java/com/termux/x11/starter/Starter.java b/app/src/main/java/com/termux/x11/CmdEntryPoint.java similarity index 94% rename from app/src/main/java/com/termux/x11/starter/Starter.java rename to app/src/main/java/com/termux/x11/CmdEntryPoint.java index bc67a9016..1a63aff60 100644 --- a/app/src/main/java/com/termux/x11/starter/Starter.java +++ b/app/src/main/java/com/termux/x11/CmdEntryPoint.java @@ -1,10 +1,9 @@ -package com.termux.x11.starter; +package com.termux.x11; import android.annotation.SuppressLint; import android.app.AppOpsManager; import android.content.ComponentName; import android.content.Intent; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; @@ -17,11 +16,12 @@ import java.io.PrintStream; import java.util.Objects; -import com.termux.x11.common.ITermuxX11Internal; +import com.termux.x11.starter.ActivityManager; +import com.termux.x11.starter.Compat; @SuppressLint("UnsafeDynamicallyLoadedCode") @SuppressWarnings({"unused", "RedundantThrows", "SameParameterValue", "FieldCanBeLocal"}) -public class Starter { +public class CmdEntryPoint { @SuppressLint("SdCardPath") private final String XwaylandPath = "/data/data/com.termux/files/usr/bin/Xwayland"; private final ComponentName TermuxX11Component = @@ -39,7 +39,7 @@ public static void main(String[] args) { try { (new Thread(() -> { try { - (new Starter()).onRun(args); + (new CmdEntryPoint()).onRun(args); } catch (Throwable e) { e.printStackTrace(); } @@ -60,7 +60,7 @@ public static void main(String[] args) { }; public void onRun(String[] args) throws Throwable { - Starter.this.args = args; + CmdEntryPoint.this.args = args; checkXdgRuntimeDir(); prepareLogFD(); if (!Compat.havePermission(AppOpsManager.OPSTR_SYSTEM_ALERT_WINDOW)) { @@ -187,7 +187,7 @@ private void startXwayland(String[] args) throws IOException { class Service extends ITermuxX11Internal.Stub { @Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws RemoteException { - Starter.this.onTransact(code, data, reply, flags); + CmdEntryPoint.this.onTransact(code, data, reply, flags); return super.onTransact(code, data, reply, flags); } @@ -195,7 +195,7 @@ public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel re public ParcelFileDescriptor getWaylandFD() throws RemoteException { System.err.println("Got getWaylandFD"); try { - return Starter.this.getWaylandFD(); + return CmdEntryPoint.this.getWaylandFD(); } catch (Throwable e) { throw new RemoteException(e.getMessage()); } @@ -211,7 +211,7 @@ public ParcelFileDescriptor getLogFD() throws RemoteException { @Override public void finish() throws RemoteException { System.err.println("Got finish request"); - handler.postDelayed(Starter.this::onFinish, 10); + handler.postDelayed(CmdEntryPoint.this::onFinish, 10); } } diff --git a/app/src/main/java/com/termux/x11/LorieService.java b/app/src/main/java/com/termux/x11/LorieService.java index 1b3e67fb7..01f94a994 100644 --- a/app/src/main/java/com/termux/x11/LorieService.java +++ b/app/src/main/java/com/termux/x11/LorieService.java @@ -453,7 +453,10 @@ public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { @SuppressWarnings("unused") // It is used in native code void setRendererVisibility(boolean visible) { - act.runOnUiThread(()-> act.findViewById(R.id.stub).setVisibility(visible?View.INVISIBLE:View.VISIBLE)); + act.runOnUiThread(()-> { + act.findViewById(R.id.stub).setVisibility(visible?View.INVISIBLE:View.VISIBLE); + act.findViewById(R.id.lorieView).setVisibility(visible?View.VISIBLE:View.INVISIBLE); + }); } @SuppressWarnings("unused") diff --git a/app/src/main/java/com/termux/x11/TermuxX11StarterReceiver.java b/app/src/main/java/com/termux/x11/TermuxX11StarterReceiver.java index a024e8f20..a27138ef9 100644 --- a/app/src/main/java/com/termux/x11/TermuxX11StarterReceiver.java +++ b/app/src/main/java/com/termux/x11/TermuxX11StarterReceiver.java @@ -16,8 +16,6 @@ import androidx.annotation.Nullable; import androidx.core.hardware.display.DisplayManagerCompat; -import com.termux.x11.common.ITermuxX11Internal; - public class TermuxX11StarterReceiver extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/com/termux/x11/starter/Compat.java b/app/src/main/java/com/termux/x11/starter/Compat.java index 2597ce556..0524d1638 100644 --- a/app/src/main/java/com/termux/x11/starter/Compat.java +++ b/app/src/main/java/com/termux/x11/starter/Compat.java @@ -19,8 +19,8 @@ import java.lang.reflect.InvocationTargetException; public class Compat { - static final String callingPackage = "com.termux"; - static int startActivity(Intent i) { + public static final String callingPackage = "com.termux"; + public static int startActivity(Intent i) { try { if (Build.VERSION.SDK_INT >= 30) { IActivityTaskManager taskManager = ActivityTaskManager.getService(); @@ -46,7 +46,7 @@ static int startActivity(Intent i) { @SuppressWarnings({"JavaReflectionMemberAccess", "SameParameterValue"}) @SuppressLint("PrivateApi") - static boolean havePermission(String permission) { + public static boolean havePermission(String permission) { try { // We do not need Context to use checkOpNoThrow/unsafeCheckOpNoThrow so it can be null IBinder binder = ServiceManager.getService("appops"); diff --git a/app/src/main/jni/lorie/android.cpp b/app/src/main/jni/lorie/android.cpp index c111a401d..3962624dd 100644 --- a/app/src/main/jni/lorie/android.cpp +++ b/app/src/main/jni/lorie/android.cpp @@ -36,18 +36,19 @@ lorie_compositor::lorie_compositor(jobject thiz): lorie_compositor() { env->CallVoidMethod(thiz, set_renderer_visibility_id, visible); }; - set_cursor_visibility = [=](bool visible) { - env->CallVoidMethod(thiz, set_cursor_visibility_id, visible); - if (!visible) - set_cursor_position = [=](int, int) {}; + set_cursor_visibility = [=](JNIEnv* jenv, bool visible) { + jenv->CallVoidMethod(thiz, set_cursor_visibility_id, visible); + if (!visible || !screen.sfc) + set_cursor_position = [=](JNIEnv*, int, int) {}; else - set_cursor_position = [=](int x, int y) { - auto b = cursor.sfc ? any_cast(cursor.sfc->user_data())->buffer : nullptr; + set_cursor_position = [=](JNIEnv* jenv, int x, int y) { + auto data = cursor.sfc ? any_cast(cursor.sfc->user_data()) : nullptr; + auto b = data->buffer ?: nullptr; int sx = x - cursor.hotspot_x; int sy = y - cursor.hotspot_y; int w = b ? b->shm_width() : 0; int h = b ? b->shm_height() : 0; - env->CallVoidMethod(thiz, set_cursor_rect_id, sx, sy, w, h); + jenv->CallVoidMethod(thiz, set_cursor_rect_id, sx, sy, w, h); }; }; @@ -228,16 +229,44 @@ JNI_DECLARE(LorieService, windowChanged)(JNIEnv *env, jobject thiz, jobject surf extern "C" JNIEXPORT void JNICALL JNI_DECLARE(LorieService, pointerMotion)(JNIEnv *env, jobject thiz, jint x, jint y) { queue<&lorie_compositor::pointer_motion>(env, thiz, x, y); + if (lorie_compositor::compositor_field_id) { + auto native = + lorie_compositor::compositor_field_id ? + reinterpret_cast(env->GetLongField(thiz,lorie_compositor::compositor_field_id)): + nullptr; + if (native) { + native->set_cursor_visibility(env, true); + native->set_cursor_position(env, x, y); + } + } } extern "C" JNIEXPORT void JNICALL JNI_DECLARE(LorieService, pointerScroll)(JNIEnv *env, jobject thiz, jint axis, jfloat value) { queue<&lorie_compositor::pointer_scroll>(env, thiz, axis, value); + if (lorie_compositor::compositor_field_id) { + auto native = + lorie_compositor::compositor_field_id ? + reinterpret_cast(env->GetLongField(thiz,lorie_compositor::compositor_field_id)): + nullptr; + if (native) { + native->set_cursor_visibility(env, true); + } + } } extern "C" JNIEXPORT void JNICALL JNI_DECLARE(LorieService, pointerButton)(JNIEnv *env, jobject thiz, jint button, jint type) { queue<&lorie_compositor::pointer_button>(env, thiz, uint32_t(button), uint32_t(type)); + if (lorie_compositor::compositor_field_id) { + auto native = + lorie_compositor::compositor_field_id ? + reinterpret_cast(env->GetLongField(thiz,lorie_compositor::compositor_field_id)): + nullptr; + if (native) { + native->set_cursor_visibility(env, true); + } + } } extern "C" void get_character_data(char** layout, int *shift, int *ec, char *ch); diff --git a/app/src/main/jni/lorie/compositor.cpp b/app/src/main/jni/lorie/compositor.cpp index a40feb91a..2a4aab4a4 100644 --- a/app/src/main/jni/lorie/compositor.cpp +++ b/app/src/main/jni/lorie/compositor.cpp @@ -39,6 +39,7 @@ lorie_compositor::lorie_compositor() { }; compositor->on_create_surface = [=](surface_t* surface) { auto data = new surface_data; + data->id = surface->id(); // For debugging purposes surface->user_data() = data; surface->on_attach = [=](buffer_t* b, int32_t, int32_t) { data->buffer = b; @@ -46,13 +47,20 @@ lorie_compositor::lorie_compositor() { surface->on_damage = [=](int32_t, int32_t, int32_t, int32_t) { data->damaged = true; }; + surface->on_damage_buffer = [=](int32_t, int32_t, int32_t, int32_t) { + data->damaged = true; + }; surface->on_frame = [=] (callback_t* cb) { data->frame_callback = cb; }; surface->on_commit = [=] { redraw(); - data->buffer->release(); - data->frame_callback->done(resource_t::timestamp()); + if (data->buffer) + data->buffer->release(); + if (data->frame_callback) { + data->frame_callback->done(resource_t::timestamp()); + data->frame_callback = nullptr; + } }; surface->on__destroy = [=] { surface->destroy(); @@ -147,17 +155,20 @@ lorie_compositor::lorie_compositor() { }; }; global_xdg_wm_base.on_bind = [=, this](client_t* client, xdg_wm_base_t* wm_base) { + auto data = any_cast(client->user_data()); wm_base->on_get_xdg_surface = [=, this](xdg_surface_t* xdg_surface, surface_t* sfc) { xdg_surface->on_get_toplevel = [=, this](xdg_toplevel_t*) { - auto data = any_cast(screen.sfc->client()->user_data()); wl_array keys{}; wl_array_init(&keys); screen.sfc = sfc; + redraw(); + set_renderer_visibility(sfc != nullptr); + if (data->pointer) data->pointer->enter(next_serial(),sfc, 0, 0); - if (data->kbd) + + if(data->kbd) data->kbd->enter(next_serial(), sfc, &keys); - redraw(); }; }; wm_base->on__destroy = [=]() { wm_base->destroy(); }; @@ -174,6 +185,8 @@ void lorie_compositor::redraw(bool force) { bool damaged = (data && data->damaged) || force; if (damaged) blit(screen.win, screen.sfc); + if (data) + data->damaged = false; } if (cursor.win) { @@ -181,6 +194,8 @@ void lorie_compositor::redraw(bool force) { bool damaged = (data && data->damaged) || force; if (damaged) blit(cursor.win, cursor.sfc); + if (data) + data->damaged = false; } } @@ -220,9 +235,6 @@ void lorie_compositor::pointer_motion(int x, int y) { data->pointer->motion(resource_t::timestamp(), double(x), double(y)); data->pointer->frame(); - - set_cursor_visibility(true); - set_cursor_position(x, y); } void lorie_compositor::pointer_scroll(int axis, float value) { @@ -235,7 +247,6 @@ void lorie_compositor::pointer_scroll(int axis, float value) { data->pointer->axis_discrete(pointer_axis(axis), (value >= 0) ? 1 : -1); data->pointer->axis(resource_t::timestamp(), pointer_axis(axis), value); data->pointer->frame(); - set_cursor_visibility(true); } void lorie_compositor::pointer_button(int button, int state) { @@ -248,7 +259,6 @@ void lorie_compositor::pointer_button(int button, int state) { LOGI("pointer button: %d %d", button, state); data->pointer->button(next_serial(), resource_t::timestamp(), button, pointer_button_state(state)); data->pointer->frame(); - set_cursor_visibility(true); } void lorie_compositor::keyboard_key(uint32_t key, keyboard_key_state state) { diff --git a/app/src/main/jni/lorie/include/lorie_compositor.hpp b/app/src/main/jni/lorie/include/lorie_compositor.hpp index 9e893f152..d9ef2bd62 100644 --- a/app/src/main/jni/lorie/include/lorie_compositor.hpp +++ b/app/src/main/jni/lorie/include/lorie_compositor.hpp @@ -39,7 +39,7 @@ class lorie_compositor: public wayland::display_t { }; struct surface_data { - uint32_t x{}, y{}; + uint32_t x{}, y{}, id{}; bool damaged{}; wayland::buffer_t *buffer{}; wayland::callback_t *frame_callback{}; @@ -60,8 +60,8 @@ class lorie_compositor: public wayland::display_t { } cursor{}; static void blit(EGLNativeWindowType win, wayland::surface_t* sfc); std::function set_renderer_visibility = [](bool){}; - std::function set_cursor_visibility = [](bool){}; - std::function set_cursor_position = [](int, int){}; + std::function set_cursor_visibility = [](JNIEnv*, bool){}; + std::function set_cursor_position = [](JNIEnv*, int, int){}; // backend features void get_keymap(int *fd, int *size); diff --git a/app/src/main/jni/lorie/lorie_wayland_server.hpp b/app/src/main/jni/lorie/lorie_wayland_server.hpp index 5f6e03412..c41a22735 100644 --- a/app/src/main/jni/lorie/lorie_wayland_server.hpp +++ b/app/src/main/jni/lorie/lorie_wayland_server.hpp @@ -148,6 +148,10 @@ namespace wayland { return userdata; } + inline int id() { + return wl_resource_get_id(*this); + } + inline void destroy() { wl_resource_destroy(*this); } diff --git a/app/src/main/jni/starter/starter.c b/app/src/main/jni/starter/starter.c index 69f074892..93b8fd31d 100755 --- a/app/src/main/jni/starter/starter.c +++ b/app/src/main/jni/starter/starter.c @@ -43,7 +43,7 @@ static int socket_action(int* fd, char* path, } JNIEXPORT void JNICALL -Java_com_termux_x11_starter_Starter_checkXdgRuntimeDir(unused JNIEnv *env, unused jobject thiz) { +Java_com_termux_x11_CmdEntryPoint_checkXdgRuntimeDir(unused JNIEnv *env, unused jobject thiz) { char* XDG_RUNTIME_DIR = getenv("XDG_RUNTIME_DIR"); if (!XDG_RUNTIME_DIR || strlen(XDG_RUNTIME_DIR) == 0) { printf("$XDG_RUNTIME_DIR is unset.\n"); @@ -71,7 +71,7 @@ static const char *getWaylandSocketPath() { } JNIEXPORT jboolean JNICALL -Java_com_termux_x11_starter_Starter_checkWaylandSocket(unused JNIEnv *env, unused jobject thiz) { +Java_com_termux_x11_CmdEntryPoint_checkWaylandSocket(unused JNIEnv *env, unused jobject thiz) { int fd; errno = 0; @@ -84,7 +84,7 @@ Java_com_termux_x11_starter_Starter_checkWaylandSocket(unused JNIEnv *env, unuse } JNIEXPORT jint JNICALL -Java_com_termux_x11_starter_Starter_createWaylandSocket(unused JNIEnv *env, unused jobject thiz) { +Java_com_termux_x11_CmdEntryPoint_createWaylandSocket(unused JNIEnv *env, unused jobject thiz) { int fd; errno = 0; @@ -100,7 +100,7 @@ Java_com_termux_x11_starter_Starter_createWaylandSocket(unused JNIEnv *env, unus #pragma clang diagnostic push #pragma ide diagnostic ignored "hicpp-signed-bitwise" JNIEXPORT jint JNICALL -Java_com_termux_x11_starter_Starter_openLogFD(unused JNIEnv *env, unused jobject thiz) { +Java_com_termux_x11_CmdEntryPoint_openLogFD(unused JNIEnv *env, unused jobject thiz) { const char* TERMUX_X11_LOG_FILE = getenv("TERMUX_X11_LOG_FILE"); int sv[2]; /* the pair of socket descriptors */ if (TERMUX_X11_LOG_FILE == NULL || strlen(TERMUX_X11_LOG_FILE) == 0) @@ -157,7 +157,7 @@ Java_com_termux_x11_starter_Starter_openLogFD(unused JNIEnv *env, unused jobject } JNIEXPORT void JNICALL -Java_com_termux_x11_starter_Starter_exec(JNIEnv *env, jclass clazz, jstring jpath, jobjectArray jargv) { +Java_com_termux_x11_CmdEntryPoint_exec(JNIEnv *env, jclass clazz, jstring jpath, jobjectArray jargv) { // execv's argv array is a bit incompatible with Java's String[], so we do some converting here... int argc = (*env)->GetArrayLength(env, jargv) + 2; // Leading executable path and terminating NULL char *argv[argc]; diff --git a/common/build.gradle b/common/build.gradle deleted file mode 100644 index 3028d594b..000000000 --- a/common/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ -plugins { - id 'com.android.library' -} - -android { - compileSdkVersion 30 - - defaultConfig { - minSdkVersion 24 - //noinspection ExpiredTargetSdkVersion,OldTargetApi - targetSdkVersion 28 - versionCode 1 - versionName "1.0" - - consumerProguardFiles "consumer-rules.pro" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} \ No newline at end of file diff --git a/common/consumer-rules.pro b/common/consumer-rules.pro deleted file mode 100644 index e69de29bb..000000000 diff --git a/common/proguard-rules.pro b/common/proguard-rules.pro deleted file mode 100644 index 481bb4348..000000000 --- a/common/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/common/src/main/AndroidManifest.xml b/common/src/main/AndroidManifest.xml deleted file mode 100644 index c2d27df65..000000000 --- a/common/src/main/AndroidManifest.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/common/src/main/jni/Android.mk b/common/src/main/jni/Android.mk deleted file mode 100644 index 5053e7d64..000000000 --- a/common/src/main/jni/Android.mk +++ /dev/null @@ -1 +0,0 @@ -include $(call all-subdir-makefiles) diff --git a/settings.gradle b/settings.gradle index 85c3ac693..26d47a38f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,5 @@ include ':shell-loader:stub' include ':shell-loader' -include ':common' include ':app:stub' include ':app' +include ':x11-client-experimental' diff --git a/shell-loader/src/main/java/com/termux/x11/Loader.java b/shell-loader/src/main/java/com/termux/x11/Loader.java index b230dd4a9..f09a5d14c 100755 --- a/shell-loader/src/main/java/com/termux/x11/Loader.java +++ b/shell-loader/src/main/java/com/termux/x11/Loader.java @@ -14,7 +14,7 @@ @SuppressLint("UnsafeDynamicallyLoadedCode") public class Loader { private final static String targetPackageName = "com.termux.x11"; - private final static String targetClassName = "com.termux.x11.starter.Starter"; + private final static String targetClassName = "com.termux.x11.CmdEntryPoint"; private final static String logTag = "Termux:X11 loader"; /** diff --git a/common/.gitignore b/x11-client-experimental/.gitignore old mode 100644 new mode 100755 similarity index 100% rename from common/.gitignore rename to x11-client-experimental/.gitignore diff --git a/x11-client-experimental/build.gradle b/x11-client-experimental/build.gradle new file mode 100755 index 000000000..113732f99 --- /dev/null +++ b/x11-client-experimental/build.gradle @@ -0,0 +1,43 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 30 + defaultConfig { + applicationId "com.termux.x11.client.experiment" + minSdkVersion 24 + // Note: targetSdkVersion affects only tests, + // normally, even though this is packaged as apk, + // it's not loaded as apk so targetSdkVersion is ignored. + // targetSdkVersion this must be < 28 because this application accesses hidden apis + //noinspection ExpiredTargetSdkVersion,OldTargetApi + targetSdkVersion 28 + versionCode 1 + versionName "0.1" + } + + signingConfigs { + debug { + storeFile file('../app/testkey_untrusted.jks') + keyAlias 'alias' + storePassword 'xrj45yWGLbsO7W0v' + keyPassword 'xrj45yWGLbsO7W0v' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + externalNativeBuild { + cmake { + path "src/main/cpp/CMakeLists.txt" + } + } + + +} + +dependencies { + compileOnly project(':shell-loader:stub') +} diff --git a/x11-client-experimental/src/main/AndroidManifest.xml b/x11-client-experimental/src/main/AndroidManifest.xml new file mode 100755 index 000000000..10efa44cf --- /dev/null +++ b/x11-client-experimental/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/x11-client-experimental/src/main/cpp/CMakeLists.txt b/x11-client-experimental/src/main/cpp/CMakeLists.txt new file mode 100644 index 000000000..4350e74b8 --- /dev/null +++ b/x11-client-experimental/src/main/cpp/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 3.22) +project(libxcb) + +find_package(Python3 REQUIRED) + +# Nothing special here, only generating xcb headers and building xcb... + +#################################################################################################### +######################################### XCB PROTOS ############################################### +#################################################################################################### + +set (XCB_GENERATED) +set(codegen "${CMAKE_CURRENT_SOURCE_DIR}/libxcb/src/c_client.py") +set(site-packages "${CMAKE_CURRENT_SOURCE_DIR}/xcbproto") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated") +file(GLOB xcbprotos "${CMAKE_CURRENT_SOURCE_DIR}/xcbproto/src/*.xml") + +foreach (xcbproto IN LISTS xcbprotos) + get_filename_component(name "${xcbproto}" NAME) + string(REGEX REPLACE "\\.xml$" ".c" gensrc "${CMAKE_CURRENT_BINARY_DIR}/generated/${name}") + string(REGEX REPLACE "\\.xml$" ".h" genhdr "${CMAKE_CURRENT_BINARY_DIR}/generated/${name}") + add_custom_command( + OUTPUT "${gensrc}" "${genhdr}" + COMMAND Python3::Interpreter "${codegen}" "-c" "libxcb 1.15" + "-l" "X Version 11" "-s" "3" "-p" "${site-packages}" "${xcbproto}" + DEPENDS "${header}" "${codegen_py}" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated" + COMMENT "Generating source code from XML (${xcbproto})" + VERBATIM + ) + set (XCB_GENERATED ${XCB_GENERATED} ${gensrc} ${genhdr}) + +endforeach () + +#################################################################################################### +######################################### XORGPROTO ################################################ +#################################################################################################### + +add_library(xorgproto INTERFACE) +target_include_directories(xorgproto INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/xorgproto/include) + +#################################################################################################### +########################################### LIBXAU ################################################# +#################################################################################################### + +set(XAU_SOURCES AuDispose.c AuFileName.c AuGetAddr.c AuGetBest.c AuLock.c AuRead.c Autest.c + AuUnlock.c AuWrite.c include/X11/Xauth.h) +list(TRANSFORM XAU_SOURCES PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/libXau/) +add_library(libXau SHARED ${XAU_SOURCES}) +target_include_directories(libXau PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/libXau/include) +target_link_libraries(libXau xorgproto) + +#################################################################################################### +########################################### LIBXCB ################################################# +#################################################################################################### + +set(XCB_SOURCES xcb_auth.c xcb_conn.c xcb_ext.c xcb_in.c xcb_list.c + xcb_out.c xcb_util.c xcb_xid.c xcb.h xcbext.h xcbint.h xcb_windefs.h) +list(TRANSFORM XCB_SOURCES PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/libxcb/src/) +include_directories("libxcb/src" "${CMAKE_CURRENT_BINARY_DIR}/generated") +add_library(libxcb SHARED ${XCB_SOURCES} ${XCB_GENERATED}) +target_compile_options(libxcb PRIVATE "-DXCB_QUEUE_BUFFER_SIZE=16384") +target_link_libraries(libxcb libXau) \ No newline at end of file diff --git a/x11-client-experimental/src/main/cpp/libXau b/x11-client-experimental/src/main/cpp/libXau new file mode 160000 index 000000000..14fdf25db --- /dev/null +++ b/x11-client-experimental/src/main/cpp/libXau @@ -0,0 +1 @@ +Subproject commit 14fdf25db9f21c8f3ad37f0d32a5b8e726efdc0d diff --git a/x11-client-experimental/src/main/cpp/libxcb b/x11-client-experimental/src/main/cpp/libxcb new file mode 160000 index 000000000..fd04ab24a --- /dev/null +++ b/x11-client-experimental/src/main/cpp/libxcb @@ -0,0 +1 @@ +Subproject commit fd04ab24a5e99d53874789439d3ffb0eb82574f7 diff --git a/x11-client-experimental/src/main/cpp/xcbproto b/x11-client-experimental/src/main/cpp/xcbproto new file mode 160000 index 000000000..ed461f379 --- /dev/null +++ b/x11-client-experimental/src/main/cpp/xcbproto @@ -0,0 +1 @@ +Subproject commit ed461f379b6cde5bea7bc99d253c270b37298401 diff --git a/x11-client-experimental/src/main/cpp/xorgproto b/x11-client-experimental/src/main/cpp/xorgproto new file mode 160000 index 000000000..824001c94 --- /dev/null +++ b/x11-client-experimental/src/main/cpp/xorgproto @@ -0,0 +1 @@ +Subproject commit 824001c947cb1962209c6a8f2c63c2637877220d