In light of Manolo's Fl_Native_Input, I decided to propose this now. I was originally waiting for a few CMake changes that Albrecht was planning.
Idea:Add widgets, drivers, libraries, fluid plugins, and tests to FLTK core at configuration time, using a single `cmake -D...` option. This is meant as an in-between step between a truly external widget, and a widget that is an integral part of the core library.Reasoning:I created an issue years ago with an interrupted implementation of the SDL driver, adding work for everyone else while I could not wrap the project up. We ended up dragging the cow around for a while, until I decided to remove it from master. For the second round, I envisioned "Add Ons". Basically a way to add The concept ist here. It only allows for adding tests, but can easily be expanded for the list above.
How difficult is it for the developer:The developer can create they add-on independently. He needs to add one or more files that are included by CMake. The rest of the structure is a mirror of the existing FLTK structure.
So make a repo with directory somewhere.
Add a test in the `tests` directory, and create `CMake/fl_addon_test.cmake`.
What changes for core developers:Not much. Statements like `fl_include_all(FLTK_CORE_ADDONS "CMake/fl_addon_test.cmake")` will be placed at five strategic positions. That's all.
……
Le mardi 6 mai 2025 à 11:42:56 UTC+2, melcher....@googlemail.com a écrit :I created an issue years ago with an interrupted implementation of the SDL driver, adding work for everyone else while I could not wrap the project up. We ended up dragging the cow around for a while, until I decided to remove it from master. For the second round, I envisioned "Add Ons". Basically a way to add The concept ist here. It only allows for adding tests, but can easily be expanded for the list above."The list above": what list?
Is this a complete modification of the FLTK source tree? or just a preliminary draft of what is aimed at?
The developer can create they add-on independently. He needs to add one or more files that are included by CMake. The rest of the structure is a mirror of the existing FLTK structure.Does that mean duplicating the FLTK source tree in another git repo?
So make a repo with directory somewhere.I don't understand this sentence.
Add a test in the `tests` directory, and create `CMake/fl_addon_test.cmake`.Is it the test directory of the FLTK source tree?
What changes for core developers:Not much. Statements like `fl_include_all(FLTK_CORE_ADDONS "CMake/fl_addon_test.cmake")` will be placed at five strategic positions. That's all.What are these strategic positions?
Matthias: could you, for example, prepare and present a complete rewrite of the Fl_Native_Input proposal in the form of an FLTK add-on?
The plan is to add four more lines like `fl_include_all(FLTK_CORE_ADDONS "CMake/fl_addon_test.cmake")` for the other add-on types in src/CMakeLists.txt, src/drivers/CMakeLists.txt, fluid/CMakeLists.txt .
Matthias: could you, for example, prepare and present a complete rewrite of the Fl_Native_Input proposal in the form of an FLTK add-on?
I will try to find the time tonight. I want to know myself if this is a good alternative.
……
(1) Regarding Manolo's proposal: I believe we need to review the code and we'd likely need more testers (as Ian wrote, maybe Chinese or other Eastern languages/scripts). I'm willing to review the code but I'm likely not able to test any input methods.
cmake -B build -DFLTK_CORE_ADDONS="../fltk-addons-1.5.git/Fl_Native_Input"
Ok, I added Native Input for macOS to fltk-addons. Just pull both repos and:cmake -B build -DFLTK_CORE_ADDONS="../fltk-addons-1.5.git/Fl_Native_Input"
…… the single little change needed in FLTK core.
Without it, arrow keys don't move the cursor in the native_input demo prog.
Le vendredi 9 mai 2025 à 07:40:42 UTC+2, Manolo a écrit :
…… the single little change needed in FLTK core.Without it, arrow keys don't move the cursor in the native_input demo prog.
This illustrates a constraint of the add-on model, if I understand it correctly:an add-on should not depend on any change of the FLTK core source code.
...
Matthias: is that correct? or would you see another way to go?
……
I should be able to add myself the code for other platforms.
Le vendredi 9 mai 2025 à 07:40:42 UTC+2, Manolo a écrit :…… the single little change needed in FLTK core.Without it, arrow keys don't move the cursor in the native_input demo prog.This illustrates a constraint of the add-on model, if I understand it correctly:an add-on should not depend on any change of the FLTK core source code.Class Fl_Native_Input does require a (tiny) change in the core, for the macOSplatform only. I don't think it can be done without this change.
Matthias: is that correct? or would you see another way to go?
The Wayland additional link dependency modification is ok that way. Just by reading it, I don't know what's wrong. Maybe OPTIONAL_LIBS is not set yet when the add-on is included. This is just a proof of concept at this point, and either the position of the include_all line can move, or the instantiation of OPTIONAL_LIBS can move - if that is what is causing your issues.
Le samedi 10 mai 2025 à 00:44:15 UTC+2, melcher....@googlemail.com a écrit :
The Wayland additional link dependency modification is ok that way. Just by reading it, I don't know what's wrong. Maybe OPTIONAL_LIBS is not set yet when the add-on is included. This is just a proof of concept at this point, and either the position of the include_all line can move, or the instantiation of OPTIONAL_LIBS can move - if that is what is causing your issues.
OK. I've found the following patches allow for an addon to require additional libraries at link stage:
1) patch to the FLTK source tree, adapted to allow for add-ons (fltk-for-addons)2) patch to the add-on source tree (addons-optional-libs)
These initialize a new cmake variable named FL_ADDON_OPTIONAL_LIBS containing extra librariesand later call macro append_optional_libs() for each such library.
BTW: Mozilla call their extensions "addons" (not "add-ons"). I suggest to use (and I use below) this spelling for FLTK as well. I hope you agree to do this also in the "official version".
On 5/10/25 08:26 Manolo wrote:
Le samedi 10 mai 2025 à 00:44:15 UTC+2, melcher....@googlemail.com a écrit :
The Wayland additional link dependency modification is ok that way. Just by reading it, I don't know what's wrong. Maybe OPTIONAL_LIBS is not set yet when the add-on is included. This is just a proof of concept at this point, and either the position of the include_all line can move, or the instantiation of OPTIONAL_LIBS can move - if that is what is causing your issues.@Matthias, to clarify: the problem was that the CMake variable `OPTIONAL_LIBS` was not used in your version (rewritten as an addon). Dealing with this variable (and `OPTIONAL_INCLUDES`) is something I plan to improve (maybe rewrite completely) anyway.
……
That is very easy to fix without adding another variable. Just move the line 662 `set(OPTIONAL_LIBS)` to the beginning of src/CMakeLists.txt . That will make it available in the addon. Then you can insert the line `list(APPEND OPTIONAL_LIBS Pkgconfig::GTK3)` and it should work fine. There are some other places where a similar strategy makes sense.
Le dimanche 11 mai 2025 à 13:02:18 UTC+2, Albrecht-S a écrit :@Manolo: for the time being you could try to use something like my code in your addon.
I've found the following patches allow for the Fl_Native_Input addon using your approach (Albrecht's):
1) patch to the FLTK source tree, adapted to allow for addons (fltk-for-addonsV2.patch.txt)2) patch to the Fl_Native_Input addon source tree (addons-Fl_Native_InputV2.patch.txt)
@Matthias: would you agree to commit these or a variant of them to your addon FLTK fork?
Thanks, Manolo, your new patches look like a step in the right direction, although they are IMHO not yet perfect.
Ok, I added Native Input for macOS to fltk-addons. Just pull both repos and:
cmake -B build -DFLTK_CORE_ADDONS="../fltk-addons-1.5.git/Fl_Native_Input"
Mathias, I have v0.1.2 of my Vulkan driver that you could try cleaning up and testing with your addons framework.
$ git clone https://github.com/ggarra13/fltk.git
$ git switch vk
$ vulkan_*.sh for your different platforms (Windows needs MSys2
for the shell script to work).
There's three Vulkan demos:
vk_shape - similar to the gl one.
vk_shape_textured - shape with a texture and depth updated
vk_cube - similar to the gl one but of course without FLTK
widgets.
The code is now in use in my viewer and these are my findings so
far:
1) Vulkan, at least with NVidia drivers, is not equivalent to
OpenGL in terms of performance. I could not get 60fps at 4K. The
best I got was 40fps.
2) Transparent textures perform badly on NVidia graphics cards (my
RTX 3080) -- ie. text rendering
3) AMD graphics card on my macOS Intel performs really good
(but...)
4) macOS Intel implementation through Vulkan is buggy. I got
redraw issues with the same code that works fine on Windows and
Linux.
-- Gonzalo Garramuño ggar...@gmail.com
Le samedi 17 mai 2025 à 13:44:10 UTC+2, Albrecht-S a écrit :
Sorry, I forgot one question about the added code in Fl_Cocoa.mm:
+ if ([[self window] firstResponder] != self) {
+ return NO;
IIRC there was an issue with two consecutive '[[' in an old macOS version, or something similar. The solution was to use parentheses like this:
+ if ([([self window]) firstResponder] != self) {
+ return NO;
Shouldn't this be done here as well?
This is typical objective-c code. There are 103 occurrences of '[[' in file Fl_cocoa.mm. I don't remember the issue you think aboutbut it must have been a misunderstanding.
The real question is different.
Fl_Native_Input requires a tiny but unavoidable change to FLTK-core.How to do that in the addon model?
I confess I'm still quite wary of this model exactly because new stuff often requires accompanying changes to the core.
On 5/17/25 14:08 Manolo wrote:
Le samedi 17 mai 2025 à 13:44:10 UTC+2, Albrecht-S a écrit :
IIRC there was an issue with two consecutive '[[' in an old macOS version, or something similar. The solution was to use parentheses like this:
+ if ([([self window]) firstResponder] != self) {
+ return NO;
Shouldn't this be done here as well?
This is typical objective-c code. There are 103 occurrences of '[[' in file Fl_cocoa.mm. I don't remember the issue you think aboutbut it must have been a misunderstanding.The report was in issue #1245, the fix was done by PR #1246 in commit 8b8d92a313f97d5e0e2290ec880758d8606e83c3.
Another question is whether we can or should add your suggested change to Fl_Cocoa.mm to the core anyway. Would it be useful, would it do any harm, or ... ? Of course, this wouldn't solve the issue of patching the core code in general if necessary, but it would resolve *this* case. I'm asking these questions because I have no idea what this code does, and why it would be needed for the addon.
That issue arose because two '[' characters of different syntactic values where consecutive, the first was opening a C-style array index,the second was opening an Objective-C message. This situation, I understand, can be a problem for compilation and should be avoided.
The modification to Fl_cocoa.mm under discussion here reads[[self window] firstResponder]which is pure Objective-C++. No mixed-type, consecutive '['.
So, please, Albrecht, stop worrying every time you read '[[' because you'll see many. (:=)
Le dimanche 18 mai 2025 à 00:44:35 UTC+2, Albrecht-S a écrit :
Another question is whether we can or should add your suggested change to Fl_Cocoa.mm to the core anyway. Would it be useful, would it do any harm, or ... ? Of course, this wouldn't solve the issue of patching the core code in general ...
This would not be useful nor would do harm to FLTK, unless an Fl_Native_Inputobject gets created, because the if condition involved would always be FALSE.
[detailed explanation removed]
Thus, this code change can be inserted to FLTK without any risk, but makes sense onlyif class Fl_Native_Input is added, or more exactly if FLTK begins to usefocus-accepting macOS native cocoa widgets, something that is not true as of today.
Overall, it doesn't seem natural to separate this code addition to Fl_cocoa.mm fromthe creation of the Fl_Native_Input class, although this would do no harm.
Generally, I'm afraid that the addon model will narly aelways stumble on big or small
changes to the core required by a proposed addition. For example, didn't classesFl_Flex and/or Fl_Grid require the creation of the virtual member functionFl_Group::on_remove(int) ?
add-ons are not completely thought out yet. This is just a tech demo, but SDL and Native_Input would be great starting point.
Matthias: there's now a new github repository https://github.com/ManoloFLTK/Fl_Native_Input containingclass Fl_Native_Input in the form of an FLTK addon.