Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Linux Console Application

alfredapple
Posts: 9
Joined: Tue Mar 12, 2024 1:21 pm

Linux Console Application

Post by alfredapple »

Is it possible to use CEF4Delphi in a Linux Console Application? Without using any forms?
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Linux Console Application

Post by salvadordf »

Hi,

I've never tried that but I guess it should be possible.

You can port the Lazarus_Windows/ConsoleBrowser2 demo to Linux.
You will probably have to replace some of its code with the code from the Lazarus_Linux_GTK3/OSRExternalPumpBrowser demo.
alfredapple
Posts: 9
Joined: Tue Mar 12, 2024 1:21 pm

Re: Linux Console Application

Post by alfredapple »

Thank you. I can't believe how couldn't I see ConsoleBrowser2 demo.

I am trying to port it now. If I am successful, I will share here.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Linux Console Application

Post by salvadordf »

I'm also creating a new console demo that should work on Linux. ;)
Your message made me realize that it was missing.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Linux Console Application

Post by salvadordf »

I just uploaded the Lazarus_Linux_Console/ConsoleBrowser demo to GitHub.

It just takes a snapshot of the default URL and saves it as snapshot.png.

It uses a browser in OSR mode with a second executable for the CEF subprocesses.
alfredapple
Posts: 9
Joined: Tue Mar 12, 2024 1:21 pm

Re: Linux Console Application

Post by alfredapple »

Thank you. You are great.
dominicelliott
Posts: 6
Joined: Tue Mar 26, 2024 4:30 am

Re: Linux Console Application

Post by dominicelliott »

alfredapple wrote: Tue Mar 12, 2024 1:23 pm Is it possible to use CEF4Delphi in a Linux Console Application? Without using any forms?
I also tried and it didn't work :( :( :(
alfredapple
Posts: 9
Joined: Tue Mar 12, 2024 1:21 pm

Re: Linux Console Application

Post by alfredapple »

salvadordf wrote: Thu Mar 14, 2024 7:08 pm I just uploaded the Lazarus_Linux_Console/ConsoleBrowser demo to GitHub.

It just takes a snapshot of the default URL and saves it as snapshot.png.

It uses a browser in OSR mode with a second executable for the CEF subprocesses.
I am trying to use CefRegisterExtension function on the demo, but OnWebKitInitialized is not running. Can you help about this?
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Linux Console Application

Post by salvadordf »

That event is called on the render subprocess and Lazarus debugs the main browser process.

Read this document if you need to debug the code in that event :
https://www.briskbard.com/index.php?lang=en&pageid=cef#debugging

Edit :
The demos that use a different executable for the CEF subprocesses have to implement the events that run in CEF subprocesses in the subprocess project. For example, the Lazarus_Windows/JavaScript/JSWindowBindingSubProcess demo implements OnContextCreated in SubProcess.lpr
alfredapple
Posts: 9
Joined: Tue Mar 12, 2024 1:21 pm

Re: Linux Console Application

Post by alfredapple »

Hmm..

It seems like it's executing while I set GlobalCEFApp.SingleProcess := True;

but it's not executing when it's false.

Why is that?
Post Reply