Fix calculate best resolution

develop
Mike Hiretsky 12 years ago
parent 32f3dcef35
commit 2d0b7a2f0f

@ -21,13 +21,14 @@ import pwd, grp
import cl_overriding
import socket
from math import sqrt
from cl_vars_share import varsShare, clLocale
from os.path import exists as pathexists
from os import path,readlink
from cl_utils import isMount, genpassword, \
getAvailableVideo, process, \
listDirectory,isPkgInstalled,lspci, readLinesFile, \
getUdevDeviceInfo
getUdevDeviceInfo,getPkgInstalled
from utils import ip
from encrypt import getHash
@ -517,54 +518,34 @@ class fillVars(varsShare):
return ""
width = int(widthVal)
height = int(heightVal)
res = [(1024,600),
(1024,768),
(1280,1024),
(1280,800),
(1366,768),
(1440,900),
(1600,1200),
(1680,1050),
(1920,1200)]
resolution = []
formats = []
for w, h in res:
formats.append(float(w)/float(h))
listFr = list(set(formats))
listFormats = {}
for fr in listFr:
listFormats[fr] = []
for w, h in res:
for fr in listFormats.keys():
if fr == float(w)/float(h):
listFormats[fr].append((w,h))
break
format = float(width)/float(height)
deltaFr = {}
for fr in listFormats.keys():
deltaFr[abs(format - fr)] = fr
resolution = listFormats[deltaFr[min(deltaFr.keys())]]
flagFound = False
stResol = []
stHeights = []
stWidths = []
stWidth = False
stHeight = False
for w, h in resolution:
if w >= width and h >= height:
stResol.append((w,h))
stHeights.append(h)
if stHeights:
stHeight = min(stHeights)
for w, h in stResol:
if stHeight == h:
stWidths.append(w)
if stWidths:
stWidth = min(stWidths)
if (not stWidth) or (not stHeight):
return "%sx%s"%(resolution[-1][0],resolution[-1][1])
gep = sqrt(height**2+width**2)
k = float(width)/float(height)
for themePkg in ['media-gfx/cldx-themes',
'media-gfx/cld-themes',
'media-gfx/cldg-themes']:
installed = getPkgInstalled(themePkg,
prefix=self.Get('cl_chroot_path'))
if installed and installed[0]['PV'].startswith('12'):
res = [(1024,576), (1024,600),
(1024,768), (1200,800), (1280,1024),
(1280,720), (1280,768), (1280,800),
(1360,768), (1366,768), (1368,768),
(1400,1050), (1440,900), (1600,1200),
(1600,768), (1600,900), (1680,1050),
(1680,945), (1920,1080), (1920,1200),
(2048,1152), (2560,1440), (2560,1600),
(640,480), (800,480) ]
break
else:
return "%sx%s"%(stWidth,stHeight)
res = [(1024,600), (1024,768),
(1280,1024), (1280,800),
(1366,768), (1440,900),
(1600,1200), (1680,1050),
(1920,1200)]
bestRes = min(res,
key=lambda x:(abs(x[0]/float(x[1])-k),
abs(gep-sqrt(x[0]**2+x[1]**2))))
return "%sx%s"%bestRes
def get_os_x11_composite(self):
"""On or off composite mode"""

Loading…
Cancel
Save