subsurface: fix changing stack order of sub-surface with its parent. 40/246940/3
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 5 Nov 2020 07:47:49 +0000 (16:47 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Mon, 9 Nov 2020 02:49:38 +0000 (11:49 +0900)
Sub-surface can be placed above or below of its parent by passing its
sub-surface with its parent as arguments to
wl_subsurface_place_above/below according to wl_subsurface description.

However, until now enlightenment seems not to have been supported this
operation correctly. In other words, enlightenment wasn't able to handle
stacking order of sub-surface in case wl_subsurface_place_above/below is
required with a parent of sub-surface.
This patch corrects it.

Change-Id: Icd65bf1759f1c7a3b950f6c9c222a41c9817a8ae

src/bin/e_comp_wl_subsurface.c
src/bin/e_policy_wl.c

index 5728416..73a31cf 100644 (file)
@@ -13,6 +13,9 @@ static void       _e_comp_wl_subsurface_parent_commit(E_Client *ec, Eina_Bool pa
 static Eina_Bool  _e_comp_wl_subsurface_synchronized_get(E_Comp_Wl_Subsurf_Data *sdata);
 static void       _e_comp_wl_subsurface_synchronized_commit(E_Client *ec);
 static void       _e_comp_wl_subsurface_remove_from_parent(E_Client *parent, E_Client *subc);
+static void       _e_comp_wl_subsurface_child_remove(E_Comp_Wl_Client_Data *parent_cdata, E_Client *child);
+static void       _e_comp_wl_subsurface_place_above(E_Client *parent, E_Client *subc, E_Client *above);
+static void       _e_comp_wl_subsurface_place_below(E_Client *parent, E_Client *subc, E_Client *below);
 
 static void
 _e_comp_wl_subsurface_restack_bg_rectangle(E_Client *ec)
@@ -334,18 +337,18 @@ _e_comp_wl_subsurface_order_commit(E_Client *ec)
    if (!ec->comp_data->sub.list_changed) return (EINA_FALSE | need_restack);
    ec->comp_data->sub.list_changed = EINA_FALSE;
 
+   E_FREE_FUNC(ec->comp_data->sub.list, eina_list_free);
    /* TODO: need to check more complicated subsurface tree */
    EINA_LIST_FOREACH(ec->comp_data->sub.list_pending, l, subc)
      {
-        ec->comp_data->sub.list = eina_list_remove(ec->comp_data->sub.list, subc);
         ec->comp_data->sub.list = eina_list_append(ec->comp_data->sub.list, subc);
 
         _e_comp_wl_subsurface_order_commit(subc);
      }
 
+   E_FREE_FUNC(ec->comp_data->sub.below_list, eina_list_free);
    EINA_LIST_FOREACH(ec->comp_data->sub.below_list_pending, l, subc)
      {
-        ec->comp_data->sub.below_list = eina_list_remove(ec->comp_data->sub.below_list, subc);
         ec->comp_data->sub.below_list = eina_list_append(ec->comp_data->sub.below_list, subc);
 
         _e_comp_wl_subsurface_order_commit(subc);
@@ -596,15 +599,7 @@ _e_comp_wl_subsurface_cb_place_above(struct wl_client *client EINA_UNUSED, struc
         return;
      }
 
-   if (!ecs->comp_data->sub.data) return;
-
-   parent->comp_data->sub.list_pending =
-     eina_list_remove(parent->comp_data->sub.list_pending, ec);
-
-   parent->comp_data->sub.list_pending =
-     eina_list_append_relative(parent->comp_data->sub.list_pending, ec, ecs);
-
-   parent->comp_data->sub.list_changed = EINA_TRUE;
+   _e_comp_wl_subsurface_place_above(parent, ec, ecs);
 }
 
 static void
@@ -635,15 +630,7 @@ _e_comp_wl_subsurface_cb_place_below(struct wl_client *client EINA_UNUSED, struc
         return;
      }
 
-   if (!ecs->comp_data->sub.data) return;
-
-   parent->comp_data->sub.list_pending =
-     eina_list_remove(parent->comp_data->sub.list_pending, ec);
-
-   parent->comp_data->sub.list_pending =
-     eina_list_prepend_relative(parent->comp_data->sub.list_pending, ec, ecs);
-
-   parent->comp_data->sub.list_changed = EINA_TRUE;
+   _e_comp_wl_subsurface_place_below(parent, ec, ecs);
 }
 
 static void
@@ -1369,3 +1356,73 @@ _e_comp_wl_subsurface_data_get(E_Client *ec)
 {
    return (ec->comp_data) ? (ec->comp_data->sub.data) : NULL;
 }
+
+static void
+_e_comp_wl_subsurface_child_remove(E_Comp_Wl_Client_Data *parent_cdata, E_Client *child)
+{
+   if (parent_cdata->sub.list_pending)
+     {
+        parent_cdata->sub.list_pending =
+           eina_list_remove(parent_cdata->sub.list_pending, child);
+     }
+   if (parent_cdata->sub.below_list_pending)
+     {
+        parent_cdata->sub.below_list_pending =
+           eina_list_remove(parent_cdata->sub.below_list_pending, child);
+     }
+}
+
+static void
+_e_comp_wl_subsurface_place_above(E_Client *parent, E_Client *subc, E_Client *above)
+{
+   E_Comp_Wl_Client_Data *pc;
+
+   pc = parent->comp_data;
+
+   _e_comp_wl_subsurface_child_remove(pc, subc);
+
+   if (parent == above)
+     {
+        pc->sub.list_pending = eina_list_prepend(pc->sub.list_pending, subc);
+     }
+   else if (eina_list_data_find(pc->sub.list_pending, above))
+     {
+        pc->sub.list_pending =
+           eina_list_append_relative(pc->sub.list_pending, subc, above);
+     }
+   else
+     {
+        pc->sub.below_list_pending =
+           eina_list_append_relative(pc->sub.below_list_pending, subc, above);
+     }
+
+   pc->sub.list_changed = EINA_TRUE;
+}
+
+static void
+_e_comp_wl_subsurface_place_below(E_Client *parent, E_Client *subc, E_Client *below)
+{
+   E_Comp_Wl_Client_Data *pc;
+
+   pc = parent->comp_data;
+
+   _e_comp_wl_subsurface_child_remove(pc, subc);
+
+   if (parent == below)
+     {
+        pc->sub.below_list_pending =
+           eina_list_append(pc->sub.below_list_pending, subc);
+     }
+   else if (eina_list_data_find(pc->sub.list_pending, below))
+     {
+        pc->sub.list_pending =
+           eina_list_prepend_relative(pc->sub.list_pending, subc, below);
+     }
+   else
+     {
+        pc->sub.below_list_pending =
+           eina_list_prepend_relative(pc->sub.below_list_pending, subc, below);
+     }
+
+   pc->sub.list_changed = EINA_TRUE;
+}
index c61a7a7..43f8a3e 100644 (file)
@@ -2058,6 +2058,7 @@ _tzpol_iface_cb_subsurf_place_below_parent(struct wl_client *client EINA_UNUSED,
    ELOGF("TZPOL", "SUBSURF|BELOW_PARENT", ec);
    epc->comp_data->sub.list = eina_list_remove(epc->comp_data->sub.list, ec);
    epc->comp_data->sub.list_pending = eina_list_remove(epc->comp_data->sub.list_pending, ec);
+   epc->comp_data->sub.below_list_pending = eina_list_append(epc->comp_data->sub.below_list_pending, ec);
    epc->comp_data->sub.below_list = eina_list_append(epc->comp_data->sub.below_list, ec);
    epc->comp_data->sub.list_changed = EINA_TRUE;
 }