Move logical DPI calculation into glfw module

Now DPI state is maintained in only one central place.
This commit is contained in:
Kovid Goyal
2017-12-14 18:30:53 +05:30
parent c7e1a12eb6
commit 684a2e05f4
7 changed files with 70 additions and 62 deletions
+2 -15
View File
@@ -19,8 +19,8 @@ from time import monotonic
from .constants import appname, is_macos, is_wayland
from .fast_data_types import (
GLSL_VERSION, glfw_primary_monitor_content_scale,
redirect_std_streams, wcwidth as wcwidth_impl, x11_display, x11_window_id
GLSL_VERSION, redirect_std_streams, wcwidth as wcwidth_impl, x11_display,
x11_window_id
)
from .rgb import Color, to_color
@@ -65,19 +65,6 @@ def sanitize_title(x):
return re.sub(r'\s+', ' ', re.sub(r'[\0-\x19]', '', x))
def get_logical_dpi(override_dpi=None):
# See https://github.com/glfw/glfw/issues/1019 for why we cant use
# glfw_get_physical_dpi()
if override_dpi is not None:
get_logical_dpi.ans = override_dpi
if not hasattr(get_logical_dpi, 'ans'):
factor = 72.0 if is_macos else 96.0
xscale, yscale = glfw_primary_monitor_content_scale()
xdpi, ydpi = xscale * factor, yscale * factor
get_logical_dpi.ans = xdpi, ydpi
return get_logical_dpi.ans
def color_as_int(val):
return val[0] << 16 | val[1] << 8 | val[2]