Commit graph

391 commits

Author SHA1 Message Date
Victoria Brekenfeld
fd85e4ea56 kms: Don't incorrectly re-use iterator in update_surface_nodes 2025-07-28 17:46:46 +02:00
Victoria Brekenfeld
6492629f90 kms: Change awkward new trait to InnerDevice 2025-07-25 17:51:01 +02:00
Victoria Brekenfeld
87742c1e0c kms: Don't commit anything before updating the mode 2025-07-25 17:51:01 +02:00
Victoria Brekenfeld
e34a289c01 kms: lock during screen conf changes 2025-07-25 17:51:01 +02:00
Victoria Brekenfeld
bb7a6a7113 chore: smithay update 2025-07-25 17:51:01 +02:00
Victoria Brekenfeld
adedb705e7 shell: handle fullscreen windows on a dedicated layer
I hoped to split this up into multiple commits, but the api
changes to `shell/workspace.rs` were to invasive to feasibly do this.

Here is a rough list of changes:

- Fullscreen windows aren't mapped to other layers anymore
  - This they need their own logic for:
    - Sending frames
    - Dmabuf Feedback
    - Primary outputs
    - On commit handlers
    - cursor tests
  - They get their own unmap/remap logic
  - They get a new restore state similar to minimized windows
    - Refactored the minimized window state to reuse as much as possible
      here
  - They need to be part of focus stacks, which means adjusting them
    to a new type `FocusTarget` as they previously only handled
    `CosmicMapped`.
  - Various shell handlers (minimize, move, menu) now have dedicated
    logic for fullscreen surfaces
    - This was partially necessary due to relying on CosmicSurface now,
      partially because they should've had their own logic from the
      start. E.g. the context menu is now reflecting the fullscreen
      state
- Fullscreen windows may be rendered behind other windows now, when they
  loose focus.
  - This needed changes to input handling / rendering
2025-07-04 19:45:54 +02:00
Ian Douglas Scott
8ef6c161a0 screencopy: Fix damage tracking bug with shm screencopy of output
Similar to the change in https://github.com/pop-os/cosmic-comp/pull/780,
but also updates it to be a little clearer than just an uncommented `age
= 0` line.

Ideally we want some robust system to re-use the offscreen buffer (but
not allocate more buffers indefinitely if the client doesn't capture
with the same `wl_buffer`).
2025-07-03 23:36:13 +02:00
Ian Douglas Scott
e5fbf21fee Remove debug prints that probably shouldn't have been merged
Also add a comment to the one place `eprintln!` is used to explain why
it's appropriate.
2025-07-03 14:25:49 +02:00
Ian Douglas Scott
1844afde09 kms: Do not attempt to import dmabuf on device not supporting format
Previously, if `expected_node` couldn't import a buffer, it would print
an error, then try the next node. There shouldn't really be a reason to
attempt import if the format/modifier isn't in `dmabuf_texture_formats`.

It seems the issue I've been seeing with cosmic-workspaces crashing
the Nvidia driver is fixed by removing this, and disabling `dma_shadow_copy`
(which was producing the same error). Importing Nvidia buffers on the AMD
GPU seems to be causing issues.

Not sure how `dma_shadow_copy` should be fixed, but a test for supported
formats is easy to add here anyway.
2025-07-01 11:32:28 -07:00
Ian Douglas Scott
614d99fc05 Update smithay, egui, and smithay-egui 2025-06-25 20:32:53 +02:00
Ian Douglas Scott
fa4bffdbe6 Add cursor_image_status/set_cursor_image_status to SeatExt
The `cursor_image_status()` function saves some duplication in various
places. The `set_cursor_image_status()` saves a bit less, but is also
handy.
2025-06-10 19:24:05 +02:00
Ian Douglas Scott
b823dd4247 kms/surface: Split off part of redraw into take_screencopy_frames 2025-06-10 16:01:04 +02:00
Ian Douglas Scott
e80e46e911 kms/surface: Update how errors in send_screencopy_result are handled
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.
2025-06-10 16:01:04 +02:00
Ian Douglas Scott
ca817e2579 kms/surface: Split off part of redraw into postprocess_elements 2025-06-10 16:01:04 +02:00
Ian Douglas Scott
39b1ac2955 kms/surface: Split off part of redraw into a send_screencopy_result
This should not change behavior in any way.
2025-06-10 16:01:04 +02:00
Ian Douglas Scott
f86cd933d4 kms/surface: Call cleanup_texture_cache for each device at end of draw
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.
2025-06-02 18:58:49 +02:00
Ian Douglas Scott
619e994955 kms: Fix inconsistent selection of primary GPU
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.
2025-06-02 12:22:13 +02:00
Victoria Brekenfeld
359c3ad899 kms: Various gpu removal fixes
- Remove gpu from `kms_state.api` as well
- Don't use `from_node_id` on device removal
- Free resources asap via `refresh_used_devices`
2025-05-27 20:00:21 +02:00
Victoria Brekenfeld
3d3a566a3c kms: Always send frame callbacks 2025-05-27 20:00:21 +02:00
Victoria Brekenfeld
a65e1d6b5f debug: More profiling annotations 2025-05-27 20:00:21 +02:00
Victoria Brekenfeld
465813c1c5 shell: Using parking_lot's RwLock for fairness guarantees 2025-05-27 20:00:21 +02:00
Victoria Brekenfeld
8194be30c6 kms: Allow updating the primary node
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.
2025-05-27 20:00:21 +02:00
Victoria Brekenfeld
913ed90b04 kms: Add allow/deny-listing of drm devices 2025-05-27 20:00:21 +02:00
Ian Douglas Scott
194d5c8967 protocols/screencopy: Make frame/session send stopped/fail on drop
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.
2025-05-19 16:53:46 -07:00
Ian Douglas Scott
e1a817bc06 kms/surface: Fix thread crash on error return of redraw
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.
2025-05-19 19:58:36 +02:00
Ian Douglas Scott
d7b37cfde5 Update smithay
Updates to use `GbmFramebufferExporter`.
2025-04-29 14:42:07 +02:00
Ian Douglas Scott
982af8ff10 Update smithay with ContextId changes
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.
2025-04-29 14:42:07 +02:00
Victoria Brekenfeld
74c7a216f5 kms: Skip overlay tests on fullscreen 2025-04-28 18:03:09 +02:00
Victoria Brekenfeld
7c222ae6d1 debug: Fix crashes and deadlocks 2025-04-28 18:03:09 +02:00
Victoria Brekenfeld
4e6713291d kms/timing: Faster cleanup 2025-04-28 18:03:09 +02:00
Victoria Brekenfeld
8aaaa12d5c kms: Fix VRR check having already missed the deadline 2025-04-28 18:03:09 +02:00
Victoria Brekenfeld
db25cc4b0b kms/timings: Base next_render_time on time to submit 2025-04-28 18:03:09 +02:00
Victoria Brekenfeld
d1e0e28d3c kms: Add tracy profiling 2025-04-28 18:03:09 +02:00
Victoria Brekenfeld
2cbe89d89d xwayland: Set scaled cursor size via xsettings 2025-04-16 21:06:51 +02:00
Victoria Brekenfeld
de1e528ba7 render/cursor: Don't round cursor coordinates early 2025-04-16 21:06:51 +02:00
Victoria Brekenfeld
e6a3f5373c render/cursor: Correctly convert hotspot coordinates 2025-04-16 21:06:51 +02:00
Ian Douglas Scott
e74eafce2c Add EdidProduct, as user data for kms Outputs
This is the same as `libdisplay_info::edid::VendorProduct`, but with
implementations for `Serialize`, `Eq`, etc.
2025-04-02 13:40:56 +02:00
Victoria Brekenfeld
0ba0a0cdaa a11y/zoom: zoom level per output 2025-03-28 18:35:06 +01:00
Victoria Brekenfeld
7a8577592d kms: Support screencopy cursor modes with active filters 2025-03-24 19:10:52 +01:00
Victoria Brekenfeld
7373b3f513 backend: Support screen filters in nested mode 2025-03-24 19:10:52 +01:00
Victoria Brekenfeld
7929e25966 kms: Support screen filters 2025-03-24 19:10:52 +01:00
Victoria Brekenfeld
18335c6758 kms: Refactor out postprocessing helpers 2025-03-24 19:10:52 +01:00
Ian Douglas Scott
b52d84dbd3 Call underlying_storage of TextureRenderElement without mapping
This was mapping `UnderlyingStorage::Memory` to `None`. I don't see any
reason for this. Though this also shouldn't change behavior since
`TextureRenderElement` doesn't provide `underlying_storage` currently.
2025-03-24 19:10:52 +01:00
Clayton Craft
29a649541d kms.timings.presented: print debug msg when frame time is overflowing
Also see: #1062
2025-03-19 18:45:44 +01:00
Clayton Craft
8f40fc7a1b kms: protect against potential overflow of Duration when calculating avg frametime
Also see: https://github.com/Smithay/smithay/pull/1685

Fixes #1062

Co-authored-by: Victoria Brekenfeld <victoria@system76.com>
2025-03-19 18:45:44 +01:00
Ian Douglas Scott
1387535252 Fix dependency_on_unit_never_type_fallback warning on latest Rustc
Apparently in Rust 2024, the inferred type here would be `!`, which
doesn't implement `Default`. Explicitly use `()` instead.

https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html
2025-03-14 17:50:17 +01:00
Peter Krull
ad2cba324e fix: Remove extra scaling of borders 2025-03-12 16:55:00 +01:00
Victoria Brekenfeld
95b27637ae chore: smithay update 2025-03-12 16:50:58 +01:00
Victoria Brekenfeld
7af3650b83 chore: Cleanup some warnings 2025-02-20 23:51:55 +01:00
Victoria Brekenfeld
909ca8cf9d zoom: Seperate animating/current focal_point 2025-02-20 23:51:55 +01:00