diff --git a/BUILD.PL b/BUILD.PL new file mode 100644 index 0000000..dea4057 --- /dev/null +++ b/BUILD.PL @@ -0,0 +1,127 @@ +use v5.30.0; + +use strict; +use warnings; + +use Data::Dumper; + +use Const::Fast; +use Path::Tiny; +use File::pushd qw/pushd/; +use JSON qw/encode_json/; + +sub build; +sub build_packages; +sub generate_jni_libs; +sub generate_deb_iteration_jni; + +const my $TERMUX_PACKAGES_URL => + 'https://gitea.sergiotarxz.freemyip.com/sergiotarxz/termux-packages'; + +build; + +sub build { + #### For the release. + ## my $tmpdir = Path::Tiny->tempdir; + my $tmpdir = path('tmpdir'); + + build_packages $tmpdir; + generate_jni_libs $tmpdir; +} + +sub generate_deb_iteration_jni { + my $source_file = path(__FILE__)->absolute; + my $current_file = 0; + my %mappings; + return ( + sub { + my $deb = shift->absolute; + my $tmpdir_extract_deb = Path::Tiny->tempdir; + my $tmpdir_extract_data = Path::Tiny->tempdir; + my $out_of_scope_deb = pushd $tmpdir_extract_deb; + system qw/ar x/, $deb; + undef $out_of_scope_deb; + system qw/tar -xf/, $tmpdir_extract_deb->child('data.tar.xz'), + '-C', $tmpdir_extract_data; + + $tmpdir_extract_data->visit( + sub { + my ( $path, $state ) = @_; + return if $path->is_dir; + my $stripped_path = $path =~ s{/.*?/.*?(?=/)}{}r; + if ($path->basename eq 'libwayland-server.so') { + system qw/cp -v/, $path, path(__FILE__)->parent->child('./app/src/main/jni/prebuilt/x86_64/libwayland-server.so'); + } + if ( -l $path || lstat $path && !stat $path ) { + $mappings{$stripped_path} = readlink($path); + return; + } + my $result_file = $source_file->parent->child( + "./app/src/main/jni/prebuilt/x86_64/lib$current_file.so" + ); + system 'cp', $path, $result_file + and die "$path not copied."; + $mappings{$stripped_path} = + '@' . $result_file->basename . ''; + $current_file++; + }, + { + recurse => 1 + } + ); + }, + sub { return \%mappings } + ); +} + +sub generate_jni_libs { + my $tmpdir = shift; + my %mappings; + my $current_file = 0; + my @debs = $tmpdir->child('output')->children; + @debs = grep { /(?:x86_64|all)\.deb$/ } @debs; + my ( $iterator, $result_func ) = generate_deb_iteration_jni(); + for my $deb (@debs) { + $iterator->($deb); + } + my $mapping_so_content = encode_json $result_func->(); + my $mapping_so = path('app/src/main/jni/prebuilt/x86_64/libmappings.so'); + $mapping_so->spew($mapping_so_content); +} + +sub build_packages { + my $tmpdir = shift; + ## my $fake_home = Path::Tiny->tempdir; + #### To avoid conflicting with real termux packages. + my $fake_home = path('fake_home')->absolute; + local $ENV{HOME} = $fake_home; + local $ENV{TERMUX_ARCH} = 'x86_64'; + #### TODO: Avoid this to be needed to avoid conflicting with real termux packages. + # path('/data/data/.built-packages/')->remove_tree; + say "CLONING $TERMUX_PACKAGES_URL."; + say "-----------------------------"; + say ''; + say ''; + system qw/git clone/, $TERMUX_PACKAGES_URL, $tmpdir; + my $out_of_scope_remove_tempdir = pushd $tmpdir; + say "PULLING $TERMUX_PACKAGES_URL."; + say "-----------------------------"; + say ''; + say ''; + system qw/git pull/; + say "Building i3."; + say "-----------------------------"; + say ''; + say ''; + system qw{./build-package.sh i3}; + say "Building xwayland."; + say "-----------------------------"; + say ''; + say ''; + system qw{./build-package.sh xwayland}; + say "Building openmg."; + say "-----------------------------"; + say ''; + say ''; + system qw{./build-package.sh openmg}; +} diff --git a/README.md b/README.md index cd9135e..b8c9505 100644 --- a/README.md +++ b/README.md @@ -56,9 +56,9 @@ You should start Termux:X11's activity with providing some additional data. ``` import android.os.ParcelFileDescriptor; import android.os.RemoteException; -import com.termux.x11.common.ITermuxX11Internal; +import me.sergiotarxz.openmg.x11.common.ITermuxX11Internal; ... -private final String TermuxX11ComponentName = "com.termux.x11/.TermuxX11StarterReceiver"; +private final String TermuxX11ComponentName = "me.sergiotarxz.openmg.x11/.TermuxX11StarterReceiver"; private void startTermuxX11() { Service svc = new Service(); @@ -66,7 +66,7 @@ private void startTermuxX11() { bundle.putBinder("", svc); Intent intent = new Intent(); - intent.putExtra("com.termux.x11.starter", bundle); + intent.putExtra("me.sergiotarxz.openmg.x11.starter", bundle); ComponentName cn = ComponentName.unflattenFromString(TermuxX11ComponentName); if (cn == null) throw new IllegalArgumentException("Bad component name: " + TermuxX11ComponentName); diff --git a/app/build.gradle b/app/build.gradle index 99419c8..15400ed 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { - applicationId "com.termux.x11" + applicationId "me.sergiotarxz.openmg.x11" minSdkVersion 24 //noinspection OldTargetApi targetSdkVersion 28 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7974c17..dfb8fc3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,17 +1,12 @@ - - - - - - - - diff --git a/app/src/main/java/com/termux/x11/AdditionalKeyboardView.java b/app/src/main/java/me/sergiotarxz/openmg/x11/AdditionalKeyboardView.java similarity index 99% rename from app/src/main/java/com/termux/x11/AdditionalKeyboardView.java rename to app/src/main/java/me/sergiotarxz/openmg/x11/AdditionalKeyboardView.java index 5436afa..53ea8af 100644 --- a/app/src/main/java/com/termux/x11/AdditionalKeyboardView.java +++ b/app/src/main/java/me/sergiotarxz/openmg/x11/AdditionalKeyboardView.java @@ -1,4 +1,4 @@ -package com.termux.x11; +package me.sergiotarxz.openmg.x11; import android.annotation.SuppressLint; import android.content.Context; diff --git a/app/src/main/java/com/termux/x11/KeyboardUtils.java b/app/src/main/java/me/sergiotarxz/openmg/x11/KeyboardUtils.java similarity index 99% rename from app/src/main/java/com/termux/x11/KeyboardUtils.java rename to app/src/main/java/me/sergiotarxz/openmg/x11/KeyboardUtils.java index 6eb9d6f..3b52600 100644 --- a/app/src/main/java/com/termux/x11/KeyboardUtils.java +++ b/app/src/main/java/me/sergiotarxz/openmg/x11/KeyboardUtils.java @@ -1,4 +1,4 @@ -package com.termux.x11; +package me.sergiotarxz.openmg.x11; import android.app.Activity; import android.graphics.Rect; diff --git a/app/src/main/java/com/termux/x11/LoriePreferences.java b/app/src/main/java/me/sergiotarxz/openmg/x11/LoriePreferences.java similarity index 97% rename from app/src/main/java/com/termux/x11/LoriePreferences.java rename to app/src/main/java/me/sergiotarxz/openmg/x11/LoriePreferences.java index fe58d6d..01aef80 100644 --- a/app/src/main/java/com/termux/x11/LoriePreferences.java +++ b/app/src/main/java/me/sergiotarxz/openmg/x11/LoriePreferences.java @@ -1,4 +1,4 @@ -package com.termux.x11; +package me.sergiotarxz.openmg.x11; import android.content.SharedPreferences; import android.inputmethodservice.Keyboard; @@ -105,7 +105,7 @@ public class LoriePreferences extends AppCompatActivity implements SharedPrefere .setTitle("Permission denied") .setMessage("Android requires WRITE_SECURE_SETTINGS permission to change this setting.\n" + "Please, launch this command using ADB:\n" + - "adb shell pm grant com.termux.x11 android.permission.WRITE_SECURE_SETTINGS") + "adb shell pm grant me.sergiotarxz.openmg.x11 android.permission.WRITE_SECURE_SETTINGS") .setNegativeButton("OK", null) .create() .show(); diff --git a/app/src/main/java/com/termux/x11/LorieService.java b/app/src/main/java/me/sergiotarxz/openmg/x11/LorieService.java similarity index 84% rename from app/src/main/java/com/termux/x11/LorieService.java rename to app/src/main/java/me/sergiotarxz/openmg/x11/LorieService.java index ff0a9b2..c1faabe 100644 --- a/app/src/main/java/com/termux/x11/LorieService.java +++ b/app/src/main/java/me/sergiotarxz/openmg/x11/LorieService.java @@ -1,4 +1,4 @@ -package com.termux.x11; +package me.sergiotarxz.openmg.x11; import android.annotation.SuppressLint; import android.app.ActivityManager; @@ -43,20 +43,27 @@ import android.widget.Toast; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import java.util.Iterator; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.json.JSONObject; @SuppressWarnings({"ConstantConditions", "SameParameterValue", "SdCardPath"}) @SuppressLint({"ClickableViewAccessibility", "StaticFieldLeak"}) public class LorieService extends Service { - static final String LAUNCHED_BY_COMPATION = "com.termux.x11.launched_by_companion"; - static final String ACTION_STOP_SERVICE = "com.termux.x11.service_stop"; - static final String ACTION_START_FROM_ACTIVITY = "com.termux.x11.start_from_activity"; - static final String ACTION_START_PREFERENCES_ACTIVITY = "com.termux.x11.start_preferences_activity"; - static final String ACTION_PREFERENCES_CHAGED = "com.termux.x11.preferences_changed"; + static final String LAUNCHED_BY_COMPATION = "me.sergiotarxz.openmg.x11.launched_by_companion"; + static final String ACTION_STOP_SERVICE = "me.sergiotarxz.openmg.x11.service_stop"; + static final String ACTION_START_FROM_ACTIVITY = "me.sergiotarxz.openmg.x11.start_from_activity"; + static final String ACTION_START_PREFERENCES_ACTIVITY = "me.sergiotarxz.openmg.x11.start_preferences_activity"; + static final String ACTION_PREFERENCES_CHAGED = "me.sergiotarxz.openmg.x11.preferences_changed"; private static LorieService instance = null; //private @@ -79,11 +86,11 @@ public class LorieService extends Service { Intent intent = new Intent(act, LorieService.class); intent.setAction(action); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - act.startForegroundService(intent); - } else { +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { +// act.startForegroundService(intent); +// } else { act.startService(intent); - } +// } } @SuppressLint({"BatteryLife", "ObsoleteSdkInt"}) @@ -93,6 +100,40 @@ public class LorieService extends Service { if (isServiceRunningInForeground(this, LorieService.class)) return; String datadir = getApplicationInfo().dataDir; + String nativeLibDir = getApplicationInfo().nativeLibraryDir; + String mappingsFile = nativeLibDir + "/libmappings.so"; + String usr = "datadir"+"/files/usr"; + try { + if (new File(usr).exists()) { + Files.walk(Paths.get(usr)) + .map(Path::toFile) + .sorted((o1, o2) -> -o1.compareTo(o2)) + .forEach(File::delete); + } + InputStream is = new FileInputStream(mappingsFile); + int size = is.available(); + byte[] buffer = new byte[size]; + is.read(buffer); + is.close(); + String json = new String(buffer, "UTF-8"); + JSONObject mappingsObject = new JSONObject(json); + Iterator keys = mappingsObject.keys(); + while (keys.hasNext()) { + String key = (String) keys.next(); + String value = mappingsObject.getString(key); + Path target; + if (value.charAt(0) == '@') { + // It is a lib\d+.so + value = nativeLibDir+"/"+value.substring(1); + } + target = Paths.get(value); + new File(key).getParentFile().mkdirs(); + Files.createSymbolicLink(Paths.get(key), target); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + String[] dirs = { datadir + "/files/locale", datadir + "/files/xkb", @@ -155,19 +196,6 @@ public class LorieService extends Service { .addAction(0, "Preferences", pendingPreferencesIntent) .addAction(0, "Exit", pendingExitIntent) .build(); - startForeground(1, notification); - - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - String packageName = getPackageName(); - PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); - if (!pm.isIgnoringBatteryOptimizations(packageName)) { - Intent whitelist = new Intent(); - whitelist.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); - whitelist.setData(Uri.parse("package:" + packageName)); - whitelist.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(whitelist); - } - } } @RequiresApi(Build.VERSION_CODES.O) @@ -225,46 +253,27 @@ public class LorieService extends Service { } private static void sendRunCommandInternal(Context ctx) { - Intent intent = new Intent(); - intent.setClassName("com.termux", "com.termux.app.RunCommandService"); - intent.setAction("com.termux.RUN_COMMAND"); - intent.putExtra("com.termux.RUN_COMMAND_PATH", - "/data/data/com.termux/files/usr/libexec/termux-x11/termux-startx11"); - intent.putExtra("com.termux.RUN_COMMAND_BACKGROUND", true); - Log.d("LorieService", "sendRunCommand: " + intent); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - ctx.startForegroundService(intent); - } else { - ctx.startService(intent); - } + // Process process = Runtime.getRuntime().exec( + // "/data/data/me.sergiotarxz.openmg.x11/files/usr/bin/bash " + + // "/data/data/me.sergiotarxz.openmg.x11/files/usr/bin/startopenmg" + // ); + + // Intent intent = new Intent(); + // intent.setClassName("com.termux", "com.termux.app.RunCommandService"); + // intent.setAction("com.termux.RUN_COMMAND"); + // intent.putExtra("com.termux.RUN_COMMAND_PATH", + // "/data/data/com.termux/files/usr/libexec/termux-x11/termux-startx11"); + // intent.putExtra("com.termux.RUN_COMMAND_BACKGROUND", true); + // Log.d("LorieService", "sendRunCommand: " + intent); + // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + // ctx.startForegroundService(intent); + // } else { + // ctx.startService(intent); + // } } public static void sendRunCommand(AppCompatActivity act) { - final String ERROR_MESSAGE = - "It is impossible to start without " + - "com.termux.permission.RUN_COMMAND permission. " + - "Sorry."; - if (act.checkSelfPermission("com.termux.permission.RUN_COMMAND") == PackageManager.PERMISSION_GRANTED) { - LorieService.sendRunCommandInternal(act); - } else { - Log.d("MainActivity", "We have no permission to sendRunCommand(). Requesting it."); - ActivityResultLauncher requestPermissionLauncher = - act.registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> { - if (isGranted) { - sendRunCommandInternal(act); - } else { - new AlertDialog.Builder(act) - .setTitle("Insufficient permission") - .setMessage(ERROR_MESSAGE) - .setPositiveButton(android.R.string.yes, - (dialog, which) -> act.finish()) - .setIcon(android.R.drawable.ic_dialog_alert) - .show(); - - } - }); - requestPermissionLauncher.launch("com.termux.permission.RUN_COMMAND"); - } + LorieService.sendRunCommandInternal(act); } diff --git a/app/src/main/java/com/termux/x11/MainActivity.java b/app/src/main/java/me/sergiotarxz/openmg/x11/MainActivity.java similarity index 99% rename from app/src/main/java/com/termux/x11/MainActivity.java rename to app/src/main/java/me/sergiotarxz/openmg/x11/MainActivity.java index 46ed1b6..9a17146 100644 --- a/app/src/main/java/com/termux/x11/MainActivity.java +++ b/app/src/main/java/me/sergiotarxz/openmg/x11/MainActivity.java @@ -1,4 +1,4 @@ -package com.termux.x11; +package me.sergiotarxz.openmg.x11; import android.app.Activity; import android.content.Intent; diff --git a/app/src/main/java/com/termux/x11/TermuxX11StarterReceiver.java b/app/src/main/java/me/sergiotarxz/openmg/x11/TermuxX11StarterReceiver.java similarity index 94% rename from app/src/main/java/com/termux/x11/TermuxX11StarterReceiver.java rename to app/src/main/java/me/sergiotarxz/openmg/x11/TermuxX11StarterReceiver.java index 0c08a5c..27ce085 100644 --- a/app/src/main/java/com/termux/x11/TermuxX11StarterReceiver.java +++ b/app/src/main/java/me/sergiotarxz/openmg/x11/TermuxX11StarterReceiver.java @@ -1,4 +1,4 @@ -package com.termux.x11; +package me.sergiotarxz.openmg.x11; import android.app.Activity; import android.content.Intent; @@ -9,7 +9,7 @@ import android.os.RemoteException; import android.util.Log; import android.widget.Toast; -import com.termux.x11.common.ITermuxX11Internal; +import me.sergiotarxz.openmg.x11.common.ITermuxX11Internal; import java.io.FileOutputStream; import java.io.IOException; @@ -35,7 +35,7 @@ public class TermuxX11StarterReceiver extends Activity { } private void handleIntent(Intent intent) { - final String extraName = "com.termux.x11.starter"; + final String extraName = "me.sergiotarxz.openmg.x11.starter"; Bundle bundle; IBinder token; ITermuxX11Internal svc; diff --git a/app/src/main/java/com/termux/x11/TouchParser.java b/app/src/main/java/me/sergiotarxz/openmg/x11/TouchParser.java similarity index 99% rename from app/src/main/java/com/termux/x11/TouchParser.java rename to app/src/main/java/me/sergiotarxz/openmg/x11/TouchParser.java index 00fdaf4..48e187c 100644 --- a/app/src/main/java/com/termux/x11/TouchParser.java +++ b/app/src/main/java/me/sergiotarxz/openmg/x11/TouchParser.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.termux.x11; +package me.sergiotarxz.openmg.x11; import android.annotation.SuppressLint; import android.content.Context; diff --git a/app/src/main/jni/libxkbcommon/Android.mk b/app/src/main/jni/libxkbcommon/Android.mk index 8638a1d..845d719 100644 --- a/app/src/main/jni/libxkbcommon/Android.mk +++ b/app/src/main/jni/libxkbcommon/Android.mk @@ -37,11 +37,11 @@ LOCAL_SRC_FILES := \ LOCAL_CFLAGS := \ -std=c99 -Wall -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wimplicit-function-declaration \ -D_GNU_SOURCE \ - -DXLOCALEDIR=\"/data/data/com.termux.x11/files/locale\" \ + -DXLOCALEDIR=\"/data/data/me.sergiotarxz.openmg.x11/files/locale\" \ -DDEFAULT_XKB_LAYOUT=\"us\" \ -DDEFAULT_XKB_MODEL=\"pc105\" \ -DDEFAULT_XKB_RULES=\"evdev\" \ - -DDFLT_XKB_CONFIG_ROOT=\"/data/data/com.termux.x11/files/xkb\" + -DDFLT_XKB_CONFIG_ROOT=\"/data/data/me.sergiotarxz.openmg.x11/files/xkb\" LOCAL_C_INCLUDES := $(LOCAL_PATH)/xkbcommon $(LOCAL_PATH)/xkbcommon/src $(LOCAL_PATH)/xkbcommon/include LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/xkbcommon/ include $(BUILD_SHARED_LIBRARY) diff --git a/app/src/main/jni/libxkbcommon/xkbcommon/src/compose/config.h b/app/src/main/jni/libxkbcommon/xkbcommon/src/compose/config.h index a0f0833..788a512 100644 --- a/app/src/main/jni/libxkbcommon/xkbcommon/src/compose/config.h +++ b/app/src/main/jni/libxkbcommon/xkbcommon/src/compose/config.h @@ -1,6 +1,6 @@ #define _GNU_SOURCE_ 1 -#define DFLT_XKB_CONFIG_EXTRA_PATH "/data/data/com.termux/files/home/.termux.wayland/xkb/config" +#define DFLT_XKB_CONFIG_EXTRA_PATH "/data/data/me.sergiotarxz.openmg.x11/files/home/.termux.wayland/xkb/config" #define DEFAULT_XKB_VARIANT "NULL" diff --git a/app/src/main/jni/libxkbcommon/xkbcommon/src/config.h b/app/src/main/jni/libxkbcommon/xkbcommon/src/config.h index a0f0833..788a512 100644 --- a/app/src/main/jni/libxkbcommon/xkbcommon/src/config.h +++ b/app/src/main/jni/libxkbcommon/xkbcommon/src/config.h @@ -1,6 +1,6 @@ #define _GNU_SOURCE_ 1 -#define DFLT_XKB_CONFIG_EXTRA_PATH "/data/data/com.termux/files/home/.termux.wayland/xkb/config" +#define DFLT_XKB_CONFIG_EXTRA_PATH "/data/data/me.sergiotarxz.openmg.x11/files/home/.termux.wayland/xkb/config" #define DEFAULT_XKB_VARIANT "NULL" diff --git a/app/src/main/jni/libxkbcommon/xkbcommon/src/xkbcomp/config.h b/app/src/main/jni/libxkbcommon/xkbcommon/src/xkbcomp/config.h index a0f0833..788a512 100644 --- a/app/src/main/jni/libxkbcommon/xkbcommon/src/xkbcomp/config.h +++ b/app/src/main/jni/libxkbcommon/xkbcommon/src/xkbcomp/config.h @@ -1,6 +1,6 @@ #define _GNU_SOURCE_ 1 -#define DFLT_XKB_CONFIG_EXTRA_PATH "/data/data/com.termux/files/home/.termux.wayland/xkb/config" +#define DFLT_XKB_CONFIG_EXTRA_PATH "/data/data/me.sergiotarxz.openmg.x11/files/home/.termux.wayland/xkb/config" #define DEFAULT_XKB_VARIANT "NULL" diff --git a/app/src/main/jni/libxkbcommon/xkbcommon/tools/interactive-wayland.c b/app/src/main/jni/libxkbcommon/xkbcommon/tools/interactive-wayland.c index d23432d..1aedbda 100644 --- a/app/src/main/jni/libxkbcommon/xkbcommon/tools/interactive-wayland.c +++ b/app/src/main/jni/libxkbcommon/xkbcommon/tools/interactive-wayland.c @@ -607,17 +607,17 @@ registry_global(void *data, struct wl_registry *registry, uint32_t name, else if (strcmp(interface, "xdg_wm_base") == 0) { inter->shell = wl_registry_bind(registry, name, &xdg_wm_base_interface, - MAX(version, 2)); + MAX(version, 4)); xdg_wm_base_add_listener(inter->shell, &shell_listener, inter); } else if (strcmp(interface, "wl_compositor") == 0) { inter->compositor = wl_registry_bind(registry, name, &wl_compositor_interface, - MAX(version, 1)); + MAX(version, 4)); } else if (strcmp(interface, "wl_shm") == 0) { inter->shm = wl_registry_bind(registry, name, &wl_shm_interface, - MAX(version, 1)); + MAX(version, 4)); } } diff --git a/app/src/main/jni/lorie/backend/android/android-app.cpp b/app/src/main/jni/lorie/backend/android/android-app.cpp index 537af65..49f3f8b 100644 --- a/app/src/main/jni/lorie/backend/android/android-app.cpp +++ b/app/src/main/jni/lorie/backend/android/android-app.cpp @@ -179,7 +179,7 @@ void LorieBackendAndroid::passfd(int fd) { #define JNI_DECLARE_INNER(package, classname, methodname ) \ Java_ ## package ## _ ## classname ## _ ## methodname #define JNI_DECLARE(classname, methodname) \ - JNI_DECLARE_INNER(com_termux_x11, classname, methodname) + JNI_DECLARE_INNER(me_sergiotarxz_openmg_x11, classname, methodname) #define WL_POINTER_MOTION 2 @@ -427,7 +427,7 @@ void fork(std::function f) { } extern "C" JNIEXPORT void JNICALL -Java_com_termux_x11_LorieService_startLogcatForFd(unused JNIEnv *env, unused jclass clazz, jint fd) { +Java_me_sergiotarxz_openmg_x11_LorieService_startLogcatForFd(unused JNIEnv *env, unused jclass clazz, jint fd) { killAllLogcats(); LOGI("Starting logcat with output to given fd"); diff --git a/app/src/main/jni/lorie/compositor.cpp b/app/src/main/jni/lorie/compositor.cpp index 6758c52..49869d9 100644 --- a/app/src/main/jni/lorie/compositor.cpp +++ b/app/src/main/jni/lorie/compositor.cpp @@ -39,6 +39,9 @@ void LorieCompositor::start() { wl_resource_t::global_create(display, this); wl_resource_t::global_create(display, this); + wl_registry *registry = wl_display_get_registry(this->display); + wl_registry_bind(registry, id, &xdg_wm_base_interface, 1); + backend_init(); wl_display_run(display); diff --git a/app/src/main/jni/lorie/scanner/protocol/wayland.xml b/app/src/main/jni/lorie/scanner/protocol/wayland.xml index 3f02347..784d971 100644 --- a/app/src/main/jni/lorie/scanner/protocol/wayland.xml +++ b/app/src/main/jni/lorie/scanner/protocol/wayland.xml @@ -91,7 +91,7 @@ + summary="method doesn't exist on the specified interface or malformed request"/> This event is used internally by the object ID management - logic. When a client deletes an object, the server will send - this event to acknowledge that it has seen the delete request. - When the client receives this event, it will know that it can - safely reuse the object ID. + logic. When a client deletes an object that it had created, + the server will send this event to acknowledge that it has + seen the delete request. When the client receives this event, + it will know that it can safely reuse the object ID. @@ -179,7 +179,7 @@ the related request is done. - + Notify the client when the related request is done. @@ -187,7 +187,7 @@ - + A compositor. This object is a singleton global. The compositor is in charge of combining the contents of multiple @@ -293,10 +293,15 @@ formats are optional and may not be supported by the particular renderer in use. - The drm format codes match the macros defined in drm_fourcc.h. - The formats actually supported by the compositor will be - reported by the format event. + The drm format codes match the macros defined in drm_fourcc.h, except + argb8888 and xrgb8888. The formats actually supported by the compositor + will be reported by the format event. + + For all wl_shm formats and unless specified in another protocol + extension, pre-multiplied alpha is used for pixel values. + @@ -355,6 +360,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -383,10 +438,15 @@ A buffer provides the content for a wl_surface. Buffers are - created through factory interfaces such as wl_drm, wl_shm or - similar. It has a width and a height and can be attached to a - wl_surface, but the mechanism by which a client provides and - updates the contents is defined by the buffer factory interface. + created through factory interfaces such as wl_shm, wp_linux_buffer_params + (from the linux-dmabuf protocol extension) or similar. It has a width and + a height and can be attached to a wl_surface, but the mechanism by which a + client provides and updates the contents is defined by the buffer factory + interface. + + If the buffer uses a format that has an alpha channel, the alpha channel + is assumed to be premultiplied in the color channels unless otherwise + specified. @@ -509,6 +569,9 @@ this request after a NULL mime type has been set in wl_data_offer.accept or no action was received through wl_data_offer.action. + + If wl_data_offer.finish request is received for a non drag and drop + operation, the invalid_finish protocol error is raised. @@ -525,7 +588,7 @@ This request determines the final result of the drag-and-drop operation. If the end result is that no action is accepted, - the drag source will receive wl_drag_source.cancelled. + the drag source will receive wl_data_source.cancelled. The dnd_actions argument must contain only values expressed in the wl_data_device_manager.dnd_actions enum, and the preferred_action @@ -546,8 +609,10 @@ This request can only be made on drag-and-drop offers, a protocol error will be raised otherwise. - - + + @@ -556,7 +621,8 @@ will be sent right after wl_data_device.enter, or anytime the source side changes its offered actions through wl_data_source.set_actions. - + @@ -597,7 +663,8 @@ final wl_data_offer.set_actions and wl_data_offer.accept requests must happen before the call to wl_data_offer.finish. - + @@ -694,7 +761,8 @@ wl_data_device.start_drag. Attempting to use the source other than for drag-and-drop will raise a protocol error. - + @@ -750,7 +818,8 @@ Clients can trigger cursor surface changes from this point, so they reflect the current action. - + @@ -776,7 +845,8 @@ for the eventual data transfer. If source is NULL, enter, leave and motion events are sent only to the client that initiated the drag and the client is expected to handle the data passing - internally. + internally. If source is destroyed, the drag-and-drop session will be + cancelled. The origin surface is the surface where the drag originates and the client must have an active implicit grab that matches the @@ -890,9 +960,10 @@ immediately before receiving keyboard focus and when a new selection is set while the client has keyboard focus. The data_offer is valid until a new data_offer or NULL is received - or until the client loses keyboard focus. The client must - destroy the previous selection data_offer, if any, upon receiving - this event. + or until the client loses keyboard focus. Switching surface with + keyboard focus within the same client doesn't mean a new selection + will be sent. The client must destroy the previous selection + data_offer, if any, upon receiving this event. @@ -1274,10 +1345,12 @@ - + - A surface is a rectangular area that is displayed on the screen. - It has a location, size and pixel contents. + A surface is a rectangular area that may be displayed on zero + or more outputs, and shown any number of times at the compositor's + discretion. They can present wl_buffers, receive user input, and + define a local coordinate system. The size of a surface (and relative positions on it) is described in surface-local coordinates, which may differ from the buffer @@ -1323,6 +1396,8 @@ + + @@ -1337,14 +1412,22 @@ The new size of the surface is calculated based on the buffer size transformed by the inverse buffer_transform and the - inverse buffer_scale. This means that the supplied buffer - must be an integer multiple of the buffer_scale. + inverse buffer_scale. This means that at commit time the supplied + buffer size must be an integer multiple of the buffer_scale. If + that's not the case, an invalid_size error is sent. The x and y arguments specify the location of the new pending buffer's upper left corner, relative to the current buffer's upper left corner, in surface-local coordinates. In other words, the x and y, combined with the new surface size define in which - directions the surface's size changes. + directions the surface's size changes. Setting anything other than 0 + as x and y arguments is discouraged, and should instead be replaced + with using the separate wl_surface.offset request. + + When the bound wl_surface version is 5 or higher, passing any + non-zero x or y is a protocol violation, and will result in an + 'invalid_offset' error being raised. To achieve equivalent semantics, + use wl_surface.offset. Surface contents are double-buffered state, see wl_surface.commit. @@ -1365,10 +1448,19 @@ will not receive a release event, and is not used by the compositor. + If a pending wl_buffer has been committed to more than one wl_surface, + the delivery of wl_buffer.release events becomes undefined. A well + behaved client should not rely on wl_buffer.release events in this + case. Alternatively, a client could create multiple wl_buffer objects + from the same backing storage or use wp_linux_buffer_release. + Destroying the wl_buffer after wl_buffer.release does not change - the surface contents. However, if the client destroys the - wl_buffer before receiving the wl_buffer.release event, the surface - contents become undefined immediately. + the surface contents. Destroying the wl_buffer before wl_buffer.release + is allowed as long as the underlying buffer storage isn't re-used (this + can happen e.g. on client process termination). However, if the client + destroys the wl_buffer before receiving the wl_buffer.release event and + mutates the underlying buffer storage, the surface contents become + undefined immediately. If wl_surface.attach is sent with a NULL wl_buffer, the following wl_surface.commit will remove the surface content. @@ -1545,6 +1637,12 @@ This is emitted whenever a surface's creation, movement, or resizing results in it no longer having any part of it within the scanout region of an output. + + Clients should not use the number of outputs the surface is on for frame + throttling purposes. The surface might be hidden even if no leave event + has been sent, and the compositor might expect new surface content + updates even if no enter event has been sent. The frame event should be + used instead. @@ -1660,9 +1758,30 @@ + + + + + + The x and y arguments specify the location of the new pending + buffer's upper left corner, relative to the current buffer's upper + left corner, in surface-local coordinates. In other words, the + x and y, combined with the new surface size define in which + directions the surface's size changes. + + Surface location offset is double-buffered state, see + wl_surface.commit. + + This request is semantically equivalent to and the replaces the x and y + arguments in the wl_surface.attach request in wl_surface versions prior + to 5. See wl_surface.attach for details. + + + + - + A seat is a group of keyboards, pointer and touch devices. This object is published as a global during start up, or when such a @@ -1680,6 +1799,14 @@ + + + These errors can be emitted in response to wl_seat requests. + + + + This is emitted whenever a seat gains or loses the pointer, @@ -1718,7 +1845,8 @@ This request only takes effect if the seat has the pointer capability, or has had the pointer capability in the past. It is a protocol violation to issue this request on a seat that has - never had the pointer capability. + never had the pointer capability. The missing_capability error will + be sent in this case. @@ -1731,7 +1859,8 @@ This request only takes effect if the seat has the keyboard capability, or has had the keyboard capability in the past. It is a protocol violation to issue this request on a seat that has - never had the keyboard capability. + never had the keyboard capability. The missing_capability error will + be sent in this case. @@ -1744,7 +1873,8 @@ This request only takes effect if the seat has the touch capability, or has had the touch capability in the past. It is a protocol violation to issue this request on a seat that has - never had the touch capability. + never had the touch capability. The missing_capability error will + be sent in this case. @@ -1753,16 +1883,29 @@ - In a multiseat configuration this can be used by the client to help - identify which physical devices the seat represents. Based on - the seat configuration used by the compositor. + In a multi-seat configuration the seat name can be used by clients to + help identify which physical devices the seat represents. + + The seat name is a UTF-8 string with no convention defined for its + contents. Each name is unique among all wl_seat globals. The name is + only guaranteed to be unique for the current compositor instance. + + The same seat names are used for all clients. Thus, the name can be + shared across processes to refer to a specific wl_seat global. + + The name event is sent after binding to the seat global. This event is + only sent once per seat object, and the name does not change over the + lifetime of the wl_seat global. + + Compositors may re-use the same seat name if the wl_seat global is + destroyed and re-created later. - + Using this request a client can tell the server that it is not going to use the seat object anymore. @@ -1820,6 +1963,10 @@ wl_surface is no longer used as the cursor. When the use as a cursor ends, the current and pending input regions become undefined, and the wl_surface is unmapped. + + The serial parameter must match the latest wl_pointer.enter + serial number sent to the client. Otherwise the request will be + ignored. This event provides a file descriptor to the client which can be - memory-mapped to provide a keyboard mapping description. + memory-mapped in read-only mode to provide a keyboard mapping + description. From version 7 onwards, the fd must be mapped with MAP_PRIVATE by the recipient, as MAP_SHARED may fail. @@ -2128,6 +2276,9 @@ Notification that this seat's keyboard focus is on a certain surface. + + The compositor must send the wl_keyboard.modifiers event after this + event. @@ -2141,6 +2292,9 @@ The leave notification is sent before the enter notification for the new focus. + + After this event client must assume that all keys, including modifiers, + are lifted and also it must stop key repeating if there's some going on. @@ -2159,6 +2313,12 @@ A key was pressed or released. The time argument is a timestamp with millisecond granularity, with an undefined base. + + The key is a platform-specific key code that can be interpreted + by feeding it to the keyboard mapping (see the keymap event). + + If this event produces a change in modifiers, then the resulting + wl_keyboard.modifiers event must be sent after this event. @@ -2352,7 +2512,7 @@ - + An output describes part of the compositor geometry. The compositor works in the 'compositor coordinate system' and an @@ -2408,12 +2568,15 @@ The physical size can be set to zero if it doesn't make sense for this output (e.g. for projectors or virtual outputs). + The geometry event will be followed by a done event (starting from + version 2). + Note: wl_output only advertises partial information about the output position and identification. Some compositors, for instance those not implementing a desktop-style output layout or those exposing virtual outputs, might fake this information. Instead of using x and y, clients should use xdg_output.logical_position. Instead of using make and model, - clients should use xdg_output.name and xdg_output.description. + clients should use name and description. @@ -2454,6 +2617,10 @@ current. In other words, the current mode is always the last mode that was received with the current flag set. + Non-current modes are deprecated. A compositor can decide to only + advertise the current mode and never send other modes. Clients + should not rely on non-current modes. + The size of a mode is given in physical hardware units of the output device. This is not necessarily the same as the output size in the global compositor space. For instance, @@ -2462,6 +2629,12 @@ willing to retrieve the output size in the global compositor space should use xdg_output.logical_size instead. + The vertical refresh rate can be set to zero if it doesn't make + sense for this output (e.g. for virtual outputs). + + The mode event will be followed by a done event (starting from + version 2). + Clients should not use the refresh rate to schedule frames. Instead, they should use the wl_surface.frame event or the presentation-time protocol. @@ -2508,6 +2681,8 @@ the scale of the output. That way the compositor can avoid scaling the surface, and the client can supply a higher detail image. + + The scale event will be followed by a done event. @@ -2520,6 +2695,62 @@ use the output object anymore. + + + + + + Many compositors will assign user-friendly names to their outputs, show + them to the user, allow the user to refer to an output, etc. The client + may wish to know this name as well to offer the user similar behaviors. + + The name is a UTF-8 string with no convention defined for its contents. + Each name is unique among all wl_output globals. The name is only + guaranteed to be unique for the compositor instance. + + The same output name is used for all clients for a given wl_output + global. Thus, the name can be shared across processes to refer to a + specific wl_output global. + + The name is not guaranteed to be persistent across sessions, thus cannot + be used to reliably identify an output in e.g. configuration files. + + Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc. However, do + not assume that the name is a reflection of an underlying DRM connector, + X11 connection, etc. + + The name event is sent after binding the output object. This event is + only sent once per output object, and the name does not change over the + lifetime of the wl_output global. + + Compositors may re-use the same output name if the wl_output global is + destroyed and re-created later. Compositors should avoid re-using the + same name if possible. + + The name event will be followed by a done event. + + + + + + + Many compositors can produce human-readable descriptions of their + outputs. The client may wish to know this description as well, e.g. for + output selection purposes. + + The description is a UTF-8 string with no convention defined for its + contents. The description is not guaranteed to be unique among all + wl_output globals. Examples might include 'Foocorp 11" Display' or + 'Virtual X11 output via :1'. + + The description event is sent after binding the output object and + whenever the description changes. The description is optional, and may + not be sent at all. + + The description event will be followed by a done event. + + + @@ -2643,7 +2874,7 @@ wl_surface state directly. A sub-surface is initially in the synchronized mode. - Sub-surfaces have also other kind of state, which is managed by + Sub-surfaces also have another kind of state, which is managed by wl_subsurface requests, as opposed to wl_surface requests. This state includes the sub-surface position relative to the parent surface (wl_subsurface.set_position), and the stacking order of diff --git a/app/src/main/jni/prebuilt/x86_64/libwayland-server.so b/app/src/main/jni/prebuilt/x86_64/libwayland-server.so index bc54780..038bc0e 100755 Binary files a/app/src/main/jni/prebuilt/x86_64/libwayland-server.so and b/app/src/main/jni/prebuilt/x86_64/libwayland-server.so differ diff --git a/app/src/main/res/layout/main_activity.xml b/app/src/main/res/layout/main_activity.xml index 0299941..a66c828 100644 --- a/app/src/main/res/layout/main_activity.xml +++ b/app/src/main/res/layout/main_activity.xml @@ -15,7 +15,7 @@ - diff --git a/build_termux_package b/build_termux_package index dbdd8f2..9f79a2a 100755 --- a/build_termux_package +++ b/build_termux_package @@ -9,7 +9,7 @@ NDKBUILD_DIR=starter/build/intermediates/ndkBuild/debug/obj/local DATA_DIR=$INTERMEDIATES/data CONTROL_DIR=$INTERMEDIATES/control PACKAGE_DIR=$INTERMEDIATES/package -PREFIX=$DATA_DIR/data/data/com.termux/files/usr +PREFIX=$DATA_DIR/data/data/me.sergiotarxz.openmg.x11/files/usr rm -rf $PACKAGE_PATH $DATA_DIR $CONTROL_DIR $PACKAGE_DIR diff --git a/common/src/main/AndroidManifest.xml b/common/src/main/AndroidManifest.xml index c2d27df..da0d91b 100644 --- a/common/src/main/AndroidManifest.xml +++ b/common/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="me.sergiotarxz.openmg.x11.common"> \ No newline at end of file diff --git a/common/src/main/aidl/com/termux/x11/common/ITermuxX11Internal.aidl b/common/src/main/aidl/me/sergiotarxz/openmg/x11/common/ITermuxX11Internal.aidl similarity index 81% rename from common/src/main/aidl/com/termux/x11/common/ITermuxX11Internal.aidl rename to common/src/main/aidl/me/sergiotarxz/openmg/x11/common/ITermuxX11Internal.aidl index 5883945..3688a0f 100644 --- a/common/src/main/aidl/com/termux/x11/common/ITermuxX11Internal.aidl +++ b/common/src/main/aidl/me/sergiotarxz/openmg/x11/common/ITermuxX11Internal.aidl @@ -1,4 +1,4 @@ -package com.termux.x11.common; +package me.sergiotarxz.openmg.x11.common; // This interface is used by utility on termux side. interface ITermuxX11Internal { diff --git a/starter/build.gradle b/starter/build.gradle index a49a9ea..51cff62 100644 --- a/starter/build.gradle +++ b/starter/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { - applicationId "com.termux.termuxam" + applicationId "me.sergiotarxz.openmg.termuxam" minSdkVersion 21 // Note: targetSdkVersion affects only tests, // normally, even though this is packaged as apk, diff --git a/starter/src/main/AndroidManifest.xml b/starter/src/main/AndroidManifest.xml index 5cae546..9f68f1d 100644 --- a/starter/src/main/AndroidManifest.xml +++ b/starter/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="me.sergiotarxz.openmg.x11.starter">