qutebrowser / qutebrowser

A keyboard-driven, vim-like browser based on Python and Qt.

Home Page:https://www.qutebrowser.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

background tabs are not background, if tabs are windows

eike-fokken opened this issue · comments

My settings are

Window manager: i3 version 4.15 (2018-03-10)
qutebrowser v1.2.1

Backend: QtWebEngine (Chromium 56.0.2924.122)

CPython: 3.6.5rc1
Qt: 5.9.2
PyQt: 5.9.2

sip: 4.19.8
colorama: no
pypeg2: 2.15
jinja2: 2.10
pygments: 2.2.0
yaml: 3.12
cssutils: no
attr: 17.4.0
PyQt5.QtWebEngineWidgets: yes
PyQt5.QtWebKitWidgets: no
pdf.js: no
sqlite: 3.22.0
QtNetwork SSL: OpenSSL 1.0.2o  27 Mar 2018

Style: QFusionStyle
Platform: Linux-4.15.0-2-amd64-x86_64-with-debian-buster-sid, 64bit
Linux distribution: Debian GNU/Linux buster/sid (debian)
Frozen: False
Imported from /usr/lib/python3/dist-packages/qutebrowser
Qt library executable path: /usr/lib/x86_64-linux-gnu/qt5/libexec, data path: /usr/share/qt5

I have these settings:
c.tabs.show = 'never'
c.tabs.tabs_are_windows = True

When I run
:open -b gnu.org

it opens gnu.org in a new window but focuses this new window.
I would like it to keep focus on the current window.

Is this possible from within qutebrowser or is it an issue of the window manager (i3wm)?

The same (and more relevant) happens when I try to open a hint in background tab with
;b

Best
Eike

I think this is a duplicate of #818 (and because of that, an issue in the WM).

Related patch from the ML:

From: Eike Fokken <ef...n@posteo.de>
Date: Fri, 13 Apr 2018 14:06:02 +0200
Subject: [PATCH] Adds the window_role "qutebrowser_background" for background
 windows

For some users it may be the desired behaviour that non-background
windows grab focus on creation, but background windows don't. To make
this possible without interfering with window manager settings this
task is left to the window manager. To make it recognize background
windows, they are given a special window role.
For example in i3 one can then set

no_focus [window_role= "qutebrowser_background"]

to disable focus grabbing only for background windows.
---
 qutebrowser/mainwindow/tabbedbrowser.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py
index ce36f0038..313dfde01 100644
--- a/qutebrowser/mainwindow/tabbedbrowser.py
+++ b/qutebrowser/mainwindow/tabbedbrowser.py
@@ -458,9 +458,14 @@ class TabbedBrowser(QWidget):
                           "related {}, idx {}".format(
                               url, background, related, idx))

+        if background is None:
+            background = config.val.tabs.background
+
         if (config.val.tabs.tabs_are_windows and self.widget.count() > 0 and
                 not ignore_tabs_are_windows):
             window = mainwindow.MainWindow(private=self.private)
+            if background:
+                window.setWindowRole("qutebrowser_background")
             window.show()
             tabbed_browser = objreg.get('tabbed-browser', scope='window',
                                         window=window.win_id)
@@ -478,8 +483,6 @@ class TabbedBrowser(QWidget):
         if url is not None:
             tab.openurl(url)

-        if background is None:
-            background = config.val.tabs.background
         if background:
             # Make sure the background tab has the correct initial size.
             # With a foreground tab, it's going to be resized correctly by the
--
2.17.0

FWIW, ICCM says:

The client must set the WM_WINDOW_ROLE property to a string that uniquely identifies that window among all windows that have the same client leader window.

So abusing setWindowRole to tell foreground/background windows apart seems like quite a hack with a possibility to break other things depending on the window manager.