From a6b92dbbd3d43e11df30739e6aa4d084e54ceb07 Mon Sep 17 00:00:00 2001 From: rien333 Date: Thu, 22 Mar 2018 02:23:21 +0100 Subject: [PATCH 01/11] General window decoration hiding option --- doc/help/settings.asciidoc | 6 +++--- qutebrowser/config/configdata.yml | 4 ++-- qutebrowser/config/configfiles.py | 14 ++++++++++++++ qutebrowser/config/configinit.py | 3 --- qutebrowser/mainwindow/mainwindow.py | 3 +++ tests/unit/config/test_configfiles.py | 12 ++++++++++++ 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 6399b88af..d81619743 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -264,7 +264,7 @@ |<>|Search engines which can be used via the address bar. |<>|Page(s) to open at the start. |<>|URL parameters to strip with `:yank url`. -|<>|Hide the window decoration when using wayland. +|<>|Hide the window decoration. |<>|Format to use for the window title. The same placeholders like for |<>|Default zoom level. |<>|Available zoom levels. @@ -3158,8 +3158,8 @@ Default: - +pass:[utm_content]+ [[window.hide_wayland_decoration]] -=== window.hide_wayland_decoration -Hide the window decoration when using wayland. +=== window.hide_decoration +Hide the window decoration. This setting requires a restart. Type: <> diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 35b514880..f41044d35 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1533,11 +1533,11 @@ url.yank_ignored_parameters: ## window -window.hide_wayland_decoration: +window.hide_decoration: type: Bool default: false restart: true - desc: Hide the window decoration when using wayland. + desc: Hide the window decoration. window.title_format: type: diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index fdb1583e0..b224fe0a2 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -262,6 +262,20 @@ class YamlConfig(QObject): del settings[old] self._mark_changed() + # window.hide_wayland_decoration was replaced by a more system agnostic + # Qt based equivalent + old = 'window.hide_wayland_decoration' + new = 'window.hide_decoration' + if old in settings: + settings[new] = {} + for scope, val in settings[old].items(): + if val: + settings[new][scope] = True + else: + settings[new][scope] = False + del settings[old] + self._mark_changed() + # bindings.default can't be set in autoconfig.yml anymore, so ignore # old values. if 'bindings.default' in settings: diff --git a/qutebrowser/config/configinit.py b/qutebrowser/config/configinit.py index 5c06a4a3d..7f40a74fb 100644 --- a/qutebrowser/config/configinit.py +++ b/qutebrowser/config/configinit.py @@ -90,9 +90,6 @@ def _init_envvars(): if config.val.qt.force_platform is not None: os.environ['QT_QPA_PLATFORM'] = config.val.qt.force_platform - if config.val.window.hide_wayland_decoration: - os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1' - if config.val.qt.highdpi: os.environ['QT_AUTO_SCREEN_SCALE_FACTOR'] = '1' diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index 3db56c0a7..dfb2f416b 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -169,6 +169,9 @@ class MainWindow(QWidget): objreg.register('message-bridge', message_bridge, scope='window', window=self.win_id) + if config.val.window.hide_decoration: + window_flags = Qt.CustomizeWindowHint | Qt.NoDropShadowWindowHint + self.setWindowFlags(Qt.Window | window_flags) self.setWindowTitle('qutebrowser') self._vbox = QVBoxLayout(self) self._vbox.setContentsMargins(0, 0, 0, 0) diff --git a/tests/unit/config/test_configfiles.py b/tests/unit/config/test_configfiles.py index 96f5d4976..40eec89d0 100644 --- a/tests/unit/config/test_configfiles.py +++ b/tests/unit/config/test_configfiles.py @@ -223,6 +223,18 @@ class TestYaml: mode = 'persist' if persist else 'normal' assert data['tabs.mode_on_change']['global'] == mode + @pytest.mark.parametrize('hide_decoration', [True, False]) + def test_merge_persist(self, yaml, autoconfig, hide_decoration): + """Tests for migration of window.hide_wayland_decoration""" + old = {'window.hide_wayland_decoration': {'global': hide_decoration}} + autoconfig.write(old) + yaml.load() + yaml._save() + + data = autoconfig.read() + assert 'window.hide_wayland_decoration' not in data + assert data['window.hide_decoration']['global'] == hide_decoration + def test_bindings_default(self, yaml, autoconfig): """Make sure bindings.default gets removed from autoconfig.yml.""" autoconfig.write({'bindings.default': {'global': '{}'}}) From 7b7faa9f661fae74642398f7b3e2ad8876ce33d7 Mon Sep 17 00:00:00 2001 From: rien333 Date: Thu, 22 Mar 2018 03:42:57 +0100 Subject: [PATCH 02/11] Fix silly redefinition --- tests/unit/config/test_configfiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/config/test_configfiles.py b/tests/unit/config/test_configfiles.py index 40eec89d0..4364da814 100644 --- a/tests/unit/config/test_configfiles.py +++ b/tests/unit/config/test_configfiles.py @@ -224,7 +224,7 @@ class TestYaml: assert data['tabs.mode_on_change']['global'] == mode @pytest.mark.parametrize('hide_decoration', [True, False]) - def test_merge_persist(self, yaml, autoconfig, hide_decoration): + def test_decoration_hiding(self, yaml, autoconfig, hide_decoration): """Tests for migration of window.hide_wayland_decoration""" old = {'window.hide_wayland_decoration': {'global': hide_decoration}} autoconfig.write(old) From 764e79e505329ef1f9e7e3429fb4bc3ef869e811 Mon Sep 17 00:00:00 2001 From: rien333 Date: Thu, 22 Mar 2018 03:44:24 +0100 Subject: [PATCH 03/11] Small refactor --- qutebrowser/config/configfiles.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index b224fe0a2..a0fa165bf 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -269,10 +269,7 @@ class YamlConfig(QObject): if old in settings: settings[new] = {} for scope, val in settings[old].items(): - if val: - settings[new][scope] = True - else: - settings[new][scope] = False + settings[new][scope] = val del settings[old] self._mark_changed() From 2d2bdad2ca1e08ee16f16862a3ce11556bc46181 Mon Sep 17 00:00:00 2001 From: rien333 Date: Thu, 22 Mar 2018 23:26:45 +0100 Subject: [PATCH 04/11] Do not require restart after decoration option change --- doc/help/settings.asciidoc | 2 +- qutebrowser/config/.#configfiles.py | 1 + qutebrowser/config/configdata.yml | 6 ++++-- qutebrowser/config/configinit.py | 3 +++ qutebrowser/mainwindow/mainwindow.py | 16 +++++++++++++--- 5 files changed, 22 insertions(+), 6 deletions(-) create mode 120000 qutebrowser/config/.#configfiles.py diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index d81619743..dbee21b8f 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -3157,7 +3157,7 @@ Default: - +pass:[utm_term]+ - +pass:[utm_content]+ -[[window.hide_wayland_decoration]] +[[window.hide_decoration]] === window.hide_decoration Hide the window decoration. This setting requires a restart. diff --git a/qutebrowser/config/.#configfiles.py b/qutebrowser/config/.#configfiles.py new file mode 120000 index 000000000..3c80a2a2a --- /dev/null +++ b/qutebrowser/config/.#configfiles.py @@ -0,0 +1 @@ +rw@domper.local.3624 \ No newline at end of file diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index f41044d35..0122bbb0d 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1536,8 +1536,10 @@ url.yank_ignored_parameters: window.hide_decoration: type: Bool default: false - restart: true - desc: Hide the window decoration. + restart: false + desc: | + Hide the window decoration. Does require a restart for + Wayland users. window.title_format: type: diff --git a/qutebrowser/config/configinit.py b/qutebrowser/config/configinit.py index 7f40a74fb..5c06a4a3d 100644 --- a/qutebrowser/config/configinit.py +++ b/qutebrowser/config/configinit.py @@ -90,6 +90,9 @@ def _init_envvars(): if config.val.qt.force_platform is not None: os.environ['QT_QPA_PLATFORM'] = config.val.qt.force_platform + if config.val.window.hide_wayland_decoration: + os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1' + if config.val.qt.highdpi: os.environ['QT_AUTO_SCREEN_SCALE_FACTOR'] = '1' diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index dfb2f416b..796c1f1b9 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -169,9 +169,6 @@ class MainWindow(QWidget): objreg.register('message-bridge', message_bridge, scope='window', window=self.win_id) - if config.val.window.hide_decoration: - window_flags = Qt.CustomizeWindowHint | Qt.NoDropShadowWindowHint - self.setWindowFlags(Qt.Window | window_flags) self.setWindowTitle('qutebrowser') self._vbox = QVBoxLayout(self) self._vbox.setContentsMargins(0, 0, 0, 0) @@ -233,6 +230,8 @@ class MainWindow(QWidget): config.instance.changed.connect(self._on_config_changed) objreg.get("app").new_window.emit(self) + self._set_decoration(config.val.window.hide_decoration) + def _init_geometry(self, geometry): """Initialize the window geometry or load it from disk.""" @@ -347,6 +346,8 @@ class MainWindow(QWidget): elif option == 'statusbar.position': self._add_widgets() self._update_overlay_geometries() + elif option == 'window.hide_decoration': + self._set_decoration(config.val.window.hide_decoration) def _add_widgets(self): """Add or readd all widgets to the VBox.""" @@ -496,6 +497,15 @@ class MainWindow(QWidget): completion_obj.on_clear_completion_selection) cmd.hide_completion.connect(completion_obj.hide) + def _set_decoration(self, hidden): + """ Set the visibility of the window decoration via Qt.""" + window_flags = Qt.Window + if hidden: + window_flags |= Qt.CustomizeWindowHint | Qt.NoDropShadowWindowHint + self.setWindowFlags(window_flags) + self.hide() + self.show() + @pyqtSlot(bool) def _on_fullscreen_requested(self, on): if not config.val.content.windowed_fullscreen: From ff299c87a84723864ddea4c11e766a47b0cc671e Mon Sep 17 00:00:00 2001 From: rien333 Date: Thu, 22 Mar 2018 23:32:37 +0100 Subject: [PATCH 05/11] Reinsert wayland specific code for toggling decoration visibility --- qutebrowser/config/configinit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/config/configinit.py b/qutebrowser/config/configinit.py index 5c06a4a3d..1f9f0f4b6 100644 --- a/qutebrowser/config/configinit.py +++ b/qutebrowser/config/configinit.py @@ -90,7 +90,7 @@ def _init_envvars(): if config.val.qt.force_platform is not None: os.environ['QT_QPA_PLATFORM'] = config.val.qt.force_platform - if config.val.window.hide_wayland_decoration: + if config.val.window.hide_decoration: os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1' if config.val.qt.highdpi: From bb0c79b5a29806c4c041fe34a99c7ae014f09d5d Mon Sep 17 00:00:00 2001 From: rien333 Date: Fri, 23 Mar 2018 01:38:45 +0100 Subject: [PATCH 06/11] Fix wayland test --- tests/unit/config/test_configinit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/config/test_configinit.py b/tests/unit/config/test_configinit.py index 2ee572860..6f3f0e1e5 100644 --- a/tests/unit/config/test_configinit.py +++ b/tests/unit/config/test_configinit.py @@ -292,7 +292,7 @@ class TestEarlyInit: 'QT_XCB_FORCE_SOFTWARE_OPENGL', '1'), ('qt.force_platform', 'toaster', 'QT_QPA_PLATFORM', 'toaster'), ('qt.highdpi', True, 'QT_AUTO_SCREEN_SCALE_FACTOR', '1'), - ('window.hide_wayland_decoration', True, + ('window.hide_decoration', True, 'QT_WAYLAND_DISABLE_WINDOWDECORATION', '1') ]) def test_env_vars(self, monkeypatch, config_stub, From 1fc0abb06417fb7f2785bae8a29cea0821209a6e Mon Sep 17 00:00:00 2001 From: rien333 Date: Fri, 23 Mar 2018 02:50:36 +0100 Subject: [PATCH 07/11] Delete .#configfiles.py --- qutebrowser/config/.#configfiles.py | 1 - 1 file changed, 1 deletion(-) delete mode 120000 qutebrowser/config/.#configfiles.py diff --git a/qutebrowser/config/.#configfiles.py b/qutebrowser/config/.#configfiles.py deleted file mode 120000 index 3c80a2a2a..000000000 --- a/qutebrowser/config/.#configfiles.py +++ /dev/null @@ -1 +0,0 @@ -rw@domper.local.3624 \ No newline at end of file From 880b33fff599a8339207881ca871e178d3634106 Mon Sep 17 00:00:00 2001 From: rien333 Date: Fri, 23 Mar 2018 15:19:37 +0100 Subject: [PATCH 08/11] Restore correct window visibility after decoration config change --- qutebrowser/mainwindow/mainwindow.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index 796c1f1b9..db96d7c73 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -500,11 +500,13 @@ class MainWindow(QWidget): def _set_decoration(self, hidden): """ Set the visibility of the window decoration via Qt.""" window_flags = Qt.Window + refresh_window = self.isVisible() if hidden: window_flags |= Qt.CustomizeWindowHint | Qt.NoDropShadowWindowHint self.setWindowFlags(window_flags) - self.hide() - self.show() + if refresh_window: + self.hide() + self.show() @pyqtSlot(bool) def _on_fullscreen_requested(self, on): From 6db1ab0a58f5930b32b8304faf84e9df33dd2bbd Mon Sep 17 00:00:00 2001 From: rien333 Date: Fri, 23 Mar 2018 15:21:02 +0100 Subject: [PATCH 09/11] Cosmetic changes --- qutebrowser/mainwindow/mainwindow.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index db96d7c73..f0594d90e 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -232,7 +232,6 @@ class MainWindow(QWidget): objreg.get("app").new_window.emit(self) self._set_decoration(config.val.window.hide_decoration) - def _init_geometry(self, geometry): """Initialize the window geometry or load it from disk.""" if geometry is not None: @@ -498,7 +497,7 @@ class MainWindow(QWidget): cmd.hide_completion.connect(completion_obj.hide) def _set_decoration(self, hidden): - """ Set the visibility of the window decoration via Qt.""" + """Set the visibility of the window decoration via Qt.""" window_flags = Qt.Window refresh_window = self.isVisible() if hidden: From e211801e16b5ecdf8e2f3353bb4f411a233104c1 Mon Sep 17 00:00:00 2001 From: rien333 Date: Fri, 23 Mar 2018 15:24:18 +0100 Subject: [PATCH 10/11] Handle wayland decoration option rename through configdata.yml --- qutebrowser/config/configdata.yml | 3 +++ qutebrowser/config/configfiles.py | 11 ----------- tests/unit/config/test_configfiles.py | 12 ------------ 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 0122bbb0d..bbc49b374 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1533,6 +1533,9 @@ url.yank_ignored_parameters: ## window +window.hide_wayland_decoration: + renamed: window.hide_decoration + window.hide_decoration: type: Bool default: false diff --git a/qutebrowser/config/configfiles.py b/qutebrowser/config/configfiles.py index a0fa165bf..fdb1583e0 100644 --- a/qutebrowser/config/configfiles.py +++ b/qutebrowser/config/configfiles.py @@ -262,17 +262,6 @@ class YamlConfig(QObject): del settings[old] self._mark_changed() - # window.hide_wayland_decoration was replaced by a more system agnostic - # Qt based equivalent - old = 'window.hide_wayland_decoration' - new = 'window.hide_decoration' - if old in settings: - settings[new] = {} - for scope, val in settings[old].items(): - settings[new][scope] = val - del settings[old] - self._mark_changed() - # bindings.default can't be set in autoconfig.yml anymore, so ignore # old values. if 'bindings.default' in settings: diff --git a/tests/unit/config/test_configfiles.py b/tests/unit/config/test_configfiles.py index 4364da814..96f5d4976 100644 --- a/tests/unit/config/test_configfiles.py +++ b/tests/unit/config/test_configfiles.py @@ -223,18 +223,6 @@ class TestYaml: mode = 'persist' if persist else 'normal' assert data['tabs.mode_on_change']['global'] == mode - @pytest.mark.parametrize('hide_decoration', [True, False]) - def test_decoration_hiding(self, yaml, autoconfig, hide_decoration): - """Tests for migration of window.hide_wayland_decoration""" - old = {'window.hide_wayland_decoration': {'global': hide_decoration}} - autoconfig.write(old) - yaml.load() - yaml._save() - - data = autoconfig.read() - assert 'window.hide_wayland_decoration' not in data - assert data['window.hide_decoration']['global'] == hide_decoration - def test_bindings_default(self, yaml, autoconfig): """Make sure bindings.default gets removed from autoconfig.yml.""" autoconfig.write({'bindings.default': {'global': '{}'}}) From fa21d280fabd33ca865ccce747e5283e689daf50 Mon Sep 17 00:00:00 2001 From: rien333 Date: Sat, 24 Mar 2018 05:09:03 +0100 Subject: [PATCH 11/11] Remove unnecessary hide operation --- qutebrowser/mainwindow/mainwindow.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index f0594d90e..596280e81 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -504,7 +504,6 @@ class MainWindow(QWidget): window_flags |= Qt.CustomizeWindowHint | Qt.NoDropShadowWindowHint self.setWindowFlags(window_flags) if refresh_window: - self.hide() self.show() @pyqtSlot(bool)