Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid creating CaretBrowsing events on window focus #5655

Open
Kestrer opened this issue Aug 8, 2020 · 1 comment
Open

Avoid creating CaretBrowsing events on window focus #5655

Kestrer opened this issue Aug 8, 2020 · 1 comment
Labels
language: javascript Issues which require knowing JavaScript. priority: 2 - low Issues which are currently not very important.

Comments

@Kestrer
Copy link

Kestrer commented Aug 8, 2020

Currently, whenever the window is focused qutebrowser produces a JavaScript event. However, this makes it difficult to use the debugger with qutebrowser as every time I move my mouse back to the page everything gets paused and I'm not able to trigger my event.

Steps to reproduce:

  1. Open the inspector on any page.
  2. Go to the "Sources" tab.
  3. Press the pause button (top-left of right panel).
  4. Move mouse back on to page.
  5. The script will pause.
@The-Compiler
Copy link
Member

Reproduced - relevant code from caret.js:

CaretBrowsing.onWindowFocus = function() {
    CaretBrowsing.isWindowFocused = true;
    CaretBrowsing.updateIsCaretVisible();
};

CaretBrowsing.onWindowBlur = function() {
    CaretBrowsing.isWindowFocused = false;
    CaretBrowsing.updateIsCaretVisible();
};

// ...

CaretBrowsing.init = function() {
    CaretBrowsing.isWindowFocused = document.hasFocus();

    document.addEventListener("click", CaretBrowsing.onClick, false);
    window.addEventListener("focus", CaretBrowsing.onWindowFocus, false);
    window.addEventListener("blur", CaretBrowsing.onWindowBlur, false);
};

We should probably register/unregister those events when caret mode is entered/left instead.

@The-Compiler The-Compiler added language: javascript Issues which require knowing JavaScript. priority: 2 - low Issues which are currently not very important. labels Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language: javascript Issues which require knowing JavaScript. priority: 2 - low Issues which are currently not very important.
Projects
None yet
Development

No branches or pull requests

2 participants