This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch up/6b-viewporter
in repository enlightenment.
View the commit online.
commit 6fa5a7f5fbde1e46aed5de02b0c1841ab675983e
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 27 22:15:50 2026 -0600
e_comp_wl_text_input - place the input popup in surface-local units
The text input's cursor rectangle is in the focused window's
surface-local units, and the rectangle sent to the input popup is in
the popup's. Both were used as canvas pixels, so on an output of scale
2 the candidate window of fcitx5 came up halfway between the window's
corner and the text cursor.
wl-input-popup now also runs as wl-input-popup-scale with
E_WL_OUTPUT_SCALE=2, its expectations scaled. It took the window's
origin from the first pointer enter, which at scale 2 comes while the
larger window still covers the pointer at its first place; it now
takes it from the last position the pointer was reported at. The
scaled run fails without this change.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/bin/e_comp_wl_text_input.c | 16 ++++---
src/tests/wayland/meson.build | 2 +
src/tests/wayland/test_input_popup.c | 87 +++++++++++++++++++++++++-----------
3 files changed, 74 insertions(+), 31 deletions(-)
diff --git a/src/bin/e_comp_wl_text_input.c b/src/bin/e_comp_wl_text_input.c
index 2c1900feb..42c4e4d68 100644
--- a/src/bin/e_comp_wl_text_input.c
+++ b/src/bin/e_comp_wl_text_input.c
@@ -429,11 +429,15 @@ _e_input_popup_place(Input_Popup *ip)
E_Client *ec = ip->ec, *focus = wl_resource_get_user_data(_focus_surface);
const Text_Input_State *st = &_active_ti->current;
int cx, cy, x, y, zx, zy, zw, zh;
+ int fscale = e_comp_wl_client_scale_get(focus);
+ int pscale = e_comp_wl_client_scale_get(ec);
- cx = focus->client.x + st->cursor_x;
- cy = focus->client.y + st->cursor_y;
+ /* The cursor is in the focused window's surface-local units, and the
+ * rectangle goes to the popup in its own. */
+ cx = focus->client.x + (st->cursor_x * fscale);
+ cy = focus->client.y + (st->cursor_y * fscale);
x = cx;
- y = cy + st->cursor_h;
+ y = cy + (st->cursor_h * fscale);
e_zone_useful_geometry_get(focus->zone, &zx, &zy, &zw, &zh);
if (x + ec->w > zx + zw) x = zx + zw - ec->w;
if (x < zx) x = zx;
@@ -441,8 +445,10 @@ _e_input_popup_place(Input_Popup *ip)
if (y + ec->h > zy + zh) y = zy + zh - ec->h;
if (y < zy) y = zy;
e_client_util_move_without_frame(ec, x, y);
- zwp_input_popup_surface_v2_send_text_input_rectangle(ip->res, cx - x, cy - y,
- st->cursor_w, st->cursor_h);
+ zwp_input_popup_surface_v2_send_text_input_rectangle(ip->res, (cx - x) / pscale,
+ (cy - y) / pscale,
+ (st->cursor_w * fscale) / pscale,
+ (st->cursor_h * fscale) / pscale);
}
static void
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index ae21b7471..46ae5b868 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -99,6 +99,8 @@ wl_protocol_tests = [
['text-input', 'test_text_input.c'],
['input-method-keyboard', 'test_input_method_keyboard.c'],
['input-popup', 'test_input_popup.c'],
+ ['input-popup-scale', 'test_input_popup.c',
+ {'E_WL_OUTPUT_SCALE': '2'}],
['privileges', 'test_privileges.c',
{'PATH': meson.current_build_dir()}],
['client-iconify', 'test_client_iconify.c',
diff --git a/src/tests/wayland/test_input_popup.c b/src/tests/wayland/test_input_popup.c
index eee600f28..b2e4f0075 100644
--- a/src/tests/wayland/test_input_popup.c
+++ b/src/tests/wayland/test_input_popup.c
@@ -1,6 +1,8 @@
/* zwp_input_popup_surface_v2, the input method's candidate list: shown if
* and only if the input method is active, below the text cursor of the
- * focused window, and told where that cursor is in its own coordinates. */
+ * focused window, and told where that cursor is in its own coordinates.
+ * Also run with E_WL_OUTPUT_SCALE=2, where those coordinates are half the
+ * screen's. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -27,7 +29,9 @@ static Tk *app, *ime;
static struct wl_seat *ime_seat;
static struct zwp_input_method_manager_v2 *im_manager;
static struct zwp_text_input_v3 *ti;
-static int origin_x, origin_y, origin_known, zone_w, zone_h;
+static int origin_x, origin_y, zone_w, zone_h, scale = 1;
+static wl_fixed_t ptr_x, ptr_y;
+static int ptr_known;
static struct wl_surface *ime_pointer_surface;
static void
@@ -79,10 +83,9 @@ _ptr_enter(void *data __attribute__((unused)), struct wl_pointer *p __attribute_
uint32_t serial __attribute__((unused)), struct wl_surface *s __attribute__((unused)),
wl_fixed_t x, wl_fixed_t y)
{
- if (origin_known) return;
- origin_x = 150 - wl_fixed_to_int(x);
- origin_y = 150 - wl_fixed_to_int(y);
- origin_known = 1;
+ ptr_x = x;
+ ptr_y = y;
+ ptr_known = 1;
}
static void
@@ -93,9 +96,10 @@ _ptr_leave(void *data __attribute__((unused)), struct wl_pointer *p __attribute_
static void
_ptr_motion(void *data __attribute__((unused)), struct wl_pointer *p __attribute__((unused)),
- uint32_t time __attribute__((unused)), wl_fixed_t x __attribute__((unused)),
- wl_fixed_t y __attribute__((unused)))
+ uint32_t time __attribute__((unused)), wl_fixed_t x, wl_fixed_t y)
{
+ ptr_x = x;
+ ptr_y = y;
}
static void
@@ -127,9 +131,16 @@ _ime_ptr_leave(void *data __attribute__((unused)), struct wl_pointer *p __attrib
ime_pointer_surface = NULL;
}
+static void
+_ime_ptr_motion(void *data __attribute__((unused)), struct wl_pointer *p __attribute__((unused)),
+ uint32_t time __attribute__((unused)), wl_fixed_t x __attribute__((unused)),
+ wl_fixed_t y __attribute__((unused)))
+{
+}
+
static const struct wl_pointer_listener _ime_ptr_listener =
{
- _ime_ptr_enter, _ime_ptr_leave, _ptr_motion, _ptr_button, _ptr_axis,
+ _ime_ptr_enter, _ime_ptr_leave, _ime_ptr_motion, _ptr_button, _ptr_axis,
NULL, NULL, NULL, NULL, NULL, NULL
};
@@ -157,9 +168,21 @@ _output_mode(void *data __attribute__((unused)), struct wl_output *o __attribute
zone_h = h;
}
+static void
+_output_done(void *data __attribute__((unused)), struct wl_output *o __attribute__((unused)))
+{
+}
+
+static void
+_output_scale(void *data __attribute__((unused)), struct wl_output *o __attribute__((unused)),
+ int32_t factor)
+{
+ scale = factor;
+}
+
static const struct wl_output_listener _output_listener =
{
- _output_geometry, _output_mode, NULL, NULL, NULL, NULL
+ _output_geometry, _output_mode, _output_done, _output_scale, NULL, NULL
};
static void
@@ -270,7 +293,7 @@ main(void)
ime = tk_connect(PROG);
tester = tk_bind(app, &wl_test_interface, 1);
app_seat = tk_bind(app, &wl_seat_interface, 1);
- output = tk_bind(app, &wl_output_interface, 1);
+ output = tk_bind(app, &wl_output_interface, 2);
ime_seat = tk_bind(ime, &wl_seat_interface, 1);
if (ime_seat)
wl_pointer_add_listener(wl_seat_get_pointer(ime_seat), &_ime_ptr_listener, NULL);
@@ -279,6 +302,7 @@ main(void)
if ((!tester) || (!app_seat) || (!output) || (!ime_seat) || (!ti_manager) || (!im_manager))
tk_fail(app, "missing global");
wl_output_add_listener(output, &_output_listener, NULL);
+ tk_sync(app);
wl_pointer_add_listener(wl_seat_get_pointer(app_seat), &_ptr_listener, NULL);
ti = zwp_text_input_manager_v3_get_text_input(ti_manager, app_seat);
@@ -289,7 +313,9 @@ main(void)
/* The window's surface origin, from where the pointer is in it. */
tk_pointer_warp(app, 150, 150);
_settle();
- if ((!origin_known) || (!zone_w) || (!zone_h)) tk_fail(app, "no pointer enter or no output mode");
+ if ((!ptr_known) || (!zone_w) || (!zone_h)) tk_fail(app, "no pointer enter or no output mode");
+ origin_x = 150 - (wl_fixed_to_int(ptr_x) * scale);
+ origin_y = 150 - (wl_fixed_to_int(ptr_y) * scale);
im = zwp_input_method_manager_v2_get_input_method(im_manager, ime_seat);
zwp_input_method_v2_add_listener(im, &_im_listener, NULL);
@@ -299,45 +325,53 @@ main(void)
_expect_hidden(early_surface, "no field enabled, buffer before the role");
_cursor(1, 10, 20);
- _expect_at(surface, &r, origin_x + 10, origin_y + 35, 0, -15, "enabled");
- _expect_at(early_surface, &early_r, origin_x + 10, origin_y + 35, 0, -15,
- "enabled, buffer before the role");
+ _expect_at(surface, &r, origin_x + (10 * scale), origin_y + (35 * scale), 0, -15,
+ "enabled");
+ _expect_at(early_surface, &early_r, origin_x + (10 * scale), origin_y + (35 * scale),
+ 0, -15, "enabled, buffer before the role");
if (tk_surface_visible(app, tk_toplevel_surface(top)) != 1)
tk_fail(app, "the window is hidden");
tk_wait_states(app, APP_ID, FOCUS, FOCUS, "the window keeps the focus");
_cursor(0, 30, 40);
- _expect_at(surface, &r, origin_x + 30, origin_y + 55, 0, -15, "the cursor moved");
+ _expect_at(surface, &r, origin_x + (30 * scale), origin_y + (55 * scale), 0, -15,
+ "the cursor moved");
/* No room below: above the cursor. */
- _cursor(0, 30, zone_h - origin_y - 20);
- _expect_at(surface, &r, origin_x + 30, zone_h - 20 - PH, 0, PH, "no room below");
+ _cursor(0, 30, (zone_h - origin_y - 20) / scale);
+ _expect_at(surface, &r, origin_x + (30 * scale), zone_h - 20 - (PH * scale), 0, PH,
+ "no room below");
/* No room above either: against the bottom edge. */
- _cursor(0, 30, zone_h - origin_y + 100);
- _expect_at(surface, &r, origin_x + 30, zone_h - PH, 0, 100 + PH, "no room at all");
+ _cursor(0, 30, (zone_h - origin_y + 100) / scale);
+ _expect_at(surface, &r, origin_x + (30 * scale), zone_h - (PH * scale), 0,
+ (100 / scale) + PH, "no room at all");
/* No room on the right: against the right edge. */
- _cursor(0, zone_w - origin_x - 10, 40);
- _expect_at(surface, &r, zone_w - PW, origin_y + 55, PW - 10, -15, "no room on the right");
+ _cursor(0, (zone_w - origin_x - 10) / scale, 40);
+ _expect_at(surface, &r, zone_w - (PW * scale), origin_y + (55 * scale),
+ PW - (10 / scale), -15, "no room on the right");
/* A resized popup is placed with its new size. */
tk_surface_paint(ime, surface, PW + 20, PH);
_settle();
- _expect_at(surface, &r, zone_w - PW - 20, origin_y + 55, PW + 10, -15, "resized");
+ _expect_at(surface, &r, zone_w - ((PW + 20) * scale), origin_y + (55 * scale),
+ PW + 20 - (10 / scale), -15, "resized");
tk_surface_paint(ime, surface, PW, PH);
_cursor(0, 10, 20);
/* Above the window, even raised, and a click does not take the focus. */
tk_action(app, tk_expect(app, APP_ID)->id, "window_raise", NULL);
- tk_pointer_warp(app, origin_x + 10 + PW / 2, origin_y + 35 + PH / 2);
+ tk_pointer_warp(app, origin_x + ((10 + (PW / 2)) * scale),
+ origin_y + ((35 + (PH / 2)) * scale));
_settle();
if (ime_pointer_surface != surface) tk_fail(ime, "the pointer is not on the popup");
tk_pointer_button(app, BTN_LEFT, 1);
tk_pointer_button(app, BTN_LEFT, 0);
_settle();
tk_wait_states(app, APP_ID, FOCUS, FOCUS, "the window keeps the focus after a click on the popup");
- _expect_at(surface, &r, origin_x + 10, origin_y + 35, 0, -15, "clicked");
+ _expect_at(surface, &r, origin_x + (10 * scale), origin_y + (35 * scale), 0, -15,
+ "clicked");
/* Unmapped by a NULL buffer, and mapped again. */
wl_surface_attach(surface, NULL, 0, 0);
@@ -346,7 +380,8 @@ main(void)
_expect_hidden(surface, "unmapped");
tk_surface_paint(ime, surface, PW, PH);
_settle();
- _expect_at(surface, &r, origin_x + 10, origin_y + 35, 0, -15, "mapped again");
+ _expect_at(surface, &r, origin_x + (10 * scale), origin_y + (35 * scale), 0, -15,
+ "mapped again");
/* A second input method is unavailable, and so is its popup. */
im2 = zwp_input_method_manager_v2_get_input_method(im_manager, ime_seat);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.