xref: /OK3568_Linux_fs/buildroot/package/enlightenment/0008-wl-Support-subsurface-stacking.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 4b7c398d252dad26e33fcb22d9c7a98c30d41aec Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Fri, 22 Jul 2022 14:55:41 +0800
4Subject: [PATCH 08/11] wl: Support subsurface stacking
5
6Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
7---
8 src/bin/e_comp_wl.c | 68 +++++++++++++++++++++++++++++++--------------
9 src/bin/e_comp_wl.h |  2 +-
10 2 files changed, 48 insertions(+), 22 deletions(-)
11
12diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
13index db8806c3b..b51eb4e33 100644
14--- a/src/bin/e_comp_wl.c
15+++ b/src/bin/e_comp_wl.c
16@@ -722,30 +722,55 @@ _e_comp_wl_evas_cb_focus_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *ob
17 }
18
19 static void
20-_e_comp_wl_evas_cb_restack(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
21+_e_comp_wl_evas_restack(E_Client *ec)
22 {
23-   E_Client *sec, *ec = data;
24-   Eina_List *l, *ll;
25+   E_Client *sec;
26+   Eina_List *l;
27+   int below;
28
29    if (e_object_is_del(E_OBJECT(ec))) return;
30    if (e_client_has_xwindow(ec)) return;
31
32-   /* only restack to enforce shell spec if config would otherwise not force restack */
33-   if (!e_config->transient.raise)
34-     e_client_transients_restack(ec);
35+   if (ec->comp_data->sub.restacking == EINA_TRUE) return;
36+   ec->comp_data->sub.restacking = EINA_TRUE;
37
38-   if (!ec->comp_data->sub.list) return;
39+   below = 1;
40    EINA_LIST_FOREACH(ec->comp_data->sub.list, l, sec)
41-     evas_object_layer_set(sec->frame, evas_object_layer_get(ec->frame));
42-   sec = eina_list_last_data_get(ec->comp_data->sub.list);
43-   evas_object_stack_above(sec->frame, ec->frame);
44-   EINA_LIST_REVERSE_FOREACH_SAFE(ec->comp_data->sub.list, l, ll, sec)
45      {
46-        E_Client *nsec = eina_list_data_get(ll);
47+        if (sec == ec)
48+          {
49+             below = 0;
50+             continue;
51+          }
52+
53+        if (below)
54+          evas_object_stack_below(sec->frame, ec->frame);
55+        else
56+          evas_object_stack_above(sec->frame, ec->frame);
57
58-        if (nsec)
59-          evas_object_stack_below(nsec->frame, sec->frame);
60+        _e_comp_wl_evas_restack(sec);
61      }
62+
63+   ec->comp_data->sub.restacking = EINA_FALSE;
64+}
65+
66+static void
67+_e_comp_wl_evas_cb_restack(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
68+{
69+   E_Client *ec = data;
70+
71+   if (e_object_is_del(E_OBJECT(ec))) return;
72+   if (e_client_has_xwindow(ec)) return;
73+   if (ec->layer_block) return;
74+
75+   /* only restack to enforce shell spec if config would otherwise not force restack */
76+   if (!e_config->transient.raise)
77+     e_client_transients_restack(ec);
78+
79+   if (ec->comp_data->sub.data)
80+     _e_comp_wl_evas_restack(ec->comp_data->sub.data->parent);
81+   else
82+     _e_comp_wl_evas_restack(ec);
83 }
84
85 static void
86@@ -758,7 +783,7 @@ _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
87    ec->comp_data->moved = 1;
88    EINA_LIST_FOREACH(ec->comp_data->sub.list, l, sec)
89      {
90-        if (!sec->comp_data->sub.data->position.set)
91+        if (ec != sec && !sec->comp_data->sub.data->position.set)
92           evas_object_move(sec->frame, ec->client.x + sec->comp_data->sub.data->position.x,
93                            ec->client.y + sec->comp_data->sub.data->position.y);
94      }
95@@ -2310,7 +2335,7 @@ _e_comp_wl_subsurface_cb_place_above(struct wl_client *client EINA_UNUSED, struc
96    /* try to get the client from the sibling resource */
97    if (!(ecs = wl_resource_get_user_data(sibling_resource))) return;
98
99-   if (!ecs->comp_data->sub.data) return;
100+   if (!ec->comp_data->sub.data) return;
101
102    if (!(parent = ec->comp_data->sub.data->parent)) return;
103
104@@ -2320,7 +2345,7 @@ _e_comp_wl_subsurface_cb_place_above(struct wl_client *client EINA_UNUSED, struc
105    parent->comp_data->sub.list =
106      eina_list_append_relative(parent->comp_data->sub.list, ec, ecs);
107
108-   parent->comp_data->sub.restack_target = parent;
109+   _e_comp_wl_evas_restack(parent);
110 }
111
112 static void
113@@ -2338,8 +2363,7 @@ _e_comp_wl_subsurface_cb_place_below(struct wl_client *client EINA_UNUSED, struc
114
115    /* try to get the client from the sibling resource */
116    if (!(ecs = wl_resource_get_user_data(sibling_resource))) return;
117-
118-   if (!ecs->comp_data->sub.data) return;
119+   if (!ec->comp_data->sub.data) return;
120
121    if (!(parent = ec->comp_data->sub.data->parent)) return;
122
123@@ -2349,7 +2373,7 @@ _e_comp_wl_subsurface_cb_place_below(struct wl_client *client EINA_UNUSED, struc
124    parent->comp_data->sub.list =
125      eina_list_prepend_relative(parent->comp_data->sub.list, ec, ecs);
126
127-   parent->comp_data->sub.restack_target = parent;
128+   _e_comp_wl_evas_restack(parent);
129 }
130
131 static void
132@@ -2558,6 +2582,8 @@ _e_comp_wl_client_cb_new(void *data EINA_UNUSED, E_Client *ec)
133         return;
134      }
135
136+   ec->comp_data->sub.list = eina_list_append(ec->comp_data->sub.list, ec);
137+
138    wl_signal_init(&ec->comp_data->destroy_signal);
139    _e_comp_wl_surface_state_init(&ec->comp_data->pending);
140
141@@ -2609,7 +2635,7 @@ _e_comp_wl_client_cb_del(void *data EINA_UNUSED, E_Client *ec)
142    /* remove sub list */
143    EINA_LIST_FREE(ec->comp_data->sub.list, subc)
144      {
145-        if (!e_object_is_del(E_OBJECT(subc)))
146+        if (ec != subc && !e_object_is_del(E_OBJECT(subc)))
147           subc->comp_data->sub.data->parent = NULL;
148      }
149
150diff --git a/src/bin/e_comp_wl.h b/src/bin/e_comp_wl.h
151index 8f844dd58..0d1163bfa 100644
152--- a/src/bin/e_comp_wl.h
153+++ b/src/bin/e_comp_wl.h
154@@ -294,7 +294,7 @@ struct _E_Comp_Wl_Client_Data
155    struct
156      {
157         E_Comp_Wl_Subsurf_Data *data;
158-        E_Client *restack_target;
159+        Eina_Bool restacking;
160         Eina_List *list;
161      } sub;
162
163--
1642.20.1
165
166