aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Rizwan <omar.rizwan@gmail.com>2020-11-22 13:14:54 -0800
committerOmar Rizwan <omar.rizwan@gmail.com>2020-11-22 13:38:25 -0800
commit3a623f17c479fd8fc79732c52d52de81fa329873 (patch)
tree79666f14b9cb702c99187198cd0ed23a94feeef4
parent374d794f73f5b81cc18275603ee3b5be44b7c23e (diff)
track last-focused window by hand
-rw-r--r--extension/background.js18
1 files changed, 7 insertions, 11 deletions
diff --git a/extension/background.js b/extension/background.js
index 5201080..4f4d115 100644
--- a/extension/background.js
+++ b/extension/background.js
@@ -77,6 +77,12 @@ function sendDebuggerCommand(tabId, method, commandParams) {
);
}
+let lastFocusedWindowId;
+browser.windows.getLastFocused().then(window => { lastFocusedWindowId = window.id; });
+browser.windows.onFocusChanged.addListener(windowId => {
+ if (windowId !== -1) lastFocusedWindowId = windowId;
+});
+
/* if I could specify a custom editor interface for all the routing
below ... I would highlight the route names in blocks of some color
that sticks out, and let you collapse them. then you could get a
@@ -243,21 +249,11 @@ router["/tabs/last-focused"] = {
};
},
async readlink(path) {
- const windowId = (await browser.windows.getLastFocused()).id;
- const id = (await browser.tabs.query({ active: true, windowId }))[0].id;
+ const id = (await browser.tabs.query({ active: true, windowId: lastFocusedWindowId }))[0].id;
return "by-id/" + id;
}
}
- /* "last-focused": {
- * // FIXME: symlink to tab by id.
- * async readlink() {
- * return "../windows/last-focused/selected-tab"
- * }
- * },
- */
-
-
// Ensure that there are routes for all ancestors. This algorithm is
// probably not correct, but whatever. I also think it would be
// better to compute this stuff on the fly, so you could patch more