Tiny cross-platform webview library for C/C++/Golang. Uses WebKit (Gtk/Cocoa) and Edge (Windows)

Overview

webview

Join the chat at https://gitter.im/zserge/webview Build Status GoDoc Go Report Card

A tiny cross-platform webview library for C/C++/Golang to build modern cross-platform GUIs. Also, there are Rust bindings, Python bindings, Nim bindings, Haskell, C# bindings and Java bindings available.

The goal of the project is to create a common HTML5 UI abstraction layer for the most widely used platforms.

It supports two-way JavaScript bindings (to call JavaScript from C/C++/Go and to call C/C++/Go from JavaScript).

It uses Cocoa/WebKit on macOS, gtk-webkit2 on Linux and Edge on Windows 10.

Webview for Go developers

If you are interested in writing Webview apps in C/C++, skip to the next section.

Getting started

Install Webview library with go get:

$ go get github.com/webview/webview

Import the package and start using it:

package main

import "github.com/webview/webview"

func main() {
	debug := true
	w := webview.New(debug)
	defer w.Destroy()
	w.SetTitle("Minimal webview example")
	w.SetSize(800, 600, webview.HintNone)
	w.Navigate("https://en.m.wikipedia.org/wiki/Main_Page")
	w.Run()
}

To build the app use the following commands:

# Linux
$ go build -o webview-example && ./webview-example

# MacOS uses app bundles for GUI apps
$ mkdir -p example.app/Contents/MacOS
$ go build -o example.app/Contents/MacOS/example
$ open example.app # Or click on the app in Finder

# Windows requires special linker flags for GUI apps.
# It's also recommended to use TDM-GCC-64 compiler for CGo.
# http://tdm-gcc.tdragon.net/download
$ go build -ldflags="-H windowsgui" -o webview-example.exe

For more details see godoc.

Distributing webview apps

On Linux you get a standalone executable. It will depend on GTK3 and GtkWebkit2, so if you distribute your app in DEB or RPM format include those dependencies. An application icon can be specified by providing a .desktop file.

On MacOS you are likely to ship an app bundle. Make the following directory structure and just zip it:

example.app
└── Contents
    ├── Info.plist
    ├── MacOS
    |   └── example
    └── Resources
        └── example.icns

Here, Info.plist is a property list file and *.icns is a special icon format. You may convert PNG to icns online.

On Windows you probably would like to have a custom icon for your executable. It can be done by providing a resource file, compiling it and linking with it. Typically, windres utility is used to compile resources. Also, on Windows, webview.dll and WebView2Loader.dll must be placed into the same directory with your app executable.

Also, if you want to cross-compile your webview app - use xgo.

Migrating from v0.1.1 to v0.10.0

  1. webview.Open() has been removed. Use other webview APIs to create a window, open a link and run main UI loop.
  2. webview.Debug() and webview.Debugf() have been removed. Use your favorite logging library to debug webview apps.
  3. webview.Settings struct has been removed. Title, URL and size are controlled via other API setters and can be updated at any time, not only when webview is created.
  4. Webview.Loop() has been removed. Use Run() instead.
  5. WebView.Run(), WebView.Terminate(), WebView.SetTitle(), WebView.Dispatch() stayed the same.
  6. WebView.Exit() has been renamed to WebView.Destroy()
  7. WebView.SetColor() and WebView.SetFullScreen() have been removed. Use Window() to get native window handle and probably write some Cgo code to adjust native window to your taste.
  8. webview.Dialog has been removed. But it is likely to be brought back as a standalone module.
  9. WebView.Eval() remained the same.
  10. WebView.InjectCSS() has been removed. Use eval to inject style tag with CSS inside.
  11. WebView.Bind() kept the name, but changed the semantics. Only functions can be bound. Not the structs, like in Lorca.

Webview for C/C++ developers

Download webview.h and include it in your C/C++ code:

C++:

// main.cc
#include "webview.h"
#ifdef WIN32
int WINAPI WinMain(HINSTANCE hInt, HINSTANCE hPrevInst, LPSTR lpCmdLine,
                   int nCmdShow) {
#else
int main() {
#endif
  webview::webview w(true, nullptr);
  w.set_title("Minimal example");
  w.set_size(480, 320, WEBVIEW_HINT_NONE);
  w.navigate("https://en.m.wikipedia.org/wiki/Main_Page");
  w.run();
  return 0;
}

Build it:

# Linux
$ c++ main.cc `pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.0` -o webview-example
# MacOS
$ c++ main.cc -std=c++11 -framework WebKit -o webview-example
# Windows (x64)
$ c++ main.cc -mwindows -L./dll/x64 -lwebview -lWebView2Loader -o webview-example.exe

C:

// main .c
#include "webview.h"
#ifdef WIN32
int WINAPI WinMain(HINSTANCE hInt, HINSTANCE hPrevInst, LPSTR lpCmdLine,
                   int nCmdShow) {
#else
int main() {
#endif
	webview_t w = webview_create(0, NULL);
	webview_set_title(w, "Webview Example");
	webview_set_size(w, 480, 320, WEBVIEW_HINT_NONE);
	webview_navigate(w, "https://en.m.wikipedia.org/wiki/Main_Page");
	webview_run(w);
	webview_destroy(w);
	return 0;
}

Build it:

# Linux
$ g++ main.c `pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.0` -o webview-example
# MacOS
$ g++ main.c -std=c++11 -framework WebKit -o webview-example
# Windows (x64)
$ g++ main.c -mwindows -L./dll/x64 -lwebview -lWebView2Loader -o webview-example.exe

On Windows it is possible to use webview library directly when compiling with cl.exe, but WebView2Loader.dll is still required. To use MinGW you may dynamically link prebuilt webview.dll (this approach is used in Cgo bindings).

Full C/C++ API is described at the top of the webview.h file.

Migrating from v0.1.1 to v0.10.0

  1. Use opaque webview_t type instead of struct webview. Size, title and URL are controlled via API setter functions. Invoke callback has been replaced with webview_bind() and webview_return() to make native function bindings inter-operate with JS.
  2. If you have been using simplified webview() API to only open a single URL in a webview window - this function has been removed. You now have to create a new webview instance, configure and run it explicitly.
  3. webview_init() is replaced by webview_create() which creates a new webview instance.
  4. webview_exit() has been replaced with more meaningful webview_destroy().
  5. Main UI loop with webview_loop() inside has been replaced with webview_run() runs infinitely until the webview window is closed.
  6. webview_terminate() remains the same.
  7. webview_dispatch() remains the same.
  8. webview_set_title() remains the same.
  9. webview_set_color() has been removed. Use webview_get_window and native window APIs to control colors, transparency and other native window properties. At some point these APIs might be brought back.
  10. webview_set_fullscreen() has been removed, see above.
  11. webview_dialog() has been removed. But I'd like to see it added back as a separate independent module or library.
  12. webview_eval() remains the same.
  13. webview_inject_css() has been removed. Use webview_eval() to create style tag manually.
  14. webview_debug() has been removed. Use whatever fits best to your programming language and environment to debug your GUI apps.

Notes

Execution on OpenBSD requires wxallowed mount(8) option. For Ubuntu Users run sudo apt install webkit2gtk-4.0(Try with webkit2gtk-4.0-dev if webkit2gtk-4.0 is not found) to install webkit2gtk-4.0 related items. FreeBSD is also supported, to install webkit2 run pkg install webkit2-gtk3.

License

Code is distributed under MIT license, feel free to use it in your proprietary projects as well.

Comments
  • Setting the Window Icon?

    Setting the Window Icon?

    Is there a way to set the window icon on Windows yet? i.e. the top left corner of the Webview window?

    Using Go 1.18.3 on Windows 11. But will need it for MacOS and Linux too.

    Thanks

    opened by precisionpete 45
  • Use Windows.UI.Xaml.Controls.WebView where possible on Windows

    Use Windows.UI.Xaml.Controls.WebView where possible on Windows

    There are plenty of serious reasons to prefer EdgeHTML to MSHTML; Edge is a more modern target than IE, with various features that you can’t get on IE.

    In Universal Windows Apps, Windows.UI.Xaml.Controls.WebView uses IE11 on Windows 8 and Edge on Windows 10.

    I don’t know how you would go about doing it and I’m not certain it’s possible to do both in the one binary (though I imagine it is), but the ideal situation is to try to use the UWP WebView where possible, before falling back to the old MSHTML.

    I expect this would require using some C++/CX.

    I expect that implementing this will involve quite a bit of research and development, but it should be possible and is very desirable.

    opened by chris-morgan 29
  • Added icon switching demo for Windows & Linux

    Added icon switching demo for Windows & Linux

    Added a simple demo of changing the webview icon at runtime for Windows, as discussed in #686

    Ideally, would be great to see this expanded with working examples for Linux and MacOS.

    Discussion points:

    • syso files need to be generated with https://github.com/tc-hib/go-winres. Should they be included in the demo, or just explained in main.go?
    • The DLL files in https://github.com/webview/webview/tree/master/dll leads to an immediate crash. #658 #632 The DLL files in https://github.com/webview/webview_csharp/tree/master/libs do appear to work in my limited testing.

    Let me know if I can futher assist.

    help wanted 
    opened by ldstein 22
  • Can't compile example with golang.

    Can't compile example with golang.

    What OS are you using (uname -a, or Windows version)?

    Windows 10 Pro 1903(18362.657)

    What programming language are you using (C/C++/Go/Rust)?

    Go:

    go version go1.14 windows/amd64

    Gcc:

    Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=C:/TDM-GCC-64/bin/../libexec/gcc/x86_64-w64-mingw32/5.1.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../../../src/gcc-5.1.0/configure --build=x86_64-w64-mingw32 --enable-targets=all --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-libgomp --enable-lto --enable-graphite --enable-cxx-flags=-DWINPTHREAD_STATIC --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-libstdcxx-debug --enable-threads=posix --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libstdcxx-threads --enable-libstdcxx-time --with-gnu-ld --disable-werror --disable-nls --disable-win32-registry --prefix=/mingw64tdm --with-local-prefix=/mingw64tdm --with-pkgversion=tdm64-1 --with-bugurl=http://tdm-gcc.tdragon.net/bugs Thread model: posix gcc version 5.1.0 (tdm64-1)

    What did you expect to see and what you saw instead?

    Hello, i can't compile example with go. Some errors occured:

    go build -ldflags="-H windowsgui" -o webview-example.exe

    # github.com/zserge/webview C:\Users\BEZRAZ~1\AppData\Local\Temp\go-build996545186\b002\_x002.o: In functionCgoWebViewBind': C:/Users/bezrazli4n0/go/src/github.com/zserge/webview/webview.go:41: undefined reference to webview_bind' C:\Users\BEZRAZ~1\AppData\Local\Temp\go-build996545186\b002\_x002.o: In function_cgo_513c5b174c28_Cfunc_webview_return': /tmp/go-build/cgo-gcc-prolog:181: undefined reference to webview_return' collect2.exe: error: ld returned 1 exit status

    opened by bezrazli4n0 22
  • Go: Failed to compile with mingw

    Go: Failed to compile with mingw

    What OS are you using (uname -a, or Windows version)?

    windows 10

    What programming language are you using (C/C++/Go/Rust)?

    Go

    What did you expect to see and what you saw instead?

    When I run go get -u "github.com/webview/webview", it shows me following:

    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmingwthrd.a when searching for -lmingwthrd
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libmingwthrd.a when searching for -lmingwthrd
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmingwthrd.a when searching for -lmingwthrd
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingwthrd
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmingw32.a when searching for -lmingw32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libmingw32.a when searching for -lmingw32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmingw32.a when searching for -lmingw32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingw32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgcc.a when searching for -lgcc
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0\libgcc.a when searching for -lgcc
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgcc.a when searching for -lgcc
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgcc_eh.a when searching for -lgcc_eh
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0\libgcc_eh.a when searching for -lgcc_eh
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgcc_eh.a when searching for -lgcc_eh
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_eh
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmoldname.a when searching for -lmoldname
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libmoldname.a when searching for -lmoldname
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmoldname.a when searching for -lmoldname
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmoldname
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmingwex.a when searching for -lmingwex
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libmingwex.a when searching for -lmingwex
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmingwex.a when searching for -lmingwex
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingwex
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmsvcrt.a when searching for -lmsvcrt
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libmsvcrt.a when searching for -lmsvcrt
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmsvcrt.a when searching for -lmsvcrt
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmsvcrt
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libpthread.dll.a when searching for -lpthread
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libpthread.a when searching for -lpthread
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libpthread.a when searching for -lpthread
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libpthread.dll.a when searching for -lpthread
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libpthread.a when searching for -lpthread
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lpthread
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libadvapi32.a when searching for -ladvapi32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libadvapi32.a when searching for -ladvapi32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libadvapi32.a when searching for -ladvapi32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ladvapi32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libshell32.a when searching for -lshell32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libshell32.a when searching for -lshell32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libshell32.a when searching for -lshell32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lshell32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libuser32.a when searching for -luser32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libuser32.a when searching for -luser32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libuser32.a when searching for -luser32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -luser32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libkernel32.a when searching for -lkernel32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libkernel32.a when searching for -lkernel32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libkernel32.a when searching for -lkernel32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lkernel32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libiconv.a when searching for -liconv
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libiconv.a when searching for -liconv
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libiconv.a when searching for -liconv
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -liconv
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmingwthrd.a when searching for -lmingwthrd
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libmingwthrd.a when searching for -lmingwthrd
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmingwthrd.a when searching for -lmingwthrd
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingwthrd
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmingw32.a when searching for -lmingw32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libmingw32.a when searching for -lmingw32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmingw32.a when searching for -lmingw32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingw32
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgcc.a when searching for -lgcc
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0\libgcc.a when searching for -lgcc
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgcc.a when searching for -lgcc
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgcc_eh.a when searching for -lgcc_eh
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0\libgcc_eh.a when searching for -lgcc_eh
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/libgcc_eh.a when searching for -lgcc_eh
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_eh
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmoldname.a when searching for -lmoldname
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libmoldname.a when searching for -lmoldname
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmoldname.a when searching for -lmoldname
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmoldname
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmingwex.a when searching for -lmingwex
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libmingwex.a when searching for -lmingwex
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmingwex.a when searching for -lmingwex
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmingwex
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmsvcrt.a when searching for -lmsvcrt
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libmsvcrt.a when searching for -lmsvcrt
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmsvcrt.a when searching for -lmsvcrt
    C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmsvcrt
    collect2.exe: error: ld returned 1 exit status
    
    opened by ghost 20
  • Linux WebKitGTK Memory Consumption

    Linux WebKitGTK Memory Consumption

    Webview looks to be a very good framework looking at the binary size, which is very tiny compared to the 115mb Electron Hello World, but there is another major problem, memory.

    I'm no benchmarking expert, but this is RAM usage in different UI frameworks:

    (Debian 10 + MATE, 8GB, i7 3770, GT 1030)

    • GTK: ~30mb
    • Webview Framework: 200-300mb, including WebKit being loaded into memory
    • Electron Quick Start: 50-130mb

    (These may be inaccurate, tell me if you have different results)

    Comparing Electron performance to Webview performance, they are about the same, as they both load a web rendering engine into memory.

    And with WebKit being 300mb to install on Linux, it can be seen to be even heavier than Electron if you don't already have it installed.

    There may be some usable alternatives to WebKit, but I think optimizations can be made, even if changing dependencies would not be possible.

    For some people, they may be using this for the HTML/CSS rendering, and don't need JS. At that point, using a UI library would be practical, but I think having an option to disable JS and use WebKit's click event binding feature would not be a bad idea, assuming it is possible within WebKitGTK.

    (I don't think this is an issue with Windows/Android, as their web rendering software is built in and ready to go.)

    Here are some raw benchmarks for WebKitGTK on my old laptop. http://petabyte.heb12.com/filedump/benchmark

    opened by petabyt 19
  • build on darwin fails

    build on darwin fails

    ~/src/webview$ go build -x
    WORK=/var/folders/q_/6fv7kfsj7b11y457c2dsssgw0000gn/T/go-build352003042
    mkdir -p $WORK/webview/_obj/
    mkdir -p $WORK/
    cd /Users/lsm/src/webview
    CGO_LDFLAGS="-g" "-O2" "-framework" "Cocoa" "-framework" "WebKit" /usr/local/Cellar/go/1.8.1/libexec/pkg/tool/darwin_amd64/cgo -objdir $WORK/webview/_obj/ -importpath webview -- -I $WORK/webview/_obj/ -g -O2 -DWEBVIEW_COCOA=1 -x objective-c webview.go
    # webview
    ./webview.go:132:3: struct size calculation error off=8 bytesize=0
    
    ~/src/webview$ uname -a 
    Darwin io.local 16.1.0 Darwin Kernel Version 16.1.0: Wed Oct 19 20:31:56 PDT 2016; root:xnu-3789.21.4~4/RELEASE_X86_64 x86_64
    
    opened by cpq 18
  • Basic JavaScript execution issue

    Basic JavaScript execution issue

    What OS are you using (uname -a, or Windows version)?

    Darwin MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64 x86_64

    What programming language are you using (C/C++/Go/Rust)?

    I'm using Deno (https://github.com/webview/webview_deno) but I am sort of guessing the issue is not with the Deno bindings but with webview itself, so I'm posting here.

    deno 1.23.2 (release, x86_64-apple-darwin)
    v8 10.4.132.8
    typescript 4.7.2
    

    What did you expect to see and what you saw instead?

    It seems like the Webview JS runtime is somehow failing to do closures correctly. Here is my code:

    import { Webview } from "https://deno.land/x/[email protected]/mod.ts";
    
    const wv = new Webview();
    
    wv.bind("log", console.log);
    wv.navigate(`data:text/html,${encodeURIComponent(`
    <html>
      <script>
        try {
          const msg = "hello world";
          log(msg);
          function thing(){
            log(msg);
          }
          thing();
        } catch (err) {
          log(err.message)
        }
      </script>
      <body>
      </body>
    </html>
    `)}`);
    
    wv.run();
    

    and here is the console output:

    hello world
    Can't find variable: msg
    

    naturally, the console output i expect is:

    hello world
    hello world
    
    opened by peetklecha 17
  • Characters represented as '?'

    Characters represented as '?'

    What OS are you using (uname -a, or Windows version)?

    Windows 10 Pro x64

    What programming language are you using (C/C++/Go/Rust)?

    go version go1.14.4 windows/amd64

    What did you expect to see and what you saw instead?

    When i create page with non english content, characters represented as '?'. How to solve that?. Sorry for my English. Sample:

    debug := true
    w := webview.New(debug)
    defer w.Destroy()
    w.SetTitle("Пример")
    w.SetSize(800, 600, webview.HintNone)
    w.Navigate(`data:text/html,
    		<!doctype html>
    		<html>
                            <head>
                              <meta charset="utf-8">
                            </head>
    			<body>Привет мир!</body>
    		</html>
    `)
    w.Run()
    
    opened by bezrazli4n0 17
  • HDPI Support?

    HDPI Support?

    Hi, I really love this library, and it is super useful to me. I was wondering about HDPI support, at least on windows. On my machine, the opened web browser looks very pixelated. IE10 looks just fine, and supports high definition fonts, but the window that this opens up just looks blocky.

    Is there any way I can make the webview work well with HDPI displays?

    help wanted 
    opened by ajusa 17
  • Add some get started tutorial.

    Add some get started tutorial.

    What OS are you using (uname -a, or Windows version)?

    Linux pop-os 5.16.11-76051611-generic #202202230823~1646248261~21.10~2b22243 SMP PREEMPT Wed Mar 2 20: x86_64 x86_64 x86_64 GNU/Linux
    

    What programming language are you using (C/C++/Go/Rust)?

    go version go1.17.7 linux/amd64
    

    What did you expect to see and what you saw instead?

    When I start to use this project, it lack a get started doc. And it makes me take a lot of time to start with. I saw that there is some example added to the project, so is it possible to create some kind of website or markdown file with a simple get-started tutorial for new users? Or some official repository to collect some good projects from the community. It really helps a lot.

    enhancement 
    opened by aimerneige 16
  • Get the snapshot

    Get the snapshot

    What OS are you using (uname -a, or Windows version)?

    Linux user-super-server 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

    What programming language are you using (C/C++/Go/Rust)?

    go version go1.18.1 linux/amd64 gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0

    What did you expect to see and what you saw instead?

    Dear all I would like to get the snapshot, then I found two APIs seem to work. I tried to implement but couldn't. Is there any example for reference? Thanks a lot

    https://webkitgtk.org/reference/webkit2gtk/unstable/method.WebView.get_snapshot.html void webkit_web_view_get_snapshot ( WebKitWebView* web_view, WebKitSnapshotRegion region, WebKitSnapshotOptions options, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data )

    https://webkitgtk.org/reference/webkit2gtk/unstable/method.WebView.get_snapshot_finish.html cairo_surface_t* webkit_web_view_get_snapshot_finish ( WebKitWebView* web_view, GAsyncResult* result, GError** error )

    Also, I found other examples, but I don't understand https://golang.hotexamples.com/examples/c/-/webkit_web_view_get_snapshot_finish/golang-webkit_web_view_get_snapshot_finish-function-examples.html

    question 
    opened by justlearn2140 1
  • Can the webview be

    Can the webview be "garbage collected" upon navigation?

    Hello! The following code - a simplified example - causes the webview to balloon to 500MB+ of physical memory on my M1 Mac:

    package main
    
    import "github.com/webview/webview"
    
    func main() {
    	w := webview.New(true)
    	defer w.Destroy()
    	w.SetTitle("Basic Example")
    	w.SetSize(480, 320, webview.HintNone)
    
    	for i := 0; i < 100000; i++ {
    		w.Navigate("data:text/html;base64,PGgxPkhlbGxvPC9oMT4=")
    	}
    	
    	w.Run()
    }
    

    The same thing happens if I use SetHtml() instead.

    In my case, I'd ideally like to open my application, and let it run for days or weeks while keeping a relatively constant footprint. I'm wondering if there are options I can set to "garbage collect" the browser history, cache, or any other resources the view is holding on to between successive calls to Navigate() or SetHtml().

    Really appreciate this project, and the ecosystem that has developed on top of it!

    opened by poundifdef 1
  • These are suggestions not issues.

    These are suggestions not issues.

    What OS are you using (uname -a, or Windows version)?

    Windows 11 Professional.

    What programming language are you using (C/C++/Go/Rust)?

    go version go1.19.4 windows/amd64

    What did you expect to see and what you saw instead?

    I saw some basic examples which are an awesome start by the way but what I would really like to see is an example that lets me create an HTML source directory, and resolve html source from embedded resources via special syntax urls. For example. When I start up the program, I would like to be able to specify an index.html page and then have that be resolved to a compiled in resource.

    Then whenever I use a URL from within the page html or javascript such as

    <img src="resource://images/myimage.png"/> 
    

    or

    window.location.href = "resource://images/page2.html"
    

    the resolution would fetch a resource relative to a logical resource root and that loads into the browser. Is that possible?

    Then maybe we could also include a MENU resource to attach to the main window which would bind to go code and allow the go code to control page loads externally. Such a scheme would also allow us to make calls out to the wrapping go process in a similar way that web apps make ajax calls today, maybe even making it so that existing pages with existing ajax could be minimally re-written to enable those same calls to work with the embedded go code in the same way that a web service operates against a remote procedure.

    Similarly for any other resource the same thing an opinionated URL to replace the normal https: scheme. Maybe even a script which would automatically take an html root directory and compile all the stuff under that directory into a resource dll to be used as the web root. This way the go code stays clean and free from UI code and in engine javascript code.

    opened by steowens 6
  • android and ios support feasible? (question)

    android and ios support feasible? (question)

    based on current design, is it even remotely possible to add mobile platform support sometime?

    it seems both tauri and wails are planning to do that, wondering if it's possible here so I can use c++ to write some GUIs on android and ios

    opened by laoshaw 1
  • Add the option to 'return' the bound argument via pass-by-reference.

    Add the option to 'return' the bound argument via pass-by-reference.

    This will resolve https://github.com/webview/webview/issues/730 and also maintains backwards-compatibility.

    void webview::unbind(const std::string &name) works as before. void webview::unbind(const std::string &name, void *&arg) implements the new desired behavior of "returning" the bound argument via pass-by-reference. void webview_unbind_return(webview_t w, const char *name, void *&arg); is the new C function. I had to change the name since overloading does not exist in C.

    Unbind without returning the arg:

    context_t context = {.w = w, .count = 0};
    webview_bind(w, "increment", increment, &context);
    ...
    webview_unbind(w, "increment");
    

    Unbind, use the arg, and free:

    context_t *context = (context_t*) malloc (sizeof(context_t));
    context->w = w;
    context->count = 0;
    webview_bind(w, "increment", increment, context);
    ...
    void* ptr;
    webview_unbind_return(w, "increment", ptr);
    context_t *context2 = (context_t*) ptr;
    printf("Count: %d\n", context2->count)
    free(ptr);
    

    The correct way to do this in C++ would be to use a template like so: template<typename T> void unbind(const std::string &name, T *& arg). Unfortunately, I could not figure out how to get C to call a C++ template function. Maybe you guys know more about that. This continues the pattern of using void* to accept an argument of any type, but using void*& is a little unsafe.

    opened by dandeto 3
  • SPA html and local access to js through file://

    SPA html and local access to js through file://

    What OS are you using (uname -a, or Windows version)?

    Windows11

    What programming language are you using (C/C++/Go/Rust)?

    C/C++

    What did you expect to see and what you saw instead?

    For SPA application, loading local js through file:// protocol is not allowed due to CORS problem. Is there any approach provided to overcome this problem except hosting a server and load it through http request, which I don't think is a elegant approach. I noticed that it seems possible to inject js through c++ code, which I think is not a good soluton either. In my case, I build a vue app(spa). I don't want to modify the c/c++ code every time upon a build of the page (page js name may change every time on a build).

    To elaborate a bit more. I have a vue spa built and open the index file content through c++, but the page does not show and have no errors output at the console, so I simply opened the index.html through browser and noticed the warning like the following occur. Access to script at 'file:///C:/Users/alan/Documents/GitHub/AResConvert/assets/index.272d8767.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome-untrusted, https, edge.

    Therefore, I think the reason why the vue spa page does not show (Open through webview library) is because of the local access to the javascript file

    opened by AlanYiNew 5
Owner
webview
Tiny cross-platform webview library. Uses WebKit (Gtk/Cocoa) and Edge (Windows)
webview
GTK is a multi-platform toolkit for creating graphical user interfaces.

GTK — The GTK toolkit General information GTK is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets,

GNOME Github Mirror 1.1k Dec 31, 2022
Gtk - Gui Toolkit Bindings for php

Gtk - Gui Toolkit Bindings for php Gtk written in pure php using FFI_. Development Status: WARNING: API is unstable WARNING: Lots of things are not im

Shubham Chaudhary 6 Dec 6, 2022
My color picker in GTK, based very heavily on the MS Powertoys color picker

My color picker in GTK, based very heavily on the MS Powertoys color picker

contribuewwt 12 Dec 2, 2022
This is gtkmm, the C++ API for GTK.

This is gtkmm, the C++ API for GTK.

GNOME Github Mirror 136 Jan 6, 2023
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.

libui: a portable GUI library for C This README is being written. Status It has come to my attention that I have not been particularly clear about how

Pietro Gagliardi 10.4k Jan 2, 2023
NWM is a simple window manager for linux which uses Xlib for managing windows

NWM is a simple window manager for linux which uses Xlib for managing windows.

Kumar Gaurav Pandey 18 Nov 27, 2022
A single-header ANSI C immediate mode cross-platform GUI library

Nuklear This is a minimal-state, immediate-mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed a

Immediate Mode UIs, Nuklear, etc. 6.7k Dec 24, 2022
A library for creating native cross-platform GUI apps

Yue A library for creating native cross-platform GUI apps. Getting started Documentations FAQ Development Examples Sample apps (with screenshots) Muba

Yue 2.8k Jan 7, 2023
Cross-platform malware development library for anti-analysis techniques

The Anti-Analysis Menagerie Cross-platform malware development library for anti-analysis techniques. Design Goals Provide a rich and convenient interf

Alan 21 Sep 16, 2022
Open Source, cross platform C++ library providing integration of VulkanSceneGraph with Qt windowing

Open Source, cross platform C++ library providing integration of VulkanSceneGraph with Qt windowing. Supports Windows, Linux and macOS.

Vulkan made easy 14 Nov 23, 2022
Cross-platform GUI library

Harbour Nuklear backend This backend provides support for Nuklear. It works on on all supported platforms with an OpenGL backend, including iOS and An

Rafał Jopek 2 Jan 19, 2022
NanoGUI is a minimalistic cross-platform widget library for OpenGL 3.x/DirectX11[12]/Vulkan

NanoGUI NanoGUI is a minimalistic cross-platform widget library for OpenGL 3.x/DirectX11[12]/Vulkan. It supports automatic layout generation, stateful

dalerank 73 Dec 22, 2022
Build performant, native and cross-platform desktop applications with Node.js and CSS like styling. 🚀

NodeGui Build performant, native and cross-platform desktop applications with Node.js and CSS like styling. ?? NodeGUI is powered by Qt5 ?? which make

NodeGui 8.1k Dec 30, 2022
Purely native C++ cross-platform GUI framework for Android and iOS development. https://www.boden.io

BODEN CROSS-PLATFORM FRAMEWORK Build purely native cross-platform experiences with Boden Website ⬡ Getting Started ⬡ API Reference ⬡ Guides ⬡ Twitter

Ashampoo Systems GmbH & Co KG 1.6k Dec 27, 2022
DeskGap is a framework for building cross-platform desktop apps with web technologies (JavaScript, HTML and CSS).

A cross-platform desktop app framework based on Node.js and the system webview

Wang, Chi 1.8k Jan 4, 2023
U++ is a C++ cross-platform rapid application development framework focused on programmer's productivity. It includes a set of libraries (GUI, SQL, Network etc.), and integrated development environment (TheIDE).

Ultimate++ Ultimate++ is a C++ cross-platform rapid application development framework focused on programmers productivity. It includes a set of librar

Ultimate++ 564 Jan 8, 2023
Electron framework lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

?? Available Translations: ???? ???? ???? ???? ???? ???? ???? ???? . View these docs in other languages at electron/i18n. The Electron framework lets

Electron 105.2k Jan 3, 2023
wxWidgets is a free and open source cross-platform C++ framework for writing advanced GUI applications using native controls.

About wxWidgets is a free and open source cross-platform C++ framework for writing advanced GUI applications using native controls. wxWidgets allows y

null 4.8k Jan 7, 2023
Simple ImGui external base. Uses ImGui DX9.

ImGui External Base ??️ What is this? ⚡ Hello all! I used to use noteffex's loader base for all my external ImGui projects. I got bored of using this

Alfie 11 Jun 29, 2022