Skip to content

Commit

Permalink
Make sure we take into account HiDPI displays properly when using Qt5
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Oct 12, 2016
1 parent dc79b01 commit 3c7667d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion vispy/app/backends/_qt.py
Expand Up @@ -304,7 +304,11 @@ def __init__(self, *args, **kwargs):
# Qt supports OS double-click events, so we set this here to
# avoid double events
self._double_click_supported = True
self._physical_size = p.size

# We call this here to set the physical size. We do this rather than set
# the physical size directly, because resizeGL takes into account any
# non-unity device pixel ratio.
self.resizeGL(*p.size)

# Activate touch and gesture.
# NOTE: we only activate touch on OS X because there seems to be
Expand Down Expand Up @@ -727,6 +731,12 @@ def initializeGL(self):
def resizeGL(self, w, h):
if self._vispy_canvas is None:
return
if qt_lib == 'pyqt5':
# We take into account devicePixelRatio, which is non-unity on
# e.g HiDPI displays.
ratio = self.devicePixelRatio()
w = w * ratio
h = h * ratio
self._vispy_set_physical_size(w, h)
self._vispy_canvas.events.resize(size=(self.width(), self.height()),
physical_size=(w, h))
Expand Down

0 comments on commit 3c7667d

Please sign in to comment.