Merge branch 'nouveau'

This commit is contained in:
Florian Bruhin 2017-05-30 17:36:58 +02:00
commit b8a32c577f
3 changed files with 40 additions and 2 deletions

View File

@ -136,7 +136,7 @@ def init(args, crash_handler):
try: try:
_init_modules(args, crash_handler) _init_modules(args, crash_handler)
except (OSError, UnicodeDecodeError) as e: except (OSError, UnicodeDecodeError, browsertab.WebTabError) as e:
error.handle_fatal_exc(e, args, "Error while initializing!", error.handle_fatal_exc(e, args, "Error while initializing!",
pre_text="Error while initializing") pre_text="Error while initializing")
sys.exit(usertypes.Exit.err_init) sys.exit(usertypes.Exit.err_init)

View File

@ -19,6 +19,7 @@
"""Wrapper over a QWebEngineView.""" """Wrapper over a QWebEngineView."""
import os
import functools import functools
import sip import sip
@ -35,7 +36,7 @@ from qutebrowser.browser.webengine import (webview, webengineelem, tabhistory,
webenginesettings) webenginesettings)
from qutebrowser.misc import miscwidgets from qutebrowser.misc import miscwidgets
from qutebrowser.utils import (usertypes, qtutils, log, javascript, utils, from qutebrowser.utils import (usertypes, qtutils, log, javascript, utils,
objreg, jinja, debug) objreg, jinja, debug, version)
_qute_scheme_handler = None _qute_scheme_handler = None
@ -49,6 +50,13 @@ def init():
global _qute_scheme_handler global _qute_scheme_handler
app = QApplication.instance() app = QApplication.instance()
software_rendering = os.environ.get('LIBGL_ALWAYS_SOFTWARE') == '1'
if version.opengl_vendor() == 'nouveau' and not software_rendering:
# FIXME:qtwebengine display something more sophisticated here
raise browsertab.WebTabError(
"QtWebEngine is not supported with Nouveau graphics (unless "
"LIBGL_ALWAYS_SOFTWARE is set as environment variable).")
log.init.debug("Initializing qute://* handler...") log.init.debug("Initializing qute://* handler...")
_qute_scheme_handler = webenginequtescheme.QuteSchemeHandler(parent=app) _qute_scheme_handler = webenginequtescheme.QuteSchemeHandler(parent=app)
_qute_scheme_handler.install(webenginesettings.default_profile) _qute_scheme_handler.install(webenginesettings.default_profile)

View File

@ -377,3 +377,33 @@ def version():
lines += ['{}: {}'.format(name, path)] lines += ['{}: {}'.format(name, path)]
return '\n'.join(lines) return '\n'.join(lines)
def opengl_vendor(): # pragma: no cover
"""Get the OpenGL vendor used."""
# We're doing those imports here because this is only available with Qt 5.4
# or newer.
from PyQt5.QtWidgets import QOpenGLWidget
from PyQt5.QtOpenGL import QGLWidget
from PyQt5.QtGui import QOpenGLContext, QSurfaceFormat, QOpenGLVersionProfile, QOffscreenSurface
assert QApplication.instance()
assert QOpenGLContext.currentContext() is None
surface = QOffscreenSurface()
surface.create()
ctx = QOpenGLContext()
ok = ctx.create()
assert ok
ok = ctx.makeCurrent(surface)
assert ok
vp = QOpenGLVersionProfile()
vp.setVersion(2, 0)
vf = ctx.versionFunctions(vp)
vendor = vf.glGetString(vf.GL_VENDOR)
ctx.doneCurrent()
return vendor