+
    SiC                    x  a  0 t $ R t^ RIHt ^ RIt^ RIHt ^ RIHtH	t	H
t
HtHtHtHtHtHtHtHtHtHtHtHtHtHtHt ^ RIHt ^ RIHtHt ^ RIH t H!t! ^ RI"H#t#H$t$ ^ R	I%H&t& ] '       d   ^ R
I'H(t(H)t) ^ RI*H+t+ R9t,Rt-^t.^ t/]/0t0 ! R R]
4      t1 ! R R]
4      t2 ! R R]
4      t3 ! R R]
4      t4 ! R R]
4      t5 ! R R]
4      t6 ! R R]
4      t7 ! R R]
4      t8/ t9]! R4      t:]! R4      t;]! R 4      t<]! ]]	! ]14      ]	! ]24      4      R! R" l4       t=R# R$ lt>R%R&]	! ]14      .]3R'R&]	! ]14      .]	! ]84      3R(R&]	! ]44      .]3R)R*]	! ]14      .]	! ]34      3R+R&]	! ]14      ]	! ]14      ]]]]]].]	! ]44      3R,R&]	! ]14      ]	! ]84      ]	! ]84      .]3R-R&].]	! ]14      3R.R&]	! ]14      ]]	! ]4      ]	! ]4      ]	! ]4      .]3R/R0]	! ]54      .]3R1R0]	! ]74      .]3R2R0]	! ]14      ]	! ]74      ].]	! ]54      3R3R0]	! ]14      ]	! ]14      .]	! ]74      3R4R0]	! ]14      ]	! ]14      .]	! ]74      3R5R&].]3/t?R6]@R7&    ! R8 R]#4      tAR# ):zXThis is part of the MSS Python's module.
Source: https://github.com/BoboTiG/python-mss.
)annotationsN)suppress)	CFUNCTYPEPOINTER	Structurebyrefc_char_pc_intc_int32c_longc_shortc_ubytec_uintc_uint32c_ulongc_ushortc_void_pcastcdllcreate_string_buffer)find_library)current_threadlocal)TYPE_CHECKINGAny)MSSBaselock)ScreenShotError)
CFunctionsMonitor)
ScreenShotMSSi c                      ] tR t^3tRtRtR# )DisplayzStructure that serves as the connection to the X server
and that contains all the information about that X server.
https://github.com/garrybodsworth/pyxlib-ctypes/blob/master/pyxlib/xlib.py#L831.
 N__name__
__module____qualname____firstlineno____doc____static_attributes__r$       O/Users/mibo/.openclaw/workspace/.venv/lib/python3.14/site-packages/mss/linux.pyr#   r#   3   s    r,   r#   c                  T    ] tR t^:tRtR]3R]! ]4      3R]3R]	3R]	3R]	3R]
33tR	tR
# )XErrorEventz{XErrorEvent to debug eventual errors.
https://tronche.com/gui/x/xlib/event-handling/protocol-errors/default-handlers.html.
typedisplayserial
error_coderequest_code
minor_code
resourceidr$   N)r&   r'   r(   r)   r*   r	   r   r#   r   r   r   _fields_r+   r$   r,   r-   r/   r/   :   sL    
 
	GG$%	7	w	!	w	x Hr,   r/   c                  f    ] tR t^JtRtR]3R]3R]3R]3R]3R]3R]3R	]! ]4      3R
]3R]	33
t
RtR# )XFixesCursorImagezCursor structure.
/usr/include/X11/extensions/Xfixes.h
https://github.com/freedesktop/xorg-libXfixes/blob/libXfixes-6.0.0/include/X11/extensions/Xfixes.h#L96.
xywidthheightxhotyhotcursor_serialpixelsatomnamer$   N)r&   r'   r(   r)   r*   r   r   r   r   r   r7   r+   r$   r,   r-   r9   r9   J   sc     
g	g	(	8			'"	77#$		Hr,   r9   c                  x    ] tR t^^tRtR]3R]3R]3R]3R]3R]3R]3R	]3R
]3R]3R]3R]3R]3R]3R]33tRt	R# )XImagezrDescription of an image as it exists in the client's memory.
https://tronche.com/gui/x/xlib/graphics/images.html.
r<   r=   xoffsetformatdata
byte_orderbitmap_unitbitmap_bit_order
bitmap_paddepthbytes_per_linebits_per_pixelred_mask
green_mask	blue_maskr$   N)
r&   r'   r(   r)   r*   r	   r   r   r7   r+   r$   r,   r-   rE   rE   ^   s    
 
%	5	E	5		u		U#	u	%	5!	5!	W	w	gHr,   rE   c                  ~    ] tR t^vtRtR]3R]3R]3R]3R]3R]3R]3R	]3R
]	! ]4      3R]
3R]3R]	! ]4      33tRtR# )XRRCrtcInfozStructure that contains CRTC information.
https://gitlab.freedesktop.org/xorg/lib/libxrandr/-/blob/master/include/X11/extensions/Xrandr.h#L360.
	timestampr:   r;   r<   r=   moderotationnoutputoutputs	rotations	npossiblepossibler$   N)r&   r'   r(   r)   r*   r   r	   r   r   r   r   r7   r+   r$   r,   r-   rT   rT   v   sv    
 
g	e	e	&	6		U	E	GFO$	h	e	WV_%Hr,   rT   c                      ] tR t^tRtRtR# )XRRModeInfozehttps://gitlab.freedesktop.org/xorg/lib/libxrandr/-/blob/master/include/X11/extensions/Xrandr.h#L248.r$   Nr%   r$   r,   r-   r^   r^      s    or,   r^   c                  r    ] tR t^tRtR]3R]3R]3R]! ]4      3R]3R]! ]4      3R]3R	]! ]	4      33t
R
tR# )XRRScreenResourceszStructure that contains arrays of XIDs that point to the
available outputs and associated CRTCs.
https://gitlab.freedesktop.org/xorg/lib/libxrandr/-/blob/master/include/X11/extensions/Xrandr.h#L265.
rU   configTimestampncrtccrtcsrX   rY   nmodemodesr$   N)r&   r'   r(   r)   r*   r   r	   r   r   r^   r7   r+   r$   r,   r-   r`   r`      s]     
g	G$	%	'&/"	E	GFO$	%	'+&'	Hr,   r`   c                      ] tR t^tRtR]3R]3R]3R]3R]3R]3R]3R	]3R
]3R]3R]3R]3R]3R]3R]3R]3R]3R]3R]3R]3R]3R]3R]33tRt	R# )XWindowAttributesz$Attributes for the specified window.r:   r;   r<   r=   border_widthrM   visualrootclassbit_gravitywin_gravitybacking_storebacking_planesbacking_pixel
save_undercolormapmapinstalled	map_stateall_event_masksyour_event_maskdo_not_propagate_maskoverride_redirectscreenr$   N)
r&   r'   r(   r)   r*   r
   r   r   r7   r+   r$   r,   r-   rg   rg      s    . 
g	g	'	7	!	'	7		'	 	 	'"	7#	'"	w	W	"	h	G$	G$	 '*	g&	7/Hr,   rg   X11XfixesXrandrc               $    V ^8  d   QhRRRRRR/# )   r1   r#   eventr/   returnintr$   )rG   s   "r-   __annotate__r      s!      G K C r,   c                   \         P                  ! \        4      pVP                  p\	        \
        4      \        \        \        .Vn        \        Vn
        VP                  p\        R4      pV! WP                  V\        V4      4       RVP                  P!                  R4      RVP                  RVP"                  RVP$                  RVP&                  RVP(                  /\*        \-        4       &   ^ # )	z/Specifies the program's supplied error handler.i   errorutf-8r3   r5   r4   r2   r0   )r   LoadLibrary_X11XGetErrorTextr   r#   r	   r   argtypesr   restypecontentsr   r3   lenvaluedecoder5   r4   r2   r0   _ERRORr   )r1   r   xlib	get_errorevtr   s   &&    r-   _error_handlerr      s     D!D""I!'*E8UCI I
..C &Eg~~uc%j9 	##G,cnncnn((#** F> r,   c               (    V ^8  d   QhRRRRRRRR/# )r~   retvalr   funcr   argsztuple[Any, Any]r   r$   )rG   s   "r-   r   r      s(     0 0c 0 0O 0? 0r,   c                   \        4       pV ^ 8w  d   V\        9  d   V# \        P                  V/ 4      pVP                   R2p\	        WTR7      h)z1Validate the returned value of a C function call.z	() failed)details)r   r   popr&   r   )r   r   r   threadr   msgs   """   r-   	_validater      sH    F{vV+jj$G]]O9
%C
#
//r,   XCloseDisplayr   XDefaultRootWindowXDestroyImageXFixesGetCursorImagexfixes	XGetImageXGetWindowAttributesXOpenDisplayXQueryExtensionXRRFreeCrtcInfoxrandrXRRFreeScreenResourcesXRRGetCrtcInfoXRRGetScreenResourcesXRRGetScreenResourcesCurrentXSetErrorHandlerr   
CFUNCTIONSc                     a  ] tR tRtRt0 RmtR V 3R lltR R ltR R ltR	 R
 lt	R R lt
R R ltR R ltRtV ;t# )r!   i  zjMultiple ScreenShots implementation for GNU/Linux.
It uses intensively the Xlib and its Xrandr extension.
c                    V ^8  d   QhRRRR/# )r~   kwargsr   r   Noner$   )rG   s   "r-   r   MSS.__annotate__  s     <L <LC <LD <Lr,   c                 < \         SV `  ! R/ VB  \        4       V n        RV P                  n        RV P                  n        RV P                  n        RV P                  n        VP                  RR4      pV'       g(    \        P                  R,          P                  R4      p\        V\        4      '       g   VP                  R4      pRV9  d   RV: R	2p\        V4      h\         '       g   R
p\        V4      h\"        P$                  ! \         4      V n        \(        '       g   Rp\        V4      h\"        P$                  ! \(        4      V n        V P,                  '       d4   \.        '       d!   \"        P$                  ! \.        4      V n        MRV n        V P3                  4        V P&                  P5                  \6        4      V P                  n        V P&                  P9                  V4      V P                  n        V P                  P                  '       g   RV: R	2p\        V4      hV P;                  R4      '       g   Rp\        V4      hV P&                  P=                  V P                  P                  4      V P                  n        \?        V P                  P                  \A        \B        4      4      V P                  n        R#   \         d    Rp\        T4      Rhi ; i)zGNU/Linux initialisations.Nr1   r,   DISPLAYr   z$DISPLAY not set.   :zBad display value: .zNo X11 library found.zNo Xrandr extension found.FzUnable to open display: RANDRzXrandr not enabled.r$   )"super__init__r   _handlesr1   drawableoriginal_error_handlerrj   getosenvironencodeKeyErrorr   
isinstancebytesr   r   r   r   _XRANDRr   with_cursor_XFIXESr   _set_cfunctionsr   r   r   _is_extension_enabledr   r   r   r#   )selfr   r1   r   	__class__s   ",  r-   r   MSS.__init__  s1   "6"  $!%/3,!**Y,5**Y/66w?
 '5))nnW-Gw'{!4C!#&&t)C!#&&$$T*	w.C!#&&&&w/w"..w7#(  04yy/I/I./Y, $		 6 6w ?}}$$$,WKq9C!#&&))'22'C!#&&!YY99$--:O:OP "&dmm&8&8'':J!K[  5)%c*45s    &K K+c                   V ^8  d   QhRR/# r~   r   r   r$   )rG   s   "r-   r   r   K  s      t r,   c                	6   V P                   P                  '       dz   \        ;_uu_ 4        V P                  P	                  V P                   P                  4       R R R 4       R V P                   n        R V P                   n        R V P                   n        V P                   P                  '       dA   V P                  P                  V P                   P                  4       R V P                   n        \        P                  4        R #   + '       g   i     L; i)N)r   r1   r   r   r   r   rj   r   r   r   clear)r   s   &r-   close	MSS.closeK  s    ==   		''(=(=> $(DMM!%)DMM"!%DMM ==/// II&&t}}'K'KL37DMM0 	# s   0DD	c                    V ^8  d   QhRRRR/# )r~   rC   strr   boolr$   )rG   s   "r-   r   r   a  s      # T r,   c               x   \        4       p\        4       p\        4       p \        ;_uu_ 4        V P                  P                  V P                  P
                  VP                  R4      \        V4      \        V4      \        V4      4       RRR4       R#   + '       g   i     R# ; i  \         d     R# i ; i)z>Return True if the given *extension* is enabled on the server.latin1NFT)	r	   r   r   r   r   r1   r   r   r   )r   rC   major_opcode_returnfirst_event_returnfirst_error_returns   ""   r-   r   MSS._is_extension_enableda  s    #g"W"W
			))MM))KK)-.,-,-      		s/   B* ABB* B'	!B* 'B* *B98B9c                   V ^8  d   QhRR/# r   r$   )rG   s   "r-   r   r   t  s     R R Rr,   c                V   V P                   pR\        V RR4      RV P                  RV P                  /p\        P                  4        FI  w  pw  rEp\        \        4      ;_uu_ 4        VR8X  d   RM\        pV! W$,          W5WgR7       RRR4       KK  	  R#   + '       g   i     K`  ; i)z7Set all ctypes functions and attach them to attributes.r   Nr   r   r   )errcheck)		_cfactorygetattrr   r   r   itemsr   AttributeErrorr   )r   cfactoryattrsr   attrr   r   r   s   &       r-   r   MSS._set_cfunctionst  s    >>gdHd3DIIdkk

 0:/?/?/A+D+47.))#'+=#=49dgQ *) 0B)))s   (!BB(c                   V ^8  d   QhRR/# r   r$   )rG   s   "r-   r   r     s     '+ '+ '+r,   c                j   V P                   P                  p\        pV P                  p\	        4       pV P
                  P                  WP                   P                  \        V4      4       V P                  P                  RV! VP                  4      RV! VP                  4      RV! VP                  4      RV! VP                  4      /4        VP                  WP                   P                   4      P"                  pVP(                  p\+        VP,                  4       F  pVP/                  WWg,          4      P"                  pVP0                  ^ 8X  d   VP3                  V4       KI  V P                  P                  RV! VP                  4      RV! VP                  4      RV! VP                  4      RV! VP                  4      /4       VP3                  V4       K  	  VP5                  V4       R#   \$         d4    TP'                  YP                   P                   4      P"                  p EL2i ; i)z;Get positions of monitors. It will populate self._monitors.lefttopr<   r=   N)r   r1   r   r   rg   r   r   rj   r   	_monitorsappendr:   r;   r<   r=   r   r   r   r   r   rc   rangerb   r   rX   r   r   )	r   r1   int_r   gwamonrc   idxcrtcs	   &        r-   _monitors_implMSS._monitors_impl  s   --''  !		&&w0B0BE#JOT#%%[%ceegtCIIPXZ^_b_i_iZjk	
	Y55g}}?U?UV__C 		#C((uzBKKD||q &&t,NN!!DL4<T$**-d4;;/	 ""4( $ 	%%c*'  	Y..w8N8NOXXC	Ys   /G4 4:H21H2c                    V ^8  d   QhRRRR/# )r~   monitorr   r   r    r$   )rG   s   "r-   r   r     s     - -' - -r,   c          
        V P                   P                  V P                  P                  V P                  P                  VR,          VR,          VR,          VR,          \
        \        4      p VP                  P                  pV\        9  d   RV R2p\        V4      h\        VP                  P                  \        \        VR,          ,          VR,          ,          ^,          4      4      p\        VP                  4      pV P                   P!                  V4       V P#                  Wa4      #   T P                   P!                  T4       i ; i)z:Retrieve all pixels from a monitor. Pixels have to be RGB.r   r   r<   r=   z6[XImage] bits per pixel value not (yet?) implemented: r   )r   r   r   r1   r   	PLAINMASKZPIXMAPr   rO   SUPPORTED_BITS_PER_PIXELSr   r   rH   r   r   	bytearrayr   	cls_image)r   r   ximagerO   r   raw_datarH   s   ""     r-   
_grab_implMSS._grab_impl  s   $$MM!!MM""FOENGH	
	,#__;;N%>>N~N^^_`%c**$$'("33gg6FFJKH X../D II##F+~~d,, II##F+s   0BD3 3Ec                   V ^8  d   QhRR/# )r~   r   r    r$   )rG   s   "r-   r   r     s     , ,j ,r,   c                   V P                   P                  V P                  P                  4      pV'       d   VP                  '       g   Rp\        V4      hVP                  pRVP                  VP                  ,
          RVP                  VP                  ,
          RVP                  RVP                  /p\        VP                  \        \        VR,          ,          VR,          ,          4      4      p\!        VP                  4      p\!        VR,          VR,          ,          ^,          4      pVR,          VR&   VR,          VR	&   VR
,          VR&   VR,          VR&   V P#                  Wt4      # )z0Retrieve all cursor data. Pixels have to be RGB.z"Cannot read XFixesGetCursorImage()r   r   r<   r=   :   N   :r  N   :r~   Nr  :r~   Nr  :   Nr  :r  Nr  :NNr  :NNr  )r   r   r   r1   r   r   r:   r>   r;   r?   r<   r=   r   rA   r   r   r   r   )r   r   r   
cursor_imgregionr   rawrH   s   &       r-   _cursor_implMSS._cursor_impl  s&    11$--2G2GH6???6C!#&&(.
JLL:??2:<<*//1Z%%j''	
 
))77VH=M3MPVW^P_3_+`a))*)F7O;a?@YT
YT
YT
HS	~~d++r,   )r   r   r   r   r   >   r   r   r   r   )r&   r'   r(   r)   r*   	__slots__r   r   r   r   r   r   r
  r+   __classcell__)r   s   @r-   r!   r!     sA     9I<L <L|,&R'+R-<, ,r,   )r!   )B__conditional_annotations__r*   
__future__r   r   
contextlibr   ctypesr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   ctypes.utilr   	threadingr   r   typingr   r   mss.baser   r   mss.exceptionr   
mss.modelsr   r   mss.screenshotr    __all__r   r   BITS_PER_PIXELS_32r   r#   r/   r9   rE   rT   r^   r`   rg   r   r   r   r   r   r   r   __annotations__r!   )r  s   @r-   <module>r     s   # 	     ( % + % " ).)
 	
  
i )  	 (Y 0) *p) p $	 < 
E
x
 
x
  5''"GK$89 :00& fww/0(;6GG$4#5w?P7QRfwv/:X(8'97CT;UV		77+UE667TYZ
 Vgg&6@Q8RT[\mTn%oqvwVhZ)9:!18WU^WUZ^]dej]k lntu7;#7"8(Cx'2D*E)FQx''"2G<N4OQW!XZabmZnoh)977;K(LgVhNij"X0@''BR/SU\]oUp$q(X6'
J .[,' [,r,   