| Summary: | Setting a value to Clipboard via a button in an unfocused window does not work. | ||
|---|---|---|---|
| Product: | [Plasma] kwin | Reporter: | zhangtingan <zhangtingan> |
| Component: | wayland-generic | Assignee: | KWin default assignee <kwin-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | kde, nate |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | demo | ||
|
Description
zhangtingan@uniontech.com
2023-09-19 09:30:11 UTC
It's a lazy way to determine that the passed serial is valid. Only focused client is going to have a serial that can be used to set the selection.
> Create a Qt window, set the `Qt::WindowDoesNotAcceptFocus` property
As far as I know, an xdg_toplevel cannot influence whether it should accept focus or not. It can only change the input shape, but it's controlled by a different flag.
(In reply to Vlad Zahorodnii from comment #1) > It's a lazy way to determine that the passed serial is valid. Only focused > client is going to have a serial that can be used to set the selection. > > > Create a Qt window, set the `Qt::WindowDoesNotAcceptFocus` property > > As far as I know, an xdg_toplevel cannot influence whether it should accept > focus or not. It can only change the input shape, but it's controlled by a > different flag. yes, i found that `Only focusedclient is going to have a serial that can be used to set the selection`. But I don't really understand what you mean by this, so let me describe my problem in detail. I have written a program through which I want to click a button to enter data for another application. The way it works now is: create a window set the `Qt::WindowStaysOnTopHint |Qt::WindowDoesNotAcceptFocus` property so that the window stays on top and the input focus is retained in the other program, then click the button and via `QClipboard->setText` put the data into the `selection` in the system by `QClipboard->setText`. However, I find that the following code in `kwayland` does not work at this point. `QObject::connect(dataDevice, &DataDeviceInterface::selectionChanged, q, [this, dataDevice]], [this, dataDevice]]. [this, dataDevice] { if(keys.focus.surface && dataDevice && dataDevice->client() == keys.focus.surface->client()) { updateSelection(dataDevice->selection(), true); } } );` When I call `setText` in my Qt app, `setSelection` is called in wayland, which then triggers Kwayland's callback function, but at this point, the source of the data is the program I've written, but keys.focus.surface is another app, causing the selection not to be updated. Maybe the kwin in my system has been modified, resulting in a difference from the original design. I will also try to test this on a native KDE system, and if necessary, I'll attach a demo I've written! Created attachment 161774 [details]
demo
Run the demo, let the input focus on any application, click the button in the demo, it will output an "ok" at the other application's focus. But it won't actually
Kwin now allows any app to change clipboard without focus. |