Skip to content
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

libscreensaver: fix detection of monitor hotplug #463

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

vamposdecampos
Copy link
Contributor

When hot-adding monitors (e.g. DisplayPort), I was seeing unobscured content behind the screensaver. Debug mode revealed:

CsScreen received 'monitors-changed' signal from GdkScreen 25675900
Found 2 Xinerama screens on display :0
Monitor 0 is 0,0 1920 x 1080
Monitor 1 is 1920,0 1920 x 1200
Cinnamon Screensaver compiled without Solaris Xinerama support
Scale factor of 1 applied.  Monitor 0 is 0,0 1920 x 1080
Scale factor of 1 applied.  Monitor 1 is 1920,0 1920 x 1200
Screen rect (0,0-3840x1200) and 2 monitor rects (0,0-503284330x1200) DO NOT add up, skipping change notification cinnamon-screensaver

This could be caused by total_monitors rect being uninitialized; zero it. Might fix #437. Seems like this could fix #460, though the log therein does not say "DO NOT add up".

Ref: #437
Ref: #460
Fixes: d23d1ea "Rework behavior surrounding sleep, display changes, fractional scaling."

@@ -416,7 +416,7 @@ is_full_change (CsScreen *screen)
{
// Check to see if the union of monitor rects is the same size as the screen

GdkRectangle total_monitors;
GdkRectangle total_monitors = {};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Zeroing worksforme, but perhaps it can have issues if there's no monitor starting at (0,0)? That could be avoided by having total_monitors = screen->monitor_infos[0].rect initially. Let me know if that's preferable, I can cook up another patch.

Copy link
Member

Choose a reason for hiding this comment

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

can you initialize it to {0} (this is the more accepted method).

This function is a sanity check for the monitor layout - the inclusive monitor rect should always match the screen rectangle. I may have been shooting myself in the foot here, mistaking where bad values were coming from.

Some of this also may not even be necessary anymore. The 'loop' described in d23d1ea ended up being a muffin issue (linuxmint/muffin@bf234250143), but I never had a chance to re-evaluate things here.

Thanks!

@clefebvre
Copy link
Member

Can you paste what you get in debug mode after applying the patch?

When hot-adding monitors (e.g. DisplayPort), I was seeing unobscured
content behind the screensaver.  Debug mode revealed:

	CsScreen received 'monitors-changed' signal from GdkScreen 25675900
	Found 2 Xinerama screens on display :0
	Monitor 0 is 0,0 1920 x 1080
	Monitor 1 is 1920,0 1920 x 1200
	Cinnamon Screensaver compiled without Solaris Xinerama support
	Scale factor of 1 applied.  Monitor 0 is 0,0 1920 x 1080
	Scale factor of 1 applied.  Monitor 1 is 1920,0 1920 x 1200
	Screen rect (0,0-3840x1200) and 2 monitor rects (0,0-503284330x1200) DO NOT add up, skipping change notification cinnamon-screensaver

This could be caused by `total_monitors` rect being uninitialized; zero
it.  Might fix linuxmint#437.  Seems like this could fix linuxmint#460, though the log
therein does _not_ say "DO NOT add up".

Ref: linuxmint#437
Ref: linuxmint#460
Fixes: d23d1ea "Rework behavior surrounding sleep, display changes, fractional scaling."
Signed-off-by: Alex Badea <[email protected]>
@vamposdecampos
Copy link
Contributor Author

Can you paste what you get in debug mode after applying the patch?

Yeah. This was started with 3 monitors, and unplugging 2 of them (i.e. the docking station):

CsScreen received 'monitors-changed' signal from GdkScreen 29732191
Found 3 Xinerama screens on display :0
Monitor 0 is 0,0 1920 x 1200
Monitor 1 is 3840,120 1920 x 1080
Monitor 2 is 1920,0 1920 x 1200
Cinnamon Screensaver compiled without Solaris Xinerama support
Scale factor of 1 applied.  Monitor 0 is 0,0 1920 x 1200
Scale factor of 1 applied.  Monitor 1 is 3840,120 1920 x 1080
Scale factor of 1 applied.  Monitor 2 is 1920,0 1920 x 1200
Screen rect (0,0-1920x1080) and 3 monitor rects (0,0-5760x1200) DO NOT add up, skipping change notification
CsScreen received 'size-changed' signal from GdkScreen 29732194
Found 3 Xinerama screens on display :0
Monitor 0 is 0,0 1920 x 1200
Monitor 1 is 3840,120 1920 x 1080
Monitor 2 is 1920,0 1920 x 1200
Cinnamon Screensaver compiled without Solaris Xinerama support
Scale factor of 1 applied.  Monitor 0 is 0,0 1920 x 1200
Scale factor of 1 applied.  Monitor 1 is 3840,120 1920 x 1080
Scale factor of 1 applied.  Monitor 2 is 1920,0 1920 x 1200
Screen rect (0,0-1920x1080) and 3 monitor rects (0,0-5760x1200) DO NOT add up, skipping change notification
** (cs-backup-locker:745849): DEBUG: 10:33:00.741: ConfigureNotify from root window (0x79e), screen size may have changed. (we're the backup-locker)
CsScreen received 'monitors-changed' signal from GdkScreen 29733630
Cinnamon Screensaver compiled without Solaris Xinerama support
No Xinerama screens, using default screen info
Scale factor of 1 applied.  Monitor 0 is 0,0 1920 x 1080
Screen rect (0,0-5760x1200) and 1 monitor rects (0,0-1920x1080) DO NOT add up, skipping change notification
CsScreen received 'size-changed' signal from GdkScreen 29733630
Cinnamon Screensaver compiled without Solaris Xinerama support
No Xinerama screens, using default screen info
Scale factor of 1 applied.  Monitor 0 is 0,0 5760 x 1200
Screen rect (0,0-5760x1200) and 1 monitor rects (0,0-5760x1200) add up, sending change notification
Stage: Received screen size-changed signal, refreshing stage
manager: queuing stage refresh
** (cs-backup-locker:745849): DEBUG: 10:33:00.745: ConfigureNotify from root window (0x79e), screen size may have changed. (we're the backup-locker)
** (cs-backup-locker:745849): DEBUG: 10:33:01.023: ConfigureNotify from root window (0x79e), screen size may have changed. (we're the backup-locker)
CsScreen received 'monitors-changed' signal from GdkScreen 29733911
Found 1 Xinerama screens on display :0
Monitor 0 is 0,0 1920 x 1080
** (cs-backup-locker:745849): DEBUG: 10:33:01.057: BackupWindow received ConfigureNotify from window '(null)' (0xae), raising ourselves.
Cinnamon Screensaver compiled without Solaris Xinerama support
Scale factor of 1 applied.  Monitor 0 is 0,0 1920 x 1080
Screen rect (0,0-5760x1200) and 1 monitor rects (0,0-1920x1080) DO NOT add up, skipping change notification
** (cs-backup-locker:745849): DEBUG: 10:33:01.058: ConfigureNotify from root window (0x79e), screen size may have changed. (we're the backup-locker)
Stage: refreshing
** (cs-backup-locker:745849): DEBUG: 10:33:01.062: ConfigureNotify from root window (0x79e), screen size may have changed. (we're the backup-locker)
** (cs-backup-locker:745849): DEBUG: 10:33:01.063: ConfigureNotify from root window (0x79e), screen size may have changed. (we're the backup-locker)

[...]

** (cinnamon-screensaver-main.py:745728): DEBUG: 10:33:01.282: ConfigureNotify from root window (0x79e), screen size may have changed. 
CsScreen received 'monitors-changed' signal from GdkScreen 29734172
Found 1 Xinerama screens on display :0
Monitor 0 is 0,0 1920 x 1080
Cinnamon Screensaver compiled without Solaris Xinerama support
Scale factor of 1 applied.  Monitor 0 is 0,0 1920 x 1080
Screen rect (0,0-1920x1080) and 1 monitor rects (0,0-1920x1080) add up, sending change notification
Stage: Received screen monitors-changed signal, refreshing stage
manager: queuing stage refresh
CsScreen received 'size-changed' signal from GdkScreen 29734173
cs-auth-pam (pid 747153): pam_start ("cinnamon-screensaver", "alex", ...) ==> 0 (Success)
Found 1 Xinerama screens on display :0
Monitor 0 is 0,0 1920 x 1080
Cinnamon Screensaver compiled without Solaris Xinerama support
Scale factor of 1 applied.  Monitor 0 is 0,0 1920 x 1080
Screen rect (0,0-1920x1080) and 1 monitor rects (0,0-1920x1080) add up, sending change notification
Stage: Received screen size-changed signal, refreshing stage
manager: queuing stage refresh
Stage: refreshing

which does show a (transient) case when they still don't add up.

Then plugging the docking station (2 monitors) back in:

** (cinnamon-screensaver-main.py:745728): DEBUG: 10:33:44.883: Screensaver received ConfigureNotify from window '(null)' (0xae), raising ourselves.
** (cinnamon-screensaver-main.py:745728): DEBUG: 10:33:44.888: ConfigureNotify from root window (0x79e), screen size may have changed. 
CsScreen received 'monitors-changed' signal from GdkScreen 29781631
Found 2 Xinerama screens on display :0
Monitor 0 is 0,0 1920 x 1080
Monitor 1 is 1920,0 1920 x 1200
Cinnamon Screensaver compiled without Solaris Xinerama support
Scale factor of 1 applied.  Monitor 0 is 0,0 1920 x 1080
Scale factor of 1 applied.  Monitor 1 is 1920,0 1920 x 1200
Screen rect (0,0-3840x1200) and 2 monitor rects (0,0-3840x1200) add up, sending change notification
Stage: Received screen monitors-changed signal, refreshing stage
manager: queuing stage refresh
** (cs-backup-locker:748659): DEBUG: 10:33:48.744: BackupWindow received ConfigureNotify from window '(null)' (0xae), raising ourselves.
CsScreen received 'size-changed' signal from GdkScreen 29781632
Found 2 Xinerama screens on display :0
Monitor 0 is 0,0 1920 x 1080
Monitor 1 is 1920,0 1920 x 1200
Cinnamon Screensaver compiled without Solaris Xinerama support
Scale factor of 1 applied.  Monitor 0 is 0,0 1920 x 1080
Scale factor of 1 applied.  Monitor 1 is 1920,0 1920 x 1200
Screen rect (0,0-3840x1200) and 2 monitor rects (0,0-3840x1200) add up, sending change notification
Stage: Received screen size-changed signal, refreshing stage
manager: queuing stage refresh
** (cs-backup-locker:748659): DEBUG: 10:33:48.744: ConfigureNotify from root window (0x79e), screen size may have changed. (we're the backup-locker)
Stage: refreshing

...


** (cinnamon-screensaver-main.py:745728): DEBUG: 10:33:52.185: ConfigureNotify from root window (0x79e), screen size may have changed. 
** (cinnamon-screensaver-main.py:745728): DEBUG: 10:33:52.187: Screensaver received ConfigureNotify from window 'backup-locker' (0x7a00006), raising ourselves.
** (cinnamon-screensaver-main.py:745728): DEBUG: 10:33:52.196: Screensaver received ConfigureNotify from window 'backup-locker' (0x7a00006), raising ourselves.
Handling message style 1: 'Password: '
cs-auth-pam (pid 749844): Waiting for respose to message style 1: 'Password: '
Waiting for lock
Waiting for response
cinnamon-screensaver-pam-helper: Got message style 1: 'Password: '
CsScreen received 'monitors-changed' signal from GdkScreen 29785097
Found 3 Xinerama screens on display :0
Monitor 0 is 0,0 1920 x 1200
Monitor 1 is 3840,120 1920 x 1080
Monitor 2 is 1920,0 1920 x 1200
Cinnamon Screensaver compiled without Solaris Xinerama support
Scale factor of 1 applied.  Monitor 0 is 0,0 1920 x 1200
Scale factor of 1 applied.  Monitor 1 is 3840,120 1920 x 1080
Scale factor of 1 applied.  Monitor 2 is 1920,0 1920 x 1200
Screen rect (0,0-5760x1200) and 3 monitor rects (0,0-5760x1200) add up, sending change notification
Stage: Received screen monitors-changed signal, refreshing stage
manager: queuing stage refresh
CsScreen received 'size-changed' signal from GdkScreen 29785109
Found 3 Xinerama screens on display :0
Monitor 0 is 0,0 1920 x 1200
Monitor 1 is 3840,120 1920 x 1080
Monitor 2 is 1920,0 1920 x 1200
Cinnamon Screensaver compiled without Solaris Xinerama support
Scale factor of 1 applied.  Monitor 0 is 0,0 1920 x 1200
Scale factor of 1 applied.  Monitor 1 is 3840,120 1920 x 1080
Scale factor of 1 applied.  Monitor 2 is 1920,0 1920 x 1200
Screen rect (0,0-5760x1200) and 3 monitor rects (0,0-5760x1200) add up, sending change notification
Stage: Received screen size-changed signal, refreshing stage
manager: queuing stage refresh
Output from pam helper: 'CS_PAM_AUTH_SET_PROMPT_Password: _'
authClient: idle add auth-prompt
Output from pam helper: 'CS_PAM_AUTH_BUSY_FALSE'
authClient: idle add auth-busy
Output from pam helper: ''
Stage: refreshing

or in summary:

$ grep 'add up' before-patch-debug.log 
Screen rect (0,0-3840x1200) and 2 monitor rects (0,0-503284330x1200) DO NOT add up, skipping change notification
Screen rect (0,0-3840x1200) and 2 monitor rects (0,0-503284330x1200) DO NOT add up, skipping change notification
Screen rect (0,0-3840x1200) and 2 monitor rects (1920,0-503282410x1200) DO NOT add up, skipping change notification
Screen rect (0,0-5760x1200) and 3 monitor rects (0,0-503284331x1200) DO NOT add up, skipping change notification
Screen rect (0,0-5760x1200) and 3 monitor rects (0,0-503284331x1200) DO NOT add up, skipping change notification
Screen rect (0,0-5760x1200) and 3 monitor rects (0,0-503284330x1200) DO NOT add up, skipping change notification

$ grep 'add up' after-patch-debug.log 
Screen rect (0,0-1920x1080) and 3 monitor rects (0,0-5760x1200) DO NOT add up, skipping change notification
Screen rect (0,0-1920x1080) and 3 monitor rects (0,0-5760x1200) DO NOT add up, skipping change notification
Screen rect (0,0-5760x1200) and 1 monitor rects (0,0-1920x1080) DO NOT add up, skipping change notification
Screen rect (0,0-5760x1200) and 1 monitor rects (0,0-5760x1200) add up, sending change notification
Screen rect (0,0-5760x1200) and 1 monitor rects (0,0-1920x1080) DO NOT add up, skipping change notification
Screen rect (0,0-1920x1080) and 1 monitor rects (0,0-1920x1080) add up, sending change notification
Screen rect (0,0-1920x1080) and 1 monitor rects (0,0-1920x1080) add up, sending change notification
Screen rect (0,0-3840x1200) and 2 monitor rects (0,0-3840x1200) add up, sending change notification
Screen rect (0,0-3840x1200) and 2 monitor rects (0,0-3840x1200) add up, sending change notification
Screen rect (0,0-5760x1200) and 3 monitor rects (0,0-5760x1200) add up, sending change notification
Screen rect (0,0-5760x1200) and 3 monitor rects (0,0-5760x1200) add up, sending change notification

@clefebvre clefebvre merged commit 338a858 into linuxmint:master Nov 26, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants