@@ -139,6 +139,38 @@ class XRRCrtcInfo(ctypes.Structure):
139
139
]
140
140
141
141
142
+ @ctypes .CFUNCTYPE (ctypes .c_int , ctypes .POINTER (Display ), ctypes .POINTER (Event ))
143
+ def error_handler (_ , event ):
144
+ # type: (ctypes.POINTER(Display), ctypes.POINTER(Event)) -> int
145
+ """ Specifies the program's supplied error handler. """
146
+
147
+ global LAST_ERROR
148
+
149
+ evt = event .contents
150
+ LAST_ERROR = {
151
+ "type" : evt .type ,
152
+ "serial" : evt .serial ,
153
+ "error_code" : evt .error_code ,
154
+ "request_code" : evt .request_code ,
155
+ "minor_code" : evt .minor_code ,
156
+ }
157
+ return 0
158
+
159
+
160
+ def validate (retval , func , args ):
161
+ # type: (int, Any, Tuple[Any, Any]) -> Any
162
+ """ Validate the returned value of a Xlib or XRANDR function. """
163
+
164
+ global LAST_ERROR
165
+
166
+ if retval != 0 and not LAST_ERROR :
167
+ return args
168
+
169
+ err = "{}() failed" .format (func .__name__ )
170
+ details = {"retval" : retval , "args" : args }
171
+ raise ScreenShotError (err , details = details )
172
+
173
+
142
174
class MSS (MSSMixin ):
143
175
"""
144
176
Multiple ScreenShots implementation for GNU/Linux.
@@ -419,35 +451,3 @@ def grab(self, monitor):
419
451
self .xlib .XDestroyImage (ximage )
420
452
421
453
return self .cls_image (data , monitor )
422
-
423
-
424
- @ctypes .CFUNCTYPE (ctypes .c_int , ctypes .POINTER (Display ), ctypes .POINTER (Event ))
425
- def error_handler (_ , event ):
426
- # type: (ctypes.POINTER(Display), ctypes.POINTER(Event)) -> int
427
- """ Specifies the program's supplied error handler. """
428
-
429
- global LAST_ERROR
430
-
431
- evt = event .contents
432
- LAST_ERROR = {
433
- "type" : evt .type ,
434
- "serial" : evt .serial ,
435
- "error_code" : evt .error_code ,
436
- "request_code" : evt .request_code ,
437
- "minor_code" : evt .minor_code ,
438
- }
439
- return 0
440
-
441
-
442
- def validate (retval , func , args ):
443
- # type: (int, Any, Tuple[Any, Any]) -> Any
444
- """ Validate the returned value of a Xlib or XRANDR function. """
445
-
446
- global LAST_ERROR
447
-
448
- if retval != 0 and not LAST_ERROR :
449
- return args
450
-
451
- err = "{}() failed" .format (func .__name__ )
452
- details = {"retval" : retval , "args" : args }
453
- raise ScreenShotError (err , details = details )
0 commit comments