webview / webview

Tiny cross-platform webview library for C/C++. Uses WebKit (GTK/Cocoa) and Edge WebView2 (Windows).
https://webview.dev
MIT License
12.44k stars 931 forks source link

Multiple window support - feature request #1121

Open gitgit3 opened 1 month ago

gitgit3 commented 1 month ago

Greetings webview crew. I am a newby. Maybe this is something that can be done but in a different way, please let me know.

Because the 'run' method blocks, it's not possible to use the main thread for anything. Is there a possibility of allowing access to the main message loop. I have implemented a simple version by calling the gtk_main_iteration_do() method by adding a 'step' call to the webview api. This allows me to run my own message loop calling 'step' for each window in my app.

How is this API designed to be used, since the 'run' method blocks, you would need to create additional threads. I am not familiar with the GTK model, so I maybe way out here.

Any thoughts welcome.

gitgit3 commented 1 month ago

I have implemented this for GTK if anyone is interested. But I don't have the OS's to write and test the MS and Mac versions.

neroist commented 1 month ago

How does your GTK implementation look like?

gitgit3 commented 1 month ago

I was just going to attach my version of webview.h but it's not allowed!

I could git pull and branch, but how do I upload?

neroist commented 1 month ago

Could you put your changes on a fork then git push?

gitgit3 commented 1 month ago

Creating a "personal access token", what a royal pain in the butt...

Here's my fork https://github.com/gitgit3/webview-jkp

It's not weapons grade code to be honest. I've not fixed the run() method to close without a gtk error, but I'm not using run() in my project.

There's also some hardcoded title-bar styling for child windows which can be ignored, although it would be nice to do that properly if multiple windows are supported.