Skip to content

Commit

Permalink
WIN32: Fixed setScale()
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalmat committed Aug 23, 2023
1 parent 93009cf commit bbf5e36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Binary file modified dist/PyMonCtl-0.0.10-py3-none-any.whl
Binary file not shown.
9 changes: 4 additions & 5 deletions src/pymonctl/_pymonctl_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ def _getPaths(self) -> Tuple[Optional[_LUID], Optional[int]]:
ret = ctypes.windll.user32.DisplayConfigGetDeviceInfo(ctypes.byref(sourceName))
if ret == 0 and sourceName.viewGdiDeviceName == self.name:
return path.sourceInfo.adapterId, path.sourceInfo.id
else:
return None, None
return None, None

def setScale(self, scale: Optional[Tuple[float, float]]):

Expand Down Expand Up @@ -292,19 +291,19 @@ def setScale(self, scale: Optional[Tuple[float, float]]):
minScale = _DPI_VALUES[scaleData.minScaleRel]
maxScale = _DPI_VALUES[scaleData.maxScaleRel]

scale = int(scale[0])
scaleValue: int = int(scale[0])
targetScale = -1
if scale < minScale:
targetScale = 0
elif scale > maxScale:
targetScale = len(_DPI_VALUES) - 1
else:
try:
targetScale = _DPI_VALUES.index(scale)
targetScale = _DPI_VALUES.index(scaleValue)
except:
for i, value in enumerate(_DPI_VALUES):
targetScale = i
if value > scale:
if value > scaleValue:
break
if targetScale >= 0:
setScaleData = _DISPLAYCONFIG_SOURCE_DPI_SCALE_SET()
Expand Down

0 comments on commit bbf5e36

Please sign in to comment.