SUMMARY Plasma 6.5.0 seems to loose keyboard focus when copying to the clipboard. Encountered when using neovim. key-repeat when holding down `x` in neovim normal mode not working and only deleting a single character when using the `vim.opt.clipboard = 'unnamedplus'` setting. I have tested this with `nvim` in Konsole and Terminator and with `neovide`. All behave the same. STEPS TO REPRODUCE 1. write the following to `/tmp/init.lua` ``` local function log_event(event) local f = io.open("/tmp/focus.log", "a") f:write(string.format("[%s] %s\n", os.date("%Y-%m-%d %H:%M:%S"), event)) f:close() end vim.api.nvim_create_autocmd("FocusLost", { callback = function() log_event("FocusLost") end }) vim.api.nvim_create_autocmd("FocusGained", { callback = function() log_event("FocusGained") end }) log_event("Start") vim.opt.clipboard = 'unnamedplus' ``` 2. run `echo "this is an example" > /tmp/example.txt` 3. in a separate terminal run `touch /tmp/focus.log && tail -f /tmp/focus.log` 4. run `nvim -u /tmp/init.lua /tmp/example.txt` 5. press and hold `x` OBSERVED RESULT only one character is deleted and `focus.log` indicates that focus was lost and immediately regained. EXPECTED RESULT holding down `x` should initiate key-repeat and the entire line should be deleted. The focus log should remain empty other than the `Start` message. This is the case for Plasma 6.4.5 and Gnome. SOFTWARE/OS VERSIONS Operating System: Arch Linux KDE Plasma Version: 6.5.0 KDE Frameworks Version: 6.19.0 Qt Version: 6.10.0 Kernel Version: 6.12.53-1-lts (64-bit) Graphics Platform: Wayland neovim: v0.11.4 ADDITIONAL INFORMATION
Thanks for the bug report and the debugging. I'd like to get a minimal reproduction case for just the symptoms. Is there a way to reproduce this with, for example, KWrite or Kate? I'm seeing key repeat work as expected with them, even when copying (adding to the clipboard)
(In reply to TraceyC from comment #1) > Thanks for the bug report and the debugging. > > I'd like to get a minimal reproduction case for just the symptoms. Is there > a way to reproduce this with, for example, KWrite or Kate? I'm seeing key > repeat work as expected with them, even when copying (adding to the > clipboard) I'm not sure exactly what the problem is here but I think it's to do with the interaction between key repeat and the clipboard (wl-clipboard) which non-vi editors won't have. Regular vim behaves exactly the same as neovim (`vim -u NONE` followed by `set clipboard=unnamedplus`). I've also observed a change in the key repeat behaviour in vscode using the vscode-neovim plugin where keys that interact with the clipboard (eg holding x or p) do repeat but at a lower frequency than keys that don't interact with the clipboard (eg j). vscode with the emulated vim plugin is not affected. With wl-clipboard uninstalled vim and neovim no longer have the key repeat issue but shows an error that no clipboard provider is installed so I'm pretty sure it's delegating clipboard interactions to that, which is momentarily stealing focus. I'm not sure if this is a bug with wl-clipboard or the clipboard portal. I tried Kate with vi mode and it doesn't have any issue, but that is probably interacting with the clipboard in an entirely different way.
Thanks for the extra details. I'm able to reproduce your results on Plasma built from git-master, using the steps in your first message.
I created a shim to see what arguments vim was calling wl-copy with. seems to be `wl-copy --type plain/text` with the content to be copied written to stdin. I tried to create a minimal example with PyQt calling out to wl-copy and seeing if focus is lost but I didn't see any 'focus gained' or 'focus lost' messages. ``` #!/usr/bin/env -S uv run --script # /// script # dependencies = [ "PyQt6" ] # /// import subprocess from PyQt6.QtCore import Qt from PyQt6.QtWidgets import QApplication, QWidget class FocusLogger(QWidget): def __init__(self): super().__init__() self.resize(300, 200) self.setFocusPolicy(Qt.FocusPolicy.StrongFocus) print("Start") def focusInEvent(self, event): print("Focus gained") event.accept() def focusOutEvent(self, event): print("Focus lost") event.accept() def keyPressEvent(self, event): if event.key() == Qt.Key.Key_Space: print('Copy') subprocess.run(["wl-copy", "--type", "text/plain"], input=b"foo", check=False) event.accept() if __name__ == "__main__": app = QApplication([]) window = FocusLogger() window.show() app.exec() ```
I also confirm this bug It's making working with yakuake/kitty-quick-terminal impossible, and is ruining my whole workflow
This is a bug in wl-clipboard, it's doing weird things. See https://github.com/bugaevc/wl-clipboard/issues/268 for more details
(In reply to Zamundaaa from comment #6) > This is a bug in wl-clipboard, it's doing weird things. See > https://github.com/bugaevc/wl-clipboard/issues/268 for more details Yes, it seems so Thank you
I can confirm that replacing wl-clipboard with wl-clipboard-git the issue is resolved for me. To summarize https://github.com/bugaevc/wl-clipboard/issues/268 Plasma removed support for the `wlr-data-control` protocol and wl-clipboard only switched over to the replacement (`ext-data-control`) in https://github.com/bugaevc/wl-clipboard/pull/255 which is not part of any release yet. So this should be resolved when wl-clipboard makes a new release.