
    
3jN                       S SK Jr  S SKrS SKrS SKJrJr  S SKJr  S SKJ	r	  S SK
JrJr  S SKJr  S SKJr  S S	KJr  \(       a  S S
KJrJr  S SKJrJrJr   S SK
Jr   S SKJr  \	" 5       r Sr! " S S5      r"Sr# " S S\5      r$SS jr% " S S5      r&\&r'g! \ a     S SKJr   NH! \ a    \r  NSf = ff = f! \ a    S SKJr  \R>                  r Nnf = f)    )annotationsN)ABCabstractmethod)datetime)Lock)TYPE_CHECKINGAny)ScreenShotError)
ScreenShot)to_png)CallableIterator)MonitorMonitorsSize)Self)UTC)timezone   c                  (    \ rS rSrSS jrSS jrSrg)_PlatformSpecific8   c                $    [        U5      U l        g N)strsphinx_repr)selfr   s     B/home/wildlama/miniconda3/lib/python3.13/site-packages/mss/base.py__init___PlatformSpecific.__init__9   s    {+    c                    U R                   $ r   r   r   s    r   __repr___PlatformSpecific.__repr__<   s     r!   r#   N)r   r	   returnNone)r'   r   )__name__
__module____qualname____firstlineno__r   r%   __static_attributes__ r!   r   r   r   8   s    , r!   r   r.   c                      \ rS rSr% SrSrS\S'   SS.SS jjr\SS	 j5       r	\SS
 j5       r
\SS j5       rSS jr\ S           SS jj5       rSrg)MSSImplementationE   zBase class for internal platform/backend implementations.

Only one of these methods will be called at a time; the containing
MSS object will hold a lock during these calls.
)performance_statuswith_cursorboolr3   F)r3   c                  Xl         / U l        g r   )r3   r2   )r   r3   s     r   r   MSSImplementation.__init__P   s     ' .0r!   c                    g)z0Retrieve all cursor data. Pixels have to be RGB.Nr.   r$   s    r   cursorMSSImplementation.cursor]       r!   c                   g)zRetrieve all pixels from a monitor. Pixels have to be RGB.

If the monitor size is not in pixel units, include a Size in
pixels (see issue #23).
Nr.   )r   monitors     r   grabMSSImplementation.graba   r:   r!   c                    g)zReturn positions of monitors.Nr.   r$   s    r   monitorsMSSImplementation.monitorsi   r:   r!   c                    g)zClean up.

This will be called at most once.

It's not necessary for subclasses to implement this if they
have nothing to clean up.
Nr.   r$   s    r   closeMSSImplementation.closem   r:   r!   Nc               N    [        X5      nX%l        X5l        U(       a  XEl        ggzDFactory to create a ctypes function and automatically manage errors.NgetattrargtypesrestypeerrcheckattrfuncrI   rJ   rK   meths         r   	_cfactoryMSSImplementation._cfactoryv   %     t" $M r!   )r3   r4   r'   r(   )r'   zScreenShot | None)r<   r   r'   z"bytearray | tuple[bytearray, Size]r'   r   r'   r(   r   rK   zCallable | NonerM   r	   rN   r   rI   z	list[Any]rJ   r	   r'   r(   )r)   r*   r+   r,   __doc__	__slots____annotations__r   r   r8   r=   r@   rC   staticmethodrP   r-   r.   r!   r   r0   r0   E   s     6I16 0 ? ?   , ,  %)% "%%% % 	% 
% %r!   r0   c                     [         R                  " 5       R                  5       nUS:X  a  SSKJn  U" S	0 U D6$ US:X  a  SSKJn  U" S	0 U D6$ US:X  a  SSKJn  U" S	0 U D6$ SU< S3n[        U5      e)
a#  Return the backend implementation for the current platform.

Detects the platform we are running on and instantiates the
appropriate internal implementation class.

.. seealso::
    - :class:`mss.MSS`
    - :class:`mss.darwin.MSS`
    - :class:`mss.linux.MSS`
    - :class:`mss.windows.MSS`
darwinr   )MSSImplDarwinlinux)choose_implwindowszSystem z not (yet?) implemented.r.   )	platformsystemlower
mss.darwinr\   	mss.linuxr^   mss.windowsr
   )kwargsos_r\   choose_impl_linuxchoose_impl_windowsmsgs         r   _choose_implrk      s     //

!
!
#C
h,&v&&
g~> !*6**
iB #,V,,C72
3C
#
r!   c                  v   \ rS rSrSr\" S5      r\" S5      r\" S5      rSS\\\S.           SS	 jjr	SS
 jr
SS jrSS jrSS jr\S S j5       r\S!S j5       rSSSS.       S"S jjrS#S jr\S$S j5       r\ S%           S&S jj5       r\S'S j5       r\S(S j5       r\S)S j5       rSrg)*MSS   a  Multiple ScreenShots class

:param backend: Backend selector, for platforms with multiple backends.
:param compression_level: PNG compression level.
:param with_cursor: Include the mouse cursor in screenshots
    (GNU/Linux only)
:type display: bool, optional (default False)
:param display: X11 display name (GNU/Linux only).
:type display: bytes | str, optional (default :envvar:`$DISPLAY`)
:param max_displays: Maximum number of displays to enumerate (macOS only).
:type max_displays: int, optional (default 32)

.. versionadded:: 8.0.0
    ``compression_level``, ``display``, ``max_displays``, and
    ``with_cursor`` keyword arguments.

.. versionadded:: 10.2.0
    ``backend`` keyword argument.
FN    default   )backendcompression_levelr3   displaymax_displaysc                 0 n[         R                  " 5       nSUS/4SUS/4SUS/44 HW  u  pn
[        U	[        5      (       a  M  Xz;  a1  [        R
                  " U SSR                  U
5       S3[        S	S
9  MS  XU'   MY     [        SSU0UD6U l	        [        U l        X l        [        5       U l        S U l        SU l        g )Nr3   Linuxrt   ru   Darwinz is only available on z, z&. This will be an error in the future.   )
stacklevelrr   Fr.   )r`   ra   
isinstancer   warningswarnjoinDeprecationWarningrk   _implr   	cls_imagers   r   _lock	_monitors_closed)r   rr   rs   r3   rt   ru   impl_kwargsra   namevaluesupported_platformss              r   r   MSS.__init__   s     "K'3'+\H:61
,D,
 %!2330 f2499=P3Q2R S; ;& 	 %*D!#1
& )5 )
)
)

 ,6 "3 V
*.r!   c                    U $ )'For the cool call `with MSS() as mss:`.r.   r$   s    r   	__enter__MSS.__enter__  s    r!   c                $    U R                  5         g)r   N)rC   )r   _s     r   __exit__MSS.__exit__  s    

r!   c                    U R                      U R                  (       a
   SSS5        gU R                  R                  5         SU l        SSS5        g! , (       d  f       g= f)aM  Clean up.

This releases resources that MSS may be using.  Once the MSS
object is closed, it may not be used again.

It is safe to call this multiple times; multiple calls have no
effect.

Rather than use :py:meth:`close` explicitly, we recommend you
use the MSS object as a context manager::

    with mss.MSS() as sct:
        ...
NT)r   r   r   rC   r$   s    r   rC   	MSS.close  s?     ZZ|| Z JJDL	 ZZs   A!A
A!c               ^   [        U[        5      (       a  US   US   US   US   -
  US   US   -
  S.nUS   S::  d	  US   S::  a  SU< 3n[        U5      eU R                     U R                  R                  U5      n[        U[        5      (       a  Uu  pEU R                  XAUS	9nOUnU R                  XA5      nU R                  R                  (       a;  U R                  R                  5       =n(       a  U R                  Xg5      sS
S
S
5        $ UsS
S
S
5        $ ! , (       d  f       g
= f)aT  Retrieve screen pixels for a given monitor.

Note: ``monitor`` can be a tuple like the one
:py:meth:`PIL.ImageGrab.grab` accepts: ``(left, top, right, bottom)``

:param monitor: The coordinates and size of the box to capture.
                See :meth:`monitors <monitors>` for object details.
:returns: Screenshot of the requested region.
r      ry      )lefttopwidthheightr   r   z"Region has zero or negative size: )sizeN)
r{   tupler
   r   r   r=   r   r3   r8   _merge)r   r<   rj   img_data_and_maybe_sizeimg_datar   
screenshotr8   s           r   r=   MSS.grab   s    gu%%
qz gaj0!!*wqz1	G 7q GH$5$:6wkBC!#&&ZZ&*jjoog&>#1599!8!^^HD^I
2!^^H>
zz%%TZZ5F5F5H+H6+H{{:6 Z  ZZs   $B%DD
D,c                    U R                      U R                  c.  U R                  R                  5       U l        U R                  c   eU R                  sSSS5        $ ! , (       d  f       g= f)a  Get positions of all monitors.
If the monitor has rotation, you have to deal with it
inside this method.

This method has to fill ``self._monitors`` with all information
and use it as a cache:

- ``self._monitors[0]`` is a dict of all monitors together
- ``self._monitors[N]`` is a dict of the monitor N (with N > 0)

Each monitor is a dict with:

- ``left``: the x-coordinate of the upper-left corner
- ``top``: the y-coordinate of the upper-left corner
- ``width``: the width
- ``height``: the height
- ``is_primary``: (optional) true if this is the primary monitor
- ``name``: (optional) human-readable device name
- ``unique_id``: (optional) platform-specific stable identifier for the monitor
- ``output``: (optional, Linux only) monitor output name, compatible with xrandr
N)r   r   r   r@   r$   s    r   r@   MSS.monitorsC  sJ    . ZZ~~%!%!4!4!6~~111>>	 ZZs   AA
A,c                    U R                   n[        U5      S::  a  Sn[        U5      e[        S USS  5       US   5      $ )a  Get the primary monitor.

Returns the monitor marked as primary. If no monitor is marked as primary
(or the platform doesn't support primary monitor detection), returns the
first monitor (at index 1).

:raises ScreenShotError: If no monitors are available.

.. versionadded:: 10.2.0
r   No monitor found.c              3  X   #    U  H   nUR                  S S5      (       d  M  Uv   M"     g7f)
is_primaryFN)get).0r<   s     r   	<genexpr>&MSS.primary_monitor.<locals>.<genexpr>r  s'      +G;;|U3 +s   *	*N)r@   lenr
   next)r   r@   rj   s      r   primary_monitorMSS.primary_monitor`  sR     ==x=A%C!#&&'|
 QK
 	
r!   r   zmonitor-{mon}.png)monoutputcallbackc            #  "  #    U R                   nU(       d  Sn[        U5      eUS:X  a  [        USS S5       H  u  pgUR                  " SUSU;   a  [        R
                  " [        5      OSS.UD6n[        U5      (       a  U" U5        U R                  U5      n	[        U	R                  U	R                  U R                  US9  Uv   M     gUS:X  a  SOUn XA   nUR                  " SUSU;   a  [        R
                  " [        5      OSS.UD6n[        U5      (       a  U" U5        U R                  U5      n	[        U	R                  U	R                  U R                  US9  Uv   g! [         a  n
S	U< S
3n[        U5      U
eSn
A
ff = f7f)a  Grab a screenshot and save it to a file.

:param int mon: The monitor to screenshot (default=0). ``-1`` grabs all
    monitors, ``0`` grabs each monitor, and ``N`` grabs monitor ``N``.
:param str output: The output filename. Keywords: ``{mon}``, ``{top}``,
    ``{left}``, ``{width}``, ``{height}``, ``{date}``.
:param callable callback: Called before saving the screenshot; receives
    the ``output`` argument.
:return: Created file(s).
r   r   r   Nz{date)r   date)levelr   zMonitor z does not exist.r.   )r@   r
   	enumerateformatr   nowr   callabler=   r   rgbr   rs   
IndexError)r   r   r   r   r@   rj   idxr<   fnamesctexcs              r   saveMSS.savez  sj    $ ==%C!#&&!8 )(12, :p#TZIZHLL4E`dphopH%%UOii(sww0F0FuU !; by!cC4"-
 ]]msgQWFWc1B]amelmF!! ))G$C377CHHD,B,B6RL  4 '78%c*34s+   CFE* BF*
F4FFFc               b    UR                  SS5      US'   [        U R                  " S0 UD65      $ )zsHelper to save the screenshot of the 1st monitor, by default.
You can pass the same arguments as for :meth:`save`.
r   r   r.   )r   r   r   )r   rf   s     r   shotMSS.shot  s/     

5!,uDII''((r!   c          	     (   UR                   UR                  su  p#u  pEU R                   U R                  su  pgu  pX$-   X5-   pXh-   Xy-   pX,:  =(       a    X:  =(       a    X=:  =(       a    X:  nU(       d  U $ U R                  nUR                  nX7-
  S-  X-
  S-  pX&-
  S-  X-
  S-  pUS:  a  U* OSnUS:  a  U* OSnUS-  [        US5      -
  nUS-  [        U
S5      -
  n[	        S5      n[	        UUS5       H  nUU-   U-  U-   nUU-  n[	        UUS5       Ho  nUU-   nUU-   nUUS-      nU(       d  M  U[
        :X  a  UUUS-    UUUS-   & M8  US-  nU H,  n[        UUU-      U-  UUU-      SU-
  -  -   5      UUU-   '   M.     Mq     M     U $ )zCreate composite image by blending screenshot and mouse cursor.

The cursor image should be in straight (not premultiplied) alpha.
   r   r   r   r   )posr   rawmaxrangeOPAQUEint)r   r8   cxcycwchxywhcx2cy2x2y2overlap
screen_raw
cursor_rawstart_count_ystart_count_xstop_count_ystop_count_xr   count_ypos_spos_ccount_xsposcposalphaalpha2is                                  r   r   
MSS._merge  s    $ZZ(2#7BGSB'=cg="'=cg^^
ZZ
6Q,QC6Q,QC!Av1!Av1AvC+AvC+Ah]L!<Gr\Q&+EbLE a@ww"4!8,F?2<TD1H2MJtdQh/"S[F /2:dQh3G&3PS]^bef^fSgkloukuSv3v/w
4!8, ! A	 =& r!   c               N    [        X5      nX%l        X5l        U(       a  XEl        ggrF   rG   rL   s         r   rP   MSS._cfactory  rR   r!   c                .    U R                   R                  $ )az  Implementation-specific notes that might affect performance.

For instance, on GNU/Linux, when using the default XShmGetImage
backend, this will include a note if the MIT-SHM extension is
not usable.

This may not be ready until one screenshot has been taken.

This is meant only for debugging purposes; the contents are
subject to change at any time.

.. versionadded:: 10.2.0
)r   r2   r$   s    r   r2   MSS.performance_status  s     zz,,,r!   c                .    U R                   R                  $ )zTMaximum number of displays to handle.

Availability: macOS

.. versionadded:: 8.0.0
)r   ru   r$   s    r   ru   MSS.max_displays  s     zz&&&r!   c                .    U R                   R                  $ )a  Include the mouse cursor in screenshots.

In some circumstances, it may not be possible to include the
cursor.  In that case, MSS will automatically change this to
False when the object is created.

This cannot be changed after creating the object.

.. versionadded:: 8.0.0
)r   r3   r$   s    r   r3   MSS.with_cursor  s     zz%%%r!   )r   r   r   r   r   rs   )rr   r   rs   r   r3   zbool | _PlatformSpecificrt   z&bytes | str | None | _PlatformSpecificru   zint | _PlatformSpecificr'   r(   )r'   r   )r   objectr'   r(   rT   )r<   z#Monitor | tuple[int, int, int, int]r'   r   rS   )r'   r   )r   r   r   r   r   zCallable[[str], None] | Noner'   zIterator[str])rf   r	   r'   r   )r   r   r8   r   r'   r   r   rU   )r'   z	list[str])r'   r   )r'   r4   )r)   r*   r+   r,   rV   r   _PD_WITH_CURSOR_PD_DISPLAY_PD_MAX_DISPLAYSr   r   r   rC   r=   propertyr@   r   r   r   rY   r   rP   r2   ru   r3   r-   r.   r!   r   rm   rm      s   : (.O#D)K(, !!"0?:E0@4 	4
 4 .4 84 .4 
4l *!F " "8 
 
: )15/ 	/
 / // 
/b) - -^  %)% "%%% % 	% 
% %4 - -  ' ' & &r!   rm   )rf   r	   r'   r0   )(
__future__r   r`   r|   abcr   r   r   	threadingr   typingr   r	   mss.exceptionr
   mss.screenshotr   	mss.toolsr   collections.abcr   r   
mss.modelsr   r   r   r   ImportErrortyping_extensionsr   r   utclockr   r   __all__r0   rk   rm   MSSBaser.   r!   r   <module>r     s    #   #   % ) % 222 v	    ?% ?%D Hy& y&z _  	. 	D	  !
,,C	s<   B B8 B5B%%B1-B50B11B58CC