Default heuristics for variable-format displays
Alexander Boström
abo at root.snowtree.se
Mon Sep 21 15:46:41 UTC 2009
Here's my suggestion...
def mode_megapixels(mode):
return mode.width * mode.height
# Sort by best refresh rate.
modes.sort(key=lambda mode: -mode['refresh'])
# Prefer to balance refresh rate vs. pixels.
if dpi_known:
acceptable = filter(lambda mode: mode.dpi >= 90, modes)
if len(acceptable) > 0:
# Anything above 90 DPI is good enough
# for a default.
# Pick the one with the best refresh.
return acceptable[0]
# DPI not known or too low, balance refresh vs. pixels.
best_megapixels = max(modes, mode_megapixels)
acceptable = filter(lambda mode: megapixels(mode) >=
best_megapixels / 2)
# Pick the mode with the highest refresh rate and at least
# half the max possible number of pixels.
acceptable[0]
/abo
More information about the fedora-devel-list
mailing list