Winit: Missing Resize/DPR events when toggling monitor power on X11

Created on 30 Apr 2020  路  1Comment  路  Source: rust-windowing/winit

This was originally reported to Alacritty in https://github.com/alacritty/alacritty/issues/3651.

It seems like on Linux/X11 when a monitor is turned off and on again with a winit window on that monitor, it leads to problems with resize events.

Based on the logs, it seems like sometimes resize events are completely missing and other times the resize events seem to have an incorrect DPR. When the DPR is incorrect, the window size is still correct relative to the 'false' DPR though.

Trimmed version of the relevant logs:

# Original dimensions
[2020-04-29 16:53:14.548184253] [INFO] Device pixel ratio: 1.0833333333333333
[2020-04-29 16:53:16.351177699] [INFO] Width: 1872, Height: 1057

# Monitor off
[2020-04-29 16:53:26.450465654] [INFO] Font size changed to Size(22) with DPR of 1
[2020-04-29 16:53:26.455567699] [DEBUG] New num_cols is 216 and num_lines is 57
[2020-04-29 16:53:26.455626189] [INFO] Width: 1728, Height: 976

# Monitor on
[2020-04-29 16:53:26.472479056] [INFO] Font size changed to Size(22) with DPR of 1
[2020-04-29 16:53:26.478389663] [DEBUG] New num_cols is 234 and num_lines is 62
[2020-04-29 16:53:26.478540907] [INFO] Width: 1872, Height: 1057

-> Window size is correct, but DPR is wrong. With such a tiny DPI difference there might not be a change in font size, so for Alacritty users this looks like it's "working".

# Monitor off
[2020-04-29 16:53:51.852333868] [INFO] Font size changed to Size(22) with DPR of 1
[2020-04-29 16:53:51.855079602] [DEBUG] New num_cols is 216 and num_lines is 57
[2020-04-29 16:53:51.855119818] [INFO] Width: 1728, Height: 976

# Monitor on

-> No new events. Size is now 1728x976. So both DPR and dimensions are broken now

Toggling fullscreen mode (and probably other window size operations like resize) will fix both the DPR and size issue.

@house-of-vanity in your output the first time broke the DPR (see output with DPR of 1) and the second time broke the width and height. Can you reliably reproduce that this always happens in this exact order, or is it coincidental when the breakage happens? I'm mainly wondering if this issue is about DPR breaking and then future monitor toggling events incorrectly re-calculating on the wrong DPR.

X11 needs investigation bug

Most helpful comment

@chrisduerr yes, it's happens in exact order always.Furthermore i have to turn monitor off twice. Window always breaks after second time.

>All comments

@chrisduerr yes, it's happens in exact order always.Furthermore i have to turn monitor off twice. Window always breaks after second time.

Was this page helpful?
0 / 5 - 0 ratings