forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on a6baef7b68fcb60dfc57a9fc04e983cfd8a028acFiltered to src/layout/tests.rsClear filter

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-12-18

layout/scrolling: Fix add_column() skipping activate_column() sometimesIvan Molodetskikh · c4462d0
layout/scrolling: Fix add_column() skipping activate_column() sometimes

When the column was added immediately to the left of the current column
and activated, the new idx would be equal to active_column_idx, which
would skip activate_column() with its variable resets.

2025-11-24

layout/tests: Amend check for window-rule testsIvan Molodetskikh · 45b45ac
layout/tests: Amend check for window-rule tests

This check doesn't handle tabbed columns properly (it should find and
take the fixed height tile's height); for now just gate it on is_tabbed.
Remove hand-written ResolvedWindowRules::empty()Ivan Molodetskikh · 9eeedff
Remove hand-written ResolvedWindowRules::empty()

It was only needed to be const fn.
layout: Round focus ring/border width to physical at the right placeIvan Molodetskikh · 0920ea9
layout: Round focus ring/border width to physical at the right place

Before this, focus ring/border width was incorrectly rounded only for
layout config, which does not take into account window rules overrides.
This means that setting width in window rules prevented correct rounding
altogether.

Tests didn't check this because window rules weren't tested. This commit
also adds basic window rules random generation, making the tests catch
this problem too.

2025-10-18

feat(move-floating-window): percentage change (#2371)Mykyta Onipchenko · Unverified79cdbc5
feat(move-floating-window): percentage change (#2371)

* feat: add percentage change to move-floating-window

* fixes

---------

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

2025-09-02

2025-09-27

Partially implement config includesIvan Molodetskikh · b3ae3ad
Partially implement config includes

Subsequent commits will add merging for all leftover sections.

2025-09-25

2025-09-20

Add per-workspace layout configIvan Molodetskikh · d5f4e79
Add per-workspace layout config

Per-workspace background-color doesn't work yet.

2025-09-26

2025-09-25

layout/tests: Make UpdateConfig an actual OpIvan Molodetskikh · e3068cd
layout/tests: Make UpdateConfig an actual Op

We can do it now that it's non-Copy. This also fixes a new stack
overflow when running the random test in debug mode (which somehow
occurs even though it's skipped in debug mode) that appeared after
adding LayoutPart for some unbeknownst to me reason.

2025-09-21

layout/tests: Generate LayoutPart instead of Layout configIvan Molodetskikh · 6aa8146
layout/tests: Generate LayoutPart instead of Layout config

Necessary for future changes, also produces much shorter failing output due to
not having to include all the options.

2025-09-20

2025-09-21

2025-09-02

2025-09-16

layout: End DnD gesture when toggling interactive move to floatingIvan Molodetskikh · c30e5c9
layout: End DnD gesture when toggling interactive move to floating

Effective behavior mostly unchanged (it would end on refresh()), but this was
failing the invariant checks.

2025-09-02

layout/tests: Mark operations_dont_panic as slowIvan Molodetskikh · cd0d45f
layout/tests: Mark operations_dont_panic as slow

It's by far the slowest test (disabling it cuts cargo test time by 2x), and it
hadn't caught much in the past months.

2025-08-28

2025-08-27

2025-06-16

2025-08-12

layout/tests: Support animation snapshotIvan Molodetskikh · 5bda304
layout/tests: Support animation snapshot

Only the size is needed in these tests; needed for testing animation progress.
layout: Remove by-ref animation_snapshot() getterIvan Molodetskikh · c9873a0
layout: Remove by-ref animation_snapshot() getter

It was used in only one place, and that place was due for an update to use the
cached data.

2025-08-11

2025-06-13

layout/scrolling: Take unfullscreen view offset unconditionallyIvan Molodetskikh · 83ec369
layout/scrolling: Take unfullscreen view offset unconditionally

It might get set and unset all while the view is frozen with a gesture.

2025-05-12

2025-03-21

add window urgency through xdg-activation-v1Duncan Overbruck · 86f57c2
add window urgency through xdg-activation-v1

urgency is done through activation requests without a serial from a
previous interaction.

https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/150

2025-05-01

2025-04-30

2025-04-25

Implement an OverviewIvan Molodetskikh · af1fca3Browse files

2025-04-24

2025-04-20

Remove cancellation from swipe gesturesIvan Molodetskikh · 59a4224
Remove cancellation from swipe gestures

It only worked for workspace switch, and even there it was more confusing than
helpful.

2025-03-31

2025-03-29

Add focus argument to move-window-to-workspace (#1332)nyx · Unverified0db48e2
Add focus argument to move-window-to-workspace (#1332)

* layout: add focus flag to move-window-to-workspace

* lib: update comment

* misc: minor dup refactor

* input: format code

* layout: minor nit

* layout: update comment

* input: remove unnecessary conditionals

* misc: replace boolean

* tests: fix the failing one

* layout: change to smart

* ipc: Option<bool> -> bool

* lib: format code

* Rewrite focus doc comment

---------

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

2025-03-22

layout: Reset unfullscreen view offset when removing windowIvan Molodetskikh · ed20822
layout: Reset unfullscreen view offset when removing window

Another old bug found by randomized tests after I expanded the testing mock
window.

2025-03-17

Implement toggle-windowed-fullscreenIvan Molodetskikh · 39f52b7
Implement toggle-windowed-fullscreen

Windowed, or fake, or detached, fullscreen, is when a window thinks that it's
fullscreen, but the compositor treats it as a normal window.

2025-03-13

2025-03-01

Keep track of RenderElementStates in offscreensIvan Molodetskikh · b351f6f
Keep track of RenderElementStates in offscreens

This both avoids sending frame callbacks to surfaces invisible on the offscreen
(fixing Firefox with subsurface compositing in the process), and fixes
searching for split popups during the resize animation.

2025-02-17

2025-02-15

Implement scrolling the view during DnDIvan Molodetskikh · ca1500a
Implement scrolling the view during DnD

DnD is external to the layout, so we just inform it when one is ongoing.