Skip to content

Commit

Permalink
WebBrowserComponent: Linux: Add support for libwebkit2gtk-4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
szarvas committed Jun 11, 2024
1 parent b5cbdfd commit 2516ad8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
11 changes: 9 additions & 2 deletions docs/Linux Dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ or
- libxrender-dev (unless `JUCE_USE_XRENDER=0`)

#### juce_gui_extra
- libwebkit2gtk-4.0-dev (unless `JUCE_WEB_BROWSER=0`)
- libwebkit2gtk-4.1-dev (unless `JUCE_WEB_BROWSER=0`)

On older systems, where 4.1 is not available, you can also use

- libwebkit2gtk-4.0-dev

Compiled JUCE applications will dynamically load whichever library version is
available during runtime.

#### juce_opengl
- libglu1-mesa-dev
Expand All @@ -58,5 +65,5 @@ The full command is as follows:
libcurl4-openssl-dev \
libfreetype6-dev \
libx11-dev libxcomposite-dev libxcursor-dev libxcursor-dev libxext-dev libxinerama-dev libxrandr-dev libxrender-dev \
libwebkit2gtk-4.0-dev \
libwebkit2gtk-4.1-dev \
libglu1-mesa-dev mesa-common-dev
31 changes: 27 additions & 4 deletions modules/juce_gui_extra/native/juce_WebBrowserComponent_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,37 @@ class WebKitSymbols final : public DeletedAtShutdown
makeSymbolBinding (juce_g_free, "g_free"));
}

struct WebKitAndDependencyLibraryNames
{
const char* webkitLib;
const char* jsLib;
const char* soupLib;
};

bool openWebKitAndDependencyLibraries (const WebKitAndDependencyLibraryNames& names)
{
if (webkitLib.open (names.webkitLib) && jsLib.open (names.jsLib) && soupLib.open (names.soupLib))
return true;

for (auto* l : { &webkitLib, &jsLib, &soupLib })
l->close();

return false;
}

//==============================================================================
DynamicLibrary webkitLib, jsLib, soupLib;

DynamicLibrary gtkLib { "libgtk-3.so" },
webkitLib { "libwebkit2gtk-4.0.so" },
jsLib { "libjavascriptcoregtk-4.0.so" },
soupLib { "libsoup-2.4.so" },
glib { "libglib-2.0.so" };

const bool webKitIsAvailable = loadWebkitSymbols()
const bool webKitIsAvailable = ( openWebKitAndDependencyLibraries ({ "libwebkit2gtk-4.1.so",
"libjavascriptcoregtk-4.1.so",
"libsoup-3.0.so" })
|| openWebKitAndDependencyLibraries ({ "libwebkit2gtk-4.0.so",
"libjavascriptcoregtk-4.0.so",
"libsoup-2.4.so" }))
&& loadWebkitSymbols()
&& loadGtkSymbols()
&& loadJsLibSymbols()
&& loadSoupLibSymbols()
Expand Down

0 comments on commit 2516ad8

Please sign in to comment.