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