From 61e75e4a12f199368f28dd274d83fc4ecd9cfec3 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Mon, 19 Jan 2026 16:34:50 +0100 Subject: All platforms use same code to remove context-dependent codepoints from text input. This commit introduces function fl_utf8_remove_context_dependent() that removes from an UTF-8 string its context-dependent codepoints. Platforms macOS, Wayland and X11 call this function to process UTF-8 text received from a character palette as input to FLTK text. This makes sure FLTK text-editing widgets process textual input equally and consistently across platforms, especially emojis entered via a palette. Platform Windows creates a series of separate system events to input an emoji via the character palette. For this reason, function fl_utf8_remove_context_dependent() is not used by this platform which does internally the same filtering of context- dependent codepoints. --- src/Fl_x.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Fl_x.cxx') diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index fa58c8076..150438755 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -1,7 +1,7 @@ // // X specific code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2025 by Bill Spitzak and others. +// Copyright 1998-2026 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -101,6 +101,7 @@ extern Fl_Window *fl_xmousewin; static void open_display_i(Display *d); // open display (internal) extern int fl_send_system_handlers(void *e); +extern int fl_utf8_remove_context_dependent(char *text, int len); #if FLTK_CONSOLIDATE_MOTION static Fl_Window *send_motion; @@ -1833,6 +1834,7 @@ int fl_handle(const XEvent& thisevent) Status status; len = XUtf8LookupString(Fl_X11_Screen_Driver::xim_ic, (XKeyPressedEvent *)&xevent.xkey, kp_buffer, kp_buffer_len, &keysym, &status); + len = fl_utf8_remove_context_dependent(kp_buffer, len); while (status == XBufferOverflow && kp_buffer_len < 50000) { kp_buffer_len = kp_buffer_len * 5 + 1; -- cgit v1.2.3