1From 6bf724c142f41ae9fe9de6aa1c421781e1f3f8e5 Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Thu, 21 Jul 2022 16:05:53 +0800
4Subject: [PATCH 07/10] HACK: wl: Support setting size in
5 wl_subsurface_position_set()
6
7Tested with waylandsink.
8
9Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
10---
11 src/bin/e_comp_wl.c | 18 ++++++++++++++++++
12 src/bin/e_comp_wl.h |  1 +
13 src/bin/e_pixmap.c  | 13 +++++++++++--
14 src/bin/e_pixmap.h  |  1 +
15 4 files changed, 31 insertions(+), 2 deletions(-)
16
17diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
18index 0df8544fa..db8806c3b 100644
19--- a/src/bin/e_comp_wl.c
20+++ b/src/bin/e_comp_wl.c
21@@ -2229,8 +2229,13 @@ _e_comp_wl_subsurface_parent_commit(E_Client *ec, Eina_Bool parent_synchronized)
22    if (!(sdata = ec->comp_data->sub.data)) return;
23    if (!(parent = sdata->parent)) return;
24
25+   _e_comp_wl_subsurface_parent_commit(parent, parent_synchronized);
26+
27    if (sdata->position.set)
28      {
29+        if (sdata->position.w && sdata->position.h)
30+          e_pixmap_viewport_set(ec->pixmap, sdata->position.w, sdata->position.h);
31+
32         evas_object_move(ec->frame, parent->client.x + sdata->position.x,
33                          parent->client.y + sdata->position.y);
34         sdata->position.set = EINA_FALSE;
35@@ -2263,6 +2268,7 @@ _e_comp_wl_subsurface_cb_position_set(struct wl_client *client EINA_UNUSED, stru
36 {
37    E_Client *ec;
38    E_Comp_Wl_Subsurf_Data *sdata;
39+   int32_t w, h;
40
41    DBG("Subsurface Cb Position Set: %d", wl_resource_get_id(resource));
42
43@@ -2271,8 +2277,20 @@ _e_comp_wl_subsurface_cb_position_set(struct wl_client *client EINA_UNUSED, stru
44
45    if (!(sdata = ec->comp_data->sub.data)) return;
46
47+   w = x >> 16;
48+   h = y >> 16;
49+   x &= (1 << 16) - 1;
50+   y &= (1 << 16) - 1;
51+
52    sdata->position.x = x;
53    sdata->position.y = y;
54+
55+   if (w && h)
56+     {
57+        sdata->position.w = w;
58+        sdata->position.h = h;
59+     }
60+
61    sdata->position.set = EINA_TRUE;
62 }
63
64diff --git a/src/bin/e_comp_wl.h b/src/bin/e_comp_wl.h
65index a18746c5d..8f844dd58 100644
66--- a/src/bin/e_comp_wl.h
67+++ b/src/bin/e_comp_wl.h
68@@ -95,6 +95,7 @@ struct _E_Comp_Wl_Subsurf_Data
69    struct
70      {
71         int x, y;
72+        int w, h;
73         Eina_Bool set;
74      } position;
75
76diff --git a/src/bin/e_pixmap.c b/src/bin/e_pixmap.c
77index ece17fee1..3d9177f4a 100644
78--- a/src/bin/e_pixmap.c
79+++ b/src/bin/e_pixmap.c
80@@ -35,6 +35,7 @@ struct _E_Pixmap
81    Ecore_Window parent;
82
83    int w, h;
84+   int viewport_w, viewport_h;
85
86 #ifndef HAVE_WAYLAND_ONLY
87    void *image;
88@@ -282,6 +283,7 @@ _e_pixmap_new(E_Pixmap_Type type)
89    cp = E_NEW(E_Pixmap, 1);
90    cp->type = type;
91    cp->w = cp->h = 0;
92+   cp->viewport_w = cp->viewport_h = 0;
93    cp->refcount = 1;
94    cp->dirty = 1;
95    return cp;
96@@ -643,14 +645,21 @@ e_pixmap_size_changed(E_Pixmap *cp, int w, int h)
97    return (w != cp->w) || (h != cp->h);
98 }
99
100+E_API void
101+e_pixmap_viewport_set(E_Pixmap *cp, int w, int h)
102+{
103+   cp->viewport_w = w;
104+   cp->viewport_h = h;
105+}
106+
107 E_API Eina_Bool
108 e_pixmap_size_get(E_Pixmap *cp, int *w, int *h)
109 {
110    if (w) *w = 0;
111    if (h) *h = 0;
112    EINA_SAFETY_ON_NULL_RETURN_VAL(cp, EINA_FALSE);
113-   if (w) *w = cp->w;
114-   if (h) *h = cp->h;
115+   if (w) *w = cp->viewport_w ?: cp->w;
116+   if (h) *h = cp->viewport_h ?: cp->h;
117    return (cp->w > 0) && (cp->h > 0);
118 }
119
120diff --git a/src/bin/e_pixmap.h b/src/bin/e_pixmap.h
121index 293a6786c..39b394f57 100644
122--- a/src/bin/e_pixmap.h
123+++ b/src/bin/e_pixmap.h
124@@ -32,6 +32,7 @@ E_API void e_pixmap_dirty(E_Pixmap *cp);
125 E_API Eina_Bool e_pixmap_refresh(E_Pixmap *cp);
126 E_API Eina_Bool e_pixmap_size_changed(E_Pixmap *cp, int w, int h);
127 E_API Eina_Bool e_pixmap_size_get(E_Pixmap *cp, int *w, int *h);
128+E_API void e_pixmap_viewport_set(E_Pixmap *cp, int w, int h);
129 E_API void e_pixmap_client_set(E_Pixmap *cp, E_Client *ec);
130 E_API E_Client *e_pixmap_client_get(E_Pixmap *cp);
131 E_API E_Pixmap *e_pixmap_find(E_Pixmap_Type type, ...);
132--
1332.20.1
134
135