Basically the code uses KWindowSystem::currentDesktop()[1] to check which virtual desktop you're on, and if there is a Kate instance running there already open the file in it, and if there isn't it starts a new instance then open the file with it. The issue is that on Wayland currentDesktop() always returns 0, so the logic doesn't work, opening a file with Kate could end up opening that file on an instance that's already running on a different virtual desktop. [1]https://invent.kde.org/utilities/kate/-/blob/master/kate/main.cpp#L407
I would consider this more an issue of the kwayland-integration. Or is there some replacement function for this?
The fix will probably have to be somewhere in kwayland*, then we can use it in Kate.
As of right now upstream Wayland has no concept of virtual desktops. That means that the existing virtual desktops in e.g. Plasma are completely compositor-defined and applications generally have no information about what desktop they are on. There may or may no come a Wayland protocol that allows this in the future, but as of right now this part of KWindowSystem can't reasonably be implemented on Wayland. That's why https://invent.kde.org/frameworks/kwindowsystem/-/merge_requests/72 renames it to make this explicit
I don't know much about Wayland; so here is an observation, assuming there is a kate instance on the current virtual desktop, and focus stealing prevention is set to none: - Ctrl+Clicking in konsole opens the file in that kate instance and activates the window - From that konsole window, using `kate /path/to/some/file`, the file is opened in kate, but the window isn't activated, and the task manager highlights the kate window as requesting attention
I've created a KWin script that mitigates this bug. It's not a complete fix as it requires that a Kate instance already be open on the workspace in question, but as long as an instance already exists files will open on the same workspace. I should also note that it works by giving Kate focus on workspace switch, so if you rely on a specific window gaining focus on workspace switch this may not work well for you. You can find it here: https://github.com/ehilton2931/kate-autofocus. I may get around to uploading it to the KDE store eventually, but there's some additional functionality for multi-monitor setups that I want to add first. Even with this mitigation, I do hope that this bug will be properly fixed before the X11 session is dropped. This is a key part of my workflow and while the script does mean this bug is no longer a showstopper for me, the need for a preexisting Kate instance is still annoying.