-
-
Notifications
You must be signed in to change notification settings - Fork 112
Enhance Monitor dict, adding primary monitor and name attributes #469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
BoboTiG
merged 12 commits into
BoboTiG:main
from
halldorfannar:task/issue-153-primary-monitor
Feb 21, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6969a82
Add Monitor class and primary monitor support
halldorfannar b39ef85
Roll back some of the Monitor related changes
halldorfannar 3f74986
Streamline tests for Monitor
halldorfannar c4ce4a9
Add TODO for Monitor class
halldorfannar dc9e3b5
Apply suggestions from code review
halldorfannar 3fd5c15
Raise exception if no monitors are attached and primary_monitor is ac…
halldorfannar 4dd4ea0
Improve the Sphinx configuration
halldorfannar 4907986
Add developer-facing changes to CHANGES.md
halldorfannar 67a60de
Add unique_id to Monitor
halldorfannar 2fab103
Rather than use a fallback for Monitor name, we now take advantage of…
halldorfannar ac79ccf
Fix how we detect windows platform for this test
halldorfannar 67455d0
Update src/mss/base.py
halldorfannar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| """This is part of the MSS Python's module. | ||
| Source: https://github.com/BoboTiG/python-mss. | ||
| """ | ||
|
|
||
| import platform | ||
| from collections.abc import Callable | ||
|
|
||
| import pytest | ||
|
|
||
| from mss.base import MSSBase | ||
|
|
||
|
|
||
| def test_primary_monitor(mss_impl: Callable[..., MSSBase]) -> None: | ||
| """Test that primary_monitor property works correctly.""" | ||
| with mss_impl() as sct: | ||
| primary = sct.primary_monitor | ||
| monitors = sct.monitors | ||
|
|
||
| # Should return a valid monitor dict | ||
| assert isinstance(primary, dict) | ||
| assert "left" in primary | ||
| assert "top" in primary | ||
| assert "width" in primary | ||
| assert "height" in primary | ||
|
|
||
| # Should be in the monitors list (excluding index 0 which is "all monitors") | ||
| assert primary in monitors[1:] | ||
|
|
||
| # Should either be marked as primary or be the first monitor as fallback | ||
| if primary.get("is_primary", False): | ||
| assert primary["is_primary"] is True | ||
| else: | ||
| assert primary == monitors[1] | ||
|
|
||
|
|
||
| @pytest.mark.skipif(platform.system() != "Windows", reason="Windows only") | ||
| def test_primary_monitor_coordinates_windows() -> None: | ||
| """Test that on Windows, the primary monitor has coordinates at (0, 0).""" | ||
| import mss # noqa: PLC0415 | ||
|
|
||
| with mss.mss() as sct: | ||
| primary = sct.primary_monitor | ||
| if primary.get("is_primary", False): | ||
| # On Windows, the primary monitor is at (0, 0) | ||
| assert primary["left"] == 0 | ||
| assert primary["top"] == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we putting these into 10.1.1, or 10.2.0?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10.2.0. But no need to deal with that, I'll adapt it at release time.