Modified to adjust the keyboard size according to scale factor 85/292285/2
authorInhong Han <inhong1.han@samsung.com>
Wed, 3 May 2023 05:27:49 +0000 (14:27 +0900)
committerInhong Han <inhong1.han@samsung.com>
Wed, 3 May 2023 05:55:41 +0000 (14:55 +0900)
Change-Id: Ia15fe5ae82949aab6d8eb47212a02a9afe6d625c

ism/extras/wayland_immodule/wayland_imcontext.c

index ad034b8..b9b01ef 100644 (file)
@@ -2473,6 +2473,32 @@ text_input_input_panel_state(void                 *data EINA_UNUSED,
     //
 }
 
+static void
+adjust_keyboard_size(WaylandIMContext *imcontext, int *width, int *height)
+{
+    int win_x, win_y, win_w, win_h;
+    ecore_wl2_window_geometry_get(imcontext->window, &win_x, &win_y, &win_w, &win_h);
+
+    int screen_w, screen_h;
+    Ecore_Wl2_Display *wl2_display = ecore_wl2_connected_display_get(NULL);
+
+    if (!wl2_display)
+    {
+        LOGW("Failed to get display");
+        return;
+    }
+
+    ecore_wl2_display_screen_size_get(wl2_display, &screen_w, &screen_h);
+    double scaling_factor = (double)win_w / (double)*width;
+
+    if (screen_w != win_w && screen_h != win_h)
+    {
+        LOGD("scaling : %f", scaling_factor);
+        *width = (int)(*width * scaling_factor);
+        *height = (int)(*height * scaling_factor);
+    }
+}
+
 // TIZEN_ONLY(20151221): Support input panel geometry
 static void
 text_input_input_panel_geometry(void                 *data,
@@ -2488,13 +2514,17 @@ text_input_input_panel_geometry(void                 *data,
         return;
     }
 
+    int new_w = (int)w;
+    int new_h = (int)h;
+    adjust_keyboard_size(imcontext, &new_w, &new_h);
+
     if (_keyboard_geometry.x != (int)x || _keyboard_geometry.y != (int)y ||
-        _keyboard_geometry.w != (int)w || _keyboard_geometry.h != (int)h)
+        _keyboard_geometry.w != (int)new_w || _keyboard_geometry.h != new_h)
     {
         _keyboard_geometry.x = x;
         _keyboard_geometry.y = y;
-        _keyboard_geometry.w = w;
-        _keyboard_geometry.h = h;
+        _keyboard_geometry.w = new_w;
+        _keyboard_geometry.h = new_h;
 
         imcontext->input_panel_position.x = x;
         imcontext->input_panel_position.y = y;