Send approximate physical screen dimensions to the VM
When properly set, applications will have a chance to automatically detect HiDPI and act accordingly. This is the case for Fedora 23 template and GNOME apps (maybe even all built on top of GTK). But for privacy reasons, don't provide real values, only some approximate one. Give enough information to distinguish DPI above 150, 200 and 300. This is some compromise between privacy and HiDPI support. QubesOS/qubes-issues#1951 This commit is migrated from gui-daemon repository (dec462795d14a336bf27cc46948bbd592c307401).
This commit is contained in:
parent
6bd127beb3
commit
067cfb7cd6
@ -45,6 +45,11 @@ REGEX_OUTPUT = re.compile(r'''
|
|||||||
(?P<x>\d+)[+]
|
(?P<x>\d+)[+]
|
||||||
(?P<y>\d+)
|
(?P<y>\d+)
|
||||||
)|[\D]) # or not a digit
|
)|[\D]) # or not a digit
|
||||||
|
([ ]\(.*\))?[ ]? # ignore options
|
||||||
|
( # 304mm x 228mm
|
||||||
|
(?P<width_mm>\d+)mm[ ]x[ ]
|
||||||
|
(?P<height_mm>\d+)mm
|
||||||
|
)?
|
||||||
.* # ignore rest of line
|
.* # ignore rest of line
|
||||||
''')
|
''')
|
||||||
|
|
||||||
@ -57,11 +62,34 @@ def get_monitor_layout():
|
|||||||
if not line.startswith("Screen") and not line.startswith(" "):
|
if not line.startswith("Screen") and not line.startswith(" "):
|
||||||
output_params = REGEX_OUTPUT.match(line).groupdict()
|
output_params = REGEX_OUTPUT.match(line).groupdict()
|
||||||
if output_params['width']:
|
if output_params['width']:
|
||||||
outputs.append("%s %s %s %s\n" % (
|
phys_size = ""
|
||||||
|
if output_params['width_mm']:
|
||||||
|
# don't provide real values for privacy reasons - see
|
||||||
|
# #1951 for details
|
||||||
|
dpi = (int(output_params['width']) * 254 /
|
||||||
|
int(output_params['width_mm']) / 10)
|
||||||
|
if dpi > 300:
|
||||||
|
dpi = 300
|
||||||
|
elif dpi > 200:
|
||||||
|
dpi = 200
|
||||||
|
elif dpi > 150:
|
||||||
|
dpi = 150
|
||||||
|
else:
|
||||||
|
# if lower, don't provide this info to the VM at all
|
||||||
|
dpi = 0
|
||||||
|
if dpi:
|
||||||
|
# now calculate dimensions based on approximate DPI
|
||||||
|
phys_size = " {} {}".format(
|
||||||
|
int(output_params['width']) * 254 / dpi / 10,
|
||||||
|
int(output_params['height']) * 254 / dpi / 10,
|
||||||
|
)
|
||||||
|
outputs.append("%s %s %s %s%s\n" % (
|
||||||
output_params['width'],
|
output_params['width'],
|
||||||
output_params['height'],
|
output_params['height'],
|
||||||
output_params['x'],
|
output_params['x'],
|
||||||
output_params['y']))
|
output_params['y'],
|
||||||
|
phys_size,
|
||||||
|
))
|
||||||
return outputs
|
return outputs
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user