Skip to content

libgdm: Remove duplicate sessions once, after all sessions have been processed

Iain Lane requested to merge deduplicate-after-collecting into master

We add sessions to a hash table keyed on the basename without extension, and while we're adding them we de-duplicate based on the translated name (the text that will be visible in the switcher).

This has a problem. In this situation:

laney@disco:~$ tree /usr/share/{wayland-,x}sessions/
/usr/share/wayland-sessions/
├── gnome.desktop
└── ubuntu-wayland.desktop
/usr/share/xsessions/
├── gnome.desktop -> gnome-xorg.desktop
├── gnome-xorg.desktop
└── ubuntu.desktop

We process the X sessions first, and then the Wayland sessions. The deduplication might end up removing xsessions/gnome-xorg and leaving xsessions/gnome. Then when we come to process the Wayland sessions, we will clobber xsessions/gnome with wayland-sessions/gnome, as they have the same ID.

When everything is working, it is actually intentional that xsessions/gnome gets clobbered, so that you end up seeing "GNOME" (wayland) and "GNOME on Xorg" in the switcher, and not (e.g.) "GNOME on Xorg" twice, and you have the correct fallback behaviour in case you ever enable/disable Wayland.

Instead of filtering while we add things, we can add all the sessions we find (clobbering duplicate IDs as before), and then process the list once at the end, removing sessions with duplicated visible names at that point.

Closes: #473 (closed)

Edited by Iain Lane

Merge request reports