parkouss / webmacs

webmacs - keyboard driven (emacs key bindings) browser, https://webmacs.readthedocs.io/en/latest/
GNU General Public License v3.0
157 stars 21 forks source link

Focus moves to the first input element on a page when buffer loses focus #106

Open TLATER opened 5 years ago

TLATER commented 5 years ago

Edit: We have a workaround!

from webmacs import keymaps
from webmacs.commands import define_command

global_map = keymaps.keymap("global")
define_command("noop", binding=lambda: None, visible=False)
global_map.define_key("Tab", "noop")

When I switch either using C-x b or to a different workspace with my window manager, webmacs will sometimes suddenly place focus on the first input element on the page displayed in the buffer that was just moved out of focus. This does not happen every time, but is pretty consistent if the switch occurs for more than a few seconds.

This is incredibly annoying since it loses my place in the page I was viewing and it takes a number of keystrokes to get rid of the focus (occasionally, C-g won't even work, forcing me to click somewhere on the page).

As a workaround I've started opening the search input with C-s before I switch windows, which inhibits any changes to the page, but well, this isn't nice.

I'm not sure if I'm accidentally triggering intended behavior and just unaware of a keybinding, but some help in figuring out what's going on would be appreciated.

parkouss commented 5 years ago

Ok, thanks for the detailed report.

Can you give me the content of the version buffer please, using ? It might be related to the Qt version.

TLATER commented 5 years ago

Yup, sorry, should have done that in the first place:

Webmacs version: | 0.8 (034a46aee33a0c33c0b66866faaaa1ea926b6a82)
-- | --
Operating system: | linux
Python version: | 3.7.2 (default, Jan 10 2019, 23:51:51) [GCC 8.2.1 20181127]
Qt version: | 5.12.1
PyQt version: | 5.12
Chromium version: | 69.0.3497.128
Opengl vendor: | NVIDIA Corporation
jollm commented 5 years ago

I'm seeing this too. Weirdly enough, it doesn't just jump to the first input element, it cycles input elements on subsequent focus events.

Webmacs version: | 0.8 (034a46aee33a0c33c0b66866faaaa1ea926b6a82)
-- | --
Operating system: | linux
Python version: | 3.7.2 (default, Jan 10 2019, 23:51:51) [GCC 8.2.1 20181127]
Qt version: | 5.12.1
PyQt version: | 5.12
Chromium version: | 69.0.3497.128
Opengl vendor: | Intel Open Source Technology Center

It happens consistently for me with C-x b. E.g. I'm seeing it on this page.

codesections commented 5 years ago

This is caused by a QtWebengine bug, as reported in the qutebrowser github issue. The issue is actually that switching to QtWebengine browsers (with at least some WMs?) sends an erroneous <TAB> keypress (which, by default, cycles to the next input element).

Thus, rebinding <TAB> to a command that doesn't scroll the buffer is a temporary (if inelegant) workaround. I'm not sure if the QtWebEngine project is aware of this bug or not.

jollm commented 5 years ago

Thanks! Can confirm that binding Tab to a noop command in global prevents the undesirable behavior.