Skip to content

Commit

Permalink
Linux: Fixed getAllScreens() for LXDE
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalmat committed Apr 8, 2022
1 parent cd4d99a commit 50416a9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
Binary file modified dist/PyWinCtl-0.0.34-py3-none-any.whl
Binary file not shown.
62 changes: 31 additions & 31 deletions src/pywinctl/_pywinctl_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,40 +1071,40 @@ def getAllScreens():
wa = EWMH.getWorkArea() or [0, 0, 0, 0]
for output in res.outputs:
params = DISP.xrandr_get_output_info(output, res.config_timestamp)
if params.crtc:
crtc = DISP.xrandr_get_crtc_info(params.crtc, res.config_timestamp)

if crtc and crtc.mode: # displays with empty (0) mode seem not to be valid
name = params.name
if name in result.keys():
name = name + str(i)
crtc = DISP.xrandr_get_crtc_info(params.crtc, res.config_timestamp)
if crtc and crtc.mode: # displays with empty (0) mode seem not to be valid
id = crtc.sequence_number
x, y, w, h = crtc.x, crtc.y, crtc.width, crtc.height
wx, wy, wr, wb = x + wa[0], y + wa[1], x + w - (screen.width_in_pixels - wa[2] - wa[0]), y + h - (screen.height_in_pixels - wa[3] - wa[1])
# check all these values with physical monitors using dpi, mms or other possible values or props
dpiX, dpiY = round(w * 25.4 / screen.width_in_mms), round(h * 25.4 / screen.height_in_mms)
# 'dpi' = (round(SCREEN.width_in_pixels * 25.4 / SCREEN.width_in_mms), round(SCREEN.height_in_pixels * 25.4 / SCREEN.height_in_mms)),
# 'dpi' = (round(crtc.width * 25.4 / params.mm_width), round(crtc.height * 25.4 / params.mm_height)),
scaleX, scaleY = round(dpiX / 96 * 100), round(dpiY / 96 * 100)
rot = int(math.log(crtc.rotation, 2))
freq = 0
for mode in modes:
if crtc.mode == mode.id:
freq = mode.dot_clock / (mode.h_total * mode.v_total)
break
depth = screen.root_depth

result[name] = {
'id': id,
'is_primary': (x, y) == (0, 0),
'pos': Point(x, y),
'size': Size(w, h),
'workarea': Rect(wx, wy, wr, wb),
'scale': (scaleX, scaleY),
'dpi': (dpiX, dpiY),
'orientation': rot,
'frequency': freq,
'colordepth': depth
}
id = crtc.sequence_number
x, y, w, h = crtc.x, crtc.y, crtc.width, crtc.height
wx, wy, wr, wb = x + wa[0], y + wa[1], x + w - (screen.width_in_pixels - wa[2] - wa[0]), y + h - (screen.height_in_pixels - wa[3] - wa[1])
# check all these values with physical monitors using dpi, mms or other possible values or props
dpiX, dpiY = round(w * 25.4 / screen.width_in_mms), round(h * 25.4 / screen.height_in_mms)
# 'dpi' = (round(SCREEN.width_in_pixels * 25.4 / SCREEN.width_in_mms), round(SCREEN.height_in_pixels * 25.4 / SCREEN.height_in_mms)),
# 'dpi' = (round(crtc.width * 25.4 / params.mm_width), round(crtc.height * 25.4 / params.mm_height)),
scaleX, scaleY = round(dpiX / 96 * 100), round(dpiY / 96 * 100)
rot = int(math.log(crtc.rotation, 2))
freq = 0
for mode in modes:
if crtc.mode == mode.id:
freq = mode.dot_clock / (mode.h_total * mode.v_total)
break
depth = screen.root_depth

result[name] = {
'id': id,
'is_primary': (x, y) == (0, 0),
'pos': Point(x, y),
'size': Size(w, h),
'workarea': Rect(wx, wy, wr, wb),
'scale': (scaleX, scaleY),
'dpi': (dpiX, dpiY),
'orientation': rot,
'frequency': freq,
'colordepth': depth
}
except:
print(traceback.format_exc())
# props = DISP.xrandr_list_output_properties(output)
Expand Down
1 change: 1 addition & 0 deletions src/pywinctl/_pywinctl_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,7 @@ def getAllScreens() -> dict:
name = monitor_info.get("Device", None)
if name == dev.DeviceName:
break

if monitor_info:
x, y, r, b = monitor_info.get("Monitor", (0, 0, 0, 0))
wx, wy, wr, wb = monitor_info.get("Work", (0, 0, 0, 0))
Expand Down

0 comments on commit 50416a9

Please sign in to comment.