瀏覽代碼

app: correct calcs for IME insets

jkds 7 月之前
父節點
當前提交
489730cb31
共有 3 個文件被更改,包括 9 次插入5 次删除
  1. 3 0
      bin/app/src/android/insets.rs
  2. 4 3
      bin/app/src/app/mod.rs
  3. 2 2
      bin/app/src/app/schema/mod.rs

+ 3 - 0
bin/app/src/android/insets.rs

@@ -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 {

+ 4 - 3
bin/app/src/app/mod.rs

@@ -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}");

+ 2 - 2
bin/app/src/app/schema/mod.rs

@@ -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");