This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch wl/dmabuf-v4
in repository enlightenment.
View the commit online.
commit 683472d2781cca98bbf9be1742be944ffbeaf52b
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 18:39:19 2026 -0600
e_comp_wl - rescale a window when its output scale changes
A Wayland window is its buffer divided by the buffer scale, times the
scale of its output. E only worked that out when the client committed:
moved to a monitor of another scale, or with the scale of its monitor
changed, a window kept its old size until the client drew again, which
an idle client may not do for a long time.
E now works the size out again from the buffer it holds when the
window moves to another zone and when an output is updated, and
resizes the window, with no commit. Its subsurfaces follow: they are
resized, and placed again at their offset, which is now kept in the
parent's surface-local units and multiplied by its scale where it is
used. Kept in canvas pixels, as it was, it could not be turned into the
new scale.
wl-output-scale no longer commits after moving its window to an output
of scale 1, and then sets that output to scale 3: the window and its
subsurface must take their new size and offset each time. Both steps
fail without this; they also fail without placing the subsurface
again, and the second without resizing it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/bin/e_comp_wl.c | 86 +++++++++++++++++++++++++++++++----
src/bin/e_comp_wl.h | 2 +
src/tests/wayland/test_output_scale.c | 38 ++++++++++++++--
3 files changed, 112 insertions(+), 14 deletions(-)
diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
index e5d1908fc..1dd1fa02f 100644
--- a/src/bin/e_comp_wl.c
+++ b/src/bin/e_comp_wl.c
@@ -984,6 +984,17 @@ _e_comp_wl_evas_cb_restack(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EIN
_e_comp_wl_subsurface_stack_sync(ec);
}
+/* A subsurface at its offset in its parent. */
+static void
+_e_comp_wl_subsurface_move(E_Client *ec)
+{
+ E_Comp_Wl_Subsurf_Data *sdata = ec->comp_data->sub.data;
+ int scale = e_comp_wl_client_scale_get(sdata->parent);
+
+ evas_object_move(ec->frame, sdata->parent->client.x + (sdata->position.x * scale),
+ sdata->parent->client.y + (sdata->position.y * scale));
+}
+
static void
_e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
@@ -995,8 +1006,7 @@ _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
EINA_LIST_FOREACH(ec->comp_data->sub.list, l, sec)
{
if (!sec->comp_data->sub.data->position.set)
- evas_object_move(sec->frame, ec->client.x + sec->comp_data->sub.data->position.x,
- ec->client.y + sec->comp_data->sub.data->position.y);
+ _e_comp_wl_subsurface_move(sec);
}
_e_comp_wl_surface_outputs_update(ec);
@@ -1619,6 +1629,55 @@ _e_comp_wl_surface_state_size_update(E_Client *ec, E_Comp_Wl_Surface_State *stat
e_comp_object_frame_geometry_set(ec->frame, 0, 0, 0, 0);
}
+/* A window's output scale changes when it moves to another zone, or when
+ * that output's scale does. What the client drew is shown at the new
+ * scale at once: it may not draw again for a while. */
+static void
+_e_comp_wl_client_rescale(E_Client *ec)
+{
+ E_Comp_Wl_Surface_State state;
+ E_Client *sec;
+ Eina_List *l;
+
+ if (e_pixmap_usable_get(ec->pixmap))
+ {
+ memset(&state, 0, sizeof(state));
+ _e_comp_wl_surface_state_size_update(ec, &state);
+ if ((state.bw != ec->comp_data->surface_w) ||
+ (state.bh != ec->comp_data->surface_h))
+ {
+ ec->comp_data->surface_w = ec->client.w = state.bw;
+ ec->comp_data->surface_h = ec->client.h = state.bh;
+ if (!ec->changes.size)
+ e_comp_object_frame_wh_adjust(ec->frame, ec->client.w, ec->client.h,
+ &ec->w, &ec->h);
+ if ((ec->comp_data->shell.surface) && (ec->comp_data->shell.configure))
+ ec->comp_data->shell.configure(ec->comp_data->shell.surface,
+ ec->client.x, ec->client.y,
+ state.bw, state.bh);
+ else
+ e_client_util_move_resize_without_frame(ec, ec->client.x, ec->client.y,
+ state.bw, state.bh);
+ }
+ }
+ EINA_LIST_FOREACH(ec->comp_data->sub.list, l, sec)
+ {
+ if (sec == ec) continue;
+ _e_comp_wl_client_rescale(sec);
+ _e_comp_wl_subsurface_move(sec);
+ }
+}
+
+/* The comp_data of an X window is not E_Comp_Wl_Client_Data. */
+static Eina_Bool
+_e_comp_wl_cb_client_zone_set(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client_Zone_Set *ev)
+{
+ if (e_object_is_del(E_OBJECT(ev->ec))) return ECORE_CALLBACK_RENEW;
+ if (e_pixmap_type_get(ev->ec->pixmap) != E_PIXMAP_TYPE_WL) return ECORE_CALLBACK_RENEW;
+ _e_comp_wl_client_rescale(ev->ec);
+ return ECORE_CALLBACK_RENEW;
+}
+
static void
_e_comp_wl_surface_state_cb_buffer_destroy(struct wl_listener *listener, void *data EINA_UNUSED)
{
@@ -2897,8 +2956,7 @@ _e_comp_wl_subsurface_parent_commit(E_Client *ec, Eina_Bool parent_synchronized)
if (sdata->position.set)
{
- evas_object_move(ec->frame, parent->client.x + sdata->position.x,
- parent->client.y + sdata->position.y);
+ _e_comp_wl_subsurface_move(ec);
sdata->position.set = EINA_FALSE;
}
@@ -2929,7 +2987,6 @@ _e_comp_wl_subsurface_cb_position_set(struct wl_client *client EINA_UNUSED, stru
{
E_Client *ec;
E_Comp_Wl_Subsurf_Data *sdata;
- int scale;
DBG("Subsurface Cb Position Set: %d", wl_resource_get_id(resource));
@@ -2938,10 +2995,8 @@ _e_comp_wl_subsurface_cb_position_set(struct wl_client *client EINA_UNUSED, stru
if (!(sdata = ec->comp_data->sub.data)) return;
- /* The offset is in the parent's surface-local units. */
- scale = e_comp_wl_client_scale_get(sdata->parent);
- sdata->pending_position.x = x * scale;
- sdata->pending_position.y = y * scale;
+ sdata->pending_position.x = x;
+ sdata->pending_position.y = y;
sdata->pending_position.set = EINA_TRUE;
}
@@ -3843,6 +3898,8 @@ e_comp_wl_init(void)
E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_MOVE,
_e_comp_wl_cb_mouse_move, NULL);
+ E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ZONE_SET,
+ _e_comp_wl_cb_client_zone_set, NULL);
E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_UNICONIFY,
_e_comp_wl_cb_uniconify, NULL);
@@ -4179,6 +4236,7 @@ e_comp_wl_output_init(const char *id, const char *make, const char *model,
Eina_List *l2;
struct wl_resource *resource;
E_Zone *zone;
+ E_Client *ec;
/* retrieve named output; or create it if it doesn't exist */
output = _e_comp_wl_output_get(e_comp_wl->outputs, id);
@@ -4227,6 +4285,16 @@ e_comp_wl_output_init(const char *id, const char *make, const char *model,
EINA_LIST_FOREACH(output->resources, l2, resource)
_e_comp_wl_output_state_send(output, resource);
+ /* Its scale may have changed. Subsurfaces follow their parent. */
+ E_CLIENT_FOREACH(ec)
+ {
+ if (e_object_is_del(E_OBJECT(ec))) continue;
+ if (e_pixmap_type_get(ec->pixmap) != E_PIXMAP_TYPE_WL) continue;
+ if ((!ec->zone) || (ec->zone->output != output)) continue;
+ if (ec->comp_data->sub.data) continue;
+ _e_comp_wl_client_rescale(ec);
+ }
+
return EINA_TRUE;
}
diff --git a/src/bin/e_comp_wl.h b/src/bin/e_comp_wl.h
index 8b1f351f9..c5df6a8d3 100644
--- a/src/bin/e_comp_wl.h
+++ b/src/bin/e_comp_wl.h
@@ -111,6 +111,8 @@ struct _E_Comp_Wl_Subsurf_Data
E_Client *parent;
+ /* In the parent's surface-local units, which its scale turns into
+ * canvas pixels wherever the subsurface is placed. */
struct
{
int x, y;
diff --git a/src/tests/wayland/test_output_scale.c b/src/tests/wayland/test_output_scale.c
index ea169d947..fe902b5aa 100644
--- a/src/tests/wayland/test_output_scale.c
+++ b/src/tests/wayland/test_output_scale.c
@@ -320,6 +320,33 @@ _size_check(Ctx *ctx, struct wl_surface *surface, int w, int h,
w, h);
}
+/* E learns that a window moved to another zone through an event of its
+ * main loop, so a new scale may take more than one round trip to show. The
+ * window must not commit meanwhile: what is checked is that E rescales what
+ * the client already drew. */
+static void
+_rescale_wait(Ctx *ctx, struct wl_surface *sub, int w, int h,
+ const char *what)
+{
+ struct timespec step = { 0, 50000000 };
+ int i, x, y, sw, sh, sx, sy, subw, subh;
+
+ for (i = 0; i < TK_WAIT_SECONDS * 20; i++)
+ {
+ tk_surface_geometry(ctx->tk, ctx->surface, &x, &y, &sw, &sh);
+ tk_surface_geometry(ctx->tk, sub, &sx, &sy, &subw, &subh);
+ /* The subsurface is 20x10 at 10,5, both in surface-local units. */
+ if ((sw == w) && (sh == h) && (subw * 100 == w * 20) &&
+ (subh * 50 == h * 10) && ((sx - x) * 100 == w * 10) &&
+ ((sy - y) * 50 == h * 5))
+ return;
+ nanosleep(&step, NULL);
+ }
+ tk_fail(ctx->tk, "%s: the window is %dx%d, wanted %dx%d, with a %dx%d "
+ "subsurface at %d,%d in it", what, sw, sh, w, h, subw, subh,
+ sx - x, sy - y);
+}
+
static void
_pointer_check(Ctx *ctx, int x, int y, double sx, double sy, const char *what)
{
@@ -481,11 +508,12 @@ main(void)
wl_test_zone_add(ctx.tester, 1024, 0, 800, 600);
tk_sync(ctx.tk);
wl_test_move_surface(ctx.tester, ctx.surface, 1200, 100);
- tk_sync(ctx.tk);
- wl_surface_commit(ctx.surface);
- tk_settle(ctx.tk);
- _size_check(&ctx, ctx.surface, 100, 50,
- "a buffer of scale 2 moved to an output of scale 1");
+ _rescale_wait(&ctx, sub, 100, 50,
+ "a buffer of scale 2 moved to an output of scale 1");
+
+ /* And when the scale of its output changes under it. */
+ wl_test_output_scale_set(ctx.tester, 1, 3);
+ _rescale_wait(&ctx, sub, 300, 150, "its output now of scale 3");
tk_disconnect(ctx.tk);
printf(PROG ": ok\n");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.