From ebf4b987ecb6c239af91bb44235567c30e288d71 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 10 Jul 2020 11:25:38 +0200 Subject: qtargs: Move --enabled-features handling to separate function Preparation for proper handling as part of #5421 --- qutebrowser/config/qtargs.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/qutebrowser/config/qtargs.py b/qutebrowser/config/qtargs.py index 8a8d40dc4..2a8f52269 100644 --- a/qutebrowser/config/qtargs.py +++ b/qutebrowser/config/qtargs.py @@ -139,6 +139,23 @@ def _darkmode_settings() -> typing.Iterator[typing.Tuple[str, str]]: yield prefix + key, str(value) +def _qtwebengine_enabled_features() -> typing.Iterator[str]: + """Get --enable-features flags for QtWebEngine.""" + if qtutils.version_check('5.11', compiled=False) and not utils.is_mac: + # There are two additional flags in Chromium: + # + # - OverlayScrollbarFlashAfterAnyScrollUpdate + # - OverlayScrollbarFlashWhenMouseEnter + # + # We don't expose/activate those, but the changes they introduce are + # quite subtle: The former seems to show the scrollbar handle even if + # there was a 0px scroll (though no idea how that can happen...). The + # latter flashes *all* scrollbars when a scrollable area was entered, + # which doesn't seem to make much sense. + if config.val.scrolling.bar == 'overlay': + yield 'OverlayScrollbar' + + def _qtwebengine_args(namespace: argparse.Namespace) -> typing.Iterator[str]: """Get the QtWebEngine arguments to use based on the config.""" is_qt_514 = (qtutils.version_check('5.14', compiled=False) and @@ -175,6 +192,10 @@ def _qtwebengine_args(namespace: argparse.Namespace) -> typing.Iterator[str]: yield '--blink-settings=' + ','.join('{}={}'.format(k, v) for k, v in blink_settings) + enabled_features = list(_qtwebengine_enabled_features()) + if enabled_features: + yield '--enable-features=' + ','.join(enabled_features) + settings = { 'qt.force_software_rendering': { 'software-opengl': None, @@ -222,24 +243,6 @@ def _qtwebengine_args(namespace: argparse.Namespace) -> typing.Iterator[str]: False: '--autoplay-policy=user-gesture-required', } - if qtutils.version_check('5.11', compiled=False) and not utils.is_mac: - # There are two additional flags in Chromium: - # - # - OverlayScrollbarFlashAfterAnyScrollUpdate - # - OverlayScrollbarFlashWhenMouseEnter - # - # We don't expose/activate those, but the changes they introduce are - # quite subtle: The former seems to show the scrollbar handle even if - # there was a 0px scroll (though no idea how that can happen...). The - # latter flashes *all* scrollbars when a scrollable area was entered, - # which doesn't seem to make much sense. - settings['scrolling.bar'] = { - 'always': None, - 'never': None, - 'when-searching': None, - 'overlay': '--enable-features=OverlayScrollbar', - } - if qtutils.version_check('5.14'): settings['colors.webpage.prefers_color_scheme_dark'] = { True: '--force-dark-mode', -- cgit v1.2.3-54-g00ecf