android: dpi_scale, scissor, JNI safe-insets, touch input
Four Android UX wins landing together; all verified end-to-end on a
Pixel 7 Pro (board fills width, info-panel text renders, status bar
inset honored, tap-to-select + tap-to-move plays 1. e4).
- AndroidPlatform.init reads density via AConfiguration_getDensity
(app->config at offset 32) and sets dpi_scale = density / 160. The
hardcoded 1.0 had been making every logical unit equal one physical
pixel; ChessBoardView's 520-default size_that_fits fallback then
rendered at ~half the framebuffer width on the device, and glyphs
rasterized at literal 11-13 physical pixels were essentially invisible
on a 2340-tall display.
- gles3.sx set_scissor un-stubbed; with dpi_scale right the renderer
feeds in valid pixel bounds and the Y-flip math lands inside the
framebuffer.
- New library/vendors/sx_android_jni/sx_android_jni.c walks
activity -> window -> decorView -> rootWindowInsets via JNI and
publishes the system-bar insets. safe_insets() lazy-queries the
first call after EGL is up (decor view isn't attached at bootstrap).
- sx_android_install_input_handler sets app->onInputEvent; sx-side
sx_android_input_event translates AMotionEvent DOWN/MOVE/UP/CANCEL
into existing mouse_down/mouse_moved/mouse_up Events so the chess
board's tap-to-select + ScrollView drag path Just Works. Coordinates
divided by dpi_scale so layout-side hit tests match. poll_events
drains its slice after returning (mirrors the SDL pattern).
- src/imports.zig now routes #import c { #source / #include } paths
through the same chain as #import (importing dir -> CWD -> stdlib
search paths). Lets library-owned C helpers like the JNI bridge
live in sx/library/vendors/ without forcing consumers to vendor a
copy. Existing CWD-relative consumer layouts (chess's vendors/...)
still resolve first, so no regression.
86/86 regression tests pass.
This commit is contained in:
@@ -202,6 +202,26 @@ pub fn resolveImports(
|
||||
if (decl.data == .c_import_decl) {
|
||||
const ci = decl.data.c_import_decl;
|
||||
|
||||
// Resolve `#source` / `#include` paths through the same chain
|
||||
// as `#import`: importing-file's directory → CWD → stdlib
|
||||
// search paths. This lets sx-library modules ship their own
|
||||
// C helpers (e.g. the Android JNI insets bridge) without
|
||||
// forcing every consumer to vendor an identically-named copy.
|
||||
if (ci.sources.len > 0) {
|
||||
var resolved = try allocator.alloc([]const u8, ci.sources.len);
|
||||
for (ci.sources, 0..) |raw_src, idx| {
|
||||
resolved[idx] = try resolveImportPath(allocator, io, base_dir, raw_src, null, stdlib_paths);
|
||||
}
|
||||
decl.data.c_import_decl.sources = resolved;
|
||||
}
|
||||
if (ci.includes.len > 0) {
|
||||
var resolved = try allocator.alloc([]const u8, ci.includes.len);
|
||||
for (ci.includes, 0..) |raw_inc, idx| {
|
||||
resolved[idx] = try resolveImportPath(allocator, io, base_dir, raw_inc, null, stdlib_paths);
|
||||
}
|
||||
decl.data.c_import_decl.includes = resolved;
|
||||
}
|
||||
|
||||
// Parse headers to get synthetic function declarations
|
||||
const result = c_import.processCImport(
|
||||
allocator,
|
||||
|
||||
Reference in New Issue
Block a user