-
-
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
Open
halldorfannar
wants to merge
8
commits into
BoboTiG:main
Choose a base branch
from
halldorfannar:task/issue-153-primary-monitor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 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 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,45 @@ | ||
| """This is part of the MSS Python's module. | ||
| Source: https://github.com/BoboTiG/python-mss. | ||
| """ | ||
|
|
||
| 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("mss.windows" not in dir(), 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.
Uh oh!
There was an error while loading. Please reload this page.