FLTK logo

Re: [fltk.coredev] Towards a Wayland platform for the FLTK library ?

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Towards a Wayland platform for the FLTK library ? Bill Spitzak Jun 07, 2021  
 
FLTK2 did change it so there was not a fallback in the if statements, making it easy to rearrange them and to make it clear when things were for X11. I certainly agree this should be done here too.

What I was saying is that the contents of the if statements were #include statements. This put each machine's code in it's own file, without any overhead of virtual functions.


On Mon, Jun 7, 2021 at 3:17 PM Albrecht Schlosser <AlbrechtS.fltk@online.de> wrote:
On 6/7/21 11:41 PM Greg Ercolano wrote:

On 6/7/21 2:26 PM, Bill Spitzak wrote:

What I meant for Device was to replace it with code like this:

#if X11
#include <X11code.C>
#elif Windows
#include <Windowscode.C>
I had used that technique in the native file chooser, but it was changed.

That technique was generally recommended IIRC in an old O'Reilly book
on multiple platform code management
I've had for decades now.

And that's exactly the point. It's decades old!

This type of code is not at all scalable (by platform). You can see this in our old (1.3) code that has exactly that, with the (above missing) #else case. It was usually something like:

#ifdef _WIN32 // Windows
...
#elif defined(__APPLE__) // macOS
...
#else // X11
...
#endif

which *implied* that the #else case is Unix/Linux/X11. This also precluded (basically) using X11 on macOS (which is definitely possible). Whenever you add another device/platform/driver/backend (call it as you like) you need to add yet another #elif case at *uncountable* places. That's the nightmare we got rid of by moving to the "driver" structure.

This driver structure is unlimited extensible by adding "just another class" with selected virtual methods that need to be overridden (sharing the code of not overridden methods). This is the ideal case. You can see it in the drawing code of the Wayland graphics driver which reuses existing Cairo driver code.

In practice, I admit, this is not as easy as it sounds. It tends to "copy and paste" code from one driver to another one, fix the "few statements" that need to be replaced, and then you end up with lots of duplicated code that needs to be maintained (mainly in the system specific parts). That's bad and not intended. The "correct" way needs a finer granularity of functions (virtual methods) and a good design. This is harder to achieve but possible (and that's why I asked Manolo about the current status of his edits and his plans for completion).

Example: We have three totally different ways to implement timer related code: Unix/Linux (Posix), Windows, and macOS. This led to incompatibilities (macOS) and lack of accuracy (Windows). I don't want to write about more details here, but I believe that a better implementation would be doable in platform-agnostic code with only minor system specific functions (here: virtual driver methods). Copying the Linux/Unix/Posix code to "Wayland drivers" (which has been done during the development) is NOT the final solution (hopefully). That's only one example...

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/13c59d6a-ef8b-298b-c932-e3858c8803dc%40online.de.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/CAL-8oAiSbMqjbmfE-rsmsr8D7EC2HViJ6DuZSMddUZX9REAfrQ%40mail.gmail.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.