1717if TYPE_CHECKING :
1818 from collections .abc import Callable , Iterator
1919
20- from mss .linux .xshmgetimage import ShmStatus
2120 from mss .models import Monitor , Monitors , Size
2221
2322 # Prior to 3.11, Python didn't have the Self type. typing_extensions does, but we don't want to depend on it.
@@ -74,7 +73,7 @@ class MSSImplementation(ABC):
7473 MSS object will hold a lock during these calls.
7574 """
7675
77- __slots__ = ("with_cursor" , )
76+ __slots__ = ("performance_status" , "with_cursor" )
7877
7978 with_cursor : bool
8079
@@ -87,6 +86,10 @@ def __init__(self, /, *, with_cursor: bool = False) -> None:
8786 # Xlib is legacy, and just complicates things.
8887 self .with_cursor = with_cursor
8988
89+ # Any notes the backend needs to give the user for debugging purposes, like why it had to fall back to a
90+ # slower implementation.
91+ self .performance_status : list [str ] = []
92+
9093 @abstractmethod
9194 def cursor (self ) -> ScreenShot | None :
9295 """Retrieve all cursor data. Pixels have to be RGB."""
@@ -169,15 +172,17 @@ class MSS:
169172
170173 :param backend: Backend selector, for platforms with multiple backends.
171174 :param compression_level: PNG compression level.
172- :param with_cursor: Include the mouse cursor in screenshots (GNU/Linux only)
175+ :param with_cursor: Include the mouse cursor in screenshots
176+ (GNU/Linux only)
173177 :type display: bool, optional (default False)
174178 :param display: X11 display name (GNU/Linux only).
175179 :type display: bytes | str, optional (default :envvar:`$DISPLAY`)
176180 :param max_displays: Maximum number of displays to enumerate (macOS only).
177181 :type max_displays: int, optional (default 32)
178182
179183 .. versionadded:: 8.0.0
180- ``compression_level``, ``display``, ``max_displays``, and ``with_cursor`` keyword arguments.
184+ ``compression_level``, ``display``, ``max_displays``, and
185+ ``with_cursor`` keyword arguments.
181186
182187 .. versionadded:: 10.2.0
183188 ``backend`` keyword argument.
@@ -498,35 +503,23 @@ def _cfactory(
498503 # max_displays, should probably be removed in 11.0. with_cursor
499504 # should probably be moved to MSS instead of MSSImplementation (as
500505 # noted there).
501- #
502- # The shm_status is mostly a debugging field, and probably should
503- # be replaced with something different. Ideas include a log
504- # message, an exception if the user explicitly requested
505- # xshmgetimage, or a platform-independent message attribute (for
506- # instance, if Windows has to fall back to GDI).
507506
508507 @property
509- def shm_status (self ) -> ShmStatus :
510- """Whether we can use the MIT-SHM extensions for this connection .
508+ def performance_status (self ) -> list [ str ] :
509+ """Implementation-specific notes that might affect performance .
511510
512- Availability: GNU/Linux, when using the default XShmGetImage backend.
511+ For instance, on GNU/Linux, when using the default XShmGetImage
512+ backend, this will include a note if the MIT-SHM extension is
513+ not usable.
513514
514- This will not be ``AVAILABLE`` until at least one capture has succeeded.
515- It may be set to ``UNAVAILABLE`` sooner.
516-
517- .. versionadded:: 10.2.0
518- """
519- return self ._impl .shm_status # type: ignore[attr-defined]
520-
521- @property
522- def shm_fallback_reason (self ) -> str | None :
523- """If MIT-SHM is unavailable, the reason why (for debugging purposes).
515+ This may not be ready until one screenshot has been taken.
524516
525- Availability: GNU/Linux, when using the default XShmGetImage backend.
517+ This is meant only for debugging purposes; the contents are
518+ subject to change at any time.
526519
527520 .. versionadded:: 10.2.0
528521 """
529- return self ._impl .shm_fallback_reason # type: ignore[attr-defined]
522+ return self ._impl .performance_status
530523
531524 @property
532525 def max_displays (self ) -> int :
0 commit comments