cretz / doogie

A Chromium-based web browser with tree-style pages
https://cretz.github.io/doogie
MIT License
279 stars 28 forks source link

Address Bar and Browser Focus Issue #52

Open cretz opened 7 years ago

cretz commented 7 years ago

Go to a link, click something (to make navigation history). Then, click off the address bar and into the browser, then back into the address bar and press backspace and watch the nav go back.

We need to solve this as a focus issue. the address bar obtaining focus is not removing focus from the browser. There are other ways of triggering this such as entering a text area in the browser, going back to the URL, going back to the text area, and seeing URL still retain a cursor.

cretz commented 7 years ago

Added small commit to set a strong policy which includes click of CEF widget focus. But we still have a problem (as mentioned in #51) where the address bar on a new window looks like it has focus and even has a cursor, but key events are not sent to it when typed.

dwarfcrank commented 7 years ago

I think I found a way to reliably reproduce this issue, at least the part related to #51. I've tested these steps on Arch Linux with the i3 window manager (with focus-follows-mouse both on and off, as I originally thought it might have something to do with this).

Qt version is 5.9.1 and CEF binary distribution is 3.3163.1666.g052c2d2.

  1. Make sure the mouse cursor is hovering over the CEF widget, not any other part of the UI.
  2. Open a new page.
  3. Without moving the mouse, type something. Nothing should appear in the address bar, even though it seems to have focus.
  4. Move the mouse off the CEF widget without clicking anything and type something. Keyboard events should work again. Likewise, when moving the mouse back to the CEF widget, keyboard events won't be sent to the URL bar anymore.
cretz commented 7 years ago

Thanks! I'll work to replicate and see if I can solve when I get some time.

dwarfcrank commented 7 years ago

I looked some more into this and noticed that key events aren't sent at all if the CEF widget doesn't have any document loaded (which is the case with a new tab).

As a hacky test, I made BrowserStack::NewBrowser load a data URI if the given URL is empty, and it seems to work (see the commit). Though in this case the browser will also have focus in addition to the URL bar.

cretz commented 7 years ago

Thanks. The reason I haven't peeked yet is that i regularly use Doogie on Windows and my focus issues are different and aren't replicated in the same way.