Setting the clipboard is only allowed when the keyboard focus is the
same client as the client trying to set the clipboard. We shouldn't
allow background windows in stacks to set the clipboard.
I don't know if anything else expects `same_client_as` to have this `any`
behavior.
This should fix https://github.com/pop-os/cosmic-comp/issues/494, and
make clipboard and primary focus consistently correct.
Changing the active element of a stack needs to change the clipboard
focus, but it wasn't being changed since the `KeyboardFocusTarget` was
unchanged. The `CosmicStack` methods that change the active stack
element also have no obvious way to change the keyboard focus. So we can
set this in `refresh_focus`, which should be correct.
If the new focus `WlSurface` is `None`, this clears the focus instead of
leaving it as the previous code did. I believe that is desirable.
Requires https://github.com/Smithay/smithay/pull/1442 to avoid repeated
`offer`s, instead of only when focus changed.
(Perhaps this could better be solved by having a `WlSurface` variant of
`KeyboardFocusTarget`, like pointer focus, or some mechanism for a stack
of focus, which could help other things. But it's also unclear exactly
how that would work with the code for setting the active stack element,
among other questions.)
We already direct touch events to Iced, and the Cosmic `HeaderBar`
widget already recognizes drags from touch events. So it seems updating
`last_seat` is all that was needed for windows SSDs.
For stacks, the same works, plus moving using the same logic for
detecting drags that is used for mouse events.
Without this check, a floating window that is dragged near an edge
between monitors causes snapping indicators to show on both, since the
window intersects both.
Handling of `PointerTarget::motion` should be unchanged.
`PointerTarget::enter` previously was comparing `loc - geo` rather than
`loc`. The generic version could accommodate that, but I assume this was
incorrect, and the position sent to `enter` wasn't handled correctly.
Using `is_tiled()` here doesn't work for fullscreen windows, since
`is_tiled()` returns `false` for them.
This (plus the previous changes for supporting minimize) seems to fix
the behavior of `SDL_MINIMIZE_ON_FOCUS_LOSS` in XWayland applications
(https://github.com/pop-os/cosmic-comp/issues/231). Wine had a similar
issue, though I haven't tested it yet.
It doesn't seem ideal visually that the fullscreen window becomes tiled
then minimized itself, but that's less of a problem.
May need to check if this is an issue with any other uses of `is_tiled()`
or `is_floating()`.