Bug 475706

Summary: Files opened from Baloo and Recent Documents Runners do not have correct Wayland activation environment set
Product: [Plasma] krunner Reporter: Nate Graham <nate>
Component: generalAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED FIXED    
Severity: minor CC: alexander.lohnau, kdedev, natalie_clarius, nicolas.fella, postix
Priority: NOR Keywords: qt6, wayland-only
Version First Reported In: master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 6.5.0
Sentry Crash Report:
Bug Depends on:    
Bug Blocks: 460318    

Description Nate Graham 2023-10-16 16:53:48 UTC
Plasma 6 git master Wayland.


STEPS TO REPRODUCE
1. Assign Kate to open all text files, if it wasn't already set up that way
1. Create a text file on the desktop named foobar.txt, add some content to it, and open it by clicking on it
2. Close the file, but do not quit Kate
3. Search for "foobar.txt" in KRunner (use the KRunner binary not a KRunner-powered search in Kickoff or Overview)
4. Open the file via either the Files or Recent Documents runner


OBSERVED RESULT
The file is opened in Kate, but Kate is not brought to the front. Instead its Task Manager icon turns orange, indicating that KWin rejected an activation request.


EXPECTED RESULT
Kate gets brought to the front.


ADDITIONAL INFORMATION
Kate gets brought to the front when the file is opened from Folder View, Dolphin, or a KRunner-powered search in Kickoff or Overview. The problem only happens when searching from KRunner itself. This suggests that Kate is set up for receiving activation events properly, but KRunner itself (and only KRunner) is not sending one correctly.
Comment 1 Nicolas Fella 2024-01-26 14:30:30 UTC
It looks like we have a mix of root causes here, depending on which specific runner is involved.

- The "Recent Files" runner works as expected, but only if KRunner is "pinned" to stay open after running the match. That suggests we have an issue similar to https://bugs.kde.org/show_bug.cgi?id=479397#c4

- The baloo runner runs out-of-process/as a DBus runner. This needs https://invent.kde.org/frameworks/krunner/-/merge_requests/96
Comment 2 Bug Janitor Service 2025-07-22 18:29:01 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/5698
Comment 3 Kai Uwe Broulik 2025-07-25 16:35:24 UTC
Git commit b5a541aadd2c23a88c9e49f4eedbcfb3bc705787 by Kai Uwe Broulik.
Committed on 25/07/2025 at 15:26.
Pushed by ngraham into branch 'master'.

runners/baloo: Set activation token on OpenUrlJob

Using the new SetActivationToken API.
Ensures that an existing instance of an app opening the file is
properly brought into foreground.

M  +7    -0    runners/baloo/baloosearchrunner.cpp
M  +2    -0    runners/baloo/baloosearchrunner.h
M  +9    -0    runners/baloo/org.kde.krunner1.xml

https://invent.kde.org/plasma/plasma-workspace/-/commit/b5a541aadd2c23a88c9e49f4eedbcfb3bc705787
Comment 4 Bug Janitor Service 2025-07-28 19:36:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/5712
Comment 5 Kai Uwe Broulik 2025-07-28 19:59:38 UTC
Git commit e13727dfcc9150fc2c5e855e461881f8a8d457f1 by Kai Uwe Broulik.
Committed on 28/07/2025 at 19:35.
Pushed by broulik into branch 'master'.

runners/recentdocuments: Use mime type we get from the results model

If we know the mime type already, we can tell OpenUrlJob and it will
skip stat'ing the file and launch much faster.

M  +6    -3    runners/recentdocuments/recentdocuments.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/e13727dfcc9150fc2c5e855e461881f8a8d457f1
Comment 6 Bug Janitor Service 2025-07-28 20:00:23 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/5713
Comment 7 Nate Graham 2025-07-28 20:45:06 UTC
And that fixes the recent documents runner!
Comment 8 Kai Uwe Broulik 2025-07-29 05:10:12 UTC
Git commit 0fe6a7492ff3b223c5f19107267c83ce89ee409f by Kai Uwe Broulik.
Committed on 28/07/2025 at 20:00.
Pushed by broulik into branch 'Plasma/6.4'.

runners/recentdocuments: Use mime type we get from the results model

If we know the mime type already, we can tell OpenUrlJob and it will
skip stat'ing the file and launch much faster.


(cherry picked from commit e13727dfcc9150fc2c5e855e461881f8a8d457f1)

Co-authored-by: Kai Uwe Broulik <kde@privat.broulik.de>

M  +6    -3    runners/recentdocuments/recentdocuments.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/0fe6a7492ff3b223c5f19107267c83ce89ee409f