@@ -151,7 +151,7 @@ def _set_argtypes(self):
151151 def _set_restypes (self ):
152152 ''' Functions return type. '''
153153
154- def validate (value ):
154+ def validate (value , func , args ):
155155 ''' Validate the returned value of xrandr.XRRGetScreenResources().
156156 We can end on a segfault if not:
157157 Xlib: extension "RANDR" missing on display "...".
@@ -162,7 +162,7 @@ def validate(value):
162162 err += ' NULL pointer received.'
163163 raise ScreenshotError (err )
164164
165- return cast ( value , POINTER ( XRRScreenResources ))
165+ return args
166166
167167 self .xlib .XOpenDisplay .restype = POINTER (Display )
168168 self .xlib .XDefaultScreen .restype = c_int
@@ -172,7 +172,8 @@ def validate(value):
172172 self .xlib .XDestroyImage .restype = c_void_p
173173 self .xlib .XCloseDisplay .restype = c_void_p
174174 self .xlib .XDefaultRootWindow .restype = POINTER (XWindowAttributes )
175- self .xrandr .XRRGetScreenResources .restype = validate
175+ self .xrandr .XRRGetScreenResources .restype = POINTER (XRRScreenResources )
176+ self .xrandr .XRRGetScreenResources .errcheck = validate
176177 self .xrandr .XRRGetCrtcInfo .restype = POINTER (XRRCrtcInfo )
177178 self .xrandr .XRRFreeScreenResources .restype = c_void_p
178179 self .xrandr .XRRFreeCrtcInfo .restype = c_void_p
0 commit comments