Skip to content

examples/monitor_list: properly print output#2658

Merged
kchibisov merged 3 commits intorust-windowing:masterfrom
dhardy:master
Jan 30, 2023
Merged

examples/monitor_list: properly print output#2658
kchibisov merged 3 commits intorust-windowing:masterfrom
dhardy:master

Conversation

@dhardy
Copy link
Copy Markdown
Contributor

@dhardy dhardy commented Jan 28, 2023

  • Tested on all platforms changed
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

The old version of examples/monitor_list.rs simply used the debug repr of MonitorHandle, which on Wayland looks like this:

[examples/monitor_list.rs:11] window.available_monitors().collect::<Vec<_>>() = [
    MonitorHandle {
        inner: Wayland(
            MonitorHandle {
                proxy: wl_output@13,
            },
        ),
    },
]
[examples/monitor_list.rs:12] window.primary_monitor() = None

Updated version prints useful, more platform consistent info:

name: eDP-1-unknown (InfoVision)
size: PhysicalSize { width: 1920, height: 1200 }
position: PhysicalPosition { x: 0, y: 0 }
refresh_rate: Some(59999) mHz
scale_factor: 1.0
mode: PhysicalSize { width: 1920, height: 1200 }, depth = 32 bits, refresh rate = 59999 mHz

@kchibisov
Copy link
Copy Markdown
Member

That looks better, but I'd suggest to separate the outputs(with at least a new line) and maybe print the video modes as well, the example will print more stuff about the monitors, so it could be used to help debugging issues.

Formatting the way sway does would be nice, but I don't really insist, it's just hard to grasp because everything is on the same level.

Maybe the output of sway's output commands could inspire you.

Output DP-2 'Dell Inc. DELL P2417H CW6Y76BQ5L2L'
  Current mode: 1920x1080 @ 60.000 Hz
  Position: 2560,100
  Scale factor: 1.000000
  Scale filter: nearest
  Subpixel hinting: rgb
  Transform: normal
  Workspace: 7
  Max render time: 3 ms
  Adaptive sync: disabled
  Available modes:
    1920x1080 @ 60.000 Hz
    1680x1050 @ 60.000 Hz
    1600x900 @ 60.000 Hz
    1280x1024 @ 75.025 Hz
    1280x1024 @ 60.020 Hz
    1440x900 @ 60.000 Hz
    1280x800 @ 60.000 Hz
    1152x864 @ 75.000 Hz
    1280x720 @ 60.000 Hz
    1024x768 @ 75.029 Hz
    1024x768 @ 60.004 Hz
    800x600 @ 75.000 Hz
    800x600 @ 60.317 Hz
    640x480 @ 75.000 Hz
    640x480 @ 59.940 Hz
    720x400 @ 70.082 Hz

Output DP-1 'LG Electronics 27GL850 005NTCZ59867' (focused)
  Current mode: 2560x1440 @ 144.000 Hz
  Position: 0,0
  Scale factor: 1.000000
  Scale filter: nearest
  Subpixel hinting: rgb
  Transform: normal
  Workspace: 1
  Max render time: 3 ms
  Adaptive sync: disabled
  Available modes:
    2560x1440 @ 144.000 Hz
    2560x1440 @ 120.000 Hz
    2560x1440 @ 99.900 Hz
    2560x1440 @ 59.951 Hz
    1920x1440 @ 75.000 Hz
    1920x1440 @ 60.000 Hz
    1856x1392 @ 75.000 Hz
    1856x1392 @ 59.995 Hz
    1792x1344 @ 74.997 Hz
    1792x1344 @ 60.000 Hz
    2048x1152 @ 60.000 Hz

for mon in window.available_monitors() {
print_info(mon);
}
if let Some(mon) = window.primary_monitor() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not very clear that the last monitor is the primary monitor (if there is one...).
I suggest to highlight the primary monitor when looping over all the monitors.

@dhardy
Copy link
Copy Markdown
Contributor Author

dhardy commented Jan 30, 2023

Updated:

Primary output: DisplayPort-2
  Current mode: 3840x2160 @ 60.0 Hz
  Position: 0,0
  Scale factor: 1.5
  Available modes (width x height x bit-depth):
    3840x2160x24 @ 59.996 Hz
    3840x2160x24 @ 60.0 Hz
    3840x2160x24 @ 50.0 Hz
    3840x2160x24 @ 59.940 Hz
    3840x2160x24 @ 30.0 Hz
    3840x2160x24 @ 25.0 Hz
    3840x2160x24 @ 24.0 Hz
    3840x2160x24 @ 29.970 Hz
    3840x2160x24 @ 23.976 Hz
    2560x1440x24 @ 59.950 Hz
    1920x1200x24 @ 59.996 Hz
    1920x1080x24 @ 60.0 Hz
    1920x1080x24 @ 50.0 Hz
    1920x1080x24 @ 59.940 Hz
    1600x1200x24 @ 59.996 Hz
    1680x1050x24 @ 59.954 Hz
    1280x1024x24 @ 60.19 Hz
    1440x900x24 @ 59.887 Hz
    1280x960x24 @ 60.0 Hz
    1280x800x24 @ 59.810 Hz
    1280x720x24 @ 60.0 Hz
    1280x720x24 @ 50.0 Hz
    1280x720x24 @ 59.940 Hz
    1024x768x24 @ 60.3 Hz
    800x600x24 @ 60.316 Hz
    800x600x24 @ 56.250 Hz
    720x576x24 @ 50.0 Hz
    720x480x24 @ 60.0 Hz
    720x480x24 @ 59.940 Hz
    640x480x24 @ 60.0 Hz
    640x480x24 @ 59.940 Hz

@kchibisov kchibisov merged commit 483c1d4 into rust-windowing:master Jan 30, 2023
@dhardy dhardy mentioned this pull request Jan 30, 2023
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants