@@ -151,7 +151,7 @@ def _set_argtypes(self):
151
151
def _set_restypes (self ):
152
152
''' Functions return type. '''
153
153
154
- def validate (value ):
154
+ def validate (value , func , args ):
155
155
''' Validate the returned value of xrandr.XRRGetScreenResources().
156
156
We can end on a segfault if not:
157
157
Xlib: extension "RANDR" missing on display "...".
@@ -162,7 +162,7 @@ def validate(value):
162
162
err += ' NULL pointer received.'
163
163
raise ScreenshotError (err )
164
164
165
- return cast ( value , POINTER ( XRRScreenResources ))
165
+ return args
166
166
167
167
self .xlib .XOpenDisplay .restype = POINTER (Display )
168
168
self .xlib .XDefaultScreen .restype = c_int
@@ -172,7 +172,8 @@ def validate(value):
172
172
self .xlib .XDestroyImage .restype = c_void_p
173
173
self .xlib .XCloseDisplay .restype = c_void_p
174
174
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
176
177
self .xrandr .XRRGetCrtcInfo .restype = POINTER (XRRCrtcInfo )
177
178
self .xrandr .XRRFreeScreenResources .restype = c_void_p
178
179
self .xrandr .XRRFreeCrtcInfo .restype = c_void_p
0 commit comments