Skip to content

Commit

Permalink
Merge pull request #4038 from t20100/workaround-wrong-dpi
Browse files Browse the repository at this point in the history
silx.gui.plot: Added workaround for erroneous DPI reported by Qt
  • Loading branch information
vallsv authored Jan 11, 2024
2 parents 749ba5a + 287ba08 commit 3c44420
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/silx/gui/_glutils/OpenGLWidget.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# /*##########################################################################
#
# Copyright (c) 2017-2022 European Synchrotron Radiation Facility
# Copyright (c) 2017-2023 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -353,13 +353,17 @@ def getDotsPerInch(self):
:rtype: float
"""
screen = self.window().windowHandle().screen()
if screen is not None:
# TODO check if this is correct on different OS/screen
# OK on macOS10.12/qt5.13.2
dpi = screen.physicalDotsPerInch() * self.getDevicePixelRatio()
else: # Fallback
dpi = 96.0 * self.getDevicePixelRatio()
return dpi
if screen is None:
return 96.0 * self.getDevicePixelRatio()

physicalDPI = screen.physicalDotsPerInch()
if physicalDPI > 1000.0:
_logger.error(
"Reported screen DPI too high: %f, using default value instead",
physicalDPI,
)
physicalDPI = 96.0
return physicalDPI * self.getDevicePixelRatio()

def getOpenGLVersion(self):
"""Returns the available OpenGL version.
Expand Down

0 comments on commit 3c44420

Please sign in to comment.