The xclass name "editor.exe"collides with the system name "Edit" that is predefined by Windows for Edit controls.That causes emojis not to be inserted.
My proposal is in attached 1360Windows.patch: prefix xclass names by "FLTK-"and use the prefixed name in the CreateWindowExW() call to create windows.
What do fellow FLTK developers think about this proposal?
There remains an issue about measuring the width of emoji characters, but that's another story.
On Tuesday, 13 January 2026 at 13:19:30 UTC Manolo wrote:The xclass name "editor.exe"collides with the system name "Edit" that is predefined by Windows for Edit controls.That causes emojis not to be inserted.That is unexpected - do we know how many characters need to be "the same" for the collision to happen? (Or rather, what name is expected by default for an edit control, I suppose?)
Issue #1360 reports that FLTK doesn't support correctly the input of emojis under Windows. Looking in more detail under Windows 11 shows this:- typing Windows+dot opens an emoji palette- test/input correctly inserts emojis selected from the palette- test/editor inserts none of the selected emojis- the cause of this difference is in an unexpected place: calling window->show(argc, argv)sets the xclass() of windows of these programs to "input.exe" and "editor.exe",respectively. Then these xclass names are used as 2nd argument of the window-creating system call under Windows, function CreateWindowExW(). The xclass name "editor.exe"collides with the system name "Edit" that is predefined by Windows for Edit controls.
[...]
My proposal is in attached 1360Windows.patch: prefix xclass names by "FLTK-"and use the prefixed name in the CreateWindowExW() call to create windows.
What do fellow FLTK developers think about this proposal?
[combining my reply to Manolo and Ian]
+1 on prefixing the Window class with FLTK (if it doesn't begin with FLTK, as the proposed patch checks already)
Regarding the patch:
(1) The old code is pretty confusing at a first glance; it seems "correct" though. I suggest to use std::string to combine strings in 1.5 because it's easier to write and to read. Unless we wanted to backporat the patch to 1.4, where we might use the patch almost as given. So, if we used std::string we might want to rewrite the entire block that's concerned with setting the class names. But I'm open for "old char string" manipulation as well.
(2) As Ian wrote:
> With the patch as-is, we end up with "first_class_name" and the "xclass" name being different - is that something we'd care about?
I think we should. As I understand the code, `first_class_name` is just a static (!) storage of the first class name we set and is used as fallback when other windows are created.
Le mardi 13 janvier 2026 à 16:09:20 UTC+1, Albrecht-S a écrit :
[combining my reply to Manolo and Ian]+1 on prefixing the Window class with FLTK (if it doesn't begin with FLTK, as the proposed patch checks already)
Regarding the patch:
(1) The old code is pretty confusing at a first glance; it seems "correct" though. I suggest to use std::string to combine strings in 1.5 because it's easier to write and to read. Unless we wanted to backporat the patch to 1.4, where we might use the patch almost as given. So, if we used std::string we might want to rewrite the entire block that's concerned with setting the class names. But I'm open for "old char string" manipulation as well.I still prefer old string.
(2) As Ian wrote:
> With the patch as-is, we end up with "first_class_name" and the "xclass" name being different - is that something we'd care about?
I think we should. As I understand the code, `first_class_name` is just a static (!) storage of the first class name we set and is used as fallback when other windows are created.
I disagree. Variables class_name (initially) and first_class_name both use FLTK-given names because both are initialized and compared to each other before the FLTK- prefix is added.Then class_name is prefixed (if necessary). It becomes a Windows-specific name and is used in 2 instances:1) recoded to UTF-16 and used by Windows system calls2) used by class_name_list.has_name() to check whether the (prefixed) name was already registered.
I believe this coexistence of non-prefixed FLTK-given names and of prefixed Windows-specific names is correct.
(2) As Ian wrote:
> With the patch as-is, we end up with "first_class_name" and the "xclass" name being different - is that something we'd care about?
I think we should.
Sets the xclass for this window.
A string used to tell the system what type of window this is. Mostly this identifies the picture to draw in the icon. This only works if called before calling show().
...
Under Microsoft Windows, this string is used as the name of the WNDCLASS structure, though it is not clear if this can have any visible effect.
If the default xclass has not yet been set, this also sets the default xclass for all windows created subsequently.
```
Therefore I wouldn't want to overwrite this string if xclass() was set by the user before show()ing a window. However, the question remains: where does this string "editor.exe" or "input.exe" come from in the first place? This should not be there!
Looking at the code: the default "window class" if xclass() is not set (as it should IMHO be in all our demo programs except clock.exe) would be "FLTK" which would prevent this conflict without prefixing the string at all.Therefore I wouldn't want to overwrite this string if xclass() was set by the user before show()ing a window. However, the question remains: where does this string "editor.exe" or "input.exe" come from in the first place? This should not be there!
diff --git a/src/Fl_arg.cxx b/src/Fl_arg.cxx
index 46e9f7073..c78d02564 100644
--- a/src/Fl_arg.cxx
+++ b/src/Fl_arg.cxx
@@ -315,8 +315,10 @@ void Fl_Window::show(int argc, char **argv) {
}
// set the class, which is used by X version of get_system_colors:
+#ifndef _WIN32
if (name) {xclass(name); name = 0;}
else if (!xclass() || !strcmp(xclass(),"FLTK")) xclass(fl_filename_name(argv[0]));
+#endif
if (title) {label(title); title = 0;}
else if (!label()) label(xclass());
$ wine bin/test/editor.exe makeWindow: class_name=FLTK, first_class_name=FLTK, w->xclass=FLTK... as I would expect, and ISTR that window class (xclass) "FLTK" was set in earlier versions. At least, IIRC, under Windows.
On 1/13/26 19:38 'Albrecht Schlosser' wrote:
Therefore I wouldn't want to overwrite this string if xclass() was set by the user before show()ing a window. However, the question remains: where does this string "editor.exe" or "input.exe" come from in the first place? This should not be there!
Well, I found the culprit. It's set in commandline argument parsing: [...]
I disabled as a "quick fix" / workaround the offending statements (see diff above), and I get:
$ wine bin/test/editor.exe makeWindow: class_name=FLTK, first_class_name=FLTK, w->xclass=FLTK... as I would expect, and ISTR that window class (xclass) "FLTK" was set in earlier versions. At least, IIRC, under Windows.
That's something we really need to investigate before we change anything.
$ wine bin/test/hello.exe makeWindow: class_name=FLTK, first_class_name=FLTK, w->xclass=FLTKas expected.
I have no information about why FLTK uses the program name for an app window's xclasswhen command line arguments are processed. Could it be related to recognition by the OSthat a collection of windows belongs to the same process?
It may be meaningful for X11 and not for Windows.
In my app, I use Fl_Window::xclass(const char *) to identify the various kinds of toplevel windowsit uses, allowing a running program to recognize to what kind an Fl_Window belongswithout dynamic_cast.Therefore, a program born under Linux that gives xclass names to its windows may unexpectedlycollide with a system-reserved class name when ported to Windows.For this reason, I believe it's desirable to prefix the user-given xclass name of a window, specificallyunder Windows, to avoid collision with system-reserved types.
Here is the list of window class names reserved by Windows:
For example, replace at the end of test/input.cxx
window->show(argc, argv);
bywindow->xclass ("EDITxxy");
window->show();
and use the unpatched FLTK library. The resulting Windows program no longer enters emojisin its text boxes because the user-chosen "EDITxxy" window class name collides withWindows system-defined "Edit" window class name. Use "EDTxxy" as xclass nameand the resulting app works OK.
……
My proposal is to remove the setting of xclass at commandline parsing time under Windows, and that should be all we need to do. This should be done in 1.5 and higher (not backported to 1.4) and clearly documented. That's it.
Le mercredi 14 janvier 2026 à 17:06:18 UTC+1, Albrecht-S a écrit :
……
My proposal is to remove the setting of xclass at commandline parsing time under Windows, and that should be all we need to do. This should be done in 1.5 and higher (not backported to 1.4) and clearly documented. That's it.
I agree. Do you (Albrecht) volunteer to implement that?
It requires to establish a new platform-dependent code pathabout window classes because what is done under Linux/Unix (use the executable name) would differ
from what is done under Windows (use "FLTK" if class name is empty). Under macOS, I would believe the overriden
function should not change the user-given class name.
My practice of using Fl_Window::xclass(const char *) to avoid dynamic_cast becomes a bit risky because collisions withreserved names under Windows must be avoided. But this can be explained in the documentation.
I'm not sure to agree about not backporting to 1.4: no change prevents to backport emoji support under Windows.
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkcoredev/2ce54183-a4b3-4be9-9d10-7853092203ba%40aljus.de.
I think it is ok to leave this as "FLTK" on both Windows and X11 unless the program actually calls xclass() (which probably nobody does).The intention was to alter what defaults are read from the defaults database depending on the program, but I don't think this ever worked and nobody uses it now.
On an irrelevant tangent - how did Manolo even spot this?I'm so old that the only way I'd have tried to put emoji into a widget would be by accidentally hitting some wrong key sequence - It's not something it would ever occur to me to actually do on purpose!
While I was writing this I got an idea: instead of applying the prefix "FLTK-" as you suggested we can add yet another variable (string) for the optional prefix which users can set by calling (for instance) Fl_Window::xclass_prefix(const char *prefix).
As long as this prefix is `nullptr` (the default) we don't apply a prefix to the class name, but users are free to set such a prefix that will be prepended to all xclass names set by the program. This could even be done in FLTK 1.4 if we wanted. But I don't think that this is necessary at all. Whatever we do should be done in 1.5, and 1.4 should be left alone..
I also believe that FLTK 1.3 failing to input emojis under Windows in an FLTK widget in some casesor displaying them with wrong widths is a bug that merits its fix to be backported from FLTK 1.5 to 1.4.I notice that Ian also supports this.Finally, I also believe leaving FLTK 1.3 in a state where the emoji fix would not work for any programwhose name starts with "edit" is another bug (responsibility is partly shared with Microsoft)that deserves to backport its fix from 1.5. I don't see how this backport would conflict with ABI compatibilityacross 1.3.x because any user- or application- set xclass() value would not be altered by the fix,and because the naming of window classes to the application name is not a documented feature of 1.3.
On Thursday, 15 January 2026 at 03:22:07 UTC Bill wrote:
I think it is ok to leave this as "FLTK" on both Windows and X11 unless the program actually calls xclass() (which probably nobody does).
The intention was to alter what defaults are read from the defaults database depending on the program, but I don't think this ever worked and nobody uses it now.
Some or other WM I was using (can't remember which one, likely some flavour of Ubuntu... and I'm on a Win machine right now so can't check) *was* reading the value set in xclass and using that to label the window icon it created.
I noticed this because a load of little test utilities I'd thrown together, in a bit of a rush, all came up with icons labelled FLTK and I couldn't tell which was which.The FLTK test examples mostly came up with "sensible" labels like "editor" and "input", presumably because their code was setting the exe name as the xclass value.
I don't know if that WM behaviour is "widespread" but if it is, then keeping the *nix builds setting xclass "magically" from show(argc, argv) might be the safe fallback?At least if the user has not explicitly set xclass anyway.
That said, I don't think the Win32 builds need to do that - it seems to be some sort of historical oversight, and as Manolo points out it has "unexpected side effects"...
So, on the basis of not really knowing what I'm talking about, it seems as if _maybe_:- Leaving the *nix version of show() setting xclass to the exe name, if it is not already set by the user, seems like a good thing (or at least harmless)- NOT having the Win32 version of show() set the xclass (i.e. just set it to FLTK unless the user sets it), also seem like the right thing.
If we do that, then we do not have to prepend the xclass value set on Win32 since to will not collide with any MS magic names unless the user does that on purpose. (So then it's their own fault!)
Is that kinda where we have got to with all this? It does look a bit like a bug to me, so maybe should be back-ported into 1.4.x?
On the other aspect of this work - Manolo's fix to handle surrogate pairs under WinXX - that seems like a Good Thing and we should have that anyway. Is that 1.5 only though, or is it back-ported to 1.4.x too?
I believe we now all agree that, under Windows, Fl_Window::show(int, char**) should not set the window's class nameto the executable program name. It should leave untouched whatever value has been set before by the app,and set it to "FLTK" if none has been set yet to avoid a void window class name.
This would remove the group of changes to Fl_win32.cxx in commit 81c965f that is in function Fl_WinAPI_Window_Driver::makeWindow().
This will make the other group of changes in the same commit related to emoji input to work alsofor a program that happens to be named starting with "edit", such as program test/editor.
I also believe that FLTK 1.4 failing to input emojis under Windows in an FLTK widget in some cases
or displaying them with wrong widths is a bug that merits its fix to be backported from FLTK 1.5 to 1.4.I notice that Ian also supports this.
Finally, I also believe leaving FLTK 1.4 in a state where the emoji fix would not work for any program
whose name starts with "edit" is another bug (responsibility is partly shared with Microsoft)that deserves to backport its fix from 1.5. I don't see how this backport would conflict with ABI compatibility
across 1.4.x because any user- or application- set xclass() value would not be altered by the fix,and because the naming of window classes to the application name is not a documented feature of 1.4.
Le mercredi 14 janvier 2026 à 22:45:28 UTC+1, Albrecht-S a écrit :
While I was writing this I got an idea: instead of applying the prefix "FLTK-" as you suggested we can add yet another variable (string) for the optional prefix which users can set by calling (for instance) Fl_Window::xclass_prefix(const char *prefix). [...]
I don't support this proposal. It's purpose it too minuscule.
Regarding xclass, perhaps stating the
obvious, and not reading all the text in this long thread:
Just adding I have a hazy memory that setting the xclass
affected the display of app icons in certain contexts to work
properly, IIRC esp. under either windows or Linux, be it in the
dock or the corner of the window title bar while the app is
running, or or desktop/folder browser icons to browse the
executable before running it.
This may have something to do with why it's set during
show(argc,argv) to help the app display those icons properly at
runtime, not sure.
I've found with old SVN commits, if the commit msg and
related STR aren't enough, you could sometimes get more context
about a confusing code change by looking at old newsgroup posts
made around the same date as the change (e.g. same day or going
back a week or so, while an issue gets hashed out) We don't have
newsgroup messages going back before 2003 due to a server crash
around that time, so changes made in e.g. 1998 won't have this,
but commits made 2003 on forward might give some extra info.
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkcoredev/d42052f3-47b4-47dc-bdaa-44bff127995a%40seriss.com.