Add a setting for window transparency

On some setups, it looks like setting WA_TranslucentBackground causes
worse performance. Additionally, it also breaks dmenu window embedding
with its `-w` flag. This adds a setting to make it optional.

I originally tried to set this in a config change handler, but even with
a subsequent .hide()/.show(), for some odd reason that causes
rendering/repainting artifacts, possibly due to a Qt bug.

Follow-up to #5546
Closes #5805
This commit is contained in:
Florian Bruhin 2020-11-20 17:44:25 +01:00
parent 74ad8fd545
commit 50cd6aa638
3 changed files with 34 additions and 2 deletions

View File

@ -327,6 +327,7 @@
|<<url.yank_ignored_parameters,url.yank_ignored_parameters>>|URL parameters to strip with `:yank url`.
|<<window.hide_decoration,window.hide_decoration>>|Hide the window decoration.
|<<window.title_format,window.title_format>>|Format to use for the window title. The same placeholders like for
|<<window.transparent,window.transparent>>|Set the main window background to transparent.
|<<zoom.default,zoom.default>>|Default zoom level.
|<<zoom.levels,zoom.levels>>|Available zoom levels.
|<<zoom.mouse_divider,zoom.mouse_divider>>|Number of zoom increments to divide the mouse wheel movements to.
@ -4206,6 +4207,22 @@ Type: <<types,FormatString>>
Default: +pass:[{perc}{current_title}{title_sep}qutebrowser]+
[[window.transparent]]
=== window.transparent
Set the main window background to transparent.
This allows having a transparent tab- or statusbar (might require a compositor such
as picom). However, it breaks some functionality such as dmenu embedding via its
`-w` option. On some systems, it was additionally reported that main window
transparency negatively affects performance.
Note this setting only affects windows opened after setting it.
Type: <<types,Bool>>
Default: +pass:[false]+
[[zoom.default]]
=== zoom.default
Default zoom level.

View File

@ -2074,6 +2074,19 @@ window.title_format:
Format to use for the window title. The same placeholders like for
`tabs.title.format` are defined.
window.transparent:
type: Bool
default: false
desc: |
Set the main window background to transparent.
This allows having a transparent tab- or statusbar (might require a compositor such
as picom). However, it breaks some functionality such as dmenu embedding via its
`-w` option. On some systems, it was additionally reported that main window
transparency negatively affects performance.
Note this setting only affects windows opened after setting it.
## zoom
zoom.default:

View File

@ -203,8 +203,10 @@ class MainWindow(QWidget):
from qutebrowser.mainwindow.statusbar import bar
self.setAttribute(Qt.WA_DeleteOnClose)
self.setAttribute(Qt.WA_TranslucentBackground)
self.palette().setColor(QPalette.Window, Qt.transparent)
if config.val.window.transparent:
self.setAttribute(Qt.WA_TranslucentBackground)
self.palette().setColor(QPalette.Window, Qt.transparent)
self._overlays: MutableSequence[_OverlayInfoType] = []
self.win_id = next(win_id_gen)
self.registry = objreg.ObjectRegistry()