Port launcher to WASI component and wasmtime Android runtime APK

This commit is contained in:
nandi committed 2026-11-13 10:45:57 -08:00
1 parent 24336b9016
commit babced838b
24 files changed
+5620

No files matched your search

+7
View File
@@ -9,3 +9,10 @@ branches = ["main"]
timeout = 3600
image = "eclipse-temurin:17-jdk-noble"
run = "bash ci/forge-apk.sh"
[[job]]
name = "wasm-apk"
branches = ["main"]
timeout = 3600
image = "eclipse-temurin:17-jdk-noble"
run = "bash ci/forge-wasm-apk.sh"
+2
View File
@@ -7,3 +7,5 @@ android/app/build/
android/local.properties
build/
build-*/
android-wasm/target/
android-wasm/assets/*.wasm
+2137
View File
File diff suppressed because it is too large. Load diff
+64
View File
@@ -0,0 +1,64 @@
[package]
name = "ultra-launcher-wasm"
version = "0.1.0"
edition = "2021"
publish = false
[lib]
crate-type = ["cdylib"]
path = "src/lib.rs"
[dependencies]
android-activity = { version = "0.6", features = ["native-activity"] }
android_logger = "0.14"
base64 = "0.22"
jni = "0.21"
log = "0.4"
ndk = "0.9"
sha2 = "0.10"
wasmtime = { version = "50", default-features = false, features = ["component-model", "cranelift", "runtime", "std"] }
wasmtime-wasi = "50"
[profile.release]
opt-level = 3
debug = false
lto = "thin"
codegen-units = 16
strip = true
[package.metadata.android]
package = "dev.ultra.launcher.wasm"
apk_name = "ultra-launcher-wasm"
build_targets = ["aarch64-linux-android"]
resources = "res"
assets = "assets"
[package.metadata.android.sdk]
min_sdk_version = 30
target_sdk_version = 35
[package.metadata.android.application]
label = "ultra Wasm"
icon = "@mipmap/ic_launcher"
theme = "@style/HomeWasm"
extract_native_libs = true
has_code = true
[package.metadata.android.application.activity]
name = "dev.ultra.launcher.wasm.LauncherActivity"
config_changes = "orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
launch_mode = "singleTask"
state_not_needed = true
clear_task_on_launch = true
exclude_from_recents = true
orientation = "unspecified"
[[package.metadata.android.application.activity.intent_filter]]
actions = ["android.intent.action.MAIN"]
categories = ["android.intent.category.HOME", "android.intent.category.DEFAULT", "android.intent.category.LAUNCHER"]
[[package.metadata.android.uses_permission]]
name = "android.permission.REQUEST_DELETE_PACKAGES"
[[package.metadata.android.uses_permission]]
name = "android.permission.QUERY_ALL_PACKAGES"
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
if [ -z "${ANDROID_HOME:-}" ] || [ ! -d "$ANDROID_HOME/ndk" ]; then
export ANDROID_HOME="/home/nandi/Android/Sdk"
fi
export ANDROID_SDK_ROOT="$ANDROID_HOME"
if [ -z "${ANDROID_NDK_ROOT:-}" ]; then
ANDROID_NDK_ROOT=$(ls -1d "$ANDROID_HOME/ndk/"* | tail -n 1)
export ANDROID_NDK_ROOT
fi
BUILD_TOOLS=$(ls -1d "$ANDROID_HOME/build-tools/"* | tail -n 1)
PLATFORM=$(ls -1d "$ANDROID_HOME/platforms/"* | tail -n 1)
KEYSTORE="${CARGO_APK_RELEASE_KEYSTORE:-$PWD/../android/app/debug.keystore}"
export CARGO_APK_RELEASE_KEYSTORE="$KEYSTORE"
export CARGO_APK_RELEASE_KEYSTORE_PASSWORD="${CARGO_APK_RELEASE_KEYSTORE_PASSWORD:-android}"
cargo apk build --release
apk="target/release/apk/ultra-launcher-wasm.apk"
work="target/java-build"
rm -rf "$work"
mkdir -p "$work/classes" "$work/dex"
javac --release 11 -classpath "$PLATFORM/android.jar" \
-d "$work/classes" java/dev/ultra/launcher/wasm/LauncherActivity.java
"$BUILD_TOOLS/d8" --min-api 30 --output "$work/dex" \
$(find "$work/classes" -name '*.class')
python3 - "$apk" "$work/dex/classes.dex" "$work/unaligned.apk" <<'PY'
import sys, zipfile
src, dex, dst = sys.argv[1], sys.argv[2], sys.argv[3]
with zipfile.ZipFile(src, "r") as zin, zipfile.ZipFile(dst, "w") as zout:
for info in zin.infolist():
if info.filename.startswith("META-INF/") or info.filename == "classes.dex":
continue
zout.writestr(info, zin.read(info.filename))
zout.write(dex, "classes.dex", compress_type=zipfile.ZIP_DEFLATED)
PY
"$BUILD_TOOLS/zipalign" -f -p 4 "$work/unaligned.apk" "$work/aligned.apk"
"$BUILD_TOOLS/apksigner" sign \
--ks "$KEYSTORE" --ks-pass pass:android --key-pass pass:android --ks-key-alias androiddebugkey \
--out "$apk" "$work/aligned.apk"
echo "Built $PWD/$apk ($(stat -c%s "$apk") bytes)"
@@ -0,0 +1,314 @@
package dev.ultra.launcher.wasm;
import android.app.NativeActivity;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.PixelFormat;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.security.MessageDigest;
import java.text.Collator;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class LauncherActivity extends NativeActivity {
private static final String TAG = "ultra-wasm";
static {
System.loadLibrary("ultra_launcher_wasm");
}
private static native void nativeOnEvent(String event);
private static native void nativeOnInsets(int top, int bottom);
private final Handler main = new Handler(Looper.getMainLooper());
private LauncherApps launcher;
private final UserHandle user = Process.myUserHandle();
private final Map<String, LauncherActivityInfo> activities = new ConcurrentHashMap<>();
private final Object iconLock = new Object();
private final LauncherApps.Callback packages = new LauncherApps.Callback() {
@Override public void onPackageRemoved(String pkg, UserHandle u) { appsChanged(pkg); }
@Override public void onPackageAdded(String pkg, UserHandle u) { appsChanged(pkg); }
@Override public void onPackageChanged(String pkg, UserHandle u) { appsChanged(pkg); }
@Override public void onPackagesAvailable(String[] pkgs, UserHandle u, boolean replacing) {
appsChanged(String.join(",", pkgs));
}
@Override public void onPackagesUnavailable(String[] pkgs, UserHandle u, boolean replacing) {
appsChanged(String.join(",", pkgs));
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().setFormat(PixelFormat.TRANSLUCENT);
super.onCreate(savedInstanceState);
launcher = getSystemService(LauncherApps.class);
launcher.registerCallback(packages, main);
seeThrough();
getWindow().getDecorView().setOnApplyWindowInsetsListener((v, insets) -> {
onInsets(insets);
return v.onApplyWindowInsets(insets);
});
getWindow().getDecorView().requestApplyInsets();
}
private void seeThrough() {
Window w = getWindow();
w.setFormat(PixelFormat.TRANSLUCENT);
w.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
w.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
w.setStatusBarColor(Color.TRANSPARENT);
w.setNavigationBarColor(Color.TRANSPARENT);
if (Build.VERSION.SDK_INT >= 30) {
w.setDecorFitsSystemWindows(false);
}
}
private void onInsets(WindowInsets insets) {
int top, bottom;
if (Build.VERSION.SDK_INT >= 30) {
Insets bars = insets.getInsets(WindowInsets.Type.systemBars() | WindowInsets.Type.displayCutout());
Insets ime = insets.getInsets(WindowInsets.Type.ime());
top = bars.top;
bottom = Math.max(bars.bottom, ime.bottom);
} else {
top = insets.getSystemWindowInsetTop();
bottom = insets.getSystemWindowInsetBottom();
}
nativeOnInsets(top, bottom);
nativeOnEvent("insets");
}
@Override
protected void onDestroy() {
if (launcher != null) launcher.unregisterCallback(packages);
super.onDestroy();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
nativeOnEvent("home");
}
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.KEYCODE_BACK) {
if (e.getAction() == KeyEvent.ACTION_UP && !e.isCanceled()) {
nativeOnEvent("back");
}
return true;
}
return super.dispatchKeyEvent(e);
}
private void appsChanged(String pkgs) {
if (pkgs != null && !pkgs.isEmpty()) {
for (String pkg : pkgs.split(",")) {
if (pkg.isEmpty()) continue;
String prefix = pkg + "/";
activities.keySet().removeIf(k -> k.startsWith(prefix));
}
}
nativeOnEvent("apps-changed:" + (pkgs == null ? "" : pkgs));
}
// ---- Called from Rust via JNI ----
public String apps() {
try {
List<LauncherActivityInfo> list = new ArrayList<>(launcher.getActivityList(null, user));
Map<LauncherActivityInfo, String> labels = new HashMap<>();
for (LauncherActivityInfo i : list) labels.put(i, String.valueOf(i.getLabel()));
Collator by = Collator.getInstance();
list.sort((x, y) -> by.compare(labels.get(x), labels.get(y)));
JSONArray out = new JSONArray();
Set<String> seen = new HashSet<>();
for (LauncherActivityInfo i : list) {
ComponentName cn = i.getComponentName();
if (cn.getPackageName().equals(getPackageName())) continue;
String c = cn.flattenToShortString();
seen.add(c);
activities.put(c, i);
JSONObject o = new JSONObject().put("label", labels.get(i)).put("component", c);
if ((i.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) != 0) o.put("system", true);
out.put(o);
}
activities.keySet().retainAll(seen);
return new JSONObject().put("apps", out).toString();
} catch (JSONException | RuntimeException e) {
Log.w(TAG, "listing apps", e);
return "{\"apps\":[]}";
}
}
public byte[] icon(String key, int size) {
if (key == null || key.length() < 3) return null;
size = Math.max(16, Math.min(size, 512));
File f = iconFile(key, size);
if (f != null && f.length() == (long) size * size * 4) {
try {
return Files.readAllBytes(f.toPath());
} catch (java.io.IOException e) {
f.delete();
}
}
byte[] px;
synchronized (iconLock) {
try {
Drawable d = appIcon(key.substring(2));
px = d == null ? null : toPixels(d, size);
} catch (RuntimeException | OutOfMemoryError e) {
Log.w(TAG, "icon for " + key, e);
return null;
}
}
if (px != null && f != null) {
File tmp = new File(f.getPath() + ".tmp");
try (FileOutputStream out = new FileOutputStream(tmp)) {
out.write(px);
} catch (java.io.IOException e) {
tmp.delete();
tmp = null;
}
if (tmp != null && !tmp.renameTo(f)) tmp.delete();
}
return px;
}
private File iconFile(String key, int size) {
try {
String pkg = key.substring(2).split("/", 2)[0];
long stamp = getPackageManager().getPackageInfo(pkg, 0).lastUpdateTime;
String id = "v2|" + key + "|" + size + "|" + stamp + "|" + getResources().getDisplayMetrics().densityDpi;
byte[] h = MessageDigest.getInstance("SHA-1").digest(id.getBytes(java.nio.charset.StandardCharsets.UTF_8));
StringBuilder name = new StringBuilder();
for (byte b : h) name.append(String.format("%02x", b));
File dir = new File(getCacheDir(), "icons");
if (!dir.isDirectory() && !dir.mkdirs()) return null;
return new File(dir, name.toString());
} catch (Exception e) {
return null;
}
}
private Drawable appIcon(String c) {
ComponentName cn = ComponentName.unflattenFromString(c);
if (cn == null) return null;
LauncherActivityInfo info = activities.get(c);
if (info == null) {
info = launcher.resolveActivity(
new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setComponent(cn), user);
}
if (info == null) return null;
Drawable d = info.getIcon(getResources().getDisplayMetrics().densityDpi);
return d != null ? d : getPackageManager().getDefaultActivityIcon();
}
private static byte[] toPixels(Drawable d, int size) {
d = d.mutate();
Bitmap bmp = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
d.setBounds(0, 0, size, size);
d.draw(new Canvas(bmp));
ByteBuffer buf = ByteBuffer.allocate(size * size * 4);
bmp.copyPixelsToBuffer(buf);
bmp.recycle();
return buf.array();
}
public void launch(String component) {
main.post(() -> {
ComponentName cn = ComponentName.unflattenFromString(component);
try {
launcher.startMainActivity(cn, user, null, null);
} catch (ActivityNotFoundException | SecurityException | NullPointerException e) {
Toast.makeText(this, "Can't open " + component, Toast.LENGTH_SHORT).show();
}
});
}
public void appInfo(String component) {
main.post(() -> {
ComponentName cn = ComponentName.unflattenFromString(component);
if (cn != null) launcher.startAppDetailsActivity(cn, user, null, null);
});
}
public void uninstall(String component) {
main.post(() -> {
ComponentName cn = ComponentName.unflattenFromString(component);
if (cn != null) {
try {
startActivity(new Intent(Intent.ACTION_DELETE,
Uri.fromParts("package", cn.getPackageName(), null))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} catch (ActivityNotFoundException e) {
Toast.makeText(this, "Not available", Toast.LENGTH_SHORT).show();
}
}
});
}
public void openSettings() {
main.post(() -> startActivity(new Intent(Settings.ACTION_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)));
}
public void pickWallpaper() {
main.post(() -> startActivity(Intent.createChooser(
new Intent(Intent.ACTION_SET_WALLPAPER), "Wallpaper").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)));
}
public void haptic() {
main.post(() -> getWindow().getDecorView().performHapticFeedback(
HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING));
}
public void setTextInput(boolean active) {
main.post(() -> {
InputMethodManager imm = getSystemService(InputMethodManager.class);
if (imm == null) return;
if (active) imm.showSoftInput(getWindow().getDecorView(), 0);
else imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);
});
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="HomeWasm" parent="@android:style/Theme.Wallpaper.NoTitleBar">
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>
</resources>
+646
View File
@@ -0,0 +1,646 @@
use android_activity::input::{InputEvent, KeyAction, Keycode, MotionAction};
use android_activity::{AndroidApp, AndroidAppWaker, InputStatus, MainEvent, PollEvent};
use base64::Engine as _;
use jni::objects::{GlobalRef, JByteArray, JObject, JString, JValue};
use jni::sys::jint;
use jni::{JNIEnv, JavaVM};
use ndk::hardware_buffer_format::HardwareBufferFormat;
use ndk::native_window::NativeWindow;
use sha2::{Digest, Sha256};
use std::collections::VecDeque;
use std::ffi::CString;
use std::path::PathBuf;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Mutex;
use std::time::{Duration, Instant};
use wasmtime::component::{Component, HasSelf, Linker, ResourceTable};
use wasmtime::{Config, Engine, Store};
use wasmtime_wasi::{FsPerms, WasiCtx, WasiCtxBuilder, WasiCtxView, WasiView};
wasmtime::component::bindgen!({
path: "../wasi/wit",
world: "gui",
});
use latha::gui::types as wt;
const B64: base64::engine::GeneralPurpose = base64::engine::general_purpose::STANDARD;
const MIN_FRAME: Duration = Duration::from_millis(16);
static EVENTS: Mutex<VecDeque<String>> = Mutex::new(VecDeque::new());
static WAKER: Mutex<Option<AndroidAppWaker>> = Mutex::new(None);
static INSET_TOP: AtomicU32 = AtomicU32::new(0);
static INSET_BOTTOM: AtomicU32 = AtomicU32::new(0);
#[no_mangle]
pub extern "system" fn Java_dev_ultra_launcher_wasm_LauncherActivity_nativeOnEvent(
mut env: JNIEnv,
_class: JObject,
event: JString,
) {
if let Ok(s) = env.get_string(&event) {
if let Ok(mut q) = EVENTS.lock() {
q.push_back(s.to_string_lossy().into_owned());
}
if let Ok(w) = WAKER.lock() {
if let Some(waker) = w.as_ref() {
waker.wake();
}
}
}
}
#[no_mangle]
pub extern "system" fn Java_dev_ultra_launcher_wasm_LauncherActivity_nativeOnInsets(
_env: JNIEnv,
_class: JObject,
top: jint,
bottom: jint,
) {
INSET_TOP.store(top.max(0) as u32, Ordering::Relaxed);
INSET_BOTTOM.store(bottom.max(0) as u32, Ordering::Relaxed);
}
struct HostState {
wasi: WasiCtx,
table: ResourceTable,
vm: JavaVM,
activity: GlobalRef,
frame_wanted: bool,
tick_at: Option<Instant>,
quit: Option<i32>,
clipboard: String,
primary: String,
dark: bool,
}
impl WasiView for HostState {
fn ctx(&mut self) -> WasiCtxView<'_> {
WasiCtxView {
ctx: &mut self.wasi,
table: &mut self.table,
}
}
}
impl HostState {
fn call_void(&self, method: &str, sig: &str, args: &[JValue]) {
if let Ok(mut env) = self.vm.attach_current_thread() {
if let Err(e) = env.call_method(&self.activity, method, sig, args) {
log::warn!("JNI {method} failed: {e}");
}
}
}
fn call_void_str(&self, method: &str, arg: &str) {
if let Ok(mut env) = self.vm.attach_current_thread() {
if let Ok(js) = env.new_string(arg) {
if let Err(e) = env.call_method(
&self.activity,
method,
"(Ljava/lang/String;)V",
&[JValue::Object(&js)],
) {
log::warn!("JNI {method}({arg}) failed: {e}");
}
}
}
}
}
impl latha::gui::host::Host for HostState {
fn request_frame(&mut self) {
self.frame_wanted = true;
}
fn request_tick(&mut self, delay_ms: u32) {
self.tick_at = Some(Instant::now() + Duration::from_millis(delay_ms as u64));
}
fn set_title(&mut self, title: String) {
log::info!("title: {title}");
}
fn set_cursor(&mut self, _shape: latha::gui::host::Cursor) {}
fn set_min_size(&mut self, _min: latha::gui::host::Size) {}
fn clipboard_text(&mut self) -> String {
self.clipboard.clone()
}
fn set_clipboard_text(&mut self, text: String) {
self.clipboard = text;
}
fn primary_text(&mut self) -> String {
self.primary.clone()
}
fn set_primary_text(&mut self, text: String) {
self.primary = text;
}
fn prefers_dark(&mut self) -> bool {
self.dark
}
fn accent_color(&mut self) -> Option<u32> {
None
}
fn bell(&mut self) {}
fn set_text_input(&mut self, active: bool) {
self.call_void("setTextInput", "(Z)V", &[JValue::Bool(active as u8)]);
}
fn open_url(&mut self, _url: String) -> bool {
false
}
fn quit(&mut self, code: i32) {
self.quit = Some(code);
}
}
impl ultra::launcher::android::Host for HostState {
fn apps(&mut self) -> String {
let Ok(mut env) = self.vm.attach_current_thread() else {
return "{\"apps\":[]}".to_owned();
};
let Ok(res) = env.call_method(&self.activity, "apps", "()Ljava/lang/String;", &[]) else {
return "{\"apps\":[]}".to_owned();
};
let Ok(obj) = res.l() else {
return "{\"apps\":[]}".to_owned();
};
let js: JString = obj.into();
env.get_string(&js)
.map(|s| s.to_string_lossy().into_owned())
.unwrap_or_else(|_| "{\"apps\":[]}".to_owned())
}
fn icon(&mut self, key: String, size: u32) -> Option<String> {
let mut env = self.vm.attach_current_thread().ok()?;
let js = env.new_string(&key).ok()?;
let res = env
.call_method(
&self.activity,
"icon",
"(Ljava/lang/String;I)[B",
&[JValue::Object(&js), JValue::Int(size as jint)],
)
.ok()?;
let obj = res.l().ok()?;
if obj.is_null() {
return None;
}
let arr: JByteArray = obj.into();
let bytes = env.convert_byte_array(arr).ok()?;
Some(B64.encode(&bytes))
}
fn launch(&mut self, component: String) {
self.call_void_str("launch", &component);
}
fn app_info(&mut self, component: String) {
self.call_void_str("appInfo", &component);
}
fn uninstall(&mut self, component: String) {
self.call_void_str("uninstall", &component);
}
fn open_settings(&mut self) {
self.call_void("openSettings", "()V", &[]);
}
fn pick_wallpaper(&mut self) {
self.call_void("pickWallpaper", "()V", &[]);
}
fn haptic(&mut self) {
self.call_void("haptic", "()V", &[]);
}
fn insets(&mut self) -> (u32, u32) {
(
INSET_TOP.load(Ordering::Relaxed),
INSET_BOTTOM.load(Ordering::Relaxed),
)
}
fn poll_events(&mut self) -> Vec<String> {
let mut out = Vec::new();
if let Ok(mut q) = EVENTS.lock() {
while let Some(ev) = q.pop_front() {
out.push(ev);
}
}
out
}
}
struct FrameBuf {
width: u32,
height: u32,
pixels: Vec<u8>, // RGBA8888 premultiplied
}
impl FrameBuf {
fn new() -> Self {
Self {
width: 0,
height: 0,
pixels: Vec::new(),
}
}
fn resize(&mut self, w: u32, h: u32) {
if self.width != w || self.height != h {
self.width = w;
self.height = h;
self.pixels.resize((w as usize) * (h as usize) * 4, 0);
}
}
fn apply_damage(&mut self, store: &mut Store<HostState>, app: &Gui, dmg: &wt::Damage) {
let fw = self.width as i32;
let fh = self.height as i32;
for m in &dmg.moves {
let x0 = m.area.x.max(0);
let y0 = m.area.y.max(0);
let x1 = (m.area.x + m.area.width as i32).min(fw);
let y1 = (m.area.y + m.area.height as i32).min(fh);
if x1 <= x0 || y1 <= y0 {
continue;
}
let w = (x1 - x0) as usize;
let h = (y1 - y0) as usize;
let stride = (self.width as usize) * 4;
let mut tmp = vec![0u8; w * h * 4];
for row in 0..h {
let src_off = ((y0 as usize + row) * stride) + (x0 as usize) * 4;
tmp[row * w * 4..(row + 1) * w * 4]
.copy_from_slice(&self.pixels[src_off..src_off + w * 4]);
}
for row in 0..h {
let dy = y0 + row as i32 + m.dy;
if dy < 0 || dy >= fh {
continue;
}
for col in 0..w {
let dx = x0 + col as i32 + m.dx;
if dx < 0 || dx >= fw {
continue;
}
let dst_off = ((dy as usize) * stride) + (dx as usize) * 4;
let src_off = (row * w + col) * 4;
self.pixels[dst_off..dst_off + 4]
.copy_from_slice(&tmp[src_off..src_off + 4]);
}
}
}
for r in &dmg.rects {
if r.width == 0 || r.height == 0 {
continue;
}
let Ok(b64) = app.latha_gui_app().call_frame_pixels(&mut *store, *r) else {
continue;
};
let Ok(bgra) = B64.decode(b64.as_bytes()) else {
continue;
};
let rw = r.width as usize;
let rh = r.height as usize;
if bgra.len() < rw * rh * 4 {
continue;
}
let stride = (self.width as usize) * 4;
for row in 0..rh {
let py = r.y + row as i32;
if py < 0 || py >= fh {
continue;
}
for col in 0..rw {
let px = r.x + col as i32;
if px < 0 || px >= fw {
continue;
}
let src = (row * rw + col) * 4;
let dst = (py as usize) * stride + (px as usize) * 4;
// BGRA -> RGBA (premultiplied)
self.pixels[dst] = bgra[src + 2];
self.pixels[dst + 1] = bgra[src + 1];
self.pixels[dst + 2] = bgra[src];
self.pixels[dst + 3] = bgra[src + 3];
}
}
}
}
fn present(&self, win: &NativeWindow) {
if self.width == 0 || self.height == 0 {
return;
}
let _ = win.set_buffers_geometry(
self.width as i32,
self.height as i32,
Some(HardwareBufferFormat::R8G8B8A8_UNORM),
);
if let Ok(mut buf) = win.lock(None) {
let dst_stride = buf.stride() * 4;
let src_stride = (self.width as usize) * 4;
let ptr = buf.bits() as *mut u8;
for row in 0..(self.height as usize) {
unsafe {
std::ptr::copy_nonoverlapping(
self.pixels.as_ptr().add(row * src_stride),
ptr.add(row * dst_stride),
src_stride,
);
}
}
}
}
}
fn keycode_text(code: Keycode, shift: bool) -> String {
let ch = match code {
Keycode::A => Some(if shift { 'A' } else { 'a' }),
Keycode::B => Some(if shift { 'B' } else { 'b' }),
Keycode::C => Some(if shift { 'C' } else { 'c' }),
Keycode::D => Some(if shift { 'D' } else { 'd' }),
Keycode::E => Some(if shift { 'E' } else { 'e' }),
Keycode::F => Some(if shift { 'F' } else { 'f' }),
Keycode::G => Some(if shift { 'G' } else { 'g' }),
Keycode::H => Some(if shift { 'H' } else { 'h' }),
Keycode::I => Some(if shift { 'I' } else { 'i' }),
Keycode::J => Some(if shift { 'J' } else { 'j' }),
Keycode::K => Some(if shift { 'K' } else { 'k' }),
Keycode::L => Some(if shift { 'L' } else { 'l' }),
Keycode::M => Some(if shift { 'M' } else { 'm' }),
Keycode::N => Some(if shift { 'N' } else { 'n' }),
Keycode::O => Some(if shift { 'O' } else { 'o' }),
Keycode::P => Some(if shift { 'P' } else { 'p' }),
Keycode::Q => Some(if shift { 'Q' } else { 'q' }),
Keycode::R => Some(if shift { 'R' } else { 'r' }),
Keycode::S => Some(if shift { 'S' } else { 's' }),
Keycode::T => Some(if shift { 'T' } else { 't' }),
Keycode::U => Some(if shift { 'U' } else { 'u' }),
Keycode::V => Some(if shift { 'V' } else { 'v' }),
Keycode::W => Some(if shift { 'W' } else { 'w' }),
Keycode::X => Some(if shift { 'X' } else { 'x' }),
Keycode::Y => Some(if shift { 'Y' } else { 'y' }),
Keycode::Z => Some(if shift { 'Z' } else { 'z' }),
Keycode::Keycode0 => Some('0'),
Keycode::Keycode1 => Some('1'),
Keycode::Keycode2 => Some('2'),
Keycode::Keycode3 => Some('3'),
Keycode::Keycode4 => Some('4'),
Keycode::Keycode5 => Some('5'),
Keycode::Keycode6 => Some('6'),
Keycode::Keycode7 => Some('7'),
Keycode::Keycode8 => Some('8'),
Keycode::Keycode9 => Some('9'),
Keycode::Space => Some(' '),
Keycode::Period => Some('.'),
Keycode::Minus => Some(if shift { '_' } else { '-' }),
_ => None,
};
ch.map(|c| c.to_string()).unwrap_or_default()
}
fn load_wasm_bytes(app: &AndroidApp) -> Result<Vec<u8>, String> {
if let Some(ext) = app.external_data_path() {
let override_path = ext.join("launcher.wasm");
if let Ok(bytes) = std::fs::read(&override_path) {
log::info!("Loaded override wasm from {}", override_path.display());
return Ok(bytes);
}
}
let mgr = app.asset_manager();
let cname = CString::new("launcher.wasm").unwrap();
let mut asset = mgr
.open(&cname)
.ok_or_else(|| "assets/launcher.wasm not found".to_owned())?;
asset
.buffer()
.map(|b| b.to_vec())
.map_err(|e| format!("reading assets/launcher.wasm: {e}"))
}
fn load_component(engine: &Engine, app: &AndroidApp) -> Result<Component, String> {
let bytes = load_wasm_bytes(app)?;
let hash = format!("{:x}", Sha256::digest(&bytes));
let cache_dir = app
.internal_data_path()
.unwrap_or_else(|| PathBuf::from("/data/local/tmp"));
let cache_file = cache_dir.join(format!("launcher-{}.cwasm", &hash[..16]));
if let Ok(cwasm) = std::fs::read(&cache_file) {
if let Ok(comp) = unsafe { Component::deserialize(engine, &cwasm) } {
log::info!("Loaded cached AOT component {}", cache_file.display());
return Ok(comp);
}
}
let comp = Component::from_binary(engine, &bytes).map_err(|e| format!("compile wasm: {e}"))?;
if let Ok(serialized) = comp.serialize() {
let _ = std::fs::write(&cache_file, serialized);
}
Ok(comp)
}
#[no_mangle]
fn android_main(app: AndroidApp) {
android_logger::init_once(
android_logger::Config::default()
.with_max_level(log::LevelFilter::Info)
.with_tag("ultra-wasm"),
);
if let Ok(mut w) = WAKER.lock() {
*w = Some(app.create_waker());
}
let vm = unsafe { JavaVM::from_raw(app.vm_as_ptr() as *mut _) }.expect("JavaVM");
let activity = {
let env = vm.attach_current_thread().expect("JNI attach");
let obj = unsafe { JObject::from_raw(app.activity_as_ptr() as *mut _) };
env.new_global_ref(obj).expect("global ref")
};
let data_dir = app
.internal_data_path()
.unwrap_or_else(|| PathBuf::from("/data/local/tmp"));
let _ = std::fs::create_dir_all(&data_dir);
let mut cfg = Config::new();
cfg.wasm_component_model(true);
let engine = Engine::new(&cfg).expect("wasmtime engine");
let component = match load_component(&engine, &app) {
Ok(c) => c,
Err(e) => {
log::error!("Failed to load launcher.wasm: {e}");
return;
}
};
let mut linker: Linker<HostState> = Linker::new(&engine);
wasmtime_wasi::p2::add_to_linker_sync(&mut linker).expect("wasi p2 linker");
latha::gui::host::add_to_linker::<_, HasSelf<_>>(&mut linker, |s| s).expect("gui host linker");
ultra::launcher::android::add_to_linker::<_, HasSelf<_>>(&mut linker, |s| s)
.expect("android host linker");
let mut wasi_builder = WasiCtxBuilder::new();
wasi_builder.inherit_stdio();
wasi_builder.env("QT_QPA_PLATFORM", "qt2wasmgui");
let _ = wasi_builder.preopened_dir(&data_dir, "/data", FsPerms::ReadWrite);
let state = HostState {
wasi: wasi_builder.build(),
table: ResourceTable::new(),
vm,
activity,
frame_wanted: true,
tick_at: None,
quit: None,
clipboard: String::new(),
primary: String::new(),
dark: true,
};
let mut store = Store::new(&engine, state);
let gui = Gui::instantiate(&mut store, &component, &linker).expect("instantiate launcher");
if let Err(e) = gui
.latha_gui_app()
.call_start(&mut store, &["ultra-home".to_owned()])
{
log::error!("app.start failed: {e}");
return;
}
let mut fb = FrameBuf::new();
let mut last_paint = Instant::now() - MIN_FRAME;
let mut running = true;
while running && store.data().quit.is_none() {
let wait = store
.data()
.tick_at
.map(|t| t.saturating_duration_since(Instant::now()))
.unwrap_or(Duration::from_millis(50));
app.poll_events(Some(wait.min(Duration::from_millis(50))), |ev| match ev {
PollEvent::Main(MainEvent::Destroy) => running = false,
PollEvent::Main(MainEvent::InitWindow { .. })
| PollEvent::Main(MainEvent::WindowResized { .. }) => {
if let Some(win) = app.native_window() {
let w = win.width().max(1) as u32;
let h = win.height().max(1) as u32;
let scale = (app.config().density().unwrap_or(420) as f64) / 160.0;
fb.resize(w, h);
let _ = gui.latha_gui_app().call_resize(&mut store, w, h, scale);
store.data_mut().frame_wanted = true;
}
}
PollEvent::Main(MainEvent::GainedFocus) => {
let _ = gui.latha_gui_app().call_focus(&mut store, true);
}
PollEvent::Main(MainEvent::LostFocus) => {
let _ = gui.latha_gui_app().call_focus(&mut store, false);
}
PollEvent::Main(MainEvent::InputAvailable) => {
if let Ok(mut iter) = app.input_events_iter() {
loop {
let read = iter.next(|event| {
match event {
InputEvent::MotionEvent(me) => {
let p = me.pointer_at_index(0);
let x = p.x() as f64;
let y = p.y() as f64;
let kind = match me.action() {
MotionAction::Down => Some((
wt::PointerKind::Press,
wt::Button::Left,
wt::Buttons::LEFT,
)),
MotionAction::Up => Some((
wt::PointerKind::Release,
wt::Button::Left,
wt::Buttons::empty(),
)),
MotionAction::Move => Some((
wt::PointerKind::Move,
wt::Button::None,
wt::Buttons::LEFT,
)),
MotionAction::Cancel => Some((
wt::PointerKind::Leave,
wt::Button::None,
wt::Buttons::empty(),
)),
_ => None,
};
if let Some((kind, button, buttons)) = kind {
let pe = wt::PointerEvent {
kind,
button,
buttons,
modifiers: wt::Modifiers::empty(),
x,
y,
clicks: 1,
};
let _ = gui.latha_gui_app().call_pointer(&mut store, pe);
store.data_mut().frame_wanted = true;
}
InputStatus::Handled
}
InputEvent::KeyEvent(ke) => {
let pressed = ke.action() == KeyAction::Down;
let keysym = match ke.key_code() {
Keycode::Del => 0xff08,
Keycode::Enter => 0xff0d,
Keycode::Escape => 0xff1b,
_ => 0,
};
let text = if pressed {
keycode_text(ke.key_code(), ke.meta_state().shift_on())
} else {
String::new()
};
if keysym != 0 || !text.is_empty() {
let ev = wt::KeyEvent {
pressed,
repeat: ke.repeat_count() > 0,
keysym,
scancode: ke.scan_code() as u32,
modifiers: wt::Modifiers::empty(),
text,
};
let _ = gui.latha_gui_app().call_key(&mut store, &ev);
store.data_mut().frame_wanted = true;
}
InputStatus::Unhandled
}
_ => InputStatus::Unhandled,
}
});
if !read {
break;
}
}
}
}
_ => {}
});
let has_events = EVENTS.lock().map(|q| !q.is_empty()).unwrap_or(false);
let due = store
.data()
.tick_at
.map(|t| Instant::now() >= t)
.unwrap_or(false);
if due || has_events {
store.data_mut().tick_at = None;
if let Ok(next) = gui.latha_gui_app().call_tick(&mut store) {
if let Some(ms) = next {
store.data_mut().tick_at = Some(Instant::now() + Duration::from_millis(ms as u64));
}
}
}
if store.data().frame_wanted && last_paint.elapsed() >= MIN_FRAME {
store.data_mut().frame_wanted = false;
last_paint = Instant::now();
if let Some(win) = app.native_window() {
if let Ok(dmg) = gui.latha_gui_app().call_paint(&mut store) {
fb.apply_damage(&mut store, &gui, &dmg);
fb.present(&win);
}
}
}
}
}
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Builds the WASI launcher component (wasi/) and the wasmtime runtime APK (android-wasm/).
set -euo pipefail
cd /src
export PIXI_HOME=/opt/pixi
curl -fsSL https://pixi.sh/install.sh | bash
export PATH="$PIXI_HOME/bin:$PATH"
pixi run --manifest-path wasi/pixi.toml build
mkdir -p android-wasm/assets
cp wasi/build/launcher.wasm android-wasm/assets/launcher.wasm
curl -fsSL https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --target aarch64-linux-android
export PATH="$HOME/.cargo/bin:$PATH"
cargo install cargo-apk --version 0.10.0 --locked
bash android-wasm/build.sh
cp android-wasm/target/release/apk/ultra-launcher-wasm.apk ultra-launcher-wasm.apk
+27
View File
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.21)
project(launcher_wasi C CXX)
include(${QT2WASM_ROOT}/cmake/Qt2Wasm.cmake)
set(FONTS_QRC_CPP "${CMAKE_CURRENT_BINARY_DIR}/qrc_fonts.cpp")
add_custom_command(
OUTPUT "${FONTS_QRC_CPP}"
COMMAND "${QT2WASM_QT_PREFIX}/../host/libexec/rcc"
--name fonts
-o "${FONTS_QRC_CPP}"
"${CMAKE_CURRENT_SOURCE_DIR}/fonts.qrc"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/fonts.qrc"
"${CMAKE_CURRENT_SOURCE_DIR}/fonts/DejaVuSans.ttf"
"${CMAKE_CURRENT_SOURCE_DIR}/fonts/DejaVuSans-Bold.ttf"
COMMENT "Compiling fonts.qrc"
)
qt2wasm_add_component(launcher GUI
SOURCES
src/main.cpp
src/launcher_window.cpp
src/layout.cpp
"${FONTS_QRC_CPP}"
INCLUDE_DIRS
src
)
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
QT2WASM_ROOT="${QT2WASM_ROOT:-$(python3 -c 'import qt2wasm, pathlib; print(pathlib.Path(qt2wasm.__file__).parent / "_data")')}"
QT2WASM_COMPAT_DIR="${QT2WASM_COMPAT_DIR:-$CONDA_PREFIX/opt/qt6-wasi/compat}"
MOC="${QT2WASM_MOC:-$QT_WASI_HOST_PATH/libexec/moc}"
BUILD_DIR="build"
GEN_DIR="$PWD/$BUILD_DIR/gen"
mkdir -p "$GEN_DIR/bindings" "$GEN_DIR/runtime"
# 1. Generate C guest bindings for `world gui` (latha:gui/gui + ultra:launcher/android).
wit-bindgen c --world gui --out-dir "$GEN_DIR/bindings" wit
# 2. Run moc on qt2wasm runtime headers and our window class.
"$MOC" "$QT2WASM_ROOT/runtime/wasieventdispatcher.h" -o "$GEN_DIR/runtime/moc_wasieventdispatcher.cpp"
"$MOC" "$QT2WASM_ROOT/gui/qt2wasmgui.h" -o "$GEN_DIR/runtime/moc_qt2wasmgui.cpp"
"$MOC" "src/launcher_window.h" -o "$GEN_DIR/moc_launcher_window.cpp"
# 3. Configure and link the core WASI reactor module.
cmake -S . -B "$BUILD_DIR" -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="$QT2WASM_QT_TOOLCHAIN" \
-DQT2WASM_ROOT="$QT2WASM_ROOT" \
-DQT2WASM_QT_PREFIX="$QT2WASM_QT_PREFIX" \
-DQT2WASM_GEN_DIR="$GEN_DIR" \
-DQT2WASM_COMPAT_DIR="$QT2WASM_COMPAT_DIR" \
-DQT2WASM_GUI_WORLD=gui \
-DQT2WASM_QPA_PLATFORM=qt2wasmgui
cmake --build "$BUILD_DIR"
# 4. Wrap as a WASI Preview 2 component.
wasm-tools component new "$BUILD_DIR/launcher.core.wasm" \
--adapt "wasi_snapshot_preview1=$QT2WASM_ADAPTER" \
-o "$BUILD_DIR/launcher.wasm"
echo "Built $PWD/$BUILD_DIR/launcher.wasm ($(stat -c%s "$BUILD_DIR/launcher.wasm") bytes)"
+6
View File
@@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/qt2wasm/fonts">
<file alias="DejaVuSans.ttf">fonts/DejaVuSans.ttf</file>
<file alias="DejaVuSans-Bold.ttf">fonts/DejaVuSans-Bold.ttf</file>
</qresource>
</RCC>
Binary file not shown.
Binary file not shown.
+1000
View File
@@ -0,0 +1,1000 @@
version: 7
platforms:
- name: linux-64
virtual-packages:
- __unix=0=0
- __linux=4.18
- __glibc=2.28
- __archspec=0=x86_64
environments:
default:
channels:
- url: https://prefix.dev/nandi-testing/
- url: https://conda.anaconda.org/conda-forge/
packages:
linux-64:
- conda: https://conda.anaconda.org/conda-forge/linux-64/binaryen-121-h5888daf_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/brotli-1.2.1-h505cf86_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/brotli-bin-1.2.1-h9908984_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/cmake-4.5.0-hff7ac6b_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/fonttools-4.68.0-py315h4d0d421_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/markupsafe-3.0.4-py315h4aa9e2b_4.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/ninja-1.13.2-h171cf75_1.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/pyyaml-6.0.3-py315h178884a_3.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/rhash-1.4.6-hb03c661_2.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/yaml-0.2.5-hebe6cf0_3.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/zensical-0.1.1-py311h7b25dd4_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/_python_abi3_support-1.0-hd8ed1ab_3.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/click-8.5.1-pyh5ded981_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/cpython-3.15.2-py315hd8ed1ab_100.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/jinja2-3.1.6-pyhcf101f3_1.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/markdown-3.11.3-pyh5ded981_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/munkres-1.1.4-pyhd8ed1ab_1.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/pathspec-1.1.1-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.21.0-pyhcf101f3_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/pymdown-extensions-13.1-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.15.2-h4df99d1_100.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/zensical-ui-0.0.42-pyh5ded981_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/_openmp_mutex-4.5-20_gnu.conda
- conda: https://prefix.dev/nandi-testing/linux-64/bzip2-1.0.8-hda65f42_10.conda
- conda: https://prefix.dev/nandi-testing/linux-64/c-ares-1.34.9-hebe6cf0_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/icu-78.3-py310h44b86e0_2.conda
- conda: https://prefix.dev/nandi-testing/linux-64/jco-1.41.0-hb0f4dca_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/keyutils-1.6.3-h7cc23a3_1.conda
- conda: https://prefix.dev/nandi-testing/linux-64/krb5-1.22.2-hbc21106_2.conda
- conda: https://prefix.dev/nandi-testing/linux-64/ld_impl_linux-64-2.46.1-default_hbd61a6d_103.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libabseil-20260526.0-cxx17_h0dc7533_2.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libbrotlicommon-1.2.1-h39a168f_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libbrotlidec-1.2.1-ha411449_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libbrotlienc-1.2.1-h018ffa1_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libcurl-8.23.0-ha042cf0_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libedit-3.1.20260512-pl5321h373387f_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libev-4.33-h280c20c_3.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libexpat-2.9.0-hd2095e1_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libffi-3.7.0-h81df57d_1.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libgcc-16.2.0-ha9f2e26_7.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libgomp-16.2.0-he0feb66_7.conda
- conda: https://prefix.dev/nandi-testing/linux-64/liblzma-5.8.3-hb03c661_1.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libmpdec-4.0.0-hb03c661_2.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libnghttp2-1.71.0-hc5e5977_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libpsl-0.23.1-hd9e3e90_1.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libsqlite-3.54.1-h13e7031_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libssh2-1.11.1-h6154650_1.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libstdcxx-16.2.0-h934c35e_7.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libuuid-2.42.4-hcfc3c73_1.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libuv-1.52.1-h280c20c_1.conda
- conda: https://prefix.dev/nandi-testing/linux-64/libzlib-1.3.2-h25fd6f3_3.conda
- conda: https://prefix.dev/nandi-testing/linux-64/ncurses-6.6-hdb14827_1.conda
- conda: https://prefix.dev/nandi-testing/linux-64/nodejs-26.10.0-ha5cdc1e_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/openssl-3.6.5-h781a0a9_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/python-3.15.2-h6e52b48_100_cp315.conda
- conda: https://prefix.dev/nandi-testing/linux-64/qt6-wasi-6.8.3-hb0f4dca_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/tk-8.6.13-noxft_h1df4ec4_4.conda
- conda: https://prefix.dev/nandi-testing/linux-64/wasi-sdk-27.0-hb0f4dca_1.conda
- conda: https://prefix.dev/nandi-testing/linux-64/wasm-tools-1.239.0-hb0f4dca_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/wit-bindgen-0.46.0-hb0f4dca_0.conda
- conda: https://prefix.dev/nandi-testing/linux-64/zstd-1.5.7-hb78ec9c_7.conda
- conda: https://prefix.dev/nandi-testing/noarch/ca-certificates-2026.10.23-hbd8a1cb_0.conda
- conda: https://prefix.dev/nandi-testing/noarch/importlib-metadata-9.0.1-pyhcf101f3_0.conda
- conda: https://prefix.dev/nandi-testing/noarch/python_abi-3.15-9_cp315.conda
- conda: https://prefix.dev/nandi-testing/noarch/qt2wasm-0.10.6-pyh4616a5c_0.conda
- conda: https://prefix.dev/nandi-testing/noarch/tomli-2.5.0-pyh5ded981_0.conda
- conda: https://prefix.dev/nandi-testing/noarch/tzdata-2026e-h5d301ff_0.conda
- conda: https://prefix.dev/nandi-testing/noarch/wasi-preview1-adapter-36.0.0-h4616a5c_0.conda
- conda: https://prefix.dev/nandi-testing/noarch/zipp-4.1.2-pyh5ded981_0.conda
packages:
- conda: https://conda.anaconda.org/conda-forge/linux-64/binaryen-121-h5888daf_0.conda
sha256: 01233c9dc409bd6285c03598409d6f9b86aaad88005088b2d72de54ed06d44f1
md5: c331a601e8643b96889adbd82961c290
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=13
- libstdcxx >=13
license: Apache-2.0
license_family: APACHE
run_exports: {}
size: 6054210
timestamp: 1734410441026
- conda: https://conda.anaconda.org/conda-forge/linux-64/brotli-1.2.1-h505cf86_0.conda
sha256: 3efb8e6ac07f12773f02e876567700f554965e33a8e30ee05ddd891c303f7aa3
md5: 65f1fc5f6a3a984a8a25641d0e60fc25
depends:
- __glibc >=2.17,<3.0.a0
- brotli-bin 1.2.1 h9908984_0
- libbrotlidec 1.2.1 ha411449_0
- libbrotlienc 1.2.1 h018ffa1_0
- libgcc >=15
license: MIT
license_family: MIT
run_exports:
weak:
- libbrotlicommon >=1.2.1,<1.3.0a0
- libbrotlienc >=1.2.1,<1.3.0a0
- libbrotlidec >=1.2.1,<1.3.0a0
size: 20477
timestamp: 1792653712185
- conda: https://conda.anaconda.org/conda-forge/linux-64/brotli-bin-1.2.1-h9908984_0.conda
sha256: c64939f0ade0fea29525d2f549a700841a331c0886b3694083d08eb4769936ce
md5: 903eceb31743f0ce070abb9b9f879714
depends:
- __glibc >=2.17,<3.0.a0
- libbrotlidec 1.2.1 ha411449_0
- libbrotlienc 1.2.1 h018ffa1_0
- libgcc >=15
license: MIT
license_family: MIT
run_exports: {}
size: 21494
timestamp: 1792653706181
- conda: https://conda.anaconda.org/conda-forge/linux-64/cmake-4.5.0-hff7ac6b_0.conda
sha256: 515262118596cd67037b345048d2c7d5a400ef218894f749973960b39e5c2a76
md5: b57a771ac5a81aa791dbeab4263e92fa
depends:
- libstdcxx >=15
- libgcc >=15
- __glibc >=2.17,<3.0.a0
- bzip2 >=1.0.8,<2.0a0
- rhash >=1.4.6,<2.0a0
- libexpat >=2.9.0,<3.0a0
- liblzma >=5.8.3,<6.0a0
- ncurses >=6.6,<7.0a0
- zstd >=1.5.7,<1.6.0a0
- libcurl >=8.23.0,<9.0a0
- libuv >=1.52.1,<2.0a0
- libzlib >=1.3.2,<2.0a0
license: BSD-3-Clause
license_family: BSD
run_exports: {}
size: 27320556
timestamp: 1794549486278
- conda: https://conda.anaconda.org/conda-forge/linux-64/fonttools-4.68.0-py315h4d0d421_0.conda
sha256: f1ca91b02a5153c27e400a6537d6413850da54d4ba0913e3f7f1a0cf42f1e38f
md5: 68744252efceeeb7f55638d9d549b0f4
depends:
- __glibc >=2.17,<3.0.a0
- brotli
- libgcc >=15
- munkres
- python >=3.15,<3.16.0a0
- python_abi 3.15.* *_cp315
license: MIT
license_family: MIT
run_exports: {}
size: 3349521
timestamp: 1793164830929
- conda: https://conda.anaconda.org/conda-forge/linux-64/markupsafe-3.0.4-py315h4aa9e2b_4.conda
sha256: 5295ef9c4510cc8365c39db60f78b636ab46b925b944f552b1259848cc16927d
md5: 718ebfa70a24dd938f999bae19220b7b
depends:
- python
- __glibc >=2.17,<3.0.a0
- libgcc >=15
- python_abi 3.15.* *_cp315
constrains:
- jinja2 >=3.0.0
license: BSD-3-Clause
license_family: BSD
run_exports: {}
size: 29174
timestamp: 1793707103879
- conda: https://conda.anaconda.org/conda-forge/linux-64/ninja-1.13.2-h171cf75_1.conda
sha256: 2b5f2e865122f9fc0637f520a7cb22e16b9727b2db6761ee16cb5e6404412c81
md5: 2db7a395d7dc2b6ed5effaf68fb99443
depends:
- __glibc >=2.17,<3.0.a0
- libstdcxx >=14
- libgcc >=14
license: Apache-2.0
license_family: APACHE
run_exports: {}
size: 186767
timestamp: 1786713048064
- conda: https://conda.anaconda.org/conda-forge/linux-64/pyyaml-6.0.3-py315h178884a_3.conda
sha256: 740a7f3a4ce68b31984909cb2412be177e4f8581f0eb28d8cbb19e5ad78f1b3f
md5: 8a07113e62a8e7977bb0ff67506442a7
depends:
- python
- yaml
- libgcc >=15
- __glibc >=2.17,<3.0.a0
- yaml >=0.2.5,<0.3.0a0
- python_abi 3.15.* *_cp315
license: MIT
license_family: MIT
run_exports: {}
size: 226096
timestamp: 1793655133957
- conda: https://conda.anaconda.org/conda-forge/linux-64/rhash-1.4.6-hb03c661_2.conda
sha256: 186a5b225077ad5f4656966da947d43307101950751ef4a239b455588756b4e1
md5: 007602d697e07c11ff9864964eba5ee3
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=14
license: MIT
license_family: MIT
run_exports:
weak:
- rhash >=1.4.6,<2.0a0
size: 194994
timestamp: 1786731436520
- conda: https://conda.anaconda.org/conda-forge/linux-64/yaml-0.2.5-hebe6cf0_3.conda
sha256: d164dfa75ecd538f6fd68765defcc06aa875bc697b9b215362d79a2a73125dd0
md5: e741576fb8f89821ac7c1c537322a33d
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=15
license: MIT
license_family: MIT
run_exports:
weak:
- yaml >=0.2.5,<0.3.0a0
size: 84936
timestamp: 1787228426393
- conda: https://conda.anaconda.org/conda-forge/linux-64/zensical-0.1.1-py311h7b25dd4_0.conda
noarch: python
sha256: ebc742d9fb379736ce379d6e1d2750450548ccae25c518b5317e11a9f03168bd
md5: 5e4b7d9df92a14258ffed0c31be2abe9
depends:
- python
- click >=8.1.8
- markdown >=3.7
- pygments >=2.20
- pymdown-extensions >=11.0
- pyyaml >=6.0.2
- tomli >=2.4.0
- jinja2 >=3.1
- pathspec >=1.0.4
- zensical-ui ==0.0.42
- __glibc >=2.17,<3.0.a0
- libgcc >=15
- _python_abi3_support 1.*
- cpython >=3.11
constrains:
- __glibc >=2.17
license: MIT
license_family: MIT
run_exports: {}
size: 7813059
timestamp: 1794378251094
- conda: https://conda.anaconda.org/conda-forge/noarch/_python_abi3_support-1.0-hd8ed1ab_3.conda
sha256: 2a7204314663eeda5dec482a956f0e2eaf289bd5b9953eaaaad0e81aa64638f2
md5: 3845f3d75991bae0fb90884662f4327c
depends:
- cpython
- python-gil
license: MIT
license_family: MIT
run_exports: {}
size: 8144
timestamp: 1784221492234
- conda: https://conda.anaconda.org/conda-forge/noarch/click-8.5.1-pyh5ded981_0.conda
sha256: f26981878e8ccdc82fc9025d25997aff119080486e5d089948cb718d428d8cb0
md5: d996564510ceb5744c225b93891316dc
depends:
- python >=3.11
- python
license: BSD-3-Clause
license_family: BSD
run_exports: {}
size: 112921
timestamp: 1794046236533
- conda: https://conda.anaconda.org/conda-forge/noarch/cpython-3.15.2-py315hd8ed1ab_100.conda
noarch: generic
sha256: 5433d0f101e153f35b99809cf81bd04ebf8d6a97c07af9ea2f5c998d624d6fe7
md5: 6c0b7c2ddf16d1a1dabfa0847641b518
depends:
- python >=3.15,<3.16.0a0
- python_abi * *_cp315
license: Python-2.0
run_exports: {}
size: 52891
timestamp: 1793014812118
- conda: https://conda.anaconda.org/conda-forge/noarch/jinja2-3.1.6-pyhcf101f3_1.conda
sha256: fc9ca7348a4f25fed2079f2153ecdcf5f9cf2a0bc36c4172420ca09e1849df7b
md5: 04558c96691bed63104678757beb4f8d
depends:
- markupsafe >=2.0
- python >=3.10
- python
license: BSD-3-Clause
license_family: BSD
run_exports: {}
size: 120685
timestamp: 1764517220861
- conda: https://conda.anaconda.org/conda-forge/noarch/markdown-3.11.3-pyh5ded981_0.conda
sha256: 00d8eab9985c4c23b4a6f3c4e6c89e220b18a54e80b07fcc73fba3fac007f067
md5: 3b24b328ea4593136b77ec4b7b2bec74
depends:
- importlib-metadata >=4.4
- python >=3.11
- python
license: BSD-3-Clause
license_family: BSD
run_exports: {}
size: 91718
timestamp: 1793922176577
- conda: https://conda.anaconda.org/conda-forge/noarch/munkres-1.1.4-pyhd8ed1ab_1.conda
sha256: d09c47c2cf456de5c09fa66d2c3c5035aa1fa228a1983a433c47b876aa16ce90
md5: 37293a85a0f4f77bbd9cf7aaefc62609
depends:
- python >=3.9
license: Apache-2.0
license_family: Apache
run_exports: {}
size: 15851
timestamp: 1749895533014
- conda: https://conda.anaconda.org/conda-forge/noarch/pathspec-1.1.1-pyhd8ed1ab_0.conda
sha256: 6eaee417d33f298db79bc7185ab1208604c0e6cf51dade34cd513c6f9db9c6f3
md5: 11adc78451c998c0fd162584abfa3559
depends:
- python >=3.10
license: MPL-2.0
license_family: MOZILLA
run_exports: {}
size: 56559
timestamp: 1777271601895
- conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.21.0-pyhcf101f3_0.conda
sha256: f5f015ff1bc3e1b7fc08eee096b1865234189ae0b82bebdb86a5369116e42fa0
md5: 2882dee445dfa45b0c5afce3ffb7730a
depends:
- python >=3.10
- python
license: BSD-2-Clause
license_family: BSD
run_exports: {}
size: 959376
timestamp: 1786995678795
- conda: https://conda.anaconda.org/conda-forge/noarch/pymdown-extensions-13.1-pyhd8ed1ab_0.conda
sha256: 78804f8a554cee0dc29545760a8ac92f798c35ded9623496f7d0a0f7e77b3004
md5: 76c6f01aa602a93377f74b246caf4fb5
depends:
- markdown >=3.10.3
- python >=3.11
- pyyaml
license: MIT
license_family: MIT
run_exports: {}
size: 185558
timestamp: 1794435013218
- conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.15.2-h4df99d1_100.conda
sha256: 631a77b41660202c5d4d551aa1816ce550cc6921352ca3d57ac58d0364cab670
md5: beef54f8f4201e9f86f8733cef15506d
depends:
- cpython 3.15.2.*
- python_abi * *_cp315
license: Python-2.0
run_exports: {}
size: 52881
timestamp: 1793014838911
- conda: https://conda.anaconda.org/conda-forge/noarch/zensical-ui-0.0.42-pyh5ded981_0.conda
sha256: ffcf5a93a8d57d248f2ec4b817fd7025ec38a4ad320acb3e382e22b6f2705edd
md5: d66c10adf1915fd628db043f3aed8715
depends:
- python >=3.11
- python
license: MIT
license_family: MIT
run_exports: {}
size: 4721527
timestamp: 1794336711109
- conda: https://prefix.dev/nandi-testing/linux-64/_openmp_mutex-4.5-20_gnu.conda
build_number: 20
sha256: 1dd3fffd892081df9726d7eb7e0dea6198962ba775bd88842135a4ddb4deb3c9
md5: a9f577daf3de00bca7c3c76c0ecbd1de
depends:
- __glibc >=2.17,<3.0.a0
- libgomp >=7.5.0
constrains:
- openmp_impl <0.0a0
license: BSD-3-Clause
run_exports:
strong:
- _openmp_mutex >=4.5
size: 28948
timestamp: 1770939786096
- conda: https://prefix.dev/nandi-testing/linux-64/bzip2-1.0.8-hda65f42_10.conda
sha256: 1a0d382c515ebf55f8ee1f38c8b81bc95af5c2acc42ad53b66bc5df932032f96
md5: e675fabcf81499adc7edf58124fb1e01
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=14
license: bzip2-1.0.6
license_family: BSD
run_exports:
weak:
- bzip2 >=1.0.8,<2.0a0
size: 257808
timestamp: 1785906269155
- conda: https://prefix.dev/nandi-testing/linux-64/c-ares-1.34.9-hebe6cf0_0.conda
sha256: bd95dd25b80b5c4faf5349542377bf89b2794e23d0f7aa7f1c431e4f3b633f3c
md5: 78b505af04bf7a87ca957ef0cb5946f5
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=15
license: MIT
run_exports:
weak:
- c-ares >=1.34.9,<2.0a0
size: 233759
timestamp: 1792507024648
- conda: https://prefix.dev/nandi-testing/linux-64/icu-78.3-py310h44b86e0_2.conda
sha256: 9f07834f0c546ab14d885ce0366285f61f44e326c0edd1fc63b8294e113ae432
md5: 72a381cbad04f24b1c2a43ef707f45b4
depends:
- __glibc >=2.17,<3.0.a0
- libstdcxx >=14
- libgcc >=14
license: MIT
run_exports:
weak:
- icu >=78.3,<79.0a0
size: 14459115
timestamp: 1786545741408
- conda: https://prefix.dev/nandi-testing/linux-64/jco-1.41.0-hb0f4dca_0.conda
sha256: a1d13934c0deda1fe1b87477b09bdfbbe0a15f7d0853e86770298f99a48d0eb1
md5: f604ca17ec935c985f91a5efe179be06
depends:
- nodejs >=20
license: Apache-2.0 WITH LLVM-exception
run_exports: {}
size: 76812028
timestamp: 1794351630770
- conda: https://prefix.dev/nandi-testing/linux-64/keyutils-1.6.3-h7cc23a3_1.conda
sha256: dd053c96dcb0dcfd59422aefea9d2fe937a190167f34fba7893ec1e10a7e8963
md5: ba55d1b89fd7775e67de8291029b4059
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=15
license: LGPL-2.1-or-later
run_exports:
weak:
- keyutils >=1.6.3,<2.0a0
size: 135295
timestamp: 1786739238128
- conda: https://prefix.dev/nandi-testing/linux-64/krb5-1.22.2-hbc21106_2.conda
sha256: 2a5c38c85e63df84c4e69ee71439841ce570d259ae3060627bb9a49a938d66f4
md5: 53318d715316929a574f83591308b1f8
depends:
- __glibc >=2.17,<3.0.a0
- keyutils >=1.6.3,<2.0a0
- libedit >=3.1.20250104,<3.2.0a0
- libedit >=3.1.20250104,<4.0a0
- libgcc >=15
- libstdcxx >=15
- openssl >=3.5.7,<4.0a0
license: MIT
run_exports:
weak:
- krb5 >=1.22.2,<1.23.0a0
size: 1394333
timestamp: 1786762112514
- conda: https://prefix.dev/nandi-testing/linux-64/ld_impl_linux-64-2.46.1-default_hbd61a6d_103.conda
sha256: 901649b1edbe841fd4ee7e2d491a05184ed540eb01cdae506872f344babc1d28
md5: 2362c70e7e79827c32db35547d9c179b
depends:
- __glibc >=2.17,<3.0.a0
- zstd >=1.5.7,<1.6.0a0
constrains:
- binutils_impl_linux-64 2.46.1
license: GPL-3.0-only
run_exports: {}
size: 742109
timestamp: 1791565468810
- conda: https://prefix.dev/nandi-testing/linux-64/libabseil-20260526.0-cxx17_h0dc7533_2.conda
sha256: 7bb3d495411b7059e85225aae500d84e7846a4bb02ebd77e4450200b20c180f0
md5: 6983bfe8e09992014b9cf393769c7a84
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=14
- libstdcxx >=14
constrains:
- abseil-cpp =20260526.0
- libabseil-static =20260526.0=cxx17*
license: Apache-2.0
license_family: Apache
run_exports:
weak:
- libabseil >=20260526.0,<20260527.0a0
- libabseil =*=cxx17*
size: 1436888
timestamp: 1787217011773
- conda: https://prefix.dev/nandi-testing/linux-64/libbrotlicommon-1.2.1-h39a168f_0.conda
sha256: 8eccfbfdb8ecba32eabfb6ee92f70e818e5f3a35a01c507f7b6bd56e00e4c617
md5: 9460bdde20bcdf9e6bbef0232b14ad2d
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=15
license: MIT
run_exports:
weak:
- libbrotlicommon >=1.2.1,<1.3.0a0
size: 80370
timestamp: 1792653685570
- conda: https://prefix.dev/nandi-testing/linux-64/libbrotlidec-1.2.1-ha411449_0.conda
sha256: 4b4bda6f70ad511bdff95fdd958dca74b6e0534ae335ddcb1d8c6569774d2429
md5: 6d934e235f4d452ebec720ec7c3638a6
depends:
- __glibc >=2.17,<3.0.a0
- libbrotlicommon 1.2.1 h39a168f_0
- libgcc >=15
license: MIT
run_exports:
weak:
- libbrotlidec >=1.2.1,<1.3.0a0
size: 34703
timestamp: 1792653694124
- conda: https://prefix.dev/nandi-testing/linux-64/libbrotlienc-1.2.1-h018ffa1_0.conda
sha256: 61974cf9bb07115ed6725dacf83d0d985443d78dd123cc4f2758856fda5376ec
md5: 8f3078564b4a4cd9602ebaafe78e0b87
depends:
- __glibc >=2.17,<3.0.a0
- libbrotlicommon 1.2.1 h39a168f_0
- libgcc >=15
license: MIT
run_exports:
weak:
- libbrotlienc >=1.2.1,<1.3.0a0
size: 298098
timestamp: 1792653699767
- conda: https://prefix.dev/nandi-testing/linux-64/libcurl-8.23.0-ha042cf0_0.conda
sha256: d2db14d80efb4f2e76e76561c633f1767f7543987f2bcb54a067a9d264d432ab
md5: 0ad16151226df493aed967f0efce0e80
depends:
- __glibc >=2.17,<3.0.a0
- krb5 >=1.22.2,<1.23.0a0
- libgcc >=15
- libnghttp2 >=1.68.1,<2.0a0
- libpsl >=0.23.1,<0.24.0a0
- libssh2 >=1.11.1,<2.0a0
- libzlib >=1.3.2,<2.0a0
- openssl >=3.5.9,<4.0a0
- zstd >=1.5.7,<1.6.0a0
license: curl
license_family: MIT
run_exports:
weak:
- libcurl >=8.23.0,<9.0a0
size: 505683
timestamp: 1791990900844
- conda: https://prefix.dev/nandi-testing/linux-64/libedit-3.1.20260512-pl5321h373387f_0.conda
sha256: 45301f14f4eb66da57cfaf2d265f3eeee73f8b07e99614ee3afc5b26eea91126
md5: 27dbd7e2984b8fe48e069379636ccfdd
depends:
- ncurses
- __glibc >=2.17,<3.0.a0
- libgcc >=14
- ncurses >=6.6,<7.0a0
license: BSD-2-Clause
run_exports:
weak:
- libedit >=3.1.20260512,<3.2.0a0
size: 135877
timestamp: 1791327370514
- conda: https://prefix.dev/nandi-testing/linux-64/libev-4.33-h280c20c_3.conda
sha256: e4418f68d01a6307c4431b585c71b584f40189877364e542ee87deb777f5e85b
md5: 7bc31538d6e3fb349e897353969237ec
depends:
- libgcc >=14
- __glibc >=2.17,<3.0.a0
license: BSD-2-Clause OR GPL-2.0-or-later
run_exports:
weak:
- libev >=4.33,<4.34.0a0
size: 43220
timestamp: 1785917328200
- conda: https://prefix.dev/nandi-testing/linux-64/libexpat-2.9.0-hd2095e1_0.conda
sha256: 7b930a8b6bc6553cb754b4977a11f9c862c719a652fc2d128d89270992ce8beb
md5: 317ecabe4a58b3068c7958dc5eb89e43
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=15
constrains:
- expat 2.9.0.*
license: MIT
license_family: MIT
run_exports: {}
size: 78894
timestamp: 1793054221966
- conda: https://prefix.dev/nandi-testing/linux-64/libffi-3.7.0-h81df57d_1.conda
sha256: c8c7583ef063bc3c430f1d48298e5ad24f796a35c22ed5b14183325825a61106
md5: 6525a0b06aa4fd390795f0740636a9dd
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=15
license: MIT
run_exports:
weak:
- libffi >=3.7.0,<3.8.0a0
size: 68004
timestamp: 1787753412298
- conda: https://prefix.dev/nandi-testing/linux-64/libgcc-16.2.0-ha9f2e26_7.conda
sha256: e031634c3a928f9594eba868bc46ef5230d6571a364a0c63215b06c4563bfcea
md5: 735629b400b70eeab21a2ba8f5b1c2ce
depends:
- __glibc >=2.17,<3.0.a0
- _openmp_mutex >=4.5
constrains:
- libgcc-ng ==16.2.0=*_7
- libgomp 16.2.0 he0feb66_7
license: GPL-3.0-only WITH GCC-exception-3.1
run_exports: {}
size: 1058444
timestamp: 1790303109576
- conda: https://prefix.dev/nandi-testing/linux-64/libgomp-16.2.0-he0feb66_7.conda
sha256: 92a0bb350c7be6a4eedcb4e111c60aefd176018e6b1c009a6e025dbe9bbcd758
md5: d904c7ddd95e026254b4b80808ee9e12
depends:
- __glibc >=2.17,<3.0.a0
license: GPL-3.0-only WITH GCC-exception-3.1
run_exports:
strong:
- _openmp_mutex >=4.5
size: 640566
timestamp: 1790303046034
- conda: https://prefix.dev/nandi-testing/linux-64/liblzma-5.8.3-hb03c661_1.conda
sha256: 9787df8c22a59c9a70d3e5a10db9ad663485e75e9ccc3f09bd092cb7b95e0dab
md5: 1390b7c5ac0b1d8e447bc5efa6d3c8c2
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=14
constrains:
- xz 5.8.3.*
license: 0BSD
run_exports:
weak:
- liblzma >=5.8.3,<6.0a0
size: 112995
timestamp: 1786348617826
- conda: https://prefix.dev/nandi-testing/linux-64/libmpdec-4.0.0-hb03c661_2.conda
sha256: 46820b4a835e175940ae20bec00fdddaff804cda27a1408ab1b95e77a2196437
md5: fcfed1dc5053eb1901b66e7b1fc32588
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=14
license: BSD-2-Clause
run_exports: {}
size: 92759
timestamp: 1786650399772
- conda: https://prefix.dev/nandi-testing/linux-64/libnghttp2-1.71.0-hc5e5977_0.conda
sha256: a4386712ad6d5bc18943b198407c39e2f8ae2fa9c6418bb37bba96f1d382f109
md5: 726df214814a8b06135a6a674bc54589
depends:
- libev >=4.33,<5.0a0
- __glibc >=2.17,<3.0.a0
- libgcc >=15
- libstdcxx >=15
- libev >=4.33,<4.34.0a0
- c-ares >=1.34.9,<2.0a0
- libzlib >=1.3.2,<2.0a0
- openssl >=3.5.9,<4.0a0
license: MIT
run_exports:
weak:
- libnghttp2 >=1.71.0,<2.0a0
size: 822778
timestamp: 1793628201366
- conda: https://prefix.dev/nandi-testing/linux-64/libpsl-0.23.1-hd9e3e90_1.conda
sha256: 09e8effdc89bc5d021349318d32b85594f5b8d8e3ab8f90a85b81f8fe695a566
md5: 77be60417aa572afcb48cbe0f967401d
depends:
- libstdcxx >=15
- libgcc >=15
- __glibc >=2.17,<3.0.a0
- icu >=78.3,<79.0a0
license: MIT
license_family: MIT
run_exports:
weak:
- libpsl >=0.23.1,<0.24.0a0
size: 72519
timestamp: 1786970753847
- conda: https://prefix.dev/nandi-testing/linux-64/libsqlite-3.54.1-h13e7031_0.conda
sha256: 07b3c98282022f05781122d073f84e944bfb4299946e8457ece3ce6c384ff78e
md5: 8f15f0ec9b69344df5c3bb5cce1751a1
depends:
- __glibc >=2.17,<3.0.a0
- icu >=78.3,<79.0a0
- libgcc >=15
- libzlib >=1.3.2,<2.0a0
license: blessing
run_exports:
weak:
- libsqlite >=3.54.1,<4.0a0
size: 983668
timestamp: 1792175587601
- conda: https://prefix.dev/nandi-testing/linux-64/libssh2-1.11.1-h6154650_1.conda
sha256: 7e463000fa1cba3f3a6597b776f6ab301d425a96e3bc20d0d9d76a3b9f237aa3
md5: 5c526561e1d2a2e071941174eae84557
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=14
- libzlib >=1.3.2,<2.0a0
- openssl >=3.5.7,<4.0a0
license: BSD-3-Clause
license_family: BSD
run_exports:
weak:
- libssh2 >=1.11.1,<2.0a0
size: 306045
timestamp: 1786713107897
- conda: https://prefix.dev/nandi-testing/linux-64/libstdcxx-16.2.0-h934c35e_7.conda
sha256: fa7018298629fc429971fffd6ecba3d27a7b02e4e890d6a93ea01ffebe8cb745
md5: 9b6707e0caca917fa6ea9ee473f37a5d
depends:
- __glibc >=2.17,<3.0.a0
- libgcc 16.2.0 ha9f2e26_7
constrains:
- libstdcxx-ng ==16.2.0=*_7
license: GPL-3.0-only WITH GCC-exception-3.1
run_exports: {}
size: 6615436
timestamp: 1790303132935
- conda: https://prefix.dev/nandi-testing/linux-64/libuuid-2.42.4-hcfc3c73_1.conda
sha256: 0e2e8f2daa9306e67f046e31092d637431d8cf0a26c407ab22401d108c2d4631
md5: d852293faea3c04a6e896b908b43aded
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=15
license: BSD-3-Clause
run_exports:
weak:
- libuuid >=2.42.4,<3.0a0
size: 36134
timestamp: 1793891599274
- conda: https://prefix.dev/nandi-testing/linux-64/libuv-1.52.1-h280c20c_1.conda
sha256: 67761d0206f84140047a367eaf9befe03a7e157a29ee25aee0047b40801cc6b6
md5: 01c4ed87826af55996768af6dbc936b4
depends:
- libgcc >=14
- __glibc >=2.17,<3.0.a0
license: MIT
run_exports:
weak:
- libuv >=1.52.1,<2.0a0
size: 420040
timestamp: 1785914567661
- conda: https://prefix.dev/nandi-testing/linux-64/libzlib-1.3.2-h25fd6f3_3.conda
sha256: eb8a0db0aa570124f7d2a93d7c7f596e3390df5e047818d873baad32985fc736
md5: 0de0122d9570a8ab637c6b73db268389
depends:
- __glibc >=2.17,<3.0.a0
constrains:
- zlib 1.3.2 *_3
license: Zlib
license_family: Other
run_exports:
weak:
- libzlib >=1.3.2,<2.0a0
size: 63713
timestamp: 1785362952714
- conda: https://prefix.dev/nandi-testing/linux-64/ncurses-6.6-hdb14827_1.conda
sha256: 5d46557214ed184381dafe835b7c94a474a1c3b307a08a250b1ea4779b44ffb3
md5: ee6c0cd80a60961a1f48aa3e0b91f986
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=14
license: X11 AND BSD-3-Clause
run_exports:
weak:
- ncurses >=6.6,<7.0a0
size: 911196
timestamp: 1786355078102
- conda: https://prefix.dev/nandi-testing/linux-64/nodejs-26.10.0-ha5cdc1e_0.conda
sha256: ea1ae98c7352198d6d6a4027f4a60d2b634e05d5fd6f0b97e72fc6c16712b2c7
md5: 46a3d9861f49b845fbd54897ff07fe4f
depends:
- libgcc >=15
- __glibc >=2.28,<3.0.a0
- libstdcxx >=15
- zstd >=1.5.7,<1.6.0a0
- libzlib >=1.3.2,<2.0a0
- libuv >=1.52.1,<2.0a0
- openssl >=3.5.8,<4.0a0
- libnghttp2 >=1.68.1,<2.0a0
- libabseil >=20260526.0,<20260527.0a0
- libabseil * cxx17*
- icu >=78.3,<79.0a0
- c-ares >=1.34.8,<2.0a0
- libsqlite >=3.53.4,<4.0a0
- libbrotlicommon >=1.2.0,<1.3.0a0
- libbrotlienc >=1.2.0,<1.3.0a0
- libbrotlidec >=1.2.0,<1.3.0a0
license: MIT
run_exports:
weak:
- nodejs >=26.10.0,<27.0a0
size: 20474429
timestamp: 1790238478566
- conda: https://prefix.dev/nandi-testing/linux-64/openssl-3.6.5-h781a0a9_0.conda
sha256: 9c1533f1cf784f0e250919c0c9762d0b0e6bc727a79290ffb7cea1ceca1d038c
md5: 5a51a2ea653f120240b1a9bf76e0aae9
depends:
- __glibc >=2.17,<3.0.a0
- ca-certificates
- libgcc >=15
license: Apache-2.0
license_family: Apache
run_exports:
weak:
- openssl >=3.6.5,<4.0a0
size: 3195299
timestamp: 1791098052301
- conda: https://prefix.dev/nandi-testing/linux-64/python-3.15.2-h6e52b48_100_cp315.conda
build_number: 100
sha256: dd6fdef748df5636029673a834ca3632ce44c86d71e4986d70bcdb2ae5607a25
md5: 38c3edc23439db3ca383be02ae2b702e
depends:
- __glibc >=2.17,<3.0.a0
- bzip2 >=1.0.8,<2.0a0
- ld_impl_linux-64 >=2.36.1
- libedit >=3.1.20260512,<3.2.0a0
- libexpat >=2.8.5,<3.0a0
- libffi >=3.7.0,<3.8.0a0
- libgcc >=15
- liblzma >=5.8.3,<6.0a0
- libmpdec >=4.0.0,<5.0a0
- libsqlite >=3.54.1,<4.0a0
- libuuid >=2.42.4,<3.0a0
- libzlib >=1.3.2,<2.0a0
- ncurses >=6.6,<7.0a0
- openssl >=3.5.9,<4.0a0
- python_abi 3.15.* *_cp315
- tk >=8.6.13,<8.7.0a0
- tzdata
- zstd >=1.5.7,<1.6.0a0
license: Python-2.0
run_exports:
weak:
- python_abi 3.15.* *_cp315
noarch:
- python
size: 29327137
timestamp: 1793015518763
python_site_packages_path: lib/python3.15/site-packages
- conda: https://prefix.dev/nandi-testing/linux-64/qt6-wasi-6.8.3-hb0f4dca_0.conda
sha256: 2e4fbae5c9cadf88828935715572474256cb6500d664f0b3214df98b49fa84e9
md5: 1f76619fb958e5df8dcc62480912857d
depends:
- wasi-sdk 27.*
- cmake >=3.21
- ninja
- libgcc >=16
- libstdcxx >=16
license: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
run_exports: {}
size: 20849123
timestamp: 1794274326934
- conda: https://prefix.dev/nandi-testing/linux-64/tk-8.6.13-noxft_h1df4ec4_4.conda
build_number: 104
sha256: a1a241d172c1ccab067ba245206dd048bc3c2d1b84504b53c9468e99adfc16a1
md5: 676a2f9b1c4fcf57b70aa5c65f6c60d0
depends:
- libgcc >=15
- __glibc >=2.17,<3.0.a0
- libzlib >=1.3.2,<2.0a0
constrains:
- xorg-libx11 >=1.8.13,<2.0a0
license: TCL
run_exports:
weak:
- tk >=8.6.13,<8.7.0a0
size: 3566806
timestamp: 1787272857910
- conda: https://prefix.dev/nandi-testing/linux-64/wasi-sdk-27.0-hb0f4dca_1.conda
sha256: e8f23f48de592aadf0ae773bc0feda1a46de174b8f49b85006c6ea06e86b8a5b
md5: 0054d5f0e3da6fc37d6510157fbcc03b
license: Apache-2.0 WITH LLVM-exception
run_exports: {}
size: 100198008
timestamp: 1794273876363
- conda: https://prefix.dev/nandi-testing/linux-64/wasm-tools-1.239.0-hb0f4dca_0.conda
sha256: 649e7ba5b6476e7ffb4b1d093bc1c22355258693013145e7659e3ee29d8ee40c
md5: aea1c6d0cc71e9027022bcd2856e6b61
license: Apache-2.0 WITH LLVM-exception
run_exports: {}
size: 5669897
timestamp: 1794274014481
- conda: https://prefix.dev/nandi-testing/linux-64/wit-bindgen-0.46.0-hb0f4dca_0.conda
sha256: 48132c985e85cc499e9dc9c899a6da0947c923938d6d0595a78ea780f0941df5
md5: e54e97c7f9a0690d2a13c2e1e2cf82d1
license: Apache-2.0 WITH LLVM-exception
run_exports: {}
size: 5453568
timestamp: 1794273951520
- conda: https://prefix.dev/nandi-testing/linux-64/zstd-1.5.7-hb78ec9c_7.conda
sha256: 47d682b9f6d6ec9eb1a6e6c3e75ea6273e899e78fb7fc59f81d39745009fbc60
md5: aa459086047c0e5e27023ab19f8cb86a
depends:
- __glibc >=2.17,<3.0.a0
- libzlib >=1.3.2,<2.0a0
license: BSD-3-Clause
run_exports:
weak:
- zstd >=1.5.7,<1.6.0a0
size: 601301
timestamp: 1786599621503
- conda: https://prefix.dev/nandi-testing/noarch/ca-certificates-2026.10.23-hbd8a1cb_0.conda
sha256: 95619b9c1184be7175392eeb0ee7eeb5ccf25d280951f4225f2d62e725790be3
md5: 3fd02989038a1e1cee627c14c2d73f29
depends:
- __unix
license: ISC
run_exports: {}
size: 130057
timestamp: 1792772446739
- conda: https://prefix.dev/nandi-testing/noarch/importlib-metadata-9.0.1-pyhcf101f3_0.conda
sha256: 95a074a7d3f58b3494c068d4789c364dcb591c56b70ca6b12f149a540f9aeea4
md5: 77ec68e0aa61c3fff9ecbf840f93d64e
depends:
- python >=3.10
- zipp >=3.20
- python
license: Apache-2.0
run_exports: {}
size: 34920
timestamp: 1787943971257
- conda: https://prefix.dev/nandi-testing/noarch/python_abi-3.15-9_cp315.conda
build_number: 9
sha256: 976c4a6db967a62385aa633daaab19a929f986b979a7ad836b8b70e15ca7aefd
md5: b23461631fe2abdbade0cb64babe7344
constrains:
- python 3.15.* *_cp315
license: BSD-3-Clause
license_family: BSD
run_exports: {}
size: 6800
timestamp: 1788302827589
- conda: https://prefix.dev/nandi-testing/noarch/qt2wasm-0.10.6-pyh4616a5c_0.conda
sha256: 54c4ee91b29d1052cc2c95881b45b3ed7282665e9ca3fdf76820dd102cd8e202
md5: 09279c4ecd79abf9642ae733faaf4ebb
depends:
- python >=3.10
- python *
- cmake >=3.21
- ninja
- binaryen
- fonttools
- qt6-wasi 6.8.3.*
- wit-bindgen 0.46.*
- wasm-tools 1.239.*
- wasi-preview1-adapter 36.*
- zensical >=0.1
- jco 1.41.*
run_exports: {}
size: 74111
timestamp: 1794580144578
- conda: https://prefix.dev/nandi-testing/noarch/tomli-2.5.0-pyh5ded981_0.conda
sha256: 93b6f517fb7adff00b62be02b798d384a1b34d0e368fdb576fb248bcb3bb9ec7
md5: 36d6a162326c52d6339c8b606f43932d
depends:
- python >=3.11
- python
license: MIT
run_exports: {}
size: 21687
timestamp: 1791394576814
- conda: https://prefix.dev/nandi-testing/noarch/tzdata-2026e-h5d301ff_0.conda
sha256: 2b7ca858879f183ce2dcc65b300f48a0133d5430550f35b23d80d405a0788dbf
md5: abccc3810d2b97e570dee487f2b46e38
license: LicenseRef-Public-Domain
run_exports: {}
size: 119208
timestamp: 1792758382821
- conda: https://prefix.dev/nandi-testing/noarch/wasi-preview1-adapter-36.0.0-h4616a5c_0.conda
sha256: 0b1610b24de6cc92d12db20b13e14fe1f989bc43543c972a1b372c0f069a797b
md5: b9137fc4706585a3da7f55c72f93d309
license: Apache-2.0 WITH LLVM-exception
run_exports: {}
size: 19423
timestamp: 1794274078296
- conda: https://prefix.dev/nandi-testing/noarch/zipp-4.1.2-pyh5ded981_0.conda
sha256: 4e5c50cf5ecc00d83a20b987c52d49b78fa96026437ab09b11f4b7c46b7fc061
md5: 3a99defa674883e167603f141728de7e
depends:
- python >=3.11
- python
license: MIT
license_family: MIT
run_exports: {}
size: 24791
timestamp: 1792622774790
+12
View File
@@ -0,0 +1,12 @@
[workspace]
name = "ultra-launcher-wasi"
channels = ["https://prefix.dev/nandi-testing", "conda-forge"]
platforms = ["linux-64"]
[dependencies]
qt2wasm = "*"
cmake = "*"
ninja = "*"
[tasks]
build = { cmd = "bash build.sh", description = "Build launcher.wasm (WASI component)" }
+780
View File
@@ -0,0 +1,780 @@
#include "launcher_window.h"
#include "gui.h"
#include <QDir>
#include <QFile>
#include <QGuiApplication>
#include <QInputMethod>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QPainter>
#include <QPainterPath>
#include <QWheelEvent>
#include <algorithm>
#include <cmath>
#include <cstring>
namespace {
gui_string_t toWitStr(const QString &s) {
QByteArray utf8 = s.toUtf8();
gui_string_t out;
gui_string_dup(&out, utf8.constData());
return out;
}
QString fromWitStr(const gui_string_t &s) {
return QString::fromUtf8(reinterpret_cast<const char *>(s.ptr), int(s.len));
}
QByteArray fromWitBytes(const gui_string_t &s) {
return QByteArray(reinterpret_cast<const char *>(s.ptr), int(s.len));
}
} // namespace
LauncherWindow::LauncherWindow() {
setTitle(QStringLiteral("ultra Home"));
QSurfaceFormat fmt = format();
fmt.setAlphaBufferSize(8);
setFormat(fmt);
resize(412, 892);
refreshInsets();
loadHome();
refreshApps();
m_pollTimer.start(100, this);
}
void LauncherWindow::refreshInsets() {
gui_tuple2_u32_u32_t ins{};
ultra_launcher_android_insets(&ins);
if (int(ins.f0) != m_physInsetTop || int(ins.f1) != m_physInsetBottom) {
m_physInsetTop = int(ins.f0);
m_physInsetBottom = int(ins.f1);
update();
}
}
void LauncherWindow::refreshApps() {
gui_string_t raw{};
ultra_launcher_android_apps(&raw);
QByteArray json = fromWitBytes(raw);
gui_string_free(&raw);
QJsonDocument doc = QJsonDocument::fromJson(json);
QJsonArray arr = doc.object().value(QStringLiteral("apps")).toArray();
m_apps.clear();
m_appIndex.clear();
m_apps.reserve(arr.size());
for (const QJsonValue &v : arr) {
QJsonObject o = v.toObject();
AppInfo info;
info.label = o.value(QStringLiteral("label")).toString();
info.component = o.value(QStringLiteral("component")).toString();
info.system = o.value(QStringLiteral("system")).toBool(false);
if (!info.component.isEmpty()) {
m_appIndex.insert(info.component, m_apps.size());
m_apps.append(info);
}
}
update();
}
void LauncherWindow::loadHome() {
QFile f(QStringLiteral("/data/home.json"));
if (!f.open(QIODevice::ReadOnly)) return;
QJsonDocument doc = QJsonDocument::fromJson(f.readAll());
if (!doc.isArray()) return;
m_home.clear();
for (const QJsonValue &v : doc.array()) {
QJsonObject o = v.toObject();
if (o.value(QStringLiteral("kind")).toString(QStringLiteral("app")) != QLatin1String("app"))
continue;
QString comp = o.value(QStringLiteral("str")).toString();
if (comp.isEmpty()) continue;
Layout::HomeSlot slot;
slot.component = comp;
slot.x = o.value(QStringLiteral("x")).toInt(-1);
slot.y = o.value(QStringLiteral("y")).toInt(-1);
m_home.append(slot);
if (m_home.size() >= 200) break;
}
}
void LauncherWindow::saveHome() const {
QDir().mkpath(QStringLiteral("/data"));
QJsonArray arr;
for (const auto &s : m_home) {
QJsonObject o;
o.insert(QStringLiteral("kind"), QStringLiteral("app"));
o.insert(QStringLiteral("str"), s.component);
o.insert(QStringLiteral("x"), s.x);
o.insert(QStringLiteral("y"), s.y);
arr.append(o);
}
QFile f(QStringLiteral("/data/home.json"));
if (f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
f.write(QJsonDocument(arr).toJson(QJsonDocument::Compact));
}
}
QImage LauncherWindow::iconFor(const QString &component, int px) {
const QString cacheKey = component + QLatin1Char('@') + QString::number(px);
auto it = m_icons.constFind(cacheKey);
if (it != m_icons.constEnd()) return it.value();
if (m_missingIcons.contains(cacheKey)) return {};
gui_string_t witKey = toWitStr(QStringLiteral("a:") + component);
gui_string_t b64{};
bool ok = ultra_launcher_android_icon(&witKey, uint32_t(px), &b64);
gui_string_free(&witKey);
if (!ok) {
m_missingIcons.insert(cacheKey);
return {};
}
QByteArray raw = QByteArray::fromBase64(fromWitBytes(b64));
gui_string_free(&b64);
const int side = int(std::lround(std::sqrt(raw.size() / 4.0)));
if (side <= 0 || side * side * 4 != raw.size()) {
m_missingIcons.insert(cacheKey);
return {};
}
QImage img(side, side, QImage::Format_RGBA8888_Premultiplied);
std::memcpy(img.bits(), raw.constData(), size_t(raw.size()));
m_icons.insert(cacheKey, img);
return img;
}
void LauncherWindow::pollHostEvents() {
gui_list_string_t evs{};
ultra_launcher_android_poll_events(&evs);
bool changedApps = false;
for (size_t i = 0; i < evs.len; ++i) {
const QString ev = fromWitStr(evs.ptr[i]);
if (ev == QLatin1String("home")) {
closeSheet();
closeDrawer();
m_liftedHome = -1;
m_homeScroll = 0.0;
update();
} else if (ev == QLatin1String("back")) {
if (m_sheet != SheetKind::None) {
closeSheet();
} else if (m_drawerOpen) {
closeDrawer();
} else if (m_liftedHome >= 0) {
m_liftedHome = -1;
update();
}
} else if (ev == QLatin1String("insets")) {
refreshInsets();
} else if (ev.startsWith(QLatin1String("apps-changed:"))) {
const QString pkgs = ev.mid(13);
if (pkgs.isEmpty()) {
m_icons.clear();
m_missingIcons.clear();
} else {
const QStringList list = pkgs.split(QLatin1Char(','), Qt::SkipEmptyParts);
for (const QString &p : list) {
const QString prefix = p + QLatin1Char('/');
for (auto it = m_icons.begin(); it != m_icons.end();) {
if (it.key().startsWith(prefix)) it = m_icons.erase(it);
else ++it;
}
for (auto it = m_missingIcons.begin(); it != m_missingIcons.end();) {
if (it->startsWith(prefix)) it = m_missingIcons.erase(it);
else ++it;
}
}
}
changedApps = true;
}
}
gui_list_string_free(&evs);
if (changedApps) refreshApps();
}
// ---- Geometry ----
qreal LauncherWindow::insetTop() const { return m_physInsetTop / devicePixelRatio(); }
qreal LauncherWindow::insetBottom() const { return m_physInsetBottom / devicePixelRatio(); }
qreal LauncherWindow::contentW() const { return std::min<qreal>(width(), 560.0); }
qreal LauncherWindow::contentX() const { return (width() - contentW()) / 2.0; }
qreal LauncherWindow::gridX() const { return contentX() + 16.0; }
qreal LauncherWindow::gridW() const { return contentW() - 32.0; }
int LauncherWindow::homeCols() const { return width() >= 480 ? 6 : 5; }
qreal LauncherWindow::homeColW() const {
const int cols = homeCols();
return (gridW() - (cols - 1) * Layout::kColGap) / cols;
}
qreal LauncherWindow::panelY() const { return insetTop() + 16.0; }
qreal LauncherWindow::gridTop() const { return panelY() + 54.0 + 16.0; }
QRectF LauncherWindow::appsPillRect() const {
return QRectF(gridX(), panelY(), gridW(), 54.0);
}
QRectF LauncherWindow::drawerSearchRect() const {
const qreal closeW = 72.0;
return QRectF(gridX(), insetTop() + 14.0, gridW() - closeW - 10.0, 48.0);
}
QRectF LauncherWindow::drawerCloseRect() const {
const QRectF s = drawerSearchRect();
return QRectF(s.right() + 10.0, s.top(), 72.0, s.height());
}
QRectF LauncherWindow::drawerClearRect() const {
const QRectF s = drawerSearchRect();
return QRectF(s.right() - 40.0, s.top() + 4.0, 36.0, 40.0);
}
QVector<AppInfo> LauncherWindow::filteredApps() const {
if (m_search.trimmed().isEmpty()) return m_apps;
const QString q = m_search.trimmed();
QVector<AppInfo> out;
for (const auto &a : m_apps) {
if (a.label.contains(q, Qt::CaseInsensitive)) out.append(a);
}
return out;
}
int LauncherWindow::hitHomeSlot(const QPointF &pos) const {
QSet<QString> hidden;
const auto packed = Layout::packHome(m_home, homeCols(), hidden);
const qreal cw = homeColW();
for (int i = 0; i < packed.cells.size(); ++i) {
if (packed.cells[i].col < 0) continue;
QRectF r = Layout::cellBox(packed.cells[i], cw);
r.translate(gridX(), gridTop() - m_homeScroll);
if (r.contains(pos)) return i;
}
return -1;
}
int LauncherWindow::hitDrawerApp(const QPointF &pos) const {
const QVector<AppInfo> list = filteredApps();
const int cols = width() >= 480 ? 5 : 4;
const qreal cw = (gridW() - (cols - 1) * Layout::kColGap) / cols;
const qreal top = drawerSearchRect().bottom() + 16.0;
if (pos.y() < top) return -1;
for (int i = 0; i < list.size(); ++i) {
const int col = i % cols;
const int row = i / cols;
const QRectF r(gridX() + col * (cw + Layout::kColGap),
top + row * (Layout::kCellH + Layout::kRowGap) - m_drawerScroll,
cw, Layout::kCellH);
if (r.contains(pos)) return i;
}
return -1;
}
int LauncherWindow::hitSheetButton(const QPointF &pos) const {
const int count = (m_sheet == SheetKind::Menu) ? 3
: (m_sheet == SheetKind::HomeItem) ? 4
: (m_sheet == SheetKind::DrawerApp) ? 3 : 0;
if (count == 0) return -1;
const qreal btnH = 52.0;
const qreal pad = 16.0;
const qreal sheetH = pad * 2 + count * btnH + (count - 1) * 8.0 + insetBottom();
const qreal sheetY = height() - sheetH;
if (pos.y() < sheetY) return -2; // outside sheet
for (int i = 0; i < count; ++i) {
const QRectF r(gridX(), sheetY + pad + i * (btnH + 8.0), gridW(), btnH);
if (r.contains(pos)) return i;
}
return -1;
}
// ---- Actions ----
void LauncherWindow::openDrawer() {
m_drawerOpen = true;
m_drawerScroll = 0.0;
m_search.clear();
m_searchFocused = false;
update();
}
void LauncherWindow::closeDrawer() {
m_drawerOpen = false;
m_search.clear();
m_searchFocused = false;
if (auto *im = QGuiApplication::inputMethod()) im->hide();
update();
}
void LauncherWindow::openSheet(SheetKind kind, int index) {
m_sheet = kind;
m_sheetIndex = index;
ultra_launcher_android_haptic();
update();
}
void LauncherWindow::closeSheet() {
m_sheet = SheetKind::None;
m_sheetIndex = -1;
update();
}
void LauncherWindow::triggerSheetAction(int actionIdx) {
if (m_sheet == SheetKind::Menu) {
closeSheet();
if (actionIdx == 0) openDrawer();
else if (actionIdx == 1) ultra_launcher_android_pick_wallpaper();
else if (actionIdx == 2) ultra_launcher_android_open_settings();
return;
}
if (m_sheet == SheetKind::HomeItem && m_sheetIndex >= 0 && m_sheetIndex < m_home.size()) {
const QString comp = m_home[m_sheetIndex].component;
const int idx = m_sheetIndex;
closeSheet();
if (actionIdx == 0) {
gui_string_t c = toWitStr(comp);
ultra_launcher_android_launch(&c);
gui_string_free(&c);
} else if (actionIdx == 1) {
gui_string_t c = toWitStr(comp);
ultra_launcher_android_app_info(&c);
gui_string_free(&c);
} else if (actionIdx == 2) {
m_home.removeAt(idx);
saveHome();
update();
} else if (actionIdx == 3) {
gui_string_t c = toWitStr(comp);
ultra_launcher_android_uninstall(&c);
gui_string_free(&c);
}
return;
}
if (m_sheet == SheetKind::DrawerApp) {
const QVector<AppInfo> list = filteredApps();
if (m_sheetIndex >= 0 && m_sheetIndex < list.size()) {
const AppInfo app = list[m_sheetIndex];
closeSheet();
if (actionIdx == 0) {
int existing = -1;
for (int i = 0; i < m_home.size(); ++i) {
if (m_home[i].component == app.component) { existing = i; break; }
}
if (existing >= 0) {
m_home.removeAt(existing);
} else if (m_home.size() < 200) {
m_home.append({app.component, -1, -1});
}
saveHome();
update();
} else if (actionIdx == 1) {
gui_string_t c = toWitStr(app.component);
ultra_launcher_android_app_info(&c);
gui_string_free(&c);
} else if (actionIdx == 2 && !app.system) {
gui_string_t c = toWitStr(app.component);
ultra_launcher_android_uninstall(&c);
gui_string_free(&c);
}
} else {
closeSheet();
}
}
}
// ---- Painting ----
void LauncherWindow::paintEvent(QPaintEvent *) {
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
p.setRenderHint(QPainter::SmoothPixmapTransform);
// Clear to transparent so the Android wallpaper shows behind the launcher.
p.setCompositionMode(QPainter::CompositionMode_Source);
p.fillRect(QRect(QPoint(0, 0), size()), Qt::transparent);
p.setCompositionMode(QPainter::CompositionMode_SourceOver);
if (m_drawerOpen) drawDrawer(p);
else drawHome(p);
if (m_sheet != SheetKind::None) drawSheet(p);
}
void LauncherWindow::drawIconAndLabel(QPainter &p, const QRectF &box, const QString &component,
const QString &label, int iconSize, bool lifted) {
const qreal scale = lifted ? 1.1 : 1.0;
const qreal sz = iconSize * scale;
const QRectF iconRect(box.center().x() - sz / 2.0, box.top() + 4.0, sz, sz);
const int px = std::max(48, int(std::ceil(sz * devicePixelRatio())));
const QImage img = iconFor(component, px);
if (!img.isNull()) {
p.drawImage(iconRect, img);
} else {
p.setPen(Qt::NoPen);
p.setBrush(QColor(255, 255, 255, 46));
p.drawEllipse(iconRect);
}
QFont f = p.font();
f.setPixelSize(12);
f.setWeight(QFont::Medium);
p.setFont(f);
const QRectF textRect(box.left() + 2.0, iconRect.bottom() + 5.0, box.width() - 4.0, 20.0);
const QString elided = p.fontMetrics().elidedText(label, Qt::ElideRight, int(textRect.width()));
p.setPen(QColor(0, 0, 0, 160));
p.drawText(textRect.translated(0, 1), Qt::AlignHCenter | Qt::AlignTop, elided);
p.setPen(Qt::white);
p.drawText(textRect, Qt::AlignHCenter | Qt::AlignTop, elided);
}
void LauncherWindow::drawHome(QPainter &p) {
// Top pill ("Apps")
const QRectF pill = appsPillRect();
p.setPen(QPen(QColor(255, 255, 255, 55), 1.0));
p.setBrush(QColor(24, 24, 30, 135));
p.drawRoundedRect(pill, 27.0, 27.0);
QFont f = p.font();
f.setPixelSize(16);
f.setWeight(QFont::Medium);
p.setFont(f);
p.setPen(Qt::white);
p.drawText(pill, Qt::AlignCenter, QStringLiteral("Apps"));
if (m_home.isEmpty()) {
f.setPixelSize(14);
f.setWeight(QFont::Normal);
p.setFont(f);
p.setPen(QColor(255, 255, 255, 190));
p.drawText(QRectF(gridX(), gridTop() + 40.0, gridW(), 60.0),
Qt::AlignHCenter | Qt::AlignTop | Qt::TextWordWrap,
QStringLiteral("Swipe down or tap Apps • Long press for menu"));
return;
}
QSet<QString> hidden;
const auto packed = Layout::packHome(m_home, homeCols(), hidden);
const qreal cw = homeColW();
for (int i = 0; i < m_home.size(); ++i) {
if (i == m_liftedHome || packed.cells[i].col < 0) continue;
QRectF r = Layout::cellBox(packed.cells[i], cw);
r.translate(gridX(), gridTop() - m_homeScroll);
if (r.bottom() < gridTop() || r.top() > height()) continue;
const int appIdx = m_appIndex.value(m_home[i].component, -1);
const QString label = appIdx >= 0 ? m_apps[appIdx].label : m_home[i].component.section(QLatin1Char('/'), 0, 0);
drawIconAndLabel(p, r, m_home[i].component, label, 52, false);
}
if (m_liftedHome >= 0 && m_liftedHome < m_home.size()) {
const QString comp = m_home[m_liftedHome].component;
const int appIdx = m_appIndex.value(comp, -1);
const QString label = appIdx >= 0 ? m_apps[appIdx].label : comp;
const QRectF r(m_liftPos.x() - cw / 2.0, m_liftPos.y() - Layout::kCellH / 2.0, cw, Layout::kCellH);
drawIconAndLabel(p, r, comp, label, 52, true);
}
}
void LauncherWindow::drawDrawer(QPainter &p) {
p.fillRect(QRect(QPoint(0, 0), size()), QColor(14, 15, 20, 222));
const QRectF search = drawerSearchRect();
p.setPen(QPen(QColor(255, 255, 255, m_searchFocused ? 140 : 60), 1.0));
p.setBrush(QColor(255, 255, 255, 24));
p.drawRoundedRect(search, 24.0, 24.0);
QFont f = p.font();
f.setPixelSize(16);
f.setWeight(QFont::Normal);
p.setFont(f);
p.setPen(m_search.isEmpty() ? QColor(255, 255, 255, 130) : Qt::white);
p.drawText(search.adjusted(18, 0, -44, 0), Qt::AlignVCenter | Qt::AlignLeft,
m_search.isEmpty() ? QStringLiteral("Search apps") : m_search);
if (!m_search.isEmpty()) {
p.setPen(QColor(255, 255, 255, 190));
p.drawText(drawerClearRect(), Qt::AlignCenter, QStringLiteral("✕"));
}
const QRectF closeBtn = drawerCloseRect();
p.setPen(Qt::white);
f.setWeight(QFont::Medium);
p.setFont(f);
p.drawText(closeBtn, Qt::AlignCenter, QStringLiteral("Close"));
const QVector<AppInfo> list = filteredApps();
const int cols = width() >= 480 ? 5 : 4;
const qreal cw = (gridW() - (cols - 1) * Layout::kColGap) / cols;
const qreal top = search.bottom() + 16.0;
p.save();
p.setClipRect(QRectF(0, top, width(), height() - top));
for (int i = 0; i < list.size(); ++i) {
const int col = i % cols;
const int row = i / cols;
const QRectF r(gridX() + col * (cw + Layout::kColGap),
top + row * (Layout::kCellH + Layout::kRowGap) - m_drawerScroll,
cw, Layout::kCellH);
if (r.bottom() < top || r.top() > height()) continue;
drawIconAndLabel(p, r, list[i].component, list[i].label, 52, false);
}
p.restore();
}
void LauncherWindow::drawSheet(QPainter &p) {
p.fillRect(QRect(QPoint(0, 0), size()), QColor(0, 0, 0, 140));
QStringList items;
if (m_sheet == SheetKind::Menu) {
items = {QStringLiteral("All apps"), QStringLiteral("Wallpaper"), QStringLiteral("Settings")};
} else if (m_sheet == SheetKind::HomeItem) {
items = {QStringLiteral("Open"), QStringLiteral("App info"), QStringLiteral("Remove from home"), QStringLiteral("Uninstall")};
} else if (m_sheet == SheetKind::DrawerApp) {
const QVector<AppInfo> list = filteredApps();
bool onHome = false;
bool isSystem = false;
if (m_sheetIndex >= 0 && m_sheetIndex < list.size()) {
isSystem = list[m_sheetIndex].system;
for (const auto &s : m_home) {
if (s.component == list[m_sheetIndex].component) { onHome = true; break; }
}
}
items << (onHome ? QStringLiteral("Remove from home") : QStringLiteral("Add to home"));
items << QStringLiteral("App info");
items << (isSystem ? QStringLiteral("System app") : QStringLiteral("Uninstall"));
}
const qreal btnH = 52.0;
const qreal pad = 16.0;
const qreal sheetH = pad * 2 + items.size() * btnH + std::max(0, int(items.size()) - 1) * 8.0 + insetBottom();
const QRectF panel(contentX(), height() - sheetH, contentW(), sheetH);
p.setPen(Qt::NoPen);
p.setBrush(QColor(28, 29, 36, 245));
p.drawRoundedRect(panel.adjusted(0, 0, 0, 24), 24.0, 24.0);
QFont f = p.font();
f.setPixelSize(16);
f.setWeight(QFont::Medium);
p.setFont(f);
for (int i = 0; i < items.size(); ++i) {
const QRectF r(gridX(), panel.top() + pad + i * (btnH + 8.0), gridW(), btnH);
p.setBrush(QColor(255, 255, 255, 22));
p.drawRoundedRect(r, 14.0, 14.0);
p.setPen(Qt::white);
p.drawText(r, Qt::AlignCenter, items[i]);
p.setPen(Qt::NoPen);
}
}
// ---- Input & Timers ----
void LauncherWindow::resizeEvent(QResizeEvent *event) {
QRasterWindow::resizeEvent(event);
refreshInsets();
update();
}
void LauncherWindow::mousePressEvent(QMouseEvent *event) {
if (event->button() != Qt::LeftButton) return;
m_pressed = true;
m_dragging = false;
m_longPressed = false;
m_pressPos = event->position();
m_lastPos = m_pressPos;
m_pressTimer.restart();
if (m_sheet != SheetKind::None) return;
if (m_drawerOpen) {
m_pressedDrawer = hitDrawerApp(m_pressPos);
if (m_pressedDrawer >= 0) m_longPressTimer.start(450, this);
} else {
m_pressedHome = hitHomeSlot(m_pressPos);
if (!appsPillRect().contains(m_pressPos)) {
m_longPressTimer.start(450, this);
}
}
}
void LauncherWindow::mouseMoveEvent(QMouseEvent *event) {
if (!m_pressed) return;
const QPointF pos = event->position();
const qreal dist = std::hypot(pos.x() - m_pressPos.x(), pos.y() - m_pressPos.y());
if (dist > 10.0 && !m_dragging) {
m_dragging = true;
m_longPressTimer.stop();
}
if (m_liftedHome >= 0) {
m_liftPos = pos;
update();
return;
}
if (m_dragging && m_drawerOpen) {
const qreal dy = m_lastPos.y() - pos.y();
const QVector<AppInfo> list = filteredApps();
const int cols = width() >= 480 ? 5 : 4;
const int rows = (list.size() + cols - 1) / cols;
const qreal top = drawerSearchRect().bottom() + 16.0;
const qreal totalH = rows * (Layout::kCellH + Layout::kRowGap) + insetBottom() + 24.0;
const qreal maxScroll = std::max<qreal>(0.0, totalH - (height() - top));
m_drawerScroll = std::clamp(m_drawerScroll + dy, 0.0, maxScroll);
update();
}
m_lastPos = pos;
}
void LauncherWindow::mouseReleaseEvent(QMouseEvent *event) {
if (event->button() != Qt::LeftButton || !m_pressed) return;
m_pressed = false;
m_longPressTimer.stop();
const QPointF pos = event->position();
if (m_liftedHome >= 0) {
const int target = hitHomeSlot(pos);
if (target >= 0 && target != m_liftedHome && target < m_home.size()) {
std::swap(m_home[m_liftedHome], m_home[target]);
saveHome();
} else if (target < 0) {
// Drop into grid coordinates if over empty cell
const qreal localX = pos.x() - gridX();
const qreal localY = pos.y() - (gridTop() - m_homeScroll);
if (localX >= 0 && localY >= 0) {
const int col = std::clamp(int(localX / (homeColW() + Layout::kColGap)), 0, homeCols() - 1);
const int row = std::max(0, int(localY / (Layout::kCellH + Layout::kRowGap)));
m_home[m_liftedHome].x = col;
m_home[m_liftedHome].y = row;
saveHome();
}
}
m_liftedHome = -1;
update();
return;
}
if (m_longPressed) return;
if (m_sheet != SheetKind::None) {
const int hit = hitSheetButton(pos);
if (hit == -2) closeSheet();
else if (hit >= 0) triggerSheetAction(hit);
return;
}
if (m_drawerOpen) {
if (!m_dragging) {
if (drawerCloseRect().contains(pos)) {
closeDrawer();
} else if (!m_search.isEmpty() && drawerClearRect().contains(pos)) {
m_search.clear();
m_drawerScroll = 0.0;
update();
} else if (drawerSearchRect().contains(pos)) {
m_searchFocused = true;
if (auto *im = QGuiApplication::inputMethod()) im->show();
update();
} else {
const int idx = hitDrawerApp(pos);
const QVector<AppInfo> list = filteredApps();
if (idx >= 0 && idx < list.size()) {
gui_string_t c = toWitStr(list[idx].component);
ultra_launcher_android_launch(&c);
gui_string_free(&c);
}
}
}
return;
}
// Home screen
if (m_dragging) {
// Swipe down opens drawer
if (pos.y() - m_pressPos.y() > 72.0) {
openDrawer();
}
return;
}
if (appsPillRect().contains(pos)) {
openDrawer();
return;
}
const int idx = hitHomeSlot(pos);
if (idx >= 0 && idx < m_home.size()) {
gui_string_t c = toWitStr(m_home[idx].component);
ultra_launcher_android_launch(&c);
gui_string_free(&c);
}
}
void LauncherWindow::wheelEvent(QWheelEvent *event) {
if (!m_drawerOpen) return;
const QVector<AppInfo> list = filteredApps();
const int cols = width() >= 480 ? 5 : 4;
const int rows = (list.size() + cols - 1) / cols;
const qreal top = drawerSearchRect().bottom() + 16.0;
const qreal totalH = rows * (Layout::kCellH + Layout::kRowGap) + insetBottom() + 24.0;
const qreal maxScroll = std::max<qreal>(0.0, totalH - (height() - top));
m_drawerScroll = std::clamp(m_drawerScroll - event->angleDelta().y() * 0.5, 0.0, maxScroll);
update();
}
void LauncherWindow::keyPressEvent(QKeyEvent *event) {
if (!m_drawerOpen) return;
if (event->key() == Qt::Key_Escape) {
closeDrawer();
return;
}
if (event->key() == Qt::Key_Backspace) {
if (!m_search.isEmpty()) {
m_search.chop(1);
m_drawerScroll = 0.0;
update();
}
return;
}
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
const QVector<AppInfo> list = filteredApps();
if (!list.isEmpty()) {
gui_string_t c = toWitStr(list.first().component);
ultra_launcher_android_launch(&c);
gui_string_free(&c);
}
return;
}
const QString t = event->text();
if (!t.isEmpty() && t.at(0).isPrint()) {
m_search += t;
m_drawerScroll = 0.0;
update();
}
}
void LauncherWindow::timerEvent(QTimerEvent *event) {
if (event->timerId() == m_pollTimer.timerId()) {
pollHostEvents();
return;
}
if (event->timerId() == m_longPressTimer.timerId()) {
m_longPressTimer.stop();
if (!m_pressed || m_dragging) return;
m_longPressed = true;
if (m_drawerOpen) {
if (m_pressedDrawer >= 0) openSheet(SheetKind::DrawerApp, m_pressedDrawer);
} else if (m_pressedHome >= 0) {
openSheet(SheetKind::HomeItem, m_pressedHome);
} else {
openSheet(SheetKind::Menu, -1);
}
}
}
+110
View File
@@ -0,0 +1,110 @@
#pragma once
#include "layout.h"
#include <QBasicTimer>
#include <QHash>
#include <QImage>
#include <QPointF>
#include <QRasterWindow>
#include <QSet>
#include <QString>
#include <QVector>
#include <QElapsedTimer>
struct AppInfo {
QString label;
QString component;
bool system = false;
};
class LauncherWindow : public QRasterWindow {
Q_OBJECT
public:
LauncherWindow();
protected:
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void timerEvent(QTimerEvent *event) override;
private:
enum class SheetKind { None, Menu, HomeItem, DrawerApp };
void pollHostEvents();
void refreshInsets();
void refreshApps();
void loadHome();
void saveHome() const;
QImage iconFor(const QString &component, int px);
// Geometry helpers (logical px)
qreal insetTop() const;
qreal insetBottom() const;
qreal contentW() const;
qreal contentX() const;
qreal gridX() const;
qreal gridW() const;
int homeCols() const;
qreal homeColW() const;
qreal panelY() const;
qreal gridTop() const;
QRectF appsPillRect() const;
QRectF drawerSearchRect() const;
QRectF drawerCloseRect() const;
QRectF drawerClearRect() const;
QVector<AppInfo> filteredApps() const;
int hitHomeSlot(const QPointF &pos) const;
int hitDrawerApp(const QPointF &pos) const;
int hitSheetButton(const QPointF &pos) const;
void openDrawer();
void closeDrawer();
void openSheet(SheetKind kind, int index);
void closeSheet();
void triggerSheetAction(int actionIdx);
void drawHome(QPainter &p);
void drawDrawer(QPainter &p);
void drawSheet(QPainter &p);
void drawIconAndLabel(QPainter &p, const QRectF &box, const QString &component,
const QString &label, int iconSize, bool lifted);
// Host state
int m_physInsetTop = 0;
int m_physInsetBottom = 0;
QVector<AppInfo> m_apps;
QHash<QString, int> m_appIndex;
QVector<Layout::HomeSlot> m_home;
QHash<QString, QImage> m_icons;
QSet<QString> m_missingIcons;
// UI state
bool m_drawerOpen = false;
qreal m_drawerScroll = 0.0;
qreal m_homeScroll = 0.0;
QString m_search;
bool m_searchFocused = false;
SheetKind m_sheet = SheetKind::None;
int m_sheetIndex = -1;
// Pointer / gesture tracking
bool m_pressed = false;
bool m_dragging = false;
bool m_longPressed = false;
int m_pressedHome = -1;
int m_pressedDrawer = -1;
int m_liftedHome = -1;
QPointF m_pressPos;
QPointF m_lastPos;
QPointF m_liftPos;
QElapsedTimer m_pressTimer;
QBasicTimer m_pollTimer;
QBasicTimer m_longPressTimer;
};
+66
View File
@@ -0,0 +1,66 @@
#include "layout.h"
#include <algorithm>
#include <vector>
namespace Layout {
PackedGrid packHome(const QVector<HomeSlot> &items, int cols, const QSet<QString> &hidden) {
PackedGrid out;
out.cells.resize(items.size(), {-1, -1});
if (cols <= 0) return out;
// Occupancy grid grows dynamically as rows are needed.
std::vector<std::vector<bool>> occ;
auto ensureRow = [&](int r) {
while (static_cast<int>(occ.size()) <= r) occ.emplace_back(cols, false);
};
auto isFree = [&](int c, int r) -> bool {
if (c < 0 || c >= cols || r < 0) return false;
if (r >= static_cast<int>(occ.size())) return true;
return !occ[r][c];
};
auto occupy = [&](int c, int r) {
ensureRow(r);
occ[r][c] = true;
out.rows = std::max(out.rows, r + 1);
};
// Pass 1: place pinned slots first if their cell is free.
QVector<bool> placed(items.size(), false);
for (int i = 0; i < items.size(); ++i) {
const auto &s = items[i];
if (hidden.contains(s.component)) continue;
if (s.x >= 0 && s.x < cols && s.y >= 0 && isFree(s.x, s.y)) {
occupy(s.x, s.y);
out.cells[i] = {s.x, s.y};
placed[i] = true;
}
}
// Pass 2: pack remaining visible slots into the earliest free cell.
int cursorR = 0;
int cursorC = 0;
for (int i = 0; i < items.size(); ++i) {
if (placed[i] || hidden.contains(items[i].component)) continue;
while (!isFree(cursorC, cursorR)) {
++cursorC;
if (cursorC >= cols) {
cursorC = 0;
++cursorR;
}
}
occupy(cursorC, cursorR);
out.cells[i] = {cursorC, cursorR};
}
return out;
}
QRectF cellBox(const CellPos &cell, qreal colW) {
const qreal x = cell.col * (colW + kColGap);
const qreal y = cell.row * (kCellH + kRowGap);
return QRectF(x, y, colW, kCellH);
}
} // namespace Layout
+33
View File
@@ -0,0 +1,33 @@
#pragma once
#include <QRectF>
#include <QSet>
#include <QString>
#include <QVector>
namespace Layout {
inline constexpr qreal kCellH = 92.0;
inline constexpr qreal kColGap = 6.0;
inline constexpr qreal kRowGap = 12.0;
struct HomeSlot {
QString component;
int x = -1;
int y = -1;
};
struct CellPos {
int col = 0;
int row = 0;
};
struct PackedGrid {
QVector<CellPos> cells; // Same length as slots; invalid (-1, -1) if hidden.
int rows = 0;
};
PackedGrid packHome(const QVector<HomeSlot> &items, int cols, const QSet<QString> &hidden);
QRectF cellBox(const CellPos &cell, qreal colW);
} // namespace Layout
+9
View File
@@ -0,0 +1,9 @@
#include "launcher_window.h"
#include <qt2wasm/gui.h>
int qt2wasm_gui_main(int, char **) {
auto *w = new LauncherWindow;
w->show();
return 0;
}
+268
View File
@@ -0,0 +1,268 @@
/// latha:gui: a GUI app as one WebAssembly component.
///
/// The app draws its window into a frame buffer and the host shows it: the
/// host owns the native window, its event loop and the clock; the app is a
/// reactor and only runs inside an export call. A host is a small, generic
/// loader (perry-gui in kwi-wasm: a GTK4 window), and any component that
/// exports `app` and imports nothing but `host` (plus `pty`, and WASI) runs
/// in it. qt2wasm builds such components from QtGui programs
/// (`qt2wasm build --gui`, its `qt2wasmgui` platform plugin).
///
/// Life of an app:
/// 1. `start(args)`: build the UI. The host then calls `resize` with the
/// real surface size before the first `paint`.
/// 2. input arrives as `key` / `text` / `pointer` / `wheel` / `focus`;
/// 3. after anything that may have changed the picture, and whenever the
/// app asked with `host.request-frame`, the host calls `paint`, which
/// returns the pixels to move (scrolling) and the damaged rectangles;
/// the host moves those in its own copy, then copies each damaged
/// rectangle with `frame-pixels`;
/// 4. `tick` runs due timers and queued work; it returns how long until the
/// app next wants one (none: only when something happens);
/// 5. `close` when the user closes the window; the app answers whether the
/// host may close now (it can also leave any time with `host.quit`).
///
/// Coordinates and sizes are device pixels, origin top left. Pixels cross the
/// boundary base64 encoded in a string: hosts lift a `list<u8>` element by
/// element, a string in one copy.
package latha:gui@0.2.3;
interface types {
/// A rectangle in device pixels.
record rect {
x: s32,
y: s32,
width: u32,
height: u32,
}
record size {
width: u32,
height: u32,
}
/// Move the pixels inside `area` by (`dx`, `dy`), as a scrolled view
/// does: the host copies them within the frame it already shows, so they
/// need not cross the boundary again. Only `area` changes: what moves out
/// of it is dropped, and the strip it uncovers keeps its old pixels until
/// a damaged rectangle repaints it.
record move {
area: rect,
dx: s32,
dy: s32,
}
/// What changed since the last `paint`: first apply `moves`, in order,
/// to the shown frame, then copy each of `rects` with `frame-pixels`.
record damage {
moves: list<move>,
rects: list<rect>,
}
/// Keyboard modifiers held during an event. `keypad` marks a key on the
/// numeric keypad.
flags modifiers {
shift,
ctrl,
alt,
meta,
keypad,
}
/// Mouse buttons held during an event.
flags buttons {
left,
right,
middle,
back,
forward,
}
enum button {
none,
left,
right,
middle,
back,
forward,
}
enum pointer-kind {
press,
release,
move,
/// The pointer entered the surface.
enter,
/// The pointer left the surface.
leave,
}
record pointer-event {
kind: pointer-kind,
/// The button that changed (`press` / `release`), else `none`.
button: button,
/// The buttons held after the event.
buttons: buttons,
modifiers: modifiers,
x: f64,
y: f64,
/// For `press`: 1 for a single click, 2 for a double click, ...
clicks: u32,
}
record key-event {
/// true on press (and auto-repeat), false on release.
pressed: bool,
repeat: bool,
/// The X11 / xkbcommon keysym (XK_*, e.g. 0xff0d Return, 0x61 `a`),
/// as GDK, Wayland and X11 report it; 0 if unknown.
keysym: u32,
/// The hardware key code (evdev + 8 on Linux), 0 if unknown.
scancode: u32,
modifiers: modifiers,
/// The text the press types, if any (control characters included,
/// e.g. "\r" for Return, "\u{3}" for Ctrl+C). Text from an input
/// method arrives through `app.text` instead.
text: string,
}
record wheel-event {
x: f64,
y: f64,
/// Wheel notches (1.0 = one notch; positive = down / right).
steps-x: f64,
steps-y: f64,
/// Smooth scrolling (touchpads), in device pixels; 0 if not known.
pixels-x: f64,
pixels-y: f64,
modifiers: modifiers,
}
/// Pointer shapes (CSS cursor names).
enum cursor {
default,
text,
pointer,
crosshair,
wait,
progress,
help,
move,
not-allowed,
grab,
grabbing,
ew-resize,
ns-resize,
nesw-resize,
nwse-resize,
col-resize,
row-resize,
none,
}
}
/// What the host gives the app.
interface host {
use types.{cursor, size};
/// The picture changed: call `paint` soon (once per host frame at most).
request-frame: func();
/// Call `tick` after `delay-ms` (0: as soon as possible), e.g. for a
/// timer the app just started. A later request replaces an earlier one.
request-tick: func(delay-ms: u32);
set-title: func(title: string);
set-cursor: func(shape: cursor);
/// The smallest window size the app can use (device pixels); 0 x 0: any.
set-min-size: func(min: size);
/// The clipboard's text, empty if it holds none.
clipboard-text: func() -> string;
set-clipboard-text: func(text: string);
/// The X11 primary selection (middle-click paste); hosts without one
/// return "" and ignore the set.
primary-text: func() -> string;
set-primary-text: func(text: string);
/// Whether the desktop prefers a dark color scheme.
prefers-dark: func() -> bool;
/// The desktop's accent color (selection, focus, active tab) as
/// 0xRRGGBB, none if the desktop has none. Since 0.2.1; a change arrives
/// as `app.color-scheme`.
accent-color: func() -> option<u32>;
bell: func();
set-text-input: func(active: bool);
/// Open `url` (http, https, mailto, file, ...) the desktop's way: in
/// the user's browser, mail client, file manager. False if the host
/// cannot or will not. Since 0.2.2.
open-url: func(url: string) -> bool;
/// Leave: the host closes the window and exits with `code`.
quit: func(code: s32);
}
/// What the app gives the host.
interface app {
use types.{rect, size, damage, key-event, pointer-event, wheel-event};
/// Build the UI. `args` are the command line after the component's
/// path, with the app's name (the wasm file's stem) first. Returns the
/// window size the app would like (device pixels at scale 1), 0 x 0 for
/// the host's default, or an error that makes the host exit.
start: func(args: list<string>) -> result<size, string>;
/// The surface is now `width` x `height` device pixels at `scale`
/// device pixels per logical pixel.
resize: func(width: u32, height: u32, scale: f64);
key: func(event: key-event);
/// Text committed by an input method (compose, dead keys, CJK, ...).
text: func(text: string);
pointer: func(event: pointer-event);
wheel: func(event: wheel-event);
focus: func(focused: bool);
/// The desktop's appearance changed: the dark / light preference (see
/// `host.prefers-dark`) or the accent color (`host.accent-color`, read it
/// again).
color-scheme: func(dark: bool);
/// The user asked to close the window: true lets the host close it.
close: func() -> bool;
/// Run due timers and queued work. Returns the delay in ms until the app
/// next needs a tick, none if only an event or `request-tick` will.
tick: func() -> option<u32>;
/// Bring the frame up to date. Returns what changed since the last
/// `paint`: pixels that moved, then rectangles to copy (both empty:
/// nothing changed). The frame is the surface's size once `resize` was
/// called; after a resize the first paint reports the whole frame and no
/// moves.
paint: func() -> damage;
frame-size: func() -> size;
/// `r`'s pixels, base64: `r.height` rows of `r.width` pixels, each
/// 4 bytes B, G, R, A with premultiplied alpha (little-endian 0xAARRGGBB:
/// cairo's ARGB32, Qt's ARGB32_Premultiplied).
frame-pixels: func(r: rect) -> string;
}
/// Pseudo-terminals, for apps that run programs (terminal emulators).
/// Output is polled: the host calls `app.tick` when a pty has data or ends.
interface pty {
/// Start `argv` (argv[0] looked up in PATH; empty: the user's shell) on a
/// new pty of `cols` x `rows`, with `env` added to the host's
/// environment and `cwd` (none: the user's home). Returns its id.
spawn: func(argv: list<string>, env: list<tuple<string, string>>, cwd: option<string>,
cols: u16, rows: u16) -> result<u32, string>;
write: func(id: u32, data: list<u8>);
/// Everything the program wrote since the last read, base64 ("" = nothing).
read: func(id: u32) -> string;
resize: func(id: u32, cols: u16, rows: u16);
/// Its exit code once it has ended and its output was read, else none.
exit-code: func(id: u32) -> option<s32>;
/// Hang up (SIGHUP) and forget it.
close: func(id: u32);
}
/// A GUI app.
world gui {
import host;
export app;
}
/// A GUI app that also runs programs on pseudo-terminals.
world gui-pty {
include gui;
import pty;
}
+23
View File
@@ -0,0 +1,23 @@
package ultra:launcher@0.1.0;
interface android {
/// JSON array of {"label": string, "component": string, "system"?: bool}.
apps: func() -> string;
/// Base64-encoded premultiplied RGBA8888 pixels (size * size * 4 bytes) for "a:COMPONENT".
icon: func(key: string, size: u32) -> option<string>;
launch: func(component: string);
app-info: func(component: string);
uninstall: func(component: string);
open-settings: func();
pick-wallpaper: func();
haptic: func();
/// System bar insets in physical screen pixels: (top, bottom).
insets: func() -> tuple<u32, u32>;
/// Drain queued host events ("home", "back", "insets", "apps-changed:<pkgs>").
poll-events: func() -> list<string>;
}
world gui {
include latha:gui/gui@0.2.3;
import android;
}