|
|
|
@ -37,7 +37,7 @@ class fillVars(object, cl_base.glob_attr):
|
|
|
|
|
|
|
|
|
|
def getX11Resolution(self):
|
|
|
|
|
"""возвращает текущее разрешение экрана (ширина, высота), X запущен"""
|
|
|
|
|
lines=self._runos("%s xdpyinfo -display :0.0"%self.path_env)
|
|
|
|
|
lines=self._runos("%s xdpyinfo"%self.path_env)
|
|
|
|
|
reRes = re.compile("dimensions:\s+(\d+)x(\d+)\s+pixels")
|
|
|
|
|
searchRes=False
|
|
|
|
|
for line in lines:
|
|
|
|
@ -61,4 +61,56 @@ class fillVars(object, cl_base.glob_attr):
|
|
|
|
|
resolution = self.getX11Resolution()
|
|
|
|
|
if resolution:
|
|
|
|
|
self.Set('hr_x11_height',resolution[1])
|
|
|
|
|
return resolution[0]
|
|
|
|
|
return resolution[0]
|
|
|
|
|
|
|
|
|
|
def get_hr_x11_standart(self):
|
|
|
|
|
"""Получить ближайший стандартный размер изображения к текущему разрешению"""
|
|
|
|
|
#Стандартные разрешения
|
|
|
|
|
width = int(self.Get('hr_x11_width'))
|
|
|
|
|
height = int(self.Get('hr_x11_height'))
|
|
|
|
|
res = [(1024,768),
|
|
|
|
|
(1280,1024),
|
|
|
|
|
(1280,800),
|
|
|
|
|
(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])
|
|
|
|
|
else:
|
|
|
|
|
return "%sx%s"%(stWidth,stHeight)
|