Commit Graph

2650 Commits

Author SHA1 Message Date
Ivan Molodetskikh 9015ff8e36 ipc: Add pw_node_id to PipeWire Casts 2026-01-15 08:42:25 +03:00
Ivan Molodetskikh e546b339a3 ipc: Add PID to screencopy Casts 2026-01-15 08:42:25 +03:00
Ivan Molodetskikh b39edf405a screencopy: Add timeout to casts considered stopped
Otherwise xdp-wlr never stops the cast after it first starts.
2026-01-15 08:42:25 +03:00
Ivan Molodetskikh b98f4906da ipc: Add CastKind 2026-01-15 08:42:25 +03:00
Ivan Molodetskikh e82830c68c ipc: Add screencopy cast tracking
Track wlr-screencopy sessions that use with_damage as screencasts. These
are used by tools like wl-screenrec for continuous recording.
2026-01-15 08:42:25 +03:00
Ivan Molodetskikh 238caaf8da ipc: Add screencast request and events for PipeWire casts
Allows desktop bars to show when screen recording is active.
2026-01-15 08:42:25 +03:00
Ivan Molodetskikh 9c79108afa Refactor wlr-screencopy state cleanup
Before we cleaned up when binding a new manager, meaning that after a
screencopy client exited, the queue kept existing until a new one is
bound. We'll need precise tracking for the screencast IPC, so this
commit refactors to do just that: clean up the queue immediately when
all referring objects no longer exist.

This commit also fixes an issue where destroyed frames (e.g. from a
killed client) didn't clean the corresponding screencopy objects,
leading them to exist forever.
2026-01-13 23:01:21 +03:00
Ivan Molodetskikh 2571242887 screencopy: Pop first screencopy instead of last
This was never found probably because no client submits multiple frames
at once.
2026-01-13 23:00:38 +03:00
Ivan Molodetskikh 6f92b3296a Store output name in CastTarget
Will be useful in the next commit to avoid fetching it every time.
2026-01-13 21:31:51 +03:00
Ivan Molodetskikh 570ea119ba Extract cast session/stream ID counters to global scope
Add CastSessionId and CastStreamId newtypes. This lifts the atomic
counters from the D-Bus mutter_screen_cast module to a shared location,
preparing for adding screencopy cast tracking which will need the same
ID types.
2026-01-13 21:31:51 +03:00
Ivan Molodetskikh df4614e62c screencasting: Use spans to reduce logging boilerplate 2026-01-12 21:33:29 +03:00
Ivan Molodetskikh 3672e79369 Delay starting dynamic casts until there's a target
This avoids a weird 1x1 stream as well as one renegotiation which is a
complex operation, and some clients apparently have a problem with it.
2026-01-12 08:45:03 +03:00
Ivan Molodetskikh 2d16abdaae Move dynamic_target set outside pw_utils 2026-01-12 08:37:58 +03:00
Ivan Molodetskikh ff081acddc screencasting: Extract some logic into functions 2026-01-12 08:37:58 +03:00
Ivan Molodetskikh afe27a143b Move xdp-gnome-screencast code into separate module 2026-01-12 07:59:56 +03:00
Ivan Molodetskikh fd2916eb72 Honor pointer visibility in screencasts
Regressed in 05599ce2c4.
2026-01-12 07:11:56 +03:00
Janis e9d888cd52 Set NIRI_BUILD_COMMIT in flake.nix (#3235) 2026-01-11 19:59:43 +03:00
abmantis 05599ce2c4 Implement cursor metadata in window screencast
Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2026-01-11 06:51:14 -08:00
Ivan Molodetskikh 0fb6c5706b Extract pointer_pos_for_window_cast()
Will be used for window screencasts too.
2026-01-11 06:51:14 -08:00
Ivan Molodetskikh 79aaa4c6c0 Upgrade dependencies 2026-01-11 15:37:00 +03:00
Ivan Molodetskikh 7e559dc468 Use unadjusted clock for config notification shown duration
It shouldn't be affected by anim slowdown (or, more importantly,
speedup).
2026-01-11 15:08:58 +03:00
Ivan Molodetskikh 45fc763281 Update Insta snapshots for new Insta version
No functional changes intended.
2026-01-10 15:45:47 +03:00
Ivan Molodetskikh 39d3cd2415 Add a push version of render()
Will be useful for screencasting.
2026-01-10 15:32:21 +03:00
Ivan Molodetskikh 19b1074a8b Fix root surface tracking for sync subsurfaces
In particular, fixes screenshot-window with show-pointer on foot CSD.
2026-01-10 15:32:21 +03:00
Ivan Molodetskikh 539a5a8030 Fix tablet cursor for screenshot-window with pointer 2026-01-10 15:32:21 +03:00
Ivan Molodetskikh 53b7477d20 render_helpers: Fix encompassing_geo() argument type 2026-01-10 15:32:21 +03:00
Ivan Molodetskikh c34f7b18ec pick_color_grab: Remove unnecessary Vec allocation 2026-01-10 15:32:21 +03:00
Anton Kesy a6baef7b68 Fix typo 2026-01-10 04:30:42 -08:00
Manuel Romei 10df9f4717 fix(pw_utils): prevent write-after-free by reordering Cast struct fields
The Cast struct fields were ordered such that `stream` was dropped before
`_listener`. In Rust, struct fields are dropped in declaration order.

Because `StreamListener` attempts to unregister itself from the stream on
drop, and `StreamRc` destroys the underlying PipeWire stream on drop, the
previous order caused `_listener` to access the stream after it had
already been freed.

This reorders the fields so `_listener` is declared before `stream`,
ensuring the listener unregisters itself while the stream is still valid.

* Apply suggestion from @YaLTeR

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2026-01-07 13:32:06 +00:00
Ivan Molodetskikh 9f8eadc5bc Add screenshot-window show-pointer=true 2026-01-07 07:53:05 +03:00
Ivan Molodetskikh a496307daf Move pointer visibility check outside render_pointer() 2026-01-07 07:53:05 +03:00
Ivan Molodetskikh bc7bb51b6f Fix Tracy span name 2026-01-07 07:53:05 +03:00
Ivan Molodetskikh b7eb8a635b default-config: Bind Mod+M to maximize-window-to-edges 2026-01-05 10:28:18 +03:00
Ivan Molodetskikh d060b06667 Replace TODO with FIXME
We use TODO for things to be fixed before committing.
2026-01-05 08:29:05 +03:00
Ivan Molodetskikh 54c2e2ab47 utils/spawning: Remove unnecessary cfgs
Forgotten when this was refactored.
2026-01-04 15:43:42 +03:00
Ivan Molodetskikh df3f3979e9 layout/scrolling: Preserve gesture anim in dnd_scroll_gesture_end()
Fixes interactive move unmaximize/unfullscreen into floating skipping
the view offset anim.
2026-01-04 15:43:42 +03:00
Vishal 6215b5f0b1 doc: link DMS compositor setup in Quick Start (#3179)
* doc: add `dms setup` command in Getting Started section along with clarification

* mention DMS setup page

* Update docs/wiki/Getting-Started.md

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2026-01-04 15:04:22 +03:00
Mark Karlinsky 3bfa4a71ff Improve dinit service files (#3193)
* Improve dinit service files and niri-session

Two main changes were made:
 - After a discussion in davmac314/dinit#496, 2 dinit services are now
   provided. The first one is 'niri', which runs niri itself, and the
   second one is 'niri.target' which brings up all the dependences from
   user configuration.
 - Made the behaviour of 'niri-session' when running under dinit closer
   to the behaviour when running under systemd. In particular, now the
   script wait for service completion, because some login managers shut
   the session down the moment the startup script completes.

* Update paths in docs
2026-01-04 10:04:03 +03:00
LuckShiba 3158f5a9c0 nix: fix path replace in SystemD service 2026-01-03 21:43:13 +03:00
Axlefublr d8250fa876 niri.service: don't hardcode the path 2026-01-03 19:43:14 +03:00
Ivan Molodetskikh cf0b4bc0ca Fix missing redraw when floating DnD in overview scrolls workspaces
Regressed in 396097c3ab
2025-12-31 08:46:49 +03:00
Ivan Molodetskikh 1ab1737653 tty: Load libinput plugins if available
Some distros like Fedora build libinput with plugin autoloading, however
by default, the compositor needs to explicitly load them. Plus, we need
to load manually if we want to also load from
$XDG_CONFIG_HOME/libinput/plugins.

Ref. https://gitlab.gnome.org/GNOME/mutter/-/commit/c5b12fbf6313d51f3279901bb561023e56181e36
2025-12-30 08:22:11 +03:00
Ivan Molodetskikh b5640d5293 Don't add padding to layer-shell popups 2025-12-26 15:25:30 +03:00
Ivan Molodetskikh 860a08cce6 Update Smithay (text-input enter/leave fix, multigpu formats improvement) 2025-12-26 08:31:34 +03:00
Ivan Molodetskikh 2a9d0e495a Fix consume-or-expel-left anim to the left of active column
Regressed in c4462d0c7f.
2025-12-25 14:26:49 +03:00
Ivan Molodetskikh 7f132ecf95 Refactor rendering to push-based instead of pull-based (#3113)
Our current rendering code constructs and returns complex
`-> impl Iterator<Item = SomeRenderElement>` types that are collected
into a vector at the top level Niri::render(). This causes some
problems:
- It's hard to write logic around returning iterators. Especially things
  like conditions, since the returned iterator must have a single type,
  you can't branch and return different iterators. This will be solved
  by gen fn but alas it's not here yet.
- In many cases, the returned `-> impl Iterator` will borrow from &self
  leading to complex lifetimes. In certain cases, it is also desirable
  for it to borrow the &mut NiriRenderer, which causes a lot of issues
  because it's exclusive (&mut).
- Sometimes those issues are too hard to deal with, leading to the
  escape hatch of allocating and returning a temporary
  Vec<SomeRenderElement>, like in
  Scrolling/FloatingSpace::render_elements(). These allocations are
  unfortunate because they are not really necessary.
- It's impossible to use some downstream combinators with this
  `-> impl Iterator` approach, leading to functions like Smithay's
  render_elements_from_surface_tree() returning a Vec. This is extra
  unfortunate because it results in a temporary allocation per Wayland
  toplevel/popup.
- It's hard to properly create profiling spans for the rendering
  functions since the spans are dropped when the (lazy) iterator is
  returned and not when all the code actually completes.
- The code compiles down to complex state machines in generated iterator
  types with logic located in Iterator::next(), which makes it annoying
  to follow in debuggers and profiling tools.

This refactor changes the code to push-based iteration: rendering
functions receive a push() closure that they call to push their render
elements. It solves all of the aforementioned problems:
- The logic becomes simpler. Just use conditionals and loops as normal.
- No borrowing and lifetimes since we're not returning anything.
- All temporary Vecs are removed because the problems they worked around
  no longer exist.
- The new push_elements_from_surface_tree() helper is the same as
  render_elements_from_surface_tree() but doesn't allocate a temporary
  Vec since it's not necessary; the push() closure can be passed down.
- Profiling spans work normally since the function returns when it ran
  all of the logic.
- The code compiles down to normal functions and calls as expected.

Generally, the iterator approach gives these advantages:
- You can wrap the returned items in the upstream logic. This is
  possible in exactly the same way with the push closure.
- You can decide to cut the iterator short in the upstream logic. This
  is not possible with push-based iteration, but we don't actually use
  it anywhere.

I chose the push closure type to be &mut dyn FnMut(SomeRenderElement).
It's deliberately not a generic impl FnMut() to avoid duplicating the
rendering logic when it's called from several different places. But it's
still a normal closure that can capture the outside context.

While my original idea for this refactor was to simplify the logic while
getting rid of temporary Vecs, it also appears to have brought a
consistent 2-3x speedup to the whole render list construction. On an old
Eee PC laptop I even observed a 8x speedup.

The refactor also results in smaller binary size, presumably due to
removing many iterator combinators and state tracking.
2025-12-25 14:26:19 +03:00
Ivan Molodetskikh 1a63089d67 Fix tracy span names 2025-12-25 09:52:50 +03:00
Ivan Molodetskikh 88dc6e22d0 Remove redundant clippy allow 2025-12-25 09:42:08 +03:00
Ivan Molodetskikh ce8171bed3 Fix wrong rendering order when switching dynamic cast to window 2025-12-25 08:51:43 +03:00
Ivan Molodetskikh 6edd29170f opening window: Remove unused method 2025-12-25 08:51:43 +03:00