Modified to keep the floating IME on the screen 17/311117/1
authorInhong Han <inhong1.han@samsung.com>
Tue, 14 May 2024 08:00:43 +0000 (17:00 +0900)
committerInhong Han <inhong1.han@samsung.com>
Tue, 14 May 2024 08:00:43 +0000 (17:00 +0900)
Change-Id: Ia729e303701b32a7bf98de1afa9ba3c6a1b16365

src/e_mod_input_panel.c

index b7ddc974cf861c8420ddd18daa11afb3cb930943..e7c036f5f769b89efc0c2971b53d64ca607f4214 100644 (file)
@@ -98,6 +98,7 @@ struct _E_Input_Panel_Floating_Info
    int new_width;
    int new_height;
    E_Input_Panel_Align align;
+   Eina_Bool resizing;
 
    struct
      {
@@ -451,26 +452,38 @@ static void
 _e_input_panel_stay_within_screen(E_Client *ec, int x, int y, int *new_x, int *new_y)
 {
    int zx, zy, zw, zh;
+   int client_w, client_h;
 
    if (!ec || !g_floating_info) return;
 
    e_client_base_output_resolution_desk_useful_geometry_get(ec, &zx, &zy, &zw, &zh, EINA_TRUE);
 
+   if (g_floating_info->new_width > 0 && g_floating_info->new_height > 0)
+     {
+        client_w = g_floating_info->new_width;
+        client_h = g_floating_info->new_height;
+     }
+   else
+     {
+        client_w = ec->w;
+        client_h = ec->h;
+     }
+
    switch (ec->e.state.rot.ang.curr)
      {
       case 90:
       case 270:
          if (x < 0)
            *new_x = 0;
-         else if (x > zh - ec->client.h)
-           *new_x = zh - ec->client.h;
+         else if (x > zh - client_h)
+           *new_x = zh - client_h;
          else
            *new_x = x;
 
          if (y < 0)
            *new_y = 0;
-         else if (y > zw - ec->client.w)
-           *new_y = zw - ec->client.w;
+         else if (y > zw - client_w)
+           *new_y = zw - client_w;
          else
            *new_y = y;
          break;
@@ -479,15 +492,15 @@ _e_input_panel_stay_within_screen(E_Client *ec, int x, int y, int *new_x, int *n
       default:
          if (x < 0)
            *new_x = 0;
-         else if (x > zw - ec->client.w)
-           *new_x = zw - ec->client.w;
+         else if (x > zw - client_w)
+           *new_x = zw - client_w;
          else
            *new_x = x;
 
          if (y < 0)
            *new_y = 0;
-         else if (y > zh - ec->client.h)
-           *new_y = zh - ec->client.h;
+         else if (y > zh - client_h)
+           *new_y = zh - client_h;
          else
            *new_y = y;
          break;
@@ -499,6 +512,7 @@ _e_input_panel_convert_floating_position(E_Client *ec, int x, int y, int *new_x,
 {
    int zx, zy, zw, zh;
    int cur_angle;
+   int client_w, client_h;
 
    if (!ec || !g_floating_info) return;
 
@@ -509,41 +523,52 @@ _e_input_panel_convert_floating_position(E_Client *ec, int x, int y, int *new_x,
 
    e_client_base_output_resolution_desk_useful_geometry_get(ec, &zx, &zy, &zw, &zh, EINA_TRUE);
 
+   if (g_floating_info->new_width > 0 && g_floating_info->new_height > 0)
+     {
+        client_w = g_floating_info->new_width;
+        client_h = g_floating_info->new_height;
+     }
+   else
+     {
+        client_w = ec->w;
+        client_h = ec->h;
+     }
+
    switch (cur_angle)
      {
       case 90:
          if (cur_type == E_INPUT_PANEL_COORDINATE_TYPE_ABSOLUTE)
            {
-              *new_x = zh - y - ec->client.h;
+              *new_x = zh - y - client_h;
               *new_y = x;
            }
          else if (cur_type == E_INPUT_PANEL_COORDINATE_TYPE_LOGICAL)
            {
               *new_x = y;
-              *new_y = zh - x - ec->client.h;
+              *new_y = zh - x - client_h;
            }
          break;
       case 180:
          if (cur_type == E_INPUT_PANEL_COORDINATE_TYPE_ABSOLUTE)
            {
-              *new_x = zh - y - ec->client.h;
-              *new_y = zw - x - ec->client.w;
+              *new_x = zh - y - client_h;
+              *new_y = zw - x - client_w;
            }
          else if (cur_type == E_INPUT_PANEL_COORDINATE_TYPE_LOGICAL)
            {
-              *new_x = zw - x - ec->client.w;
-              *new_y = zh - y - ec->client.h;
+              *new_x = zw - x - client_w;
+              *new_y = zh - y - client_h;
            }
          break;
       case 270:
          if (cur_type == E_INPUT_PANEL_COORDINATE_TYPE_ABSOLUTE)
            {
               *new_x = y;
-              *new_y = zw - x - ec->client.w;
+              *new_y = zw - x - client_w;
            }
          else if (cur_type == E_INPUT_PANEL_COORDINATE_TYPE_LOGICAL)
            {
-              *new_x = zw - y - ec->client.w;
+              *new_x = zw - y - client_w;
               *new_y = x;
            }
          break;
@@ -594,6 +619,9 @@ _e_input_panel_position_set(E_Client *ec, int w, int h)
 
    if (ec->vkbd.floating)
      {
+        if (g_floating_info && g_floating_info->resizing)
+          return;
+
         int sx, sy;
         if ((is_portrait && !g_floating_info->init_portrait_position) || (!is_portrait && !g_floating_info->init_landscape_position))
           _e_input_panel_init_floating_position(ec);
@@ -604,20 +632,21 @@ _e_input_panel_position_set(E_Client *ec, int w, int h)
           _e_input_panel_stay_within_screen(ec, g_floating_info->start_position.landscape_x, g_floating_info->start_position.landscape_y, &sx, &sy);
 
         _e_input_panel_convert_floating_position(ec, sx, sy, &nx, &ny, E_INPUT_PANEL_COORDINATE_TYPE_LOGICAL);
-     }
 
-   if (ec->vkbd.floating && g_floating_info->new_width > 0 && g_floating_info->new_height > 0)
-     {
-        LOGI("x : %d, y : %d, w : %d, h : %d", nx, ny, g_floating_info->new_width, g_floating_info->new_height);
-        e_client_util_move_resize_without_frame(ec, nx, ny, g_floating_info->new_width, g_floating_info->new_height);
-        g_floating_info->new_width = -1;
-        g_floating_info->new_height = -1;
-     }
-   else
-     {
-        LOGI("x : %d, y : %d", nx, ny);
-        e_client_util_move_without_frame(ec, nx, ny);
+        if (g_floating_info->new_width > 0 && g_floating_info->new_height > 0)
+          {
+             LOGI("x : %d, y : %d, w : %d, h : %d", nx, ny, g_floating_info->new_width, g_floating_info->new_height);
+             g_floating_info->resizing = EINA_TRUE;
+             e_client_util_move_resize_without_frame(ec, nx, ny, g_floating_info->new_width, g_floating_info->new_height);
+             g_floating_info->resizing = EINA_FALSE;
+             g_floating_info->new_width = -1;
+             g_floating_info->new_height = -1;
+             return;
+          }
      }
+
+   LOGI("x : %d, y : %d", nx, ny);
+   e_client_util_move_without_frame(ec, nx, ny);
 }
 
 static void
@@ -948,7 +977,7 @@ _e_ips_cb_evas_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *e
 
    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
 
-   LOGI("current angle : %d", ec->e.state.rot.ang.curr);
+   LOGI("current angle : %d, width : %d, height : %d", ec->e.state.rot.ang.curr, w, h);
    _e_input_panel_position_set(ec, w, h);
 
    ips = _e_input_panel_surface_get(ec);
@@ -1686,7 +1715,22 @@ e_input_panel_floating_position_set(int x, int y)
      }
 
    if (floating_ips->showing)
-     _e_input_panel_position_set(floating_ec, floating_ec->client.w, floating_ec->client.h);
+     {
+        int client_w, client_h;
+
+        if (g_floating_info->new_width > 0 && g_floating_info->new_height > 0)
+          {
+             client_w = g_floating_info->new_width;
+             client_h = g_floating_info->new_height;
+          }
+        else
+          {
+             client_w = floating_ec->w;
+             client_h = floating_ec->h;
+          }
+
+        _e_input_panel_position_set(floating_ec, client_w, client_h);
+     }
 }
 
 Eina_Bool