app: correct calcs for IME insets

This commit is contained in:
jkds
2025-12-31 11:02:41 +01:00
parent 13755ab328
commit 489730cb31
3 changed files with 9 additions and 5 deletions

View File

@@ -63,6 +63,9 @@ pub unsafe extern "C" fn Java_darkfi_darkfi_1app_ResizingLayout_onApplyInsets(
);
let mut globals = GLOBALS.lock();
globals.insets = [sys_left as f32, sys_top as f32, sys_right as f32, sys_bottom as f32];
if ime_bottom > 0 {
globals.insets[3] = ime_bottom as f32;
}
if let Some(sender) = &globals.sender {
let _ = sender.try_send(globals.insets.clone());
} else {

View File

@@ -96,9 +96,10 @@ impl App {
sled_tree: settings_tree,
});
#[cfg(target_os = "android")]
let window_scale = android::get_screen_density() / 2.625;
#[cfg(not(target_os = "android"))]
// TODO: apply this to insets otherwise its wrong
//#[cfg(target_os = "android")]
//let window_scale = android::get_screen_density() / 2.625;
//#[cfg(not(target_os = "android"))]
let window_scale = 1.;
d!("Setting window scale to {window_scale}");

View File

@@ -325,9 +325,9 @@ pub async fn make(app: &App, window: SceneNodePtr, i18n_fish: &I18nBabelFish) {
let prop = content.get_property("rect").unwrap();
prop.set_expr(atom, Role::App, 0, expr::load_var("insets_left")).unwrap();
prop.set_expr(atom, Role::App, 1, expr::load_var("insets_top")).unwrap();
let code = cc.compile("w - insets_right").unwrap();
let code = cc.compile("w - insets_left - insets_right").unwrap();
prop.set_expr(atom, Role::App, 2, code).unwrap();
let code = cc.compile("h - insets_bottom").unwrap();
let code = cc.compile("h - insets_top - insets_bottom").unwrap();
prop.set_expr(atom, Role::App, 3, code).unwrap();
let window_insets = window.get_property("insets").unwrap();
prop.add_depend(&window_insets, 0, "insets_left");