diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-14 15:24:11 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-14 15:24:11 +0300 |
| commit | f288612f177711207be3e077922c09925d7c0063 (patch) | |
| tree | 09f69f60fe3661e232be6a5cd42e55c4eb9614aa /src/platform/wayland/ime.c | |
| parent | 9c851d0fbb346467bbd92f8b5ba95b9b6eb73052 (diff) | |
Map text purposes to Wayland content purposes
The Wayland backend passed yasl's purpose values straight to
set_content_type. The values differ: yasl TERMINAL (3) reached the
compositor as the protocol's NUMBER. Map each yasl purpose to its
protocol constant. Unknown values fall back to normal text.
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src/platform/wayland/ime.c')
| -rw-r--r-- | src/platform/wayland/ime.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/platform/wayland/ime.c b/src/platform/wayland/ime.c index 62e5936..4af55b3 100644 --- a/src/platform/wayland/ime.c +++ b/src/platform/wayland/ime.c @@ -1,4 +1,5 @@ #include "internal.h" +#include "yasl/yasl.h" #include <errno.h> @@ -35,6 +36,18 @@ void ime_send_caret(struct wayland_surface *w) wayland_surface_update_text_input(w); } +/* yasl's purposes are its own values. The protocol's values differ, so map + * each one. Unknown values fall back to normal text. */ +static uint32_t content_purpose(unsigned purpose) +{ + switch (purpose) { + case YASL_TEXT_PASSWORD: return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PASSWORD; + case YASL_TEXT_NUMBER: return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NUMBER; + case YASL_TEXT_TERMINAL: return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_TERMINAL; + default: return ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL; + } +} + bool wayland_surface_update_text_input(struct wayland_surface *w) { if (!w || !w->conn) { @@ -61,11 +74,8 @@ bool wayland_surface_update_text_input(struct wayland_surface *w) zwp_text_input_v3_enable(seat->text_input); seat->ime_enabled = true; } - unsigned purpose = w->base.text_purpose; - if (purpose > ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_TERMINAL) - purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL; zwp_text_input_v3_set_content_type(seat->text_input, - ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE, purpose); + ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE, content_purpose(w->base.text_purpose)); const char *surrounding = w->base.text_surrounding ? w->base.text_surrounding : ""; size_t length = w->base.text_surrounding ? w->base.text_length : 0; size_t cursor = w->base.text_surrounding ? w->base.text_end : 0; |
