-
Notifications
You must be signed in to change notification settings - Fork 28
Description
The address bar is a QLineEdit that spawns a new QListWidget for the autocomplete. Various window hints are set on the QListWidget's window, to always display on top, be frameless, and to not accept focus. On Windows these hints are absolutely applied, however on Linux these are mere hints to the Window Manager.
With Window Managers for Linux (I'm testing with AwesomeWM, though I believe this is also true on i3) a NET_WM_WINDOW_TYPE_NORMAL window will appear in window switchers and be able to take focus. We can implement a handler for the WM_TAKE_FOCUS protocol by calling QWidget::FocusPolicy(Qt::NoPolicy), which will reject focus and send it back to the previous window.
Unfortunately, it seems the UrlEdit::focusInEvent(QFocusEvent*) and UrlEdit::focusOutEvent(QFocusEvent*) methods are still called with the autocomplete's focus policy is Qt::NoPolicy. The good news is that this happens fast enough my keystrokes aren't lost anymore. The bad news is the autocomplete is always hidden.
My next thought is to try replacing the autocomplete functionality using QLineEdit's support for using QCompleter. By default, this will give us popups using QListViews, like we're drawing now, though it looks like we can customize this behavior by subclassing QCompleter.