This is an automated email from the git hooks/post-receive script.
git pushed a commit to reference refs/pull/219/head
in repository enlightenment.
View the commit online.
commit ccfbbea5d99e7161788a3460d482ca47ea675e83
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 27 22:06:03 2026 -0600
e_comp_wl - give wl_output.scale a meaning
wl_output.scale says how many pixels of the display a surface-local
unit covers. E advertised 1, or e_scale when an output came up without
one. e_scale magnifies E's own widgets and a user may set it on any
display to make them readable; a client told 2 on a 1080p panel lays
itself out for 960x540 and overflows it.
Outputs now start at 1, or at E_WL_OUTPUT_SCALE when it is set. It is
not guessed from EDID, whose physical size is often wrong or missing,
and a wrong guess rescales every client. The variable is also what
lets a scale above 1 be tried without HiDPI hardware.
e_comp_wl_client_scale_get() now returns the scale of the output of
the client's zone, which turns on the conversions of the previous
commits. E_Zone.output is also written by e_comp_x_randr.c and wl_drm
with their own types, so it is only read once it is found among E's
wl_outputs.
A client moved to an output of another scale gets its new size at its
next commit, which it makes when wl_output tells it the new scale.
wl_test gets output_scale_set (version 10). wl-output-scale puts the
output at scale 2 and checks that clients are told, that a buffer of
scale 1 is drawn twice as large and one of scale 2 one to one, and
that the pointer position, the input region, a subsurface offset, a
popup's positioner and configure, and the maximized configure size are
all in surface-local units. Then the window moves to an output of
scale 1 and halves. It fails without each of those conversions. The
min and max sizes are converted too, but nothing in E that a test can
reach applies them to a Wayland window.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/bin/e_comp_wl.c | 50 +++-
src/modules/wl_test/e_mod_main.c | 26 +-
src/protocol/wl-test.xml | 12 +-
src/tests/wayland/meson.build | 1 +
src/tests/wayland/test_output_scale.c | 493 ++++++++++++++++++++++++++++++++++
5 files changed, 569 insertions(+), 13 deletions(-)
diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c
index acc68347a..09d4db9a5 100644
--- a/src/bin/e_comp_wl.c
+++ b/src/bin/e_comp_wl.c
@@ -197,10 +197,44 @@ e_comp_wl_pointer_frame_send(struct wl_resource *res)
wl_pointer_send_frame(res);
}
-/* How many canvas pixels one surface-local unit of this client covers. */
-E_API int
-e_comp_wl_client_scale_get(const E_Client *ec EINA_UNUSED)
+/* The scale outputs start at. Not e_scale, which magnifies E's own widgets
+ * and may be set on any display to make them readable: wl_output.scale
+ * tells clients the display has that many pixels per logical unit, and a
+ * client told 2 on a 1080p panel lays itself out for 960x540. Not guessed
+ * from EDID either, whose physical size is often wrong or missing.
+ * E_WL_OUTPUT_SCALE sets it, which is also what lets a scale above 1 be
+ * tried without HiDPI hardware. */
+static int
+_e_comp_wl_output_scale_default(void)
{
+ const char *s = getenv("E_WL_OUTPUT_SCALE");
+ int scale = s ? atoi(s) : 1;
+
+ return (scale > 0) ? scale : 1;
+}
+
+static int
+_e_comp_wl_output_scale_get(const E_Comp_Wl_Output *output)
+{
+ return (output->scale >= 1.0) ? (int)(output->scale + 0.5) : 1;
+}
+
+/* How many canvas pixels one surface-local unit of this client covers:
+ * the scale of the output of its zone. */
+E_API int
+e_comp_wl_client_scale_get(const E_Client *ec)
+{
+ E_Comp_Wl_Output *output;
+ Eina_List *l;
+
+ if ((!ec) || (!ec->zone)) return 1;
+ /* E_Zone.output is also written by e_comp_x_randr.c and wl_drm, with
+ * their own types: only read it once it is known to be ours. */
+ EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
+ {
+ if (output == ec->zone->output)
+ return _e_comp_wl_output_scale_get(output);
+ }
return 1;
}
@@ -3364,7 +3398,7 @@ _e_comp_wl_output_state_send(E_Comp_Wl_Output *output, struct wl_resource *resou
output->model ?: "", output->transform);
if (version >= WL_OUTPUT_SCALE_SINCE_VERSION)
- wl_output_send_scale(resource, output->scale);
+ wl_output_send_scale(resource, _e_comp_wl_output_scale_get(output));
/* 3 == preferred + current */
wl_output_send_mode(resource, 3, output->w, output->h, output->refresh);
@@ -4001,10 +4035,7 @@ e_comp_wl_output_init(const char *id, const char *make, const char *model,
4, output, _e_comp_wl_cb_output_bind);
output->resources = NULL;
- /* Not e_scale: wl_surface.set_buffer_scale is not honoured, so a
- * client believing a scale of 2 attaches buffers we paint at
- * twice the size. */
- output->scale = 1;
+ output->scale = _e_comp_wl_output_scale_default();
zone->output = output;
}
@@ -4020,9 +4051,6 @@ e_comp_wl_output_init(const char *id, const char *make, const char *model,
output->subpixel = subpixel;
output->transform = transform;
- if (output->scale <= 0)
- output->scale = e_scale;
-
/* Before wl_output.done, which closes the update for xdg_output too. */
e_comp_wl_extension_xdg_output_update(output);
diff --git a/src/modules/wl_test/e_mod_main.c b/src/modules/wl_test/e_mod_main.c
index 9de6494b9..ed8c14c7f 100644
--- a/src/modules/wl_test/e_mod_main.c
+++ b/src/modules/wl_test/e_mod_main.c
@@ -355,6 +355,29 @@ _wl_test_cb_get_pixel(struct wl_client *client EINA_UNUSED, struct wl_resource *
wl_test_send_pixel(resource, x, y, argb);
}
+static void
+_wl_test_cb_output_scale_set(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, uint32_t zone, int32_t scale)
+{
+ E_Comp_Wl_Output *output;
+ E_Zone *z = e_comp_zone_number_get(zone);
+ Eina_List *l;
+
+ if (!z) return;
+ EINA_LIST_FOREACH(e_comp_wl->outputs, l, output)
+ {
+ if (output != z->output) continue;
+ output->scale = scale;
+ /* Sends the new state to every client bound to the output. */
+ e_comp_wl_output_init(output->id, output->make, output->model,
+ output->x, output->y, output->w, output->h,
+ output->phys_width, output->phys_height,
+ output->refresh / 1000, output->subpixel,
+ output->transform, zone);
+ return;
+ }
+ ERR("wl_test: zone %u has no wl_output", zone);
+}
+
static void
_wl_test_cb_get_screensaver(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
{
@@ -642,6 +665,7 @@ static const struct wl_test_interface _wl_test_implementation =
_wl_test_cb_get_screensaver,
_wl_test_cb_key_modified,
_wl_test_cb_get_pixel,
+ _wl_test_cb_output_scale_set,
};
static void
@@ -675,7 +699,7 @@ e_modapi_init(E_Module *m)
return NULL;
}
- _wl_test_global = wl_global_create(e_comp_wl->wl.disp, &wl_test_interface, 9,
+ _wl_test_global = wl_global_create(e_comp_wl->wl.disp, &wl_test_interface, 10,
NULL, _wl_test_cb_bind);
if (!_wl_test_global)
{
diff --git a/src/protocol/wl-test.xml b/src/protocol/wl-test.xml
index f1049d1fe..b371e0ec9 100644
--- a/src/protocol/wl-test.xml
+++ b/src/protocol/wl-test.xml
@@ -23,7 +23,7 @@
DEALINGS IN THE SOFTWARE.
</copyright>
- <interface name="wl_test" version="9">
+ <interface name="wl_test" version="10">
<description summary="private interface for the compositor test suite">
A back door into the compositor for its own test suite. It exposes
internal state and synthesises input, so it is only built with
@@ -362,5 +362,15 @@
<arg name="y" type="int"/>
<arg name="argb" type="uint"/>
</event>
+
+ <request name="output_scale_set" since="10">
+ <description summary="set the scale of the output of a zone">
+ Every output comes up at the same scale, so a test needs this to
+ put outputs of different scales side by side. Clients bound to
+ the output are told, as for a monitor change.
+ </description>
+ <arg name="zone" type="uint" summary="index of the zone"/>
+ <arg name="scale" type="int"/>
+ </request>
</interface>
</protocol>
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index 41b8f5fa3..b05c7214b 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -89,6 +89,7 @@ wl_protocol_tests = [
['shm-truncate', 'test_shm_truncate.c'],
['output', 'test_output.c'],
['buffer-scale', 'test_buffer_scale.c'],
+ ['output-scale', 'test_output_scale.c'],
['activation', 'test_activation.c'],
['activation-expiry', 'test_activation.c',
{'E_TEST_ACTIVATION_TOKEN_LIFETIME': '1'}],
diff --git a/src/tests/wayland/test_output_scale.c b/src/tests/wayland/test_output_scale.c
new file mode 100644
index 000000000..ea169d947
--- /dev/null
+++ b/src/tests/wayland/test_output_scale.c
@@ -0,0 +1,493 @@
+/* On an output of scale 2, a client speaks in surface-local units half the
+ * size of the screen's pixels: E advertises the scale, draws a buffer of
+ * scale 1 twice as large, and converts sizes, positions and regions both
+ * ways. */
+#define _GNU_SOURCE 1
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include "e_wl_testkit.h"
+
+#define PROG "test-output-scale"
+#define APP_ID "e.test.output-scale"
+
+#define TL 0xffff0000
+#define TR 0xff00ff00
+#define BL 0xff0000ff
+#define BR 0xffffff00
+
+typedef struct
+{
+ Tk *tk;
+ struct wl_test *tester;
+ struct wl_shm *shm;
+ struct wl_surface *surface;
+ struct xdg_toplevel *toplevel;
+ int output_scale;
+ int configured;
+ int configure_w, configure_h;
+ unsigned int maximized;
+ int entered;
+ wl_fixed_t px, py;
+ int popup_x, popup_y, popup_w, popup_h;
+ unsigned int argb;
+ int answered;
+} Ctx;
+
+static void
+_pixel(void *data, struct wl_test *t __attribute__((unused)),
+ int32_t x __attribute__((unused)), int32_t y __attribute__((unused)),
+ uint32_t argb)
+{
+ Ctx *ctx = data;
+
+ ctx->argb = argb;
+ ctx->answered = 1;
+}
+
+/* Only the requests this test sends are answered on its own wl_test. */
+static const struct wl_test_listener _tester_listener =
+{
+ .pixel = _pixel
+};
+
+static void
+_output_geometry(void *data __attribute__((unused)),
+ struct wl_output *o __attribute__((unused)),
+ int32_t x __attribute__((unused)),
+ int32_t y __attribute__((unused)),
+ int32_t pw __attribute__((unused)),
+ int32_t ph __attribute__((unused)),
+ int32_t subpixel __attribute__((unused)),
+ const char *make __attribute__((unused)),
+ const char *model __attribute__((unused)),
+ int32_t transform __attribute__((unused)))
+{
+}
+
+static void
+_output_mode(void *data __attribute__((unused)),
+ struct wl_output *o __attribute__((unused)),
+ uint32_t flags __attribute__((unused)),
+ int32_t w __attribute__((unused)),
+ int32_t h __attribute__((unused)),
+ int32_t refresh __attribute__((unused)))
+{
+}
+
+static void
+_output_done(void *data __attribute__((unused)),
+ struct wl_output *o __attribute__((unused)))
+{
+}
+
+static void
+_output_scale(void *data, struct wl_output *o __attribute__((unused)),
+ int32_t scale)
+{
+ Ctx *ctx = data;
+
+ ctx->output_scale = scale;
+}
+
+static const struct wl_output_listener _output_listener =
+{
+ _output_geometry, _output_mode, _output_done, _output_scale, NULL, NULL
+};
+
+static void
+_enter(void *data, struct wl_pointer *p __attribute__((unused)),
+ uint32_t serial __attribute__((unused)), struct wl_surface *s,
+ wl_fixed_t x, wl_fixed_t y)
+{
+ Ctx *ctx = data;
+
+ if (s != ctx->surface) return;
+ ctx->entered = 1;
+ ctx->px = x;
+ ctx->py = y;
+}
+
+static void
+_leave(void *data, struct wl_pointer *p __attribute__((unused)),
+ uint32_t serial __attribute__((unused)),
+ struct wl_surface *s __attribute__((unused)))
+{
+ Ctx *ctx = data;
+
+ ctx->entered = 0;
+}
+
+static void
+_motion(void *data, struct wl_pointer *p __attribute__((unused)),
+ uint32_t time __attribute__((unused)), wl_fixed_t x, wl_fixed_t y)
+{
+ Ctx *ctx = data;
+
+ ctx->px = x;
+ ctx->py = y;
+}
+
+static void
+_button(void *data __attribute__((unused)),
+ struct wl_pointer *p __attribute__((unused)),
+ uint32_t serial __attribute__((unused)),
+ uint32_t time __attribute__((unused)),
+ uint32_t button __attribute__((unused)),
+ uint32_t state __attribute__((unused)))
+{
+}
+
+static void
+_axis(void *data __attribute__((unused)),
+ struct wl_pointer *p __attribute__((unused)),
+ uint32_t time __attribute__((unused)),
+ uint32_t axis __attribute__((unused)),
+ wl_fixed_t value __attribute__((unused)))
+{
+}
+
+static const struct wl_pointer_listener _pointer_listener =
+{
+ _enter, _leave, _motion, _button, _axis, NULL, NULL, NULL, NULL, NULL, NULL
+};
+
+static void
+_configure(void *data, struct xdg_surface *xdg_surface, uint32_t serial)
+{
+ Ctx *ctx = data;
+
+ xdg_surface_ack_configure(xdg_surface, serial);
+ ctx->configured++;
+}
+
+static const struct xdg_surface_listener _xdg_surface_listener =
+{
+ _configure
+};
+
+static void
+_toplevel_configure(void *data, struct xdg_toplevel *t __attribute__((unused)),
+ int32_t w, int32_t h, struct wl_array *states)
+{
+ Ctx *ctx = data;
+ uint32_t *state;
+
+ ctx->configure_w = w;
+ ctx->configure_h = h;
+ ctx->maximized = 0;
+ wl_array_for_each(state, states)
+ if (*state == XDG_TOPLEVEL_STATE_MAXIMIZED) ctx->maximized = 1;
+}
+
+static void
+_toplevel_close(void *data __attribute__((unused)),
+ struct xdg_toplevel *t __attribute__((unused)))
+{
+}
+
+static void
+_toplevel_bounds(void *data __attribute__((unused)),
+ struct xdg_toplevel *t __attribute__((unused)),
+ int32_t w __attribute__((unused)),
+ int32_t h __attribute__((unused)))
+{
+}
+
+static void
+_toplevel_capabilities(void *data __attribute__((unused)),
+ struct xdg_toplevel *t __attribute__((unused)),
+ struct wl_array *caps __attribute__((unused)))
+{
+}
+
+static const struct xdg_toplevel_listener _toplevel_listener =
+{
+ _toplevel_configure, _toplevel_close, _toplevel_bounds,
+ _toplevel_capabilities
+};
+
+static void
+_popup_configure(void *data, struct xdg_popup *p __attribute__((unused)),
+ int32_t x, int32_t y, int32_t w, int32_t h)
+{
+ Ctx *ctx = data;
+
+ ctx->popup_x = x;
+ ctx->popup_y = y;
+ ctx->popup_w = w;
+ ctx->popup_h = h;
+}
+
+static void
+_popup_done(void *data __attribute__((unused)),
+ struct xdg_popup *p __attribute__((unused)))
+{
+}
+
+static const struct xdg_popup_listener _popup_listener =
+{
+ _popup_configure, _popup_done, NULL
+};
+
+/* A buffer of four solid quadrants. */
+static struct wl_buffer *
+_buffer(Ctx *ctx, int w, int h)
+{
+ uint32_t colors[4] = { TL, TR, BL, BR };
+ struct wl_shm_pool *pool;
+ struct wl_buffer *buffer;
+ uint32_t *pixels;
+ int fd, x, y;
+
+ fd = memfd_create(PROG, MFD_CLOEXEC);
+ if ((fd < 0) || (ftruncate(fd, w * h * 4) < 0))
+ tk_fail(ctx->tk, "cannot make a %dx%d buffer", w, h);
+ pixels = mmap(NULL, w * h * 4, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (pixels == MAP_FAILED) tk_fail(ctx->tk, "cannot map a buffer");
+ for (y = 0; y < h; y++)
+ for (x = 0; x < w; x++)
+ pixels[(y * w) + x] = colors[((y >= h / 2) * 2) + (x >= w / 2)];
+ munmap(pixels, w * h * 4);
+ pool = wl_shm_create_pool(ctx->shm, fd, w * h * 4);
+ buffer = wl_shm_pool_create_buffer(pool, 0, w, h, w * 4,
+ WL_SHM_FORMAT_ARGB8888);
+ wl_shm_pool_destroy(pool);
+ close(fd);
+ return buffer;
+}
+
+static void
+_paint(Ctx *ctx, struct wl_surface *surface, int w, int h, int scale)
+{
+ wl_surface_set_buffer_scale(surface, scale);
+ wl_surface_attach(surface, _buffer(ctx, w * scale, h * scale), 0, 0);
+ wl_surface_damage_buffer(surface, 0, 0, w * scale, h * scale);
+ wl_surface_commit(surface);
+ tk_settle(ctx->tk);
+}
+
+static unsigned int
+_pixel_get(Ctx *ctx, int x, int y)
+{
+ ctx->answered = 0;
+ wl_test_get_pixel(ctx->tester, x, y);
+ tk_sync(ctx->tk);
+ if (!ctx->answered) tk_fail(ctx->tk, "no answer to get_pixel");
+ return ctx->argb;
+}
+
+/* The theme animates a window being shown. */
+static void
+_pixel_wait(Ctx *ctx, int x, int y, unsigned int want, const char *what)
+{
+ struct timespec step = { 0, 50000000 };
+ unsigned int argb = 0;
+ int i;
+
+ for (i = 0; i < TK_WAIT_SECONDS * 20; i++)
+ {
+ argb = _pixel_get(ctx, x, y);
+ if (argb == want) return;
+ nanosleep(&step, NULL);
+ }
+ tk_fail(ctx->tk, "%s: pixel %d,%d is %#x, wanted %#x", what, x, y,
+ argb, want);
+}
+
+static void
+_quadrants_check(Ctx *ctx, int x, int y, int w, int h, const char *what)
+{
+ _pixel_wait(ctx, x + (w / 4), y + (h / 4), TL, what);
+ _pixel_wait(ctx, x + (3 * w / 4), y + (h / 4), TR, what);
+ _pixel_wait(ctx, x + (w / 4), y + (3 * h / 4), BL, what);
+ _pixel_wait(ctx, x + (3 * w / 4), y + (3 * h / 4), BR, what);
+}
+
+static void
+_size_check(Ctx *ctx, struct wl_surface *surface, int w, int h,
+ const char *what)
+{
+ int sw, sh;
+
+ tk_surface_geometry(ctx->tk, surface, NULL, NULL, &sw, &sh);
+ if ((sw != w) || (sh != h))
+ tk_fail(ctx->tk, "%s: the window is %dx%d, wanted %dx%d", what, sw, sh,
+ w, h);
+}
+
+static void
+_pointer_check(Ctx *ctx, int x, int y, double sx, double sy, const char *what)
+{
+ tk_pointer_warp(ctx->tk, x, y);
+ if (!ctx->entered) tk_fail(ctx->tk, "%s: the pointer did not enter", what);
+ if ((ctx->px != wl_fixed_from_double(sx)) ||
+ (ctx->py != wl_fixed_from_double(sy)))
+ tk_fail(ctx->tk, "%s: the pointer is at %g,%g, wanted %g,%g", what,
+ wl_fixed_to_double(ctx->px), wl_fixed_to_double(ctx->py),
+ sx, sy);
+}
+
+int
+main(void)
+{
+ struct wl_compositor *compositor;
+ struct wl_subcompositor *subcompositor;
+ struct xdg_surface *xdg_surface, *popup_xdg_surface;
+ struct xdg_positioner *positioner;
+ struct xdg_popup *popup;
+ struct wl_surface *sub, *popup_surface;
+ struct wl_region *region;
+ struct wl_output *output;
+ struct wl_seat *seat;
+ Ctx ctx = { 0 };
+ int x, y, w, h, configured;
+
+ ctx.tk = tk_connect(PROG);
+ ctx.tester = tk_bind(ctx.tk, &wl_test_interface, 10);
+ if (!ctx.tester) tk_fail(ctx.tk, "no wl_test version 10");
+ wl_test_add_listener(ctx.tester, &_tester_listener, &ctx);
+ ctx.shm = tk_bind(ctx.tk, &wl_shm_interface, 1);
+ compositor = tk_bind(ctx.tk, &wl_compositor_interface, 4);
+ subcompositor = tk_bind(ctx.tk, &wl_subcompositor_interface, 1);
+ seat = tk_bind(ctx.tk, &wl_seat_interface, 1);
+ wl_pointer_add_listener(wl_seat_get_pointer(seat), &_pointer_listener, &ctx);
+ output = tk_bind(ctx.tk, &wl_output_interface, 2);
+ wl_output_add_listener(output, &_output_listener, &ctx);
+ tk_sync(ctx.tk);
+ if (ctx.output_scale != 1)
+ tk_fail(ctx.tk, "the output starts at scale %d, wanted 1",
+ ctx.output_scale);
+
+ wl_test_output_scale_set(ctx.tester, 0, 2);
+ tk_sync(ctx.tk);
+ if (ctx.output_scale != 2)
+ tk_fail(ctx.tk, "the output is at scale %d after setting 2",
+ ctx.output_scale);
+
+ ctx.surface = tk_surface_new(ctx.tk);
+ xdg_surface = xdg_wm_base_get_xdg_surface(tk_wm_base(ctx.tk), ctx.surface);
+ xdg_surface_add_listener(xdg_surface, &_xdg_surface_listener, &ctx);
+ ctx.toplevel = xdg_surface_get_toplevel(xdg_surface);
+ xdg_toplevel_add_listener(ctx.toplevel, &_toplevel_listener, &ctx);
+ xdg_toplevel_set_app_id(ctx.toplevel, APP_ID);
+ wl_surface_commit(ctx.surface);
+ while (!ctx.configured)
+ wl_display_dispatch(tk_display(ctx.tk));
+
+ /* The cursor is drawn on the same canvas. */
+ tk_pointer_warp(ctx.tk, 1023, 767);
+
+ _paint(&ctx, ctx.surface, 100, 50, 1);
+ tk_expect(ctx.tk, APP_ID);
+ _size_check(&ctx, ctx.surface, 200, 100, "a 100x50 buffer of scale 1");
+ tk_surface_geometry(ctx.tk, ctx.surface, &x, &y, NULL, NULL);
+ _quadrants_check(&ctx, x, y, 200, 100, "a buffer of scale 1, upscaled");
+
+ _paint(&ctx, ctx.surface, 100, 50, 2);
+ _size_check(&ctx, ctx.surface, 200, 100, "a 200x100 buffer of scale 2");
+ _quadrants_check(&ctx, x, y, 200, 100, "a buffer of scale 2");
+
+ /* Positions go to the client in halves of a canvas pixel. */
+ _pointer_check(&ctx, x + 40, y + 20, 20, 10, "pointer in the window");
+ _pointer_check(&ctx, x + 41, y + 20, 20.5, 10, "pointer one pixel on");
+
+ /* The input region is surface-local too: 50x25 covers 100x50. */
+ region = wl_compositor_create_region(compositor);
+ wl_region_add(region, 0, 0, 50, 25);
+ wl_surface_set_input_region(ctx.surface, region);
+ wl_region_destroy(region);
+ wl_surface_commit(ctx.surface);
+ tk_settle(ctx.tk);
+ tk_pointer_warp(ctx.tk, 1023, 767);
+ _pointer_check(&ctx, x + 90, y + 40, 45, 20, "pointer in the input region");
+ wl_surface_set_input_region(ctx.surface, NULL);
+ wl_surface_commit(ctx.surface);
+ tk_settle(ctx.tk);
+ tk_pointer_warp(ctx.tk, 1023, 767);
+
+ /* So is a subsurface's offset in its parent. */
+ sub = wl_compositor_create_surface(compositor);
+ wl_subsurface_set_position(wl_subcompositor_get_subsurface(subcompositor,
+ sub,
+ ctx.surface),
+ 10, 5);
+ _paint(&ctx, sub, 20, 10, 1);
+ wl_surface_commit(ctx.surface);
+ tk_settle(ctx.tk);
+ tk_surface_geometry(ctx.tk, sub, &w, &h, NULL, NULL);
+ if ((w != x + 20) || (h != y + 10))
+ tk_fail(ctx.tk, "a subsurface at 10,5 is at %d,%d in a window at %d,%d",
+ w, h, x, y);
+ _size_check(&ctx, sub, 40, 20, "a 20x10 subsurface");
+
+ /* A positioner is surface-local, and so is the popup's configure. */
+ positioner = xdg_wm_base_create_positioner(tk_wm_base(ctx.tk));
+ xdg_positioner_set_size(positioner, 20, 10);
+ xdg_positioner_set_anchor_rect(positioner, 30, 15, 1, 1);
+ xdg_positioner_set_anchor(positioner, XDG_POSITIONER_ANCHOR_TOP_LEFT);
+ xdg_positioner_set_gravity(positioner, XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT);
+ popup_surface = tk_surface_new(ctx.tk);
+ popup_xdg_surface = xdg_wm_base_get_xdg_surface(tk_wm_base(ctx.tk),
+ popup_surface);
+ xdg_surface_add_listener(popup_xdg_surface, &_xdg_surface_listener, &ctx);
+ popup = xdg_surface_get_popup(popup_xdg_surface, xdg_surface, positioner);
+ xdg_popup_add_listener(popup, &_popup_listener, &ctx);
+ xdg_positioner_destroy(positioner);
+ configured = ctx.configured;
+ wl_surface_commit(popup_surface);
+ while (ctx.configured == configured)
+ wl_display_dispatch(tk_display(ctx.tk));
+ if ((ctx.popup_x != 30) || (ctx.popup_y != 15) ||
+ (ctx.popup_w != 20) || (ctx.popup_h != 10))
+ tk_fail(ctx.tk, "a 20x10 popup at 30,15 is configured %dx%d at %d,%d",
+ ctx.popup_w, ctx.popup_h, ctx.popup_x, ctx.popup_y);
+ _paint(&ctx, popup_surface, 20, 10, 1);
+ tk_surface_geometry(ctx.tk, popup_surface, &w, &h, NULL, NULL);
+ if ((w != x + 60) || (h != y + 30))
+ tk_fail(ctx.tk, "a popup at 30,15 is at %d,%d in a window at %d,%d",
+ w, h, x, y);
+ _size_check(&ctx, popup_surface, 40, 20, "a 20x10 popup");
+ xdg_popup_destroy(popup);
+ xdg_surface_destroy(popup_xdg_surface);
+ wl_surface_destroy(popup_surface);
+ tk_settle(ctx.tk);
+
+ /* Configure sizes go to the client in surface-local units. */
+ configured = ctx.configured;
+ xdg_toplevel_set_maximized(ctx.toplevel);
+ while ((ctx.configured == configured) || (!ctx.maximized))
+ wl_display_dispatch(tk_display(ctx.tk));
+ if ((ctx.configure_w * 2 > 1024) || (ctx.configure_h * 2 > 768) ||
+ (ctx.configure_w < 1) || (ctx.configure_h < 1))
+ tk_fail(ctx.tk, "maximized on a 1024x768 output of scale 2, the "
+ "configure asks for %dx%d", ctx.configure_w,
+ ctx.configure_h);
+ _paint(&ctx, ctx.surface, ctx.configure_w, ctx.configure_h, 2);
+ tk_surface_geometry(ctx.tk, ctx.surface, NULL, NULL, &w, &h);
+ if ((w != ctx.configure_w * 2) || (h != ctx.configure_h * 2))
+ tk_fail(ctx.tk, "maximized to %dx%d, the window is %dx%d",
+ ctx.configure_w, ctx.configure_h, w, h);
+ xdg_toplevel_unset_maximized(ctx.toplevel);
+ while (ctx.maximized)
+ wl_display_dispatch(tk_display(ctx.tk));
+ _paint(&ctx, ctx.surface, 100, 50, 2);
+
+ /* The same client on an output of scale 1 is half the size. */
+ 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");
+
+ tk_disconnect(ctx.tk);
+ printf(PROG ": ok\n");
+ return 0;
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.