Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,13 @@ changing the tooling itself. Two rules hold wherever the catalogue is touched:
the entry before touching a patch and write one with every patch added. What
is there, by area:
- **Web view** — `juce-disable-webview2-zoom` (Windows),
`juce-no-double-escape-url` (macOS), and five for WebKitGTK:
`juce-no-double-escape-url` (macOS), and six for WebKitGTK:
`juce-linux-webkit-gpu` and `-render-device` (a pair; GPU compositing, with
`PLECTRIFY_WEBKIT_SOFTWARE_RENDERING=1` as the way back),
`-persistent-cookies`, `-versioned-sonames` (issue #12) and `-utf8-ipc`
`-persistent-cookies`, `-versioned-sonames` (issue #12), `-utf8-ipc`
(issue #48, whose entry also covers the page's one-time stored-text repair,
`mojibake.ts`).
`mojibake.ts`) and `-clipboard` (issue #55; the app's own page may write
the clipboard, since a click into the embedded view grants no activation).
- **Hosted plugins** — `juce-vst3-no-mac-content-scale`,
`juce-vst3-scale-before-attach` and `juce-graph-host-owned-bypass` (a
host-requested bypass is enforced by the graph, pinned by
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ FetchContent_Declare(
"-DPATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/juce-linux-webkit-utf8-ipc.patch"
"-DSOURCE_DIR=<SOURCE_DIR>"
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ApplyPatch.cmake"
COMMAND "${CMAKE_COMMAND}"
"-DGIT_EXECUTABLE=${GIT_EXECUTABLE}"
"-DPATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/cmake/juce-linux-webkit-clipboard.patch"
"-DSOURCE_DIR=<SOURCE_DIR>"
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ApplyPatch.cmake"
)
FetchContent_MakeAvailable(JUCE)

Expand Down
15 changes: 15 additions & 0 deletions cmake/JUCE_PATCHES.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,18 @@ the entry before touching a patch, and write one with every patch added.
cannot be reached by a pass, so the plugin's page repairs one as it reads
it (`parseHostSession`) unless it carries the `textIntact` stamp every
session written since carries.
- `juce-linux-webkit-clipboard.patch` — every Copy button on Linux said
"Copy failed" (issue #55): WebKit refuses `navigator.clipboard.writeText`
and `execCommand("copy")` with `NotAllowedError` unless the document has
transient user activation, and a click delivered to the view inside JUCE's
XEmbed window never grants it — instrumented in the app, the Copy handler
ran with `navigator.userActivation.isActive` false on a secure, focused
page. A stock WebKitGTK 2.52 window serving the same `juce://` scheme
copies fine from a click, so the cause is the embedding, not the scheme.
The patch turns on `javascript-can-access-clipboard`, WebKit's own bypass
of that check (JUCE binds the symbol and never calls it), and only for a
view with native integrations — the page the app serves itself. The
TONE3000 window shows a third-party site and keeps the default, which is
also what keeps that site from reading the clipboard. A JUCE bump should
check whether clicks into the plug grant activation by now; if they do,
the patch can go.
37 changes: 37 additions & 0 deletions cmake/juce-linux-webkit-clipboard.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Let the app's own page write the clipboard in the Linux web view.

WebKit rejects navigator.clipboard.writeText and execCommand("copy") with
NotAllowedError unless the document has transient user activation. A click
delivered to the view inside JUCE's XEmbed window never grants it: the handler
runs with navigator.userActivation.isActive false, on a secure context with
focus, so every Copy button in the UI reported "Copy failed". A stock
WebKitGTK window on the same juce:// scheme copies fine from a click.

webkit_settings_set_javascript_can_access_clipboard is WebKit's own bypass of
that check (JUCE already binds the symbol but never calls it). It is set only
when native integrations are enabled, i.e. for a page the app serves itself; a
browser showing a third-party site keeps JUCE's default, which also keeps that
site from reading the clipboard.

--- a/modules/juce_gui_extra/native/juce_WebBrowserComponent_linux.cpp
+++ b/modules/juce_gui_extra/native/juce_WebBrowserComponent_linux.cpp
@@ -932,6 +932,19 @@
wk.juce_webkit_settings_set_enable_developer_extras (settings, true);
#endif

+ // PLECTRIFY_WEBKIT_CLIPBOARD: let the app's own page write the
+ // clipboard. WebKit rejects navigator.clipboard.writeText (and
+ // execCommand("copy")) with NotAllowedError unless the document has
+ // transient user activation, and a click delivered to this view inside
+ // JUCE's XEmbed window never grants it: navigator.userActivation stays
+ // inactive in the click handler itself. So every Copy button failed.
+ // This setting is WebKit's own bypass of that check. Only for a view
+ // with native integrations, i.e. a page the app serves itself: a
+ // browser showing a third-party site keeps JUCE's default, which also
+ // keeps that site from reading the clipboard.
+ if (initialisationData->nativeIntegrationsEnabled)
+ wk.juce_webkit_settings_set_javascript_can_access_clipboard (settings, true);
+
auto* webviewWidget = WebKitSymbols::getInstance()->juce_webkit_web_view_new_with_settings (settings);
webview = (WebKitWebView*) webviewWidget;

5 changes: 5 additions & 0 deletions scripts/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ export const JUCE_PATCHES = [
file: 'modules/juce_gui_extra/native/juce_WebBrowserComponent_linux.cpp',
marker: 'PLECTRIFY_WEBKIT_UTF8_IPC',
},
{
patch: 'cmake/juce-linux-webkit-clipboard.patch',
file: 'modules/juce_gui_extra/native/juce_WebBrowserComponent_linux.cpp',
marker: 'PLECTRIFY_WEBKIT_CLIPBOARD',
},
] as const;

/** The commit CMakeLists.txt pins a FetchContent dependency to, read out of
Expand Down
Loading