Skip to content

Commit eeb5402

Browse files
author
BoboTiG
committed
Linux: better error message on xlib.XGetImage() failure
1 parent cf6697f commit eeb5402

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

mss/linux.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ def enum_display_monitors(self, force=False):
223223
'left': int(gwa.x),
224224
'top': int(gwa.y),
225225
'width': int(gwa.width),
226-
'height': int(gwa.height)
226+
'height': int(gwa.height),
227+
'monitor': 0
227228
})
228229

229230
# Each monitors
@@ -238,7 +239,8 @@ def enum_display_monitors(self, force=False):
238239
'left': int(crtc.contents.x),
239240
'top': int(crtc.contents.y),
240241
'width': int(crtc.contents.width),
241-
'height': int(crtc.contents.height)
242+
'height': int(crtc.contents.height),
243+
'monitor': num
242244
})
243245
self.xrandr.XRRFreeCrtcInfo(crtc)
244246
self.xrandr.XRRFreeScreenResources(mon)
@@ -261,7 +263,11 @@ def get_pixels(self, monitor):
261263
self.width, self.height, allplanes,
262264
zpixmap)
263265
if not ximage:
264-
raise ScreenshotError('xlib.XGetImage() failed.')
266+
err = 'xlib.XGetImage() failed. Monitor informations: '
267+
for key, val in sorted(monitor.items()):
268+
err = '{0}{1}: {2}, '.format(err, key, val)
269+
err = err.strip(', ')
270+
raise ScreenshotError(err)
265271

266272
if not self.use_mss:
267273
self.get_pixels_slow(ximage)

0 commit comments

Comments
 (0)