Skip to content

Comments

Add identifying information about monitors under Linux#477

Open
jholveck wants to merge 9 commits intoBoboTiG:mainfrom
jholveck:feat-xcb-better-monitors
Open

Add identifying information about monitors under Linux#477
jholveck wants to merge 9 commits intoBoboTiG:mainfrom
jholveck:feat-xcb-better-monitors

Conversation

@jholveck
Copy link
Contributor

Changes proposed in this PR

Adds new attributes to the _monitors dicts. These are all optional; they’re only populated if they can be probed via XRandR.

  • output: The output name, as used in XRandR. This is the main identifier used in some monitor configuration tools, like the Linux xrandr command-line tool. This is only populated under Linux.
  • name: The human-friendly monitor name, from the EDID block
  • unique_id: A platform-specific string that tries to identify the monitor as specifically as possible, across reconnections and configuration changes. On Linux, this is a URL-query-formatted string including the ID, serial, and dates from the EDID block.
  • is_primary: True if the monitor is marked as “primary”. This is where things like the taskbar are expected to appear.

This change also adds support for RandR 1.5 Monitors, a user-configurable concept that aligns with the MSS monitor concept. This separates the physical CRTC concept from the logical concept, used for things like tiled displays.

This change also adds some small developer-visible improvements: it adds support for InternAtom, and also makes XIDs and other X primitive types comparable (preventing one class of bugs).

Fixes #153 (for Linux)
Related to #469 ; this is the Linux side

Otherwise, you need things like `this_visual_id.value == that_visual_id.value`,
and get unexpected negatives for just `this_visual_id == that_visual_id`.
This can be a potential source of bugs.
This will be needed to get the monitor's human-friendly name under
Linux: XRandR will give us the EDID block, but we need to parse it.
See BoboTiG/python-mss PR BoboTiG#469 and issue BoboTiG#153.

There are no plans to add similar code to the legacy Xlib backend.
Uses the := walrus operator to reduce redundant dict lookups.

Also (this wasn't in the review), refactors an "in" test from a version I wrote when I needed a more complicated test, to one that's easier to read.
In the previous code, "is_primary" would only be set on the primary
monitor (where it's True).

This change sets it on all monitors, to parallel the Windows behavior.

This code won't set it at all if the primary monitor cannot be
determined (XRandR 1.2), although it might set all of them to False if
XRandR tells us explicitly that no monitor is primary.
(MSSBase.primary_monitor, in the pending PR BoboTiG#469, will use the first
monitor in that event.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How can I tell which is the primary monitor in the monitors array?

2 participants