Skip to content

Commit

Permalink
Allow to call requestFocus for user gesture
Browse files Browse the repository at this point in the history
  • Loading branch information
JingMatrix committed Aug 11, 2024
1 parent fb048a0 commit 5ddf6a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/src/main/assets/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (typeof Symbol.ChromeXt == "undefined") {

document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "visible")
ChromeXt.dispatch("focus", undefined, initKey);
ChromeXt.dispatch("focus", { requestFocus: false }, initKey);
});
// update current active tab

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/org/matrix/chromext/Listener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ object Listener {
}
"focus" -> {
Chrome.updateTab(currentTab)
val detail = JSONObject(payload)
val requestFocus = detail.getBoolean("requestFocus")
val activity = Chrome.getContext()
if (requestFocus &&
currentTab != null &&
activity::class.java == UserScriptProxy.chromeTabbedActivity) {
(activity as Activity).window.decorView.requestFocus()
}
}
"installScript" -> {
val script = parseScript(payload)
Expand Down

0 comments on commit 5ddf6a8

Please sign in to comment.