Dear all,

in issue 818 [1] people (among them me) had the problem that background windows grab focus and as it were I could only tell the window manager to unfocus all qutebrowser windows or none. I wrote a patch that gives background windows the window_role "qutebrowser_background" so that the window manager can tell them apart and treat them differently.

I think this adds functionality without breaking anything for people not using it.

Best

Eike

[1] https://github.com/qutebrowser/qutebrowser/issues/818
>From 989cd86fbcc56a07e72798ba7c1fe66de8a2bde8 Mon Sep 17 00:00:00 2001
From: Eike Fokken <efok...@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

Reply via email to