Skip to content

Commit 02ccb8f

Browse files
andreasbuhrBoboTiG
authored andcommitted
fix issue BoboTiG#79: do monitor detection in MSS constructor
1 parent f3c83cf commit 02ccb8f

File tree

6 files changed

+10
-2
lines changed

6 files changed

+10
-2
lines changed

CONTRIBUTORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
Alexander 'thehesiod' Mohr [https://github.com/thehesiod]
1010
- Windows: robustness to MSS.get_pixels()
1111

12+
Andreas Buhr [https://www.andreasbuhr.de]
13+
- Bugfix for multi-monitor detection
14+
1215
bubulle [http://indexerror.net/user/bubulle]
1316
- Windows: efficiency of MSS.get_pixels()
1417

mss/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class MSSBase(object):
1616

1717
cls_image = ScreenShot # type: object
1818
compression_level = 6 # type: int
19-
_monitors = [] # type: List[Dict[str, int]]
2019

2120
def __enter__(self):
2221
# type: () -> MSSBase

mss/darwin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def __init__(self):
6767
# type: () -> None
6868
""" macOS initialisations. """
6969

70+
self._monitors = [] # type: List[Dict[str, int]]
71+
7072
coregraphics = ctypes.util.find_library("CoreGraphics")
7173
if not coregraphics:
7274
raise ScreenShotError("No CoreGraphics library found.")

mss/linux.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ def __init__(self, display=None):
160160
# type: (bytes) -> None
161161
""" GNU/Linux initialisations. """
162162

163+
self._monitors = [] # type: List[Dict[str, int]]
164+
163165
if not display:
164166
try:
165167
display = os.environ["DISPLAY"].encode("utf-8")

mss/windows.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def __init__(self):
6262
# type: () -> None
6363
""" Windows initialisations. """
6464

65+
self._monitors = [] # type: List[Dict[str, int]]
66+
6567
self.monitorenumproc = ctypes.WINFUNCTYPE(
6668
ctypes.wintypes.INT,
6769
ctypes.wintypes.DWORD,

tests/test_implementation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_entry_point(capsys, sct):
114114

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

0 commit comments

Comments
 (0)