It can still get unthrottled frame callbacks by not having any primary
scanout output, but presumably we want this. Alongside the code setting
it for cursor surfaces, and dragged windows.
Previously, some errors in the screencopy code resulted in `redraw`
returning an error, while others make the screencopy frame fail, and
logged a warning.
Instead, make all errors here log a warning, and call `reset()` on the
session, but continue running `redraw()`.
Calling `frame.error` explictly isn't needed, since the same error will
be sent on drop otherwise.
Fixes an issue where a dual GPU system would keep allocating dGPU PBOs in
`cpu_copy()` every frame, but `cleanup()` was not being called, since the
surface thread for the builtin output was rendered on the
primary/integrated GPU, targeting the same GPU.
Even if a different monitor was compositing on the dGPU, That wouldn't
help since that thread has it's own `GpuManager` with it's own renderer
and cache.
Running cleanup at the end (or start) of each frame seems like a good
idea. Not sure if it would be best to avoid additional calls, or if
that's desirable/fine.
Instead of choosing a primary GPU the first time `device_added` is
called (and then not updating it on the next call, even if that should
be the primary GPU), set the primary GPU only after all devices have
been initially added, and on future changes.
Alternately, the `was_empty` test can just be removed, but it's probably
best not to select the primary GPU multiple times each time the
compositor starts on a multi-GPU system.
Fixes https://github.com/pop-os/cosmic-comp/issues/1437.
Add more sophisticated code to handle the primary node disappearing.
Also overhaul the selection logic to respect our allow/deny-list and
prefer devices with built-in connectors before using the boot gpu.
This will also allow triggering a primary node switch at runtime
for debugging purposes in the future.
Previously, a click on a client like squeekboard would give keyboard
focus to the window behind it, if any.
If we are in the input region of the layer surface, we shouldn't give
keyboard focus to the surface behind it on click. And should just leave
the focus unchanged. Returning `None` here seems to be correct.
Previously, `Frame` was stored in KMS frame udata, but in some cases the
udata was dropped without a capture happening, and `Frame` did not
implement `Drop`, so `fail` was never sent.
Instead, rename `DropableFrame` to `Frame` and `Frame` to `FrameRef`, so
we can have a single instance of `Frame`, that will send `fail` on drop.
This guarantees either `.success` or `.fail` are send, as long as its
not leaked.
This seems to fix https://github.com/pop-os/cosmic-comp/issues/1305.
xdg-desktop-portal-cosmic prints an error, buy retries (as it should for
an `Unknown` error; though maybe there should be a retry limit) and the
session continues working.
(Not sure if it should be sending `failed`, or queing it with the next
frame so it can send `success` to the client, but this works and is
desirable as a failsafe anyway.)
`Session` and `CursorSession` are similiarly updated.
`.fail()`, `.success()`, and `.stop()` now consume
`Frame`/`Session`/`CursorSession`. So to stop a session, it is now
necessary to call `.remove_session()`, but then simply dropping with
send `.stop()`.
Factoring out some `Request::Capture` handling into a `capture_frame`
function seems to clean up error handling and such a bit.
If `redraw()` returned early, before updating `self.state`, but after
calling `queue_frame`, `on_vblank` would later be called, and reach
`unreachable` since state isn't set to `WaitinfForVBlank`.
In particular, this was happening when the dmabuf from the image copy
frame failed to `bind`.
To avoid this, make sure to update `self.state` immediately after
calling `queue_frame`, before any early return from an error.
The new type bounds seem to be addressable using `AsGlowRenderer`.
Though things like this will need a different solution when we want to
support Pixman rendering.
Adds support for cosmic-workspace-v2 pin, unpin, move_after, and
move_before requests.
Both features need some work with workspaces span displays mode, so that
will need more fixes later.
We also want to generate a unique id for pinned workspaces to send in
the ext-workspace-v1 protocol. But that isn't a strict requirement for
anything. So I haven't yet fully implemented that. We'll also want to
persist other things, like workspace naming when that's added.
Overall, though, with separate workspaces per display, this is working
pretty well.
This is slightly simpler, if there's not some reason I'm missing to do
this as it was previously done. And in particular provides a cleaner
API (if we wanted to move this to Smithay; perhaps without the Cosmic
extension).
But it also should be more correct. Presumably if a client (unusually)
had multiple components with their own `ext_workspace_manager_v1`
instance, they should have their own queues, and
`ext_workspace_manager_v1::commit` should be independent.
Inevitably, there's a racy element to multiple components trying to
update the workspace state like this, but it should behave the same as
two clients with separate connections.
(This is different from `CompositorClientState`, since the commit queue
there is fundamentally tied to the client, and different components with
their own compositor instance way have related surfaces.)