Use the focused E_Client for floating position 58/202558/1
authorSungmin Kwak <sungmin.kwak@samsung.com>
Thu, 28 Mar 2019 10:44:21 +0000 (19:44 +0900)
committerSungmin Kwak <sungmin.kwak@samsung.com>
Mon, 1 Apr 2019 00:39:49 +0000 (00:39 +0000)
if the focused EC angle is different with the floating EC angle, avoid setting the position.

Change-Id: Idc2bd9d5fd2307f065fa418c1c560c02e57dd9c3
(cherry picked from commit 5b60bdf996782384b3bcec9b7438185a9cfe6a4c)

src/e_mod_input_panel.c

index 7bca6c7..72aae2f 100644 (file)
@@ -66,6 +66,7 @@ struct _E_Input_Panel_Floating_Info
 
 E_Input_Panel *g_input_panel = NULL;
 E_Input_Panel_Floating_Info *g_floating_info = NULL;
+static Eina_Bool use_main_ec_for_position_set = EINA_FALSE;
 Eina_List *handlers = NULL;
 static Eina_Bool panel_show_need_rerun = EINA_FALSE;
 static Ecore_Timer *g_timer_wait_update  = NULL;
@@ -343,6 +344,31 @@ _e_input_panel_surface_resource_destroy(struct wl_resource *resource)
    free(ips);
 }
 
+static Eina_Bool
+_e_input_panel_allow_position_set(E_Client *ec, E_Client *focused_ec, const char *function)
+{
+   E_Client *f_ec = focused_ec;
+
+   if (!ec) return EINA_FALSE;
+   if (!f_ec)
+   {
+      f_ec = e_client_focused_get();
+      if (!f_ec) return EINA_FALSE;
+   }
+
+   if (ec->e.state.rot.ang.curr != f_ec->e.state.rot.ang.curr)
+   {
+      if (!use_main_ec_for_position_set)
+      {
+         LOGW("%s: focused_ec's angle(%d) is different with %d", function, f_ec->e.state.rot.ang.curr, ec->e.state.rot.ang.curr);
+         return EINA_FALSE;
+      }
+   }
+   use_main_ec_for_position_set = EINA_FALSE;
+
+   return EINA_TRUE;
+}
+
 static void
 _e_input_panel_init_floating_position(E_Client *ec)
 {
@@ -382,6 +408,7 @@ _e_input_panel_stay_within_screen(E_Client *ec, int x, int y, int *new_x, int *n
    int zx, zy, zw, zh;
 
    if (!ec || !g_floating_info) return;
+   if (!_e_input_panel_allow_position_set(ec, NULL, __FUNCTION__)) return;
 
    e_zone_useful_geometry_get(ec->zone, &zx, &zy, &zw, &zh);
 
@@ -430,6 +457,7 @@ _e_input_panel_convert_floating_position(E_Client *ec, int x, int y, int *new_x,
    int cur_angle;
 
    if (!ec || !g_floating_info) return;
+   if (!_e_input_panel_allow_position_set(ec, NULL, __FUNCTION__)) return;
 
    cur_angle = ec->e.state.rot.ang.curr;
    if ((!g_floating_info->init_portrait_position && (cur_angle == 0 || cur_angle == 180)) ||
@@ -487,11 +515,17 @@ _e_input_panel_convert_floating_position(E_Client *ec, int x, int y, int *new_x,
 static void
 _e_input_panel_position_set(E_Client *ec, int w, int h)
 {
+   E_Client *focused_ec;
    int nx, ny;
    int zx, zy, zw, zh;
    Eina_Bool is_portrait;
 
-   if (!ec || !g_floating_info) return;
+   focused_ec = e_client_focused_get();
+
+   if (!ec || !g_floating_info || !focused_ec) return;
+
+   if (!_e_input_panel_allow_position_set(ec, focused_ec, __FUNCTION__))
+      return;
 
    e_zone_useful_geometry_get(ec->zone, &zx, &zy, &zw, &zh);
 
@@ -535,6 +569,8 @@ _e_input_panel_position_set(E_Client *ec, int w, int h)
         _e_input_panel_convert_floating_position(ec, sx, sy, &nx, &ny, E_INPUT_PANEL_COORDINATE_TYPE_LOGICAL);
      }
 
+   LOGD("focused_ec's angle=%d, ec's angle=%d, nx=%d, ny=%d", focused_ec->e.state.rot.ang.curr, ec->e.state.rot.ang.curr, nx, ny);
+
    e_client_util_move_without_frame(ec, nx, ny);
 }
 
@@ -710,8 +746,12 @@ _e_input_panel_client_cb_rotation_change_end(void *data, int type, void *event)
    if (ec != ips->ec)
      goto end;
 
-   if (ips->showing)
+   if (ips->showing) {
+     LOGD("ec->client.w=%d, ec->client.h=%d", ec->client.w, ec->client.h);
+     use_main_ec_for_position_set = EINA_FALSE;
      _e_input_panel_position_set(ec, ec->client.w, ec->client.h);
+     use_main_ec_for_position_set = EINA_TRUE;
+   }
 
 end:
    return ECORE_CALLBACK_PASS_ON;
@@ -729,7 +769,10 @@ _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);
 
+   LOGD("w=%d, h=%d", w, h);
+   use_main_ec_for_position_set = EINA_FALSE;
    _e_input_panel_position_set(ec, w, h);
+   use_main_ec_for_position_set = EINA_TRUE;
 }
 
 static void
@@ -776,6 +819,8 @@ _e_ips_cb_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *ev
    if (!g_floating_info->moving_req || !g_floating_info->mouse_pressed)
      return;
 
+   if (!_e_input_panel_allow_position_set(ec, NULL, __FUNCTION__)) return;
+
    evas_object_geometry_get(obj, &x, &y, &w, &h);
 
    d_x = x + (ev->cur.canvas.x - g_floating_info->before_canvas_x);
@@ -1307,7 +1352,7 @@ e_input_panel_show_need_rerun_set(Eina_Bool need_rerun)
 void
 e_input_panel_floating_position_set(int x, int y)
 {
-   E_Client *floating_ec = NULL;
+   E_Client *floating_ec = NULL, *focused_ec = NULL;
    E_Input_Panel_Surface *ips;
    Eina_List *l;
    Eina_List *l_next;
@@ -1322,9 +1367,13 @@ e_input_panel_floating_position_set(int x, int y)
           }
      }
 
-   if (!floating_ec || !g_floating_info) return;
+   focused_ec = e_client_focused_get();
+
+   if (!floating_ec || !focused_ec || !g_floating_info) return;
+
+   LOGD("x=%d, y=%d", x, y);
 
-   switch (floating_ec->e.state.rot.ang.curr)
+   switch (focused_ec->e.state.rot.ang.curr)
      {
         case 90:
         case 270: