forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to src/ui/screenshot_ui.rsClear filter

2026-10-26

input: Refactor screenshot binds to work like othersIvan Molodetskikh · 9aa245c
input: Refactor screenshot binds to work like others

Remove all screenshot hardcoding in the code.

Behavior changes:
- Escape to close now works only when no modifiers are held.
- Other screenshot binds like Ctrl+C or Space used to ignore the state
  of some modifiers like Super, they now need them released.
- Repeat is disabled for screenshot binds, practically holding P won't
  repeatedly cycle the pointer.
- Inside the screenshot UI, the screenshot binds take precedence over
  allowed configured binds (e.g. if you configured Ctrl+C to spawn, or
  binds with MouseLeft).

2026-05-02

Clamp pointer to output inside screenshot_uiIvan Molodetskikh · f115f2e
Clamp pointer to output inside screenshot_ui

- Removes some duplication
- Allows for better handling by screenshot UI itself depending on the
  case

2025-12-25

Refactor rendering to push-based instead of pull-based (#3113)Ivan Molodetskikh · Unverified7f132ec
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-10-19

Add --path argument for niri msg screenshot* commands (#2126)Lin Xianyi · Unverified23cd5aa
Add --path argument for niri msg screenshot* commands (#2126)

* Check for empty screenshot parent before creating

Avoids a warning.

* Add --path argument for niri msg screenshot* commands

* fix

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>

2025-06-12

2025-06-11

2025-05-09

Add a clickable button to capture the screenshotIvan Molodetskikh · 0763c7e
Add a clickable button to capture the screenshot

Allows tablet-, touch- and mouse-only confirmation.

2025-03-29

screenshot: make selection area modifiable via move/resize keybinds (#1279)nyx · Unverified7dc015e
screenshot: make selection area modifiable via move/resize keybinds (#1279)

* screenshot: make selection area modifiable via keybinds

* input: run fmt

* Reimplement screenshot UI binds in a better way

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>

2025-03-09

2025-02-14

2025-01-14

2025-01-04

2024-11-24

2024-11-23

2024-07-08

2024-07-07

screenshot-ui: Fix last selection preservationIvan Molodetskikh · 62c9d44
screenshot-ui: Fix last selection preservation

Another missed thing from the fractional scale refactor...

2024-06-09

Rename apply_scale to to_physical_precise_roundIvan Molodetskikh · 6c47bd6
Rename apply_scale to to_physical_precise_round

Consistency with Smithay.

2024-06-01

Implement our own TextureBuffer/RenderElementIvan Molodetskikh · 3c63be6
Implement our own TextureBuffer/RenderElement

Supports fractional texture scale + has some getters.

2024-03-24

2024-03-22

2024-02-21