Always open the windowed standalone UI when invoked from the contextual menu (thanks ZeroUnderscoreOu for reporting).

This commit is contained in:
hackademix 2023-01-17 09:02:21 +01:00
parent b203b73898
commit b65a48d719
No known key found for this signature in database
GPG Key ID: 231A83AFDA9C2434
1 changed files with 10 additions and 9 deletions

View File

@ -126,7 +126,7 @@
toggleCtxMenuItem();
browser.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId == ctxMenuId) {
this.openPageUI();
messageHandler.openStandalonePopup(tab);
}
});
}
@ -196,23 +196,24 @@
ns.computeChildPolicy)(...arguments);
},
async openStandalonePopup() {
let [tab] = (await browser.tabs.query({
async openStandalonePopup(tab) {
if (!tab) tab = (await browser.tabs.query({
currentWindow: true,
active: true
}));
}))[0];
if (!tab || tab.id === -1) {
log("No tab found to open the UI for");
return;
}
let win = await browser.windows.getCurrent();
let win = await browser.windows.get(tab.windowId);
let width = 610, height = 400;
browser.windows.create({
url: popupFor(tab.id),
width: 800,
height: 600,
top: win.top + 48,
left: win.left + 48,
width,
height,
top: win.top + Math.round((win.height - height) / 2),
left: win.left + Math.round((win.width - width) / 2),
type: "panel"
});
},