diff --git a/qutebrowser/app.py b/qutebrowser/app.py index b8649b7fb..05420a9e4 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -513,12 +513,13 @@ class Quitter: with tokenize.open(os.path.join(dirpath, fn)) as f: compile(f.read(), fn, 'exec') - def _get_restart_args(self, pages=(), session=None): + def _get_restart_args(self, pages=(), session=None, override_args=None): """Get the current working directory and args to relaunch qutebrowser. Args: pages: The pages to re-open. session: The session to load, or None. + override_args: Argument overrides as a dict. Return: An (args, cwd) tuple. @@ -569,6 +570,9 @@ class Quitter: argdict['temp_basedir'] = False argdict['temp_basedir_restarted'] = True + if override_args is not None: + argdict.update(override_args) + # Dump the data data = json.dumps(argdict) args += ['--json-args', data] @@ -593,7 +597,7 @@ class Quitter: if ok: self.shutdown(restart=True) - def restart(self, pages=(), session=None): + def restart(self, pages=(), session=None, override_args=None): """Inner logic to restart qutebrowser. The "better" way to restart is to pass a session (_restart usually) as @@ -606,6 +610,7 @@ class Quitter: Args: pages: A list of URLs to open. session: The session to load, or None. + override_args: Argument overrides as a dict. Return: True if the restart succeeded, False otherwise. @@ -621,7 +626,7 @@ class Quitter: session_manager.save(session, with_private=True) # Open a new process and immediately shutdown the existing one try: - args, cwd = self._get_restart_args(pages, session) + args, cwd = self._get_restart_args(pages, session, override_args) if cwd is None: subprocess.Popen(args) else: diff --git a/qutebrowser/misc/backendproblem.py b/qutebrowser/misc/backendproblem.py index fdd13346c..806c32a36 100644 --- a/qutebrowser/misc/backendproblem.py +++ b/qutebrowser/misc/backendproblem.py @@ -35,8 +35,10 @@ from qutebrowser.utils import usertypes, objreg, version, qtutils, log from qutebrowser.misc import objects, msgbox -_Result = usertypes.enum('_Result', ['quit', 'restart'], is_int=True, - start=QDialog.Accepted + 1) +_Result = usertypes.enum( + '_Result', + ['quit', 'restart', 'restart_webkit', 'restart_webengine'], + is_int=True, start=QDialog.Accepted + 1) @attr.s @@ -105,7 +107,13 @@ class _Dialog(QDialog): config.instance.set_obj(setting, value, save_yaml=True) save_manager = objreg.get('save-manager') save_manager.save_all(is_exit=True) - self.done(_Result.restart) + + if setting == 'backend' and value == 'webkit': + self.done(_Result.restart_webkit) + elif setting == 'backend' and value == 'webengine': + self.done(_Result.restart_webengine) + else: + self.done(_Result.restart) def _show_dialog(*args, **kwargs): @@ -113,17 +121,21 @@ def _show_dialog(*args, **kwargs): dialog = _Dialog(*args, **kwargs) status = dialog.exec_() + quitter = objreg.get('quitter') if status in [_Result.quit, QDialog.Rejected]: - sys.exit(usertypes.Exit.err_init) + pass + elif status == _Result.restart_webkit: + quitter.restart(override_args={'backend': 'webkit'}) + elif status == _Result.restart_webengine: + quitter.restart(override_args={'backend': 'webengine'}) elif status == _Result.restart: - # FIXME pass --backend webengine - quitter = objreg.get('quitter') quitter.restart() - sys.exit(usertypes.Exit.err_init) else: assert False, status + sys.exit(usertypes.Exit.err_init) + def _handle_nouveau_graphics(): force_sw_var = 'QT_XCB_FORCE_SOFTWARE_OPENGL'