Repository navigation
fix(kde): resolve focused window to its .desktop ID so picker bindings activate - #175
Merged
Merged
Conversation
…s activate The "add profile" picker records an app under its .desktop file ID, but KDeDesktop::focusChanged passed KWin's desktopFileName through verbatim. On Wayland that is the window's app_id, which is not always a .desktop ID: flatpak Chrome reports "google-chrome" while its desktop file is com.google.Chrome.desktop (StartupWMClass=google-chrome). A Chrome binding created from the picker therefore never matched and Chrome stayed on Default. focusChanged now trusts desktopFileName only when it names an installed .desktop file; otherwise it resolves it (then resourceClass) through StartupWMClass / reverse-DNS tail, the same lookup Hyprland and GNOME use, and falls back to KWin's name when nothing claims the window. LinuxDesktopBase gains findDesktopFile(), which checks for an exact .desktop ID before the fuzzy scan (so native Chrome's google-chrome.desktop still wins when both builds are installed) and reports "no match" as an empty string. resolveDesktopFile() keeps its fall-back-to-input contract on top of it. Tests: picker -> binding -> KWin focus round trip against fixture desktop dirs (new setDesktopDirsForTest seam), covering flatpak Chrome plus the reverse-DNS apps already bound in the wild (Okular, Evince, Xournal++, Dolphin, Telegram) and the X11 no-desktopFileName path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Adding an app profile for Google Chrome (flatpak) from the "add profile" picker created a binding that never activated; Chrome stayed on Default.
The picker (
LinuxDesktopBase::runningApplications) records each app under its.desktopfile ID →com.google.Chrome.KDeDesktop::focusChangedpassed KWin'sdesktopFileNamethrough verbatim. On Wayland that is the window'sapp_id, which is not always a.desktopID. Read from a live Plasma 6 session:resourceClassdesktopFileName.desktopfilegoogle-chromegoogle-chromecom.google.Chrome.desktop(StartupWMClass=google-chrome)org.gnome.Evinceorg.gnome.Evinceorg.gnome.Evince.desktoporg.kde.dolphinorg.kde.dolphinorg.kde.dolphin.desktopProfileEngine::profileForAppcompares exactly (case-insensitive), sogoogle-chrome≠com.google.Chrome→ Default.Fix
Fixed at the source, in the desktop layer.
ProfileEnginestays exact-match, which keeps the design from 6b7dedd (identity resolution lives in the desktop backend).KDeDesktop::focusChangedusesdesktopFileNameonly when it names an installed.desktopfile. Otherwise it resolvesdesktopFileName, thenresourceClass, throughStartupWMClassor the reverse-DNS tail. Hyprland and GNOME already use this lookup. If nothing claims the window, it falls back to KWin's name.LinuxDesktopBase::findDesktopFile()checks for an exact.desktopID across all dirs before the fuzzy scan, and returns empty on no match. Native Chrome'sgoogle-chrome.desktoptherefore still wins when both builds are installed, so existinggoogle-chromebindings made for native Chrome keep working.resolveDesktopFile()keeps its fall-back-to-input contract, so the Hyprland and GNOME call sites are unchanged. They now also get the exact-ID-first behaviour.focusdebug line logs when a KWin window is remapped (KWin window "google-chrome" resolved to desktop file "com.google.Chrome").setDesktopDirsForTest().Reverse-DNS apps whose
desktopFileNamealready is their.desktopID resolve exactly as before: Okular, Evince, Xournal++, Dolphin, Telegram.Tests
tests/test_wmclass_resolution.cppadds a picker → binding → KWin-focus round trip against fixture desktop dirs:FlatpakChromePickerBindingActivatesOnFocus: the regression. It failed before the fix (focus emittedgoogle-chrome).ExistingDesktopFileNameIsTrustedVerbatim: nativegoogle-chrome.desktopbeats flatpak'sStartupWMClassclaim.UnknownAppFallsBackToDesktopFileNameReverseDnsApps/KdeFocusRoundTrip: Evince, Dolphin, flatpak Okular, Xournal++, flatpak Telegram, plus the X11 / no-desktopFileNamepath for Okular and Telegram.logitune-tests: 784 passed (withXDG_DATA_DIRS=<build dir>). The pre-push hook ran the C++, tray, QML and Python suites, all green.Hardware check (KDE Plasma 6 Wayland, MX Master 3S)
I relaunched the app from this branch with a
com.google.Chrome=Google Chromebinding on the connected mouse, then focused flatpak Chrome:Focusing away re-applied Default.
Not changed
Bindings stored under a key that no longer names an installed app (for example
google-chromeafter moving from native to flatpak Chrome) don't match the flatpak window. The picker shows the app under its new ID, so re-adding the profile fixes it.🤖 Generated with Claude Code