2020
2121__all__ = ("MSS" ,)
2222
23+ MAC_VERSION_CATALINA = 10.16
24+
2325
2426def cgfloat () -> type [c_double | c_float ]:
2527 """Get the appropriate value for a float."""
@@ -59,7 +61,7 @@ def __repr__(self) -> str:
5961#
6062# Note: keep it sorted by cfunction.
6163CFUNCTIONS : CFunctions = {
62- # cfunction: (attr, argtypes, restype)
64+ # Syntax: cfunction: (attr, argtypes, restype)
6365 "CGDataProviderCopyData" : ("core" , [c_void_p ], c_void_p ),
6466 "CGDisplayBounds" : ("core" , [c_uint32 ], CGRect ),
6567 "CGDisplayRotation" : ("core" , [c_uint32 ], c_float ),
@@ -98,7 +100,7 @@ def __init__(self, /, **kwargs: Any) -> None:
98100 def _init_library (self ) -> None :
99101 """Load the CoreGraphics library."""
100102 version = float ("." .join (mac_ver ()[0 ].split ("." )[:2 ]))
101- if version < 10.16 :
103+ if version < MAC_VERSION_CATALINA :
102104 coregraphics = ctypes .util .find_library ("CoreGraphics" )
103105 else :
104106 # macOS Big Sur and newer
@@ -136,9 +138,13 @@ def _monitors_impl(self) -> None:
136138 rect = core .CGDisplayBounds (display )
137139 rect = core .CGRectStandardize (rect )
138140 width , height = rect .size .width , rect .size .height
141+
142+ # 0.0: normal
143+ # 90.0: right
144+ # -90.0: left
139145 if core .CGDisplayRotation (display ) in {90.0 , - 90.0 }:
140- # {0.0: "normal", 90.0: "right", -90.0: "left"}
141146 width , height = height , width
147+
142148 self ._monitors .append (
143149 {
144150 "left" : int_ (rect .origin .x ),
@@ -161,7 +167,6 @@ def _monitors_impl(self) -> None:
161167
162168 def _grab_impl (self , monitor : Monitor , / ) -> ScreenShot :
163169 """Retrieve all pixels from a monitor. Pixels have to be RGB."""
164-
165170 core = self .core
166171 rect = CGRect ((monitor ["left" ], monitor ["top" ]), (monitor ["width" ], monitor ["height" ]))
167172
0 commit comments