https://bugs.kde.org/show_bug.cgi?id=474686

--- Comment #2 from zhangtin...@uniontech.com <zhangtin...@uniontech.com> ---
(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!

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to