Skip to content

Commit

Permalink
Send approximate physical screen dimensions to the VM
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marmarek authored and WetwareLabs committed Aug 8, 2016
1 parent 467aa9a commit 9db76d4
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions screen-layout-handler/monitorlayoutnotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
(?P<x>\d+)[+]
(?P<y>\d+)
)|[\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
""")

Expand All @@ -50,11 +55,34 @@ def get_monitor_layout():
if not line.startswith("Screen") and not line.startswith(" "):
output_params = REGEX_OUTPUT.match(line).groupdict()
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['height'],
output_params['x'],
output_params['y']))
output_params['y'],
phys_size,
))
return outputs

def notify_vm(vm, monitor_layout):
Expand Down

0 comments on commit 9db76d4

Please sign in to comment.