Skip to content

Commit

Permalink
fix issue #79: do monitor detection in MSS constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasbuhr authored and BoboTiG committed Nov 20, 2018
1 parent f3c83cf commit 02ccb8f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
Alexander 'thehesiod' Mohr [https://github.com/thehesiod]
- Windows: robustness to MSS.get_pixels()

Andreas Buhr [https://www.andreasbuhr.de]
- Bugfix for multi-monitor detection

bubulle [http://indexerror.net/user/bubulle]
- Windows: efficiency of MSS.get_pixels()

Expand Down
1 change: 0 additions & 1 deletion mss/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class MSSBase(object):

cls_image = ScreenShot # type: object
compression_level = 6 # type: int
_monitors = [] # type: List[Dict[str, int]]

def __enter__(self):
# type: () -> MSSBase
Expand Down
2 changes: 2 additions & 0 deletions mss/darwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def __init__(self):
# type: () -> None
""" macOS initialisations. """

self._monitors = [] # type: List[Dict[str, int]]

coregraphics = ctypes.util.find_library("CoreGraphics")
if not coregraphics:
raise ScreenShotError("No CoreGraphics library found.")
Expand Down
2 changes: 2 additions & 0 deletions mss/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def __init__(self, display=None):
# type: (bytes) -> None
""" GNU/Linux initialisations. """

self._monitors = [] # type: List[Dict[str, int]]

if not display:
try:
display = os.environ["DISPLAY"].encode("utf-8")
Expand Down
2 changes: 2 additions & 0 deletions mss/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def __init__(self):
# type: () -> None
""" Windows initialisations. """

self._monitors = [] # type: List[Dict[str, int]]

self.monitorenumproc = ctypes.WINFUNCTYPE(
ctypes.wintypes.INT,
ctypes.wintypes.DWORD,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_entry_point(capsys, sct):

fmt = "sct_{mon}-{date:%Y-%m-%d}.png"
for opt in ("-o", "--out"):
main([opt, fmt])
main(["-m 1", opt, fmt])
filename = fmt.format(mon=1, date=datetime.now())
out, _ = capsys.readouterr()
assert out.endswith(filename + "\n")
Expand Down

0 comments on commit 02ccb8f

Please sign in to comment.