@@ -252,22 +252,16 @@ class USEROBJECTFLAGS(ctypes.Structure):
252
252
# process not running under the same user id as the current console
253
253
# user. To avoid that, raise an exception if the window manager
254
254
# connection is not available.
255
- from ctypes import cdll , c_int , pointer , Structure
256
- from ctypes . util import find_library
257
-
258
- app_services = cdll . LoadLibrary ( find_library ( "ApplicationServices" ) )
259
-
260
- if app_services . CGMainDisplayID () == 0 :
261
- reason = "gui tests cannot run without OS X window manager"
255
+ import subprocess
256
+ try :
257
+ rc = subprocess . run ([ "launchctl" , "managername" ],
258
+ capture_output = True , check = True )
259
+ managername = rc . stdout . decode ( "utf-8" ). strip ()
260
+ except subprocess . CalledProcessError :
261
+ reason = "unable to detect macOS launchd job manager"
262
262
else :
263
- class ProcessSerialNumber (Structure ):
264
- _fields_ = [("highLongOfPSN" , c_int ),
265
- ("lowLongOfPSN" , c_int )]
266
- psn = ProcessSerialNumber ()
267
- psn_p = pointer (psn )
268
- if ( (app_services .GetCurrentProcess (psn_p ) < 0 ) or
269
- (app_services .SetFrontProcess (psn_p ) < 0 ) ):
270
- reason = "cannot run without OS X gui process"
263
+ if managername != "Aqua" :
264
+ reason = f"{ managername = } -- can only run in a macOS GUI session"
271
265
272
266
# check on every platform whether tkinter can actually do anything
273
267
if not reason :
0 commit comments