Skip to content

Commit

Permalink
Bug fix: On macOS, pasting a clipping doesn't work when browser windo…
Browse files Browse the repository at this point in the history
…w is full screen

(issue #432)
- Ported from version 6.5
  • Loading branch information
aecreations committed Jun 1, 2024
1 parent c8e464d commit 0efc3bb
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions wx-src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,19 @@ async function pasteClipping(aClippingInfo, aIsExternalRequest, aTabID)

async function pasteProcessedClipping(aClippingContent, aTabID)
{
// Focus the target window and tab to ensure that the clipping is
// successfully pasted into the web page.
let tab;
try {
tab = await browser.tabs.get(aTabID);
}
catch (e) {
// Browser tab was closed.
warn("Clippings/wx: pasteProcessedClipping(): Can't find browser tab " + aTabID);
return;
}
await browser.windows.update(tab.windowId, {focused: true});

let prefs = await aePrefs.getAllPrefs();
let msg = {
msgID: "paste-clipping",
Expand All @@ -1751,18 +1764,7 @@ async function pasteProcessedClipping(aClippingContent, aTabID)
log(`Clippings/wx: Extension sending message "paste-clipping" to content script (active tab ID = ${aTabID})`);
log(msg);

// The placeholder prompt or keyboard paste dialog may not be fully closed
// when the message is sent to the content script, which can't insert the
// clipping if the web page doesn't have focus.
// Work around by sending message after a short delay.
setTimeout(async () => {
try {
await browser.tabs.sendMessage(aTabID, msg);
}
catch (e) {
console.error("Clippings/wx: pasteProcessedClipping(): Failed to paste clipping: " + e);
}
}, 150);
await browser.tabs.sendMessage(aTabID, msg);
}


Expand Down

0 comments on commit 0efc3bb

Please sign in to comment.