In principal a demo just for Mac would be fine. However the differences are very small.salvadordf wrote: Wed Feb 17, 2021 10:25 am I see that you've moved the MacOS demo to a new directory and you added support for other OSs.
CEF and Chromium have very different ways of doing things depending on the OS and widgetset used.
A few examples would be :Having all that in one demo is possible but I would recommend that we focus on a demo only for MacOS because adding support for other OSs only takes time away from having a full MacOS demo.
- Unique app bundles for Mac.
- Different ways to resize, show and hide the internal browser view in Windows, Linux and probably MacOS.
- Different destruction steps.
- Different ways to handle the web page image in OSR mode.
- etc.
The combined demo has, but a very few IFDEF. So with the existing of that combined demo, I am not sure if there really still is the need for the Mac only demo.
And about the combined demo: Many Lazarus users write their apps, and cross compile them. Mac may not be the most frequented target, but Linux+Win is probably common.
Those users need a demo, how to write code that compiles for all required targets. So IMHO a good idea.
I am even working on a subclassed component, that will handle most of the stuff that is currently in the user code (size events, close events, start in timer, ....). I got it working on my machines already. But more on that later.
The demo only shows the TCefLinkedParentWindow.salvadordf wrote: Wed Feb 17, 2021 10:25 am In general, CEF is more complicated to use than TWebBrowser and I decided to create more demos that were easier to understand and maintain.
Most of the current demos (not all) show how to do a reduced set of things and this should make it easier for the developers to take the code they need from the demos to their own applications. Small changes in the CEF API, which are not infrequent, are also easier to detect and fix this way.
And it only shows ExternalPump.
So on Linux and Win it can be run with the threaded message-loop too.
The only in consequent bit is that it mixes External/Separate Subprocess and build in.
- That is, on Mac the SubProcess must be a different exe (actually 4 copies of one different exe)
- But on Windows and Linux the demo uses the main-project as subprocess. Which indeed adds a few lines of code.
For Win/Linux the demo includes (commented) the code for using a separate exe. That is one single line to uncomment. (And a few lines that could get commented instead, but are kept)
This is the one thing, that could have been put into a separate demo.
On the other hand for me the amount of demos is rather confusing (to some part still is). There is no (or I have not found) detail on where the demos differ.
Even demos with the same name, do not do the same thing. ExternalPump for Linux uses TCefLinkedWindowParent but for Windos it uses TCefWindowParent. That is despite the former works on windows too. The latter exists on Windows only.
So as a user I can not even compare the examples for target-diffs. Let alone that even equal examples, over time got more and more different. Just code moved to diff locations. Or changes that could work on all targets applied to only one (IIRC, need doublecheck).
salvadordf wrote: Wed Feb 17, 2021 10:25 am About the shutdown issues, there are a couple of suggestions :
- Windows and Linux have slightly different destruction steps that need to be implemented in order to avoid shutdown issues. As you can see in the "ExternalMessageBrowser" demos, the TChromium.OnClose event sets a different value for the aAction parameter because the Windows demo needs to destroy CEFWindowParent1. That is necessary to receive the TChromium.OnBeforeClose event and then close the main form. The Linux demo in the other hand doesn't need all that and you can set aAction to cbaClose to continue closing the browser. I would have to learn a lot more about MacOS and check the CEF sources to know what MacOS needs for that event in a Lazarus demo.
I missed the GlobalCEFWorkScheduler.StopSchedulersalvadordf wrote: Wed Feb 17, 2021 10:25 am [*]The other "ExternalMessageBrowser" demos have some extra code in the LPR file to free the main application form and call GlobalCEFWorkScheduler.StopScheduler before the DestroyGlobalCEFApp and DestroyGlobalCEFWorkScheduler calls. This is also necessary to avoid shutdown issues. https://github.com/salvadordf/CEF4Delphi/blob/master/demos/Lazarus_Linux/ExternalPumpBrowser/ExternalPumpBrowser.lpr
[/list]
I will take a look.
I moved as much of the lpr code as possible into other units. This is to avoid the user having to edit the lpr file to much.
The only thing still needed in the lpr is one unit in the uses clause, that has to be before "Interfaces" so it can intercept the start up, before the LCL widgetset starts. And create the CEF app.
I do not know for sure, but does that order (cef vs widgetset) affect the subprocess only, or also the main app?
Because if it is subprocess only, and the user uses AppHelper, then they would need no change to the lpr at all.