Compare commits

..

446 Commits

Author SHA1 Message Date
Ivan Molodetskikh b94a5db879 Bump version to 25.02 2025-02-21 09:05:26 +03:00
Ivan Molodetskikh 4a4dcb85ef Update dependencies 2025-02-21 08:03:48 +03:00
Ivan Molodetskikh 7b70cb66bc wiki: Add Since to xkb file 2025-02-20 22:26:40 +03:00
Ivan Molodetskikh cd6522bcc6 wiki: Mention screenshow-screen/window write-to-disk=false 2025-02-20 22:26:40 +03:00
dependabot[bot] 8885233c7e build(deps): bump the rust-dependencies group with 4 updates
Bumps the rust-dependencies group with 4 updates: [anyhow](https://github.com/dtolnay/anyhow), [glam](https://github.com/bitshifter/glam-rs), [serde](https://github.com/serde-rs/serde) and [serde_json](https://github.com/serde-rs/json).


Updates `anyhow` from 1.0.95 to 1.0.96
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.95...1.0.96)

Updates `glam` from 0.29.2 to 0.30.0
- [Changelog](https://github.com/bitshifter/glam-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitshifter/glam-rs/compare/0.29.2...0.30.0)

Updates `serde` from 1.0.217 to 1.0.218
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.217...v1.0.218)

Updates `serde_json` from 1.0.138 to 1.0.139
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.138...v1.0.139)

---
updated-dependencies:
- dependency-name: anyhow
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: glam
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-20 01:08:29 -08:00
Ivan Molodetskikh 7478784343 Change default DnD scroll delay-ms to 100 2025-02-19 07:49:29 +03:00
Ivan Molodetskikh dca187de37 Don't snap after DnD scroll if view position didn't change
Otherwise, any DnD breaks temporarily centered columns.
2025-02-18 19:06:40 +03:00
Ivan Molodetskikh fe660a253b Don't activate window when pressing the Mod+MMB view gesture
Avoid unnecessary movement.
2025-02-18 19:06:40 +03:00
dependabot[bot] ad49e5820a build(deps): bump clap in the rust-dependencies group
Bumps the rust-dependencies group with 1 update: [clap](https://github.com/clap-rs/clap).


Updates `clap` from 4.5.29 to 4.5.30
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.29...clap_complete-v4.5.30)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-18 01:50:42 -08:00
dependabot[bot] 4c40e6ce06 build(deps): bump ordered-float from 4.6.0 to 5.0.0
Bumps [ordered-float](https://github.com/reem/rust-ordered-float) from 4.6.0 to 5.0.0.
- [Release notes](https://github.com/reem/rust-ordered-float/releases)
- [Commits](https://github.com/reem/rust-ordered-float/compare/v4.6.0...v5.0.0)

---
updated-dependencies:
- dependency-name: ordered-float
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-18 01:50:32 -08:00
Ivan Molodetskikh 44c9797844 Take tab indicators into account in expand-column-to-available-width 2025-02-17 22:36:30 +03:00
Ivan Molodetskikh 652d2923bb Use toggle_full_width() for expand-column-to-available-width edge case 2025-02-17 21:57:35 +03:00
Ivan Molodetskikh 85349ce475 Fix expand-column-to-available-width for always-center 2025-02-17 21:48:00 +03:00
Ivan Molodetskikh 92cc2b89f7 Implement expand-column-to-available-width 2025-02-17 21:30:23 +03:00
dependabot[bot] 078383ea82 build(deps): bump pango in the rust-dependencies group
Bumps the rust-dependencies group with 1 update: [pango](https://github.com/gtk-rs/gtk-rs-core).


Updates `pango` from 0.20.7 to 0.20.9
- [Release notes](https://github.com/gtk-rs/gtk-rs-core/releases)
- [Changelog](https://github.com/gtk-rs/gtk-rs-core/blob/main/CHANGELOG.md)
- [Commits](https://github.com/gtk-rs/gtk-rs-core/compare/0.20.7...0.20.9)

---
updated-dependencies:
- dependency-name: pango
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-17 02:18:38 -08:00
Ivan Molodetskikh d27d6a504d Make idle notify lazy 2025-02-17 09:09:59 +03:00
Ivan Molodetskikh ec5144feca Make pointer inactivity timer reset lazy 2025-02-17 09:04:07 +03:00
David 05e0e44a77 Fix link in Application-Issues.md 2025-02-16 09:16:59 -08:00
Ivan Molodetskikh 108e88e211 Enable fancy miette errors for the main binary
Seems there's not much dependency/binary size impact now, compared to when I
first made the KDL config.
2025-02-16 19:37:37 +03:00
Ivan Molodetskikh a693f64c41 Add blank line 2025-02-16 10:26:59 +03:00
Ivan Molodetskikh 5c0468d469 wiki: Document the DnD edge view scroll gesture and config 2025-02-16 10:18:00 +03:00
Ivan Molodetskikh f2b1fc66f2 Make DnD edge view scroll configurable 2025-02-16 10:18:00 +03:00
Ivan Molodetskikh 22302bf224 config: Deindent the snapshot 2025-02-16 10:18:00 +03:00
Ivan Molodetskikh bb6663ebac config: Convert parse test to a snapshot test
Updating it by hand got really old tbh
2025-02-16 10:18:00 +03:00
Ivan Molodetskikh c6e98d5a96 Add a small delay to DnD view scrolling 2025-02-16 10:18:00 +03:00
Ivan Molodetskikh d077350ae4 layout: Remove unused method 2025-02-16 10:18:00 +03:00
w-jablonski f01c840ebe Slightly clearer wording in Tabs.md 2025-02-15 05:15:07 -08:00
Ivan Molodetskikh ca1500ae90 Implement scrolling the view during DnD
DnD is external to the layout, so we just inform it when one is ongoing.
2025-02-15 13:28:57 +03:00
Ivan Molodetskikh d7f3ca00c7 Implement scrolling the view during interactive move 2025-02-15 13:28:57 +03:00
Ivan Molodetskikh fd8140e091 Hook up are_transitions_ongoing() for floating and tiles
Don't spoil it
2025-02-15 13:28:57 +03:00
Ivan Molodetskikh d94fbe9895 layout: Check move output in are_animations_ongoing() 2025-02-15 13:28:57 +03:00
Ivan Molodetskikh 7816f20e6a Implement ext-data-control 2025-02-14 09:03:20 +03:00
Ivan Molodetskikh 0d3610416c Update Smithay (idle-notify 2) 2025-02-14 09:03:20 +03:00
Ivan Molodetskikh 377ad54016 wiki: Document calibration-matrix 2025-02-14 09:03:20 +03:00
Ivan Chinenov 9e794f358b feat: support for setting tablet calibration matrix; this allows for rotating tablet inputs (#1122)
* feat: support for setting tablet calibration matrix

* Change default matrix
2025-02-14 05:15:45 +00:00
dependabot[bot] 4e17cbb9ea build(deps): bump clap in the rust-dependencies group
Bumps the rust-dependencies group with 1 update: [clap](https://github.com/clap-rs/clap).


Updates `clap` from 4.5.28 to 4.5.29
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.28...clap_complete-v4.5.29)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-13 21:05:26 -08:00
rustN00b 4c98b87486 Add missing period to doc comment 2025-02-13 10:39:25 +03:00
rustN00b 5b753be213 Add missing periods to action doc comments 2025-02-13 10:37:41 +03:00
Ivan Molodetskikh a605e7f622 Implement custom hotkey overlay titles 2025-02-13 10:30:33 +03:00
Ivan Molodetskikh 513488f6b8 hotkey overlay: Add pretty for space 2025-02-13 10:30:33 +03:00
Ivan Molodetskikh 43ea4a172a hotkey overlay: Put Ctrl and Shift before Alt
They are commonly written this way.
2025-02-13 10:30:33 +03:00
Ivan Molodetskikh d47b59879a animation/spring: Add a check for from = to in duration()
The overdamped code below was dividing by zero in this case and triggering a
panic.
2025-02-13 08:47:23 +03:00
Ivan Molodetskikh ef80bcc834 Parse the config on the file watcher thread
It takes a while, so let's not block the main thread.
2025-02-12 20:56:32 +03:00
Ivan Molodetskikh eb8bd3894a watcher: Allow running a processing function on the thread 2025-02-12 20:56:32 +03:00
Ivan Molodetskikh 7e552333a9 tab indicator: Add corner-radius setting 2025-02-12 07:59:46 +03:00
Ivan Molodetskikh 213eafa203 wiki: Add Since to drag-lock 2025-02-11 18:24:17 +03:00
Ivan Molodetskikh 7b18ff8870 input: Intercept Enter key when confirming the exit dialog 2025-02-11 13:22:11 +03:00
Ivan Molodetskikh 5246e2ff25 wiki: Add note that is-window-cast-target doesn't match monitor casts 2025-02-11 10:40:51 +03:00
Ivan Molodetskikh dde9214ae4 wiki: Move sentence to a better spot 2025-02-11 10:35:15 +03:00
Ivan Molodetskikh 29b7a41692 Implement is-window-cast-target window rule matcher 2025-02-11 10:31:12 +03:00
Ivan Molodetskikh 216753678a wiki: Add a page for tabs 2025-02-11 08:30:03 +03:00
dependabot[bot] b9e67f6565 build(deps): bump zbus in the rust-dependencies group across 1 directory
Bumps the rust-dependencies group with 1 update in the / directory: [zbus](https://github.com/dbus2/zbus).


Updates `zbus` from 5.3.1 to 5.5.0
- [Release notes](https://github.com/dbus2/zbus/releases)
- [Commits](https://github.com/dbus2/zbus/compare/zbus-5.3.1...zbus-5.5.0)

---
updated-dependencies:
- dependency-name: zbus
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-10 21:04:23 -08:00
Mikołaj Lercher 3a481b5250 wiki: describe running games with gamescope (#1112)
* wiki: describe running games with gamescope

* Update wiki/Application-Issues.md

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2025-02-11 07:52:53 +03:00
Ivan Molodetskikh 20769b4c2f tab indicator: Animate opening 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 14ac2cff4c tab indicator: Dim colors when column is inactive 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh fde627d955 Implement MulAssign<f32> for Color 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 6942ecc13a Implement clicking on tab to switch 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 963ff14ed0 Store hit type in PointContents 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 96a3ded2ec scrolling: Extract tab_indicator_area() 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh a21196ec54 tab indicator: Extract tab_rects() 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 0b83d9932b tab indicator: Use full column height 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 6bd92ab926 tab indicator: Fix gradient area computation
The gradient area should be relative to each tab's geometry. In most cases
these geometries will all match, but not when some tabs have a different size,
for example when they have a fixed size.
2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 02eccf7762 layout: Fix/add animations around tabbed columns 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 89cf276779 tests: Mark window_opening/target_size as slow 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh bc701cd529 mapped: Force a frame callback on configure
Lets hidden windows respond to events like resizes immediately. This is mainly
relevant for tabbed columns.

This commit doesn't actually force sending the frame callbacks in case we don't
redraw. We'll see if this is a problem or not.
2025-02-10 07:29:33 -08:00
Ivan Molodetskikh bfd81fc290 Make send_frame() a function on Mapped
We'll add some extra logic there.
2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 0dd8e883b0 tab indicator: Add gaps-between-tabs 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh c31b58e2c9 tab indicator: Implement place-within-column setting 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh b163045757 wiki: Add hide-when-single-tab to default-column-display example 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 41e9ec1364 wiki: Document tab indicators 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 64544a5726 tab indicator: Add position setting 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh d7d5a7f8f6 tab indicator: Add hide-when-single-tab 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh a451f75917 Implement tab indicators 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 1515410012 Add default-column-display window rule 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 8f9e0d029c Add set-column-display action 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 90f24da631 Move ColumnDisplay to niri-ipc 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh df70140b36 Allow tabbed columns to go fullscreen 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh f90eb0cbe4 Implement tabbed column display mode 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 55e2ea0c3b layout: Extract tile.hit(), HitType::hit_tile() 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 1d883931b4 Account for border in contents_under()
Fixes pointer clicks going through window borders to a layer surface below,
also fixes window not getting activated in all cases from a border click.
2025-02-10 07:29:33 -08:00
Ivan Molodetskikh b65fad09d8 Remove unnecessary mut 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 09a559d3c9 layout: Fix variable names 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 9fc749f3d4 layout/tile: Rename variable 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh f836d1c28a layout/scrolling: Extract activate_idx() 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 4f05a74aa8 Add alpha parameter to shaders
Lets us add extra opacity.
2025-02-10 07:29:33 -08:00
Ivan Molodetskikh c30f522ef2 shader: Return real alpha from alpha() 2025-02-10 07:29:33 -08:00
Ivan Molodetskikh 397e704d64 layout/scrolling: Extract variable 2025-02-07 10:03:38 +03:00
Ivan Molodetskikh acc9d3e409 layout/scrolling: Extract variable 2025-02-07 10:03:38 +03:00
Ivan Molodetskikh 0c59fc304c layout/scrolling: Use early return in tiles_origin() 2025-02-07 10:03:38 +03:00
Ivan Molodetskikh abd7f1dce3 layout/scrolling: Extract two variables 2025-02-07 10:03:38 +03:00
Ivan Molodetskikh 1d87da00b7 layout/scrolling: Extract two variables 2025-02-07 10:02:25 +03:00
Ivan Molodetskikh 91515ac6dc layout/scrolling: Extract resolve_* as methods on Column 2025-02-07 10:02:25 +03:00
Ivan Molodetskikh 7ec771f7ec layout: Rename toplevel_bounds() to new_window_toplevel_bounds() 2025-02-07 09:26:43 +03:00
Ivan Molodetskikh a42a5ac696 layout: Remove redundant () 2025-02-07 08:03:39 +03:00
Ivan Molodetskikh b31c0359eb layout: Extract col variable 2025-02-06 10:30:03 +03:00
Ivan Molodetskikh 934e5a6033 layout: Preserve focused window in column when window above is closed
Might be the longest standing bug in niri?
2025-02-06 09:41:15 +03:00
peelz 690d635505 Initialize tracing_subscriber earlier 2025-02-05 18:06:46 +03:00
Ivan Molodetskikh a444efd0eb Add focus-window-in-column (by index) action 2025-02-05 17:25:57 +03:00
Ivan Molodetskikh c41f93a468 Add focus-window-top/bottom/down-or-top/up-or-bottom actions 2025-02-05 17:25:51 +03:00
Mathias Zhang 900da597e4 input: add touchpad drag-lock setting 2025-02-05 13:35:13 +03:00
Ivan Molodetskikh d320833f40 Update Smithay (text-input double input fix) 2025-02-05 12:54:25 +03:00
dependabot[bot] c384b2489f build(deps): bump clap in the rust-dependencies group
Bumps the rust-dependencies group with 1 update: [clap](https://github.com/clap-rs/clap).


Updates `clap` from 4.5.27 to 4.5.28
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.27...clap_complete-v4.5.28)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-05 12:52:57 +03:00
Ivan Molodetskikh ddcac86d1d mapped: Add needs_configure flag
Allows to de-duplicate configures from requests that require one.
2025-02-05 09:36:58 +03:00
Ivan Molodetskikh 734e3a6d3c Fix find_window_and_output() returning None with no outputs
As far as I can tell, this would mess up a ton of the logic. Not sure
how anything worked with no outputs before?
2025-02-05 09:35:10 +03:00
Ivan Molodetskikh f18b1a7043 mapped: Document RequestSizeOnce 2025-02-05 08:41:40 +03:00
Ivan Molodetskikh 7d24ad23c2 layout/scrolling: Extract tiles_origin() 2025-02-04 10:42:44 +03:00
Ivan Molodetskikh 691bc064bb wiki: Fix copy-paste typo 2025-02-04 10:42:44 +03:00
dependabot[bot] 553b1ba852 build(deps): bump the rust-dependencies group with 3 updates
Bumps the rust-dependencies group with 3 updates: [wayland-backend](https://github.com/smithay/wayland-rs), [wayland-scanner](https://github.com/smithay/wayland-rs) and [wayland-client](https://github.com/smithay/wayland-rs).


Updates `wayland-backend` from 0.3.7 to 0.3.8
- [Release notes](https://github.com/smithay/wayland-rs/releases)
- [Changelog](https://github.com/Smithay/wayland-rs/blob/master/historical_changelog.md)
- [Commits](https://github.com/smithay/wayland-rs/commits)

Updates `wayland-scanner` from 0.31.5 to 0.31.6
- [Release notes](https://github.com/smithay/wayland-rs/releases)
- [Changelog](https://github.com/Smithay/wayland-rs/blob/master/historical_changelog.md)
- [Commits](https://github.com/smithay/wayland-rs/commits)

Updates `wayland-client` from 0.31.7 to 0.31.8
- [Release notes](https://github.com/smithay/wayland-rs/releases)
- [Changelog](https://github.com/Smithay/wayland-rs/blob/master/historical_changelog.md)
- [Commits](https://github.com/smithay/wayland-rs/commits)

---
updated-dependencies:
- dependency-name: wayland-backend
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: wayland-scanner
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: wayland-client
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-03 13:42:47 +03:00
Ivan Molodetskikh d5592743cb Add impl From<Color> for Gradient 2025-02-02 09:55:40 +03:00
Jesse Hallett 019e75955d document interaction between hide-when-typing and wine wayland (#1076)
* document interaction between hide-when-typing and wine wayland

* Update wiki/Configuration:-Miscellaneous.md

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2025-02-02 04:53:16 +00:00
Ivan Molodetskikh 32ad545f84 layout: Extract max_tile_height 2025-02-01 13:05:07 +03:00
Ivan Molodetskikh 4eddcef1be layout: Inline variable 2025-02-01 13:05:07 +03:00
Ivan Molodetskikh 68776f1cee layout: Verify that individual tiles don't get sized taller than working area 2025-02-01 10:48:16 +03:00
Ivan Molodetskikh a0e2a15c60 Take border into account for fixed preset-column-width for tiled windows 2025-01-31 21:30:22 +03:00
Ivan Molodetskikh 88c6778771 Extract SizeChange::from(PresetSize) 2025-01-31 21:15:43 +03:00
Ivan Molodetskikh 73f6d3366e wiki: Remove foot mention
This issue has been fixed in foot.
2025-01-31 20:42:50 +03:00
Ivan Molodetskikh 48a4d5c8a3 Fix typo in comment 2025-01-31 19:24:42 +03:00
Ivan Molodetskikh 6f2f7fa259 layout: Update module comment 2025-01-31 18:05:09 +03:00
Ivan Molodetskikh 49ddf66c2f layout: Move tests to separate file
This way changing just the tests won't rebuild the main library.
2025-01-31 17:56:43 +03:00
fable a169e0335d adjust horizontal view movement gestures snap points for center-focused-column "on-overflow" (#1052)
* Adjust snap points for center-focused-column "on-overflow"

* fix outer gaps not being accounted for in is_overflowing
2025-01-30 17:17:16 +03:00
may e412a0fc6b add option to set xkb config from file (#1062)
* add option to set xkb config from file

* Apply suggestions from code review

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2025-01-30 13:50:05 +00:00
dependabot[bot] fb5fedbf24 build(deps): bump pipewire from 86df391 to fd3d8f7
Bumps pipewire from `86df391` to `fd3d8f7`.

---
updated-dependencies:
- dependency-name: pipewire
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-30 13:57:34 +03:00
bbb651 6b04b1e454 misc: Use helper function for restriced protocol filters
I looked at cosmic-comp as a sanity check and they do the same thing,
I ended up yoinking their function name because it reads better,
not sure about "unrestricted" vs "privileged".
2025-01-30 07:18:42 +03:00
bbb651 0c340ec5ea misc: Use CursorImageSurfaceData type alias
instead of `Mutex<CursorImageAttributes>`
2025-01-30 07:18:42 +03:00
bbb651 34679c75a4 misc: Fix typos
Using [`typos`](https://github.com/crate-ci/typos) cli
2025-01-30 07:18:42 +03:00
Ivan Molodetskikh 1d3820a064 layout: Do not update original output for named workspaces upon adding windows
The way named workspaces are generally used makes them more "attached" to their
original output.

For example, you have a two-monitor setup with named workspaces on both. When
you disconnect the monitor to go somewhere and work for a while, then return,
you probably want your named workspaces to return to where they were on your
second monitor.

This is in contrast to unnamed workspaces which are more transient and should
more easily follow you wherever you're working.
2025-01-29 13:56:26 +03:00
Ivan Molodetskikh 1c749f578c layout: Update workspace original output on moving even if same monitor
Moving is an explicit action that puts the workspace on a specific monitor. It
makes sense to update the original output even if the workspace already happens
to be on the target monitor.
2025-01-29 13:56:26 +03:00
Ivan Molodetskikh 3a887a6e49 wiki/named-workspaces: Mention un/set-workspace-name 2025-01-29 13:56:26 +03:00
dependabot[bot] beef2da628 build(deps): bump the rust-dependencies group across 1 directory with 2 updates
Bumps the rust-dependencies group with 2 updates in the / directory: [serde_json](https://github.com/serde-rs/json) and [insta](https://github.com/mitsuhiko/insta).


Updates `serde_json` from 1.0.137 to 1.0.138
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.137...v1.0.138)

Updates `insta` from 1.42.0 to 1.42.1
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.42.0...1.42.1)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-29 11:28:39 +03:00
Ivan Molodetskikh 9b4d73f13a spec: Don't set XDG_RUNTIME_DIR
It should once again no longer be necessary.
2025-01-27 08:34:12 +03:00
Ivan Molodetskikh 0226d9aec2 Don't create on-disk sockets in tests 2025-01-27 08:30:22 +03:00
Ivan Molodetskikh 902222675a Use Niri::insert_client() in tests 2025-01-27 08:16:09 +03:00
Ivan Molodetskikh ec43493522 Extract Niri::insert_client() 2025-01-27 08:06:33 +03:00
Evgeny Zemtsov baa0518912 Extend switch-layout action to accept layout index (#1045)
* Extend switch-layout action to accept layout index

* Update src/input/mod.rs

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2025-01-26 19:09:01 +00:00
Ivan Molodetskikh d665079b84 CI: Don't forget to build randomized tests in release 2025-01-26 09:54:40 +03:00
Ivan Molodetskikh f0d935dee1 CI: Further reduce the number of proptest cases 2025-01-26 09:39:04 +03:00
Ivan Molodetskikh 314b82caa0 CI: Reduce number of proptest cases 2025-01-26 09:20:49 +03:00
Ivan Molodetskikh 8f79139b78 CI: Add a randomized tests job 2025-01-26 08:37:25 +03:00
Ivan Molodetskikh c5296b870a CI: Write out dependencies once at the top 2025-01-26 08:37:24 +03:00
Ivan Molodetskikh 78697d1cea Switch Smithay back to git
Release currently has an unfortunate merge that breaks IMEs.
2025-01-25 11:51:45 +03:00
Kirottu 852da5714a Add move-workspace-to-index and move-workspace-to-monitor actions (#1007)
* Added move-workspace-to-index and move-workspace-to-monitor IPC actions

* Added redraws to the workspace handling actions, fixed tests that panicked, fixed other mentioned problems.

* Fixed workspace focusing and handling numbered workspaces with `move-workspace-to-index`

* Fixed more inconsistencies with move-workspace-to-monitor

* Added back `self.workspace_switch = None`

* Reordered some workspace cleanup logic

* Fix formatting

* Add missing blank lines

* Fix moving workspace to same monitor and wrong current index updating

* Move function up and add fixme comment

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2025-01-25 08:49:51 +00:00
Ivan Molodetskikh 4f79303811 CI: Remove version string from msrv job
Required checks on GitHub need to be updated every time otherwise.
2025-01-25 10:54:07 +03:00
Ivan Molodetskikh f294d527e1 wiki: Add clipboard section 2025-01-25 10:52:43 +03:00
peelz 54a1cd5069 Add clipboard disable-primary setting 2025-01-25 10:36:36 +03:00
Ivan Molodetskikh 748d90b443 Update Smithay to a crates.io version
What a time to be alive
2025-01-24 08:42:11 +03:00
bbb651 128b01e049 Add scroll-factor window rule 2025-01-23 12:07:32 +03:00
Ivan Molodetskikh 788c9c6c54 Add find_root_shell_surface() that goes through popups 2025-01-23 12:07:32 +03:00
Ivan Molodetskikh a10705fb20 Add toggle-window-rule-opacity action 2025-01-23 11:13:55 +03:00
dependabot[bot] b01b8afa8c build(deps): bump clap in the rust-dependencies group
Bumps the rust-dependencies group with 1 update: [clap](https://github.com/clap-rs/clap).


Updates `clap` from 4.5.26 to 4.5.27
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.26...clap_complete-v4.5.27)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-21 11:56:26 +03:00
Ivan Molodetskikh acd4cb51aa Implement shadows for layer surfaces 2025-01-21 11:31:30 +03:00
Ivan Molodetskikh 5ebcae997e wiki: Add missing property to window rules example 2025-01-21 11:31:30 +03:00
Ivan Molodetskikh 2511a98e8b Extract Niri::update_shaders() 2025-01-21 11:31:30 +03:00
Ivan Molodetskikh a7692d10c4 Add update_render_elements() to MappedLayer 2025-01-21 11:31:30 +03:00
Ivan Molodetskikh c892f04c96 tile: Rename update() to update_render_elements() 2025-01-21 11:31:30 +03:00
Ivan Molodetskikh 3aad5a39ea Fix two comments 2025-01-21 11:31:30 +03:00
dependabot[bot] 7f025da5b6 build(deps): bump the rust-dependencies group with 2 updates
Bumps the rust-dependencies group with 2 updates: [sd-notify](https://github.com/lnicola/sd-notify) and [serde_json](https://github.com/serde-rs/json).


Updates `sd-notify` from 0.4.4 to 0.4.5
- [Changelog](https://github.com/lnicola/sd-notify/blob/master/CHANGELOG.md)
- [Commits](https://github.com/lnicola/sd-notify/compare/v0.4.4...v0.4.5)

Updates `serde_json` from 1.0.135 to 1.0.137
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.135...v1.0.137)

---
updated-dependencies:
- dependency-name: sd-notify
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-20 13:53:29 +03:00
dependabot[bot] 01285bdbbe build(deps): bump the smithay group with 2 updates
Bumps the smithay group with 2 updates: [smithay](https://github.com/Smithay/smithay) and [smithay-drm-extras](https://github.com/Smithay/smithay).


Updates `smithay` from `fe31867` to `953959e`
- [Release notes](https://github.com/Smithay/smithay/releases)
- [Commits](https://github.com/Smithay/smithay/compare/fe31867e3afac2543c4016fb8ed99df3e11eb6da...953959e6069b3e14dba96fdaa46c65990c21d5c9)

Updates `smithay-drm-extras` from `fe31867` to `953959e`
- [Release notes](https://github.com/Smithay/smithay/releases)
- [Commits](https://github.com/Smithay/smithay/compare/fe31867e3afac2543c4016fb8ed99df3e11eb6da...953959e6069b3e14dba96fdaa46c65990c21d5c9)

---
updated-dependencies:
- dependency-name: smithay
  dependency-type: direct:production
  dependency-group: smithay
- dependency-name: smithay-drm-extras
  dependency-type: direct:production
  dependency-group: smithay
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-20 13:51:41 +03:00
Ivan Molodetskikh 8182484572 Remove Vec from Shadow::render() 2025-01-18 17:43:58 +03:00
sodiboo 0584dd2f1e implement keyboard-shortcuts-inhibit and wlr-virtual-pointer (#630)
* stub keyboard-shortcuts-inhibit and virtual-pointer impls

* implement keyboard-shortcuts-inhibit

* implement virtual-pointer

* deal with supressed key release edge-case; add allow-inhibiting property

* add toggle-keyboard-shortcuts-inhibit bind

* add InputBackend extensions; use Device::output() for absolute pos events

* add a `State` parameter to the backend exts and better document future intent

* Add some tests for is_inhibiting_shortcuts

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2025-01-18 17:26:42 +03:00
Ivan Molodetskikh bd559a2660 Implement window shadows 2025-01-17 23:10:01 +03:00
dependabot[bot] b4add625b2 build(deps): bump sd-notify in the rust-dependencies group
Bumps the rust-dependencies group with 1 update: [sd-notify](https://github.com/lnicola/sd-notify).


Updates `sd-notify` from 0.4.3 to 0.4.4
- [Changelog](https://github.com/lnicola/sd-notify/blob/master/CHANGELOG.md)
- [Commits](https://github.com/lnicola/sd-notify/compare/v0.4.3...v0.4.4)

---
updated-dependencies:
- dependency-name: sd-notify
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-17 11:34:41 +03:00
Val Packett 890bbff007 dbus: DisplayConfig: implement apply_monitors_config
This enables gnome-control-center to apply display configuration
changes. Only temporarily, persistence is ignored currently.
2025-01-17 11:16:10 +03:00
Val Packett b853d5b124 dbus: DisplayConfig: report fractional scales as supported 2025-01-17 11:16:10 +03:00
Val Packett 693e0e09f7 dbus: DisplayConfig: report disabled monitors in get_current_state
This is required for gnome-control-center to be able to turn
monitors back on.
2025-01-17 11:16:10 +03:00
Val Packett d52356b131 dbus: DisplayConfig: add properties required by display settings panel 2025-01-17 11:16:10 +03:00
dependabot[bot] b11b995d03 build(deps): bump the rust-dependencies group with 2 updates
Bumps the rust-dependencies group with 2 updates: [bitflags](https://github.com/bitflags/bitflags) and [log](https://github.com/rust-lang/log).


Updates `bitflags` from 2.7.0 to 2.8.0
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitflags/bitflags/compare/2.7.0...2.8.0)

Updates `log` from 0.4.22 to 0.4.25
- [Release notes](https://github.com/rust-lang/log/releases)
- [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/log/compare/0.4.22...0.4.25)

---
updated-dependencies:
- dependency-name: bitflags
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: log
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-16 12:51:04 +03:00
Ivan Molodetskikh 99ba295082 Remove obsolete comment 2025-01-15 15:18:11 +03:00
Ivan Molodetskikh 8c2b5957eb Rename FoIPosition to FloatingPosition 2025-01-15 14:29:35 +03:00
dependabot[bot] 4472164447 build(deps): bump the smithay group with 2 updates
Bumps the smithay group with 2 updates: [smithay](https://github.com/Smithay/smithay) and [smithay-drm-extras](https://github.com/Smithay/smithay).


Updates `smithay` from `2a0d430` to `fe31867`
- [Release notes](https://github.com/Smithay/smithay/releases)
- [Commits](https://github.com/Smithay/smithay/compare/2a0d4307430dc478b0b2f278bc5dc56ec02aa5ca...fe31867e3afac2543c4016fb8ed99df3e11eb6da)

Updates `smithay-drm-extras` from `2a0d430` to `fe31867`
- [Release notes](https://github.com/Smithay/smithay/releases)
- [Commits](https://github.com/Smithay/smithay/compare/2a0d4307430dc478b0b2f278bc5dc56ec02aa5ca...fe31867e3afac2543c4016fb8ed99df3e11eb6da)

---
updated-dependencies:
- dependency-name: smithay
  dependency-type: direct:production
  dependency-group: smithay
- dependency-name: smithay-drm-extras
  dependency-type: direct:production
  dependency-group: smithay
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-15 12:32:32 +03:00
Ivan Molodetskikh a3cbe3514b clipped_surface: Store complete uniforms in the struct
This mistake shall never happen again.
2025-01-14 21:25:17 +03:00
Ivan Molodetskikh efa7c862a4 Add missing clipped surface uniform 2025-01-14 21:19:05 +03:00
Gustav Sörnäs 0df7a085de add write-to-disk argument to screenshot actions 2025-01-14 13:39:52 +03:00
dependabot[bot] 6ae51f287c build(deps): bump the smithay group with 2 updates
Bumps the smithay group with 2 updates: [smithay](https://github.com/Smithay/smithay) and [smithay-drm-extras](https://github.com/Smithay/smithay).


Updates `smithay` from `e1a863b` to `2a0d430`
- [Release notes](https://github.com/Smithay/smithay/releases)
- [Commits](https://github.com/Smithay/smithay/compare/e1a863b3ffc2d560007e3b89e5bbe9500c69221e...2a0d4307430dc478b0b2f278bc5dc56ec02aa5ca)

Updates `smithay-drm-extras` from `e1a863b` to `2a0d430`
- [Release notes](https://github.com/Smithay/smithay/releases)
- [Commits](https://github.com/Smithay/smithay/compare/e1a863b3ffc2d560007e3b89e5bbe9500c69221e...2a0d4307430dc478b0b2f278bc5dc56ec02aa5ca)

---
updated-dependencies:
- dependency-name: smithay
  dependency-type: direct:production
  dependency-group: smithay
- dependency-name: smithay-drm-extras
  dependency-type: direct:production
  dependency-group: smithay
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-14 11:35:00 +03:00
Erica Z 36076d5279 make niri-session POSIX compatible (#970)
* make niri-session POSIX compatible

* Update resources/niri-session

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2025-01-14 09:41:50 +03:00
dependabot[bot] 427c4e3982 build(deps): bump directories from 5.0.1 to 6.0.0
Bumps [directories](https://github.com/soc/directories-rs) from 5.0.1 to 6.0.0.
- [Commits](https://github.com/soc/directories-rs/commits)

---
updated-dependencies:
- dependency-name: directories
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-13 13:36:17 +03:00
dependabot[bot] 1632ce87a5 build(deps): bump zbus in the rust-dependencies group
Bumps the rust-dependencies group with 1 update: [zbus](https://github.com/dbus2/zbus).


Updates `zbus` from 5.2.0 to 5.3.0
- [Release notes](https://github.com/dbus2/zbus/releases)
- [Commits](https://github.com/dbus2/zbus/compare/zbus-5.2.0...zbus-5.3.0)

---
updated-dependencies:
- dependency-name: zbus
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-13 13:35:10 +03:00
bbb651 c523c80598 Support WAYLAND_SOCKET in winit backend
I know of a single compositor that supports `WAYLAND_SOCKET` but not
`WAYLAND_DISPLAY`: https://gitlab.freedesktop.org/mstoeckl/windowtolayer

This should also make niri more robust against accidentally setting
`WAYLAND_SOCKET` when starting as a session, before programs could fail
if they preffered `WAYLAND_SOCKET` over `WAYLAND_DISPLAY`
2025-01-13 08:19:17 +03:00
mrheinen 0bd6df507b Highlight that the path in niri.service should be checked (#962)
* Highlight that the path in niri.service should be checked

Having just installed niri I ran into this issue.  When building from source on Ubuntu the install location using the instructions in this document is /usr/local//bin/niri.

However niri.service pointed to /usr/bin/niri so my session would not start at all. Hopefully this update helps

* Update wiki/Getting-Started.md

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2025-01-13 06:59:21 +03:00
sodiboo 6e41220dbf use standard padding syntax instead of implementing our own
the padding of the two-digit-month can be implemented much more
concisely using `std::fmt` syntax.
2025-01-12 21:38:51 +03:00
Ivan Molodetskikh e05bc269e6 README: Update screenshot 2025-01-11 19:53:25 +03:00
Ivan Molodetskikh d574341f1f wiki: Add missing period 2025-01-11 09:10:45 +03:00
Ivan Molodetskikh 481958f8f7 wiki: Document version string in Packaging 2025-01-11 09:09:25 +03:00
Ivan Molodetskikh 4094469d59 README: Replace next release with version 2025-01-11 09:00:15 +03:00
Ivan Molodetskikh 2261fcb631 wiki: Add Packaging niri page 2025-01-11 08:59:39 +03:00
Ivan Molodetskikh 279c8b6aa2 Back out "rpkg: Print license summary"
This backs out commit 89c991b636.
2025-01-10 17:10:21 +03:00
Ivan Molodetskikh e35c630c1d Format version as calver automatically 2025-01-10 16:37:46 +03:00
Ivan Molodetskikh d3047afa7f rpkg: Set NIRI_BUILD_COMMIT in cargo.toml 2025-01-10 16:19:06 +03:00
Ivan Molodetskikh a03783f54c CI: Add permission to release 2025-01-10 16:04:19 +03:00
Ivan Molodetskikh cbf0d6190d rpkg: Update licenses 2025-01-10 16:02:30 +03:00
Ivan Molodetskikh 89c991b636 rpkg: Print license summary 2025-01-10 15:59:22 +03:00
Ivan Molodetskikh bbbd35e9ef CI: Fix grep check 2025-01-10 15:42:22 +03:00
Ivan Molodetskikh c308be315d wiki: Put version in Since: next release 2025-01-10 15:39:02 +03:00
Ivan Molodetskikh d825e3125e CI: Add a prepare-release workflow 2025-01-10 15:28:50 +03:00
Ivan Molodetskikh 64288de04e rpkg: Use NIRI_BUILD_COMMIT 2025-01-10 15:25:49 +03:00
Ivan Molodetskikh fb4471e69d Add NIRI_BUILD_COMMIT env variable override 2025-01-10 15:20:27 +03:00
Ivan Molodetskikh 8be8694f5f Add NIRI_BUILD_VERSION_STRING env variable to override the version 2025-01-10 15:17:04 +03:00
Ivan Molodetskikh 60b78dc2cd Bump version to 25.01 2025-01-10 15:16:36 +03:00
Ivan Molodetskikh 80fe5a8167 CI: Rearrange some dependencies 2025-01-10 15:15:50 +03:00
dependabot[bot] df58c49876 build(deps): bump the rust-dependencies group with 2 updates
Bumps the rust-dependencies group with 2 updates: [bitflags](https://github.com/bitflags/bitflags) and [clap](https://github.com/clap-rs/clap).


Updates `bitflags` from 2.6.0 to 2.7.0
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitflags/bitflags/compare/2.6.0...2.7.0)

Updates `clap` from 4.5.24 to 4.5.26
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.24...clap_complete-v4.5.26)

---
updated-dependencies:
- dependency-name: bitflags
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-10 11:40:45 +03:00
Ivan Molodetskikh 7dee2f6995 Fix two manual let-else 2025-01-10 09:11:31 +03:00
Ivan Molodetskikh 623687e59b Fix new Clippy warnings 2025-01-10 09:11:31 +03:00
rustn00b 5958d3be62 Allow workspace names to be changed dynamically (#904)
* Add un/set workspace name actions

* Add SetWorkspaceName reference to proptests

* Simplify unname_workspace

* Add ewaf version of set first workspace name test

* Simplify more

* Fix comment

* Make workspace in set-workspace-name a positional option

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2025-01-10 06:03:19 +00:00
Ivan Molodetskikh 142e57450d Add missing interactively moved window check in center_window 2025-01-09 11:55:01 +03:00
rustn00b 80815a1591 Add a window swap operation (#899)
Swap the active window with the a neighboring column's active window.


---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Take into account PR comments

- no longer behave like an expel when a swap is made in a direction
  where there is no column to swap with
- fix janky animation
2025-01-09 08:29:36 +00:00
Ivan Molodetskikh 8412bfb813 Add missing cursor warp when focusing floating/tiling 2025-01-09 10:49:24 +03:00
Ivan Molodetskikh a0f279691a Update dependencies 2025-01-09 10:23:44 +03:00
Ivan Molodetskikh 92aeddb9fe Force-update insta snapshots
1.42.0 reverted a 1.41.0 change to snapshot metadata.
2025-01-09 10:22:39 +03:00
dependabot[bot] d7da88853b build(deps): bump the rust-dependencies group across 1 directory with 4 updates
Bumps the rust-dependencies group with 4 updates in the / directory: [clap](https://github.com/clap-rs/clap), [libdisplay-info](https://github.com/Smithay/libdisplay-info-rs), [serde_json](https://github.com/serde-rs/json) and [insta](https://github.com/mitsuhiko/insta).


Updates `clap` from 4.5.23 to 4.5.24
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.23...clap_complete-v4.5.24)

Updates `libdisplay-info` from 0.1.0 to 0.2.2
- [Release notes](https://github.com/Smithay/libdisplay-info-rs/releases)
- [Commits](https://github.com/Smithay/libdisplay-info-rs/compare/v0.1.0...v0.2.2)

Updates `serde_json` from 1.0.134 to 1.0.135
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.134...v1.0.135)

Updates `insta` from 1.41.1 to 1.42.0
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.41.1...1.42.0)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: libdisplay-info
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-08 08:55:36 +00:00
Frans Skarman 89678c7b1e Set is-active-in-column to true for unmapped windows (#934)
* Set is-active-in-column to true for unmapped windows

* Update wiki/Configuration:-Window-Rules.md

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2025-01-05 13:38:26 +03:00
Ivan Molodetskikh 098c826095 Search for connector duplicates across all devices 2025-01-04 23:32:09 +03:00
Ivan Molodetskikh befbdc3ae5 default-config: Fix typo 2025-01-04 20:56:45 +03:00
Ivan Molodetskikh dca0364f4c Unname connector if a duplicate is detected 2025-01-04 18:03:08 +03:00
Ivan Molodetskikh 37771259d9 Fetch monitor name from EDID only once
Reduce spam when it's unavailable. Assume the name cannot change at runtime;
before if it changed, bad things would probably happen anyway.
2025-01-04 17:56:13 +03:00
Ivan Molodetskikh 4618e4851c Default to unrestricted primary plane scanout 2025-01-04 13:02:22 +03:00
Ivan Molodetskikh b2ca280c49 Restart PipeWire on errors
This lets you restart pipewire and then get a screencast successfully.
2025-01-04 12:23:25 +03:00
Ivan Molodetskikh bf6995f759 CI: Fix MSRV 2025-01-04 11:49:27 +03:00
Ivan Molodetskikh ab0cce7cb7 Add Xrgb/Xbgr to color formats
At least until the scanout check is fixed in Smithay again.
2025-01-04 11:22:56 +03:00
Ivan Molodetskikh 2e422fc026 Update dependencies 2025-01-04 11:22:56 +03:00
Ivan Molodetskikh a2f9d132a0 Migrate to new Rectangle functions 2025-01-04 11:22:56 +03:00
Ivan Molodetskikh 1973b97cc2 Upgrade Smithay (DrmCompositor changes) 2025-01-04 11:22:56 +03:00
Ivan Molodetskikh b3c6f0e661 Add floating binds to the hotkey overlay 2025-01-03 17:26:36 +03:00
Ivan Molodetskikh 6998b17f9e wiki: Update default hotkeys 2025-01-03 17:23:29 +03:00
Ivan Molodetskikh ed9932d70d wiki: Update the layer-shell components page 2025-01-03 17:02:18 +03:00
Ivan Molodetskikh a5f3b2a949 Clear on-demand layer-shell focus in more cases 2025-01-03 17:00:13 +03:00
Ivan Molodetskikh 152ed59502 Allow keyboard focus for bottom and background layers 2025-01-03 16:41:39 +03:00
Ivan Molodetskikh 8e16be9e11 Allow pop-up grabs for bottom and background layers 2025-01-03 16:24:23 +03:00
Ivan Molodetskikh 300701f44e Render layer-shell pop-ups on top 2025-01-03 15:57:59 +03:00
Ivan Molodetskikh d1370622d8 wiki: Expand application issues a bit 2025-01-03 12:30:17 +03:00
Ivan Molodetskikh 0134166009 README: Expand Status a bit 2025-01-03 11:11:11 +03:00
Ivan Molodetskikh ddb9084260 wiki/Xwayland: Add a labwc section 2025-01-03 10:50:02 +03:00
Ivan Molodetskikh 0224452cef wiki/Xwayland: Clarify xwayland-satellite 2025-01-03 10:50:02 +03:00
Julian Schuler c17d4dc050 Add actions to focus/move to next/previous monitor 2025-01-02 15:15:23 +03:00
bbb651 4e33f45522 Add Mouse{Left,Right,Middle,Back,Forward} binds 2025-01-02 14:59:15 +03:00
Christian Meissl b16d7abb35 skip keyboard focus for layer shell surfaces not...
...requesting keyboard interactivity
2025-01-02 14:24:39 +03:00
Christian Meissl 2f17a30157 xdg: do not focus unmapped popup on grab
a grab is requested for an unmapped popup,
delay focusing the popup until the first keyboard
interaction
2025-01-02 14:24:39 +03:00
Ivan Molodetskikh 0dbd14ebdc Update dependencies 2025-01-02 11:50:51 +03:00
Ivan Molodetskikh 8b3d8ccb47 Update dependabot.yml 2025-01-02 11:34:04 +03:00
Ivan Molodetskikh f8ff2e4e28 Update dependabot.yml 2025-01-02 11:32:34 +03:00
Ivan Molodetskikh 044f0d41a5 Update dependabot.yml 2025-01-02 11:31:37 +03:00
Ivan Molodetskikh 4089bebd83 Create dependabot.yml 2025-01-02 11:30:01 +03:00
Ivan Molodetskikh d4787c75fd Delete dependabot.yml 2025-01-02 11:26:49 +03:00
Ivan Molodetskikh 3bf0a57b82 Create dependabot.yml 2025-01-02 11:20:47 +03:00
Ivan Molodetskikh cc505ae49f Delete dependabot.yml
Let's see if re-creating fixes it.
2025-01-02 11:19:20 +03:00
dependabot[bot] 2f6de136dd build(deps): bump the rust-dependencies group with 19 updates
Bumps the rust-dependencies group with 19 updates:

| Package | From | To |
| --- | --- | --- |
| [anyhow](https://github.com/dtolnay/anyhow) | `1.0.93` | `1.0.95` |
| [bytemuck](https://github.com/Lokathor/bytemuck) | `1.19.0` | `1.21.0` |
| [calloop](https://github.com/Smithay/calloop) | `0.14.1` | `0.14.2` |
| [clap](https://github.com/clap-rs/clap) | `4.5.20` | `4.5.23` |
| [fastrand](https://github.com/smol-rs/fastrand) | `2.2.0` | `2.3.0` |
| [libc](https://github.com/rust-lang/libc) | `0.2.162` | `0.2.169` |
| [ordered-float](https://github.com/reem/rust-ordered-float) | `4.5.0` | `4.6.0` |
| [pango](https://github.com/gtk-rs/gtk-rs-core) | `0.20.4` | `0.20.7` |
| [pangocairo](https://github.com/gtk-rs/gtk-rs-core) | `0.20.4` | `0.20.7` |
| [png](https://github.com/image-rs/image-png) | `0.17.14` | `0.17.16` |
| [portable-atomic](https://github.com/taiki-e/portable-atomic) | `1.9.0` | `1.10.0` |
| [serde](https://github.com/serde-rs/serde) | `1.0.214` | `1.0.217` |
| [serde_json](https://github.com/serde-rs/json) | `1.0.132` | `1.0.134` |
| [tracing](https://github.com/tokio-rs/tracing) | `0.1.40` | `0.1.41` |
| [tracy-client](https://github.com/nagisa/rust_tracy_client) | `0.17.4` | `0.17.6` |
| [url](https://github.com/servo/rust-url) | `2.5.3` | `2.5.4` |
| [proptest](https://github.com/proptest-rs/proptest) | `1.5.0` | `1.6.0` |
| [proptest-derive](https://github.com/proptest-rs/proptest) | `0.5.0` | `0.5.1` |
| [xshell](https://github.com/matklad/xshell) | `0.2.6` | `0.2.7` |


Updates `anyhow` from 1.0.93 to 1.0.95
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.93...1.0.95)

Updates `bytemuck` from 1.19.0 to 1.21.0
- [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md)
- [Commits](https://github.com/Lokathor/bytemuck/compare/v1.19.0...v1.21.0)

Updates `calloop` from 0.14.1 to 0.14.2
- [Release notes](https://github.com/Smithay/calloop/releases)
- [Changelog](https://github.com/Smithay/calloop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Smithay/calloop/compare/v0.14.1...v0.14.2)

Updates `clap` from 4.5.20 to 4.5.23
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.20...clap_complete-v4.5.23)

Updates `fastrand` from 2.2.0 to 2.3.0
- [Release notes](https://github.com/smol-rs/fastrand/releases)
- [Changelog](https://github.com/smol-rs/fastrand/blob/master/CHANGELOG.md)
- [Commits](https://github.com/smol-rs/fastrand/compare/v2.2.0...v2.3.0)

Updates `libc` from 0.2.162 to 0.2.169
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Changelog](https://github.com/rust-lang/libc/blob/0.2.169/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.162...0.2.169)

Updates `ordered-float` from 4.5.0 to 4.6.0
- [Release notes](https://github.com/reem/rust-ordered-float/releases)
- [Commits](https://github.com/reem/rust-ordered-float/compare/v4.5.0...v4.6.0)

Updates `pango` from 0.20.4 to 0.20.7
- [Release notes](https://github.com/gtk-rs/gtk-rs-core/releases)
- [Changelog](https://github.com/gtk-rs/gtk-rs-core/blob/main/CHANGELOG.md)
- [Commits](https://github.com/gtk-rs/gtk-rs-core/compare/0.20.4...0.20.7)

Updates `pangocairo` from 0.20.4 to 0.20.7
- [Release notes](https://github.com/gtk-rs/gtk-rs-core/releases)
- [Changelog](https://github.com/gtk-rs/gtk-rs-core/blob/main/CHANGELOG.md)
- [Commits](https://github.com/gtk-rs/gtk-rs-core/compare/0.20.4...0.20.7)

Updates `png` from 0.17.14 to 0.17.16
- [Changelog](https://github.com/image-rs/image-png/blob/master/CHANGES.md)
- [Commits](https://github.com/image-rs/image-png/compare/v0.17.14...v0.17.16)

Updates `portable-atomic` from 1.9.0 to 1.10.0
- [Release notes](https://github.com/taiki-e/portable-atomic/releases)
- [Changelog](https://github.com/taiki-e/portable-atomic/blob/main/CHANGELOG.md)
- [Commits](https://github.com/taiki-e/portable-atomic/compare/v1.9.0...v1.10.0)

Updates `serde` from 1.0.214 to 1.0.217
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.214...v1.0.217)

Updates `serde_json` from 1.0.132 to 1.0.134
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.132...v1.0.134)

Updates `tracing` from 0.1.40 to 0.1.41
- [Release notes](https://github.com/tokio-rs/tracing/releases)
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.40...tracing-0.1.41)

Updates `tracy-client` from 0.17.4 to 0.17.6
- [Commits](https://github.com/nagisa/rust_tracy_client/compare/tracy-client-v0.17.4...tracy-client-v0.17.6)

Updates `url` from 2.5.3 to 2.5.4
- [Release notes](https://github.com/servo/rust-url/releases)
- [Commits](https://github.com/servo/rust-url/compare/v2.5.3...v2.5.4)

Updates `proptest` from 1.5.0 to 1.6.0
- [Release notes](https://github.com/proptest-rs/proptest/releases)
- [Changelog](https://github.com/proptest-rs/proptest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/proptest-rs/proptest/commits)

Updates `proptest-derive` from 0.5.0 to 0.5.1
- [Release notes](https://github.com/proptest-rs/proptest/releases)
- [Changelog](https://github.com/proptest-rs/proptest/blob/0.5.1/CHANGELOG.md)
- [Commits](https://github.com/proptest-rs/proptest/compare/proptest-derive-0.5.0...0.5.1)

Updates `xshell` from 0.2.6 to 0.2.7
- [Changelog](https://github.com/matklad/xshell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/xshell/compare/v0.2.6...v0.2.7)

---
updated-dependencies:
- dependency-name: anyhow
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: bytemuck
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: calloop
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: fastrand
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: libc
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: ordered-float
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: pango
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: pangocairo
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: png
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: portable-atomic
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: tracing
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: tracy-client
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: url
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: proptest
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: rust-dependencies
- dependency-name: proptest-derive
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
- dependency-name: xshell
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rust-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-02 11:15:11 +03:00
dependabot[bot] da21b50137 build(deps): bump smithay-drm-extras from c3f3ac8 to 5186cf7
Bumps [smithay-drm-extras](https://github.com/Smithay/smithay) from `c3f3ac8` to `5186cf7`.
- [Release notes](https://github.com/Smithay/smithay/releases)
- [Commits](https://github.com/Smithay/smithay/compare/c3f3ac8dc0776d47bc50f9a1911b613a56e6e04b...5186cf7dec2472a91e3c248772954b1141dab7f2)

---
updated-dependencies:
- dependency-name: smithay-drm-extras
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-02 10:59:24 +03:00
Ivan Molodetskikh a38a5c529f Create dependabot.yml
Copied from Helix.
2025-01-02 10:44:27 +03:00
Ivan Molodetskikh 44b5612697 Remove notify-rust dependency
It uses outdated zbus.
2025-01-02 09:33:54 +03:00
bbb651 0113292cf6 Upgrade zbus and async-io 2025-01-02 08:50:48 +03:00
Ivan Molodetskikh 4741ab2e04 spec: Set XDG_RUNTIME_DIR for tests 2024-12-30 22:15:44 +03:00
Ivan Molodetskikh 08fb9435fd Fix width shrinking when going from floating to scrolling 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 793e92e9d6 Add default-floating-position relative-to property 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh a7c57f4faf Add toggle-window-width by-id action 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 8409107a5b Implement default-window-height for scrolling windows 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 9089c3fb02 Fix move-window-to-workspace panic when wrong monitor is active 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 6c897d5201 Add center-window by-id action 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 6cb5135f34 Clamp single tiled window height
Now that we have floating for taller-than-screen windows.
2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 44bf45794e Dump post-unfullscreen configure in snapshot tests 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh d6da9f47d8 tests: Respond to post-initial configures 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh be05b66ac3 Hide focus ring for unfocused layout and under interactive move 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh d1998ae3fa Disable double-resize-click for floating windows 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 3c2e1554c6 Add default-floating-position window rule 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 744955ba69 floating: Remove initial offset when always-centering 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 7af33f9e6a wiki: Add some floating window documentation 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 3c0705b0ae Implement buffer delta for toplevels 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 4ea4d2bd3b layout: Add animate arg to move_floating_window() 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 6c52077d92 Add move-floating-window action 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 73bf7b1730 Allow hyphen values for set-window-width/height arg
Make args like set-window-height -10 parse as is, without having to insert a --.
2024-12-30 20:12:37 +03:00
Ivan Molodetskikh b394cb6379 floating: Cancel resize when moving or changing size 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 60854e180e Add is_floating to Window IPC 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 5b4750a009 Add focus-floating/tiling actions 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh ad50dd21fe Add move-window-to-floating/tiling actions 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 8b0cb0bb57 Add set-window-width action 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh a24a6e4e3c Implement is-floating window rule matcher 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 6fba4c371e Implement default-window-height window rule
Only works for floats that aren't initially fullscreen atm.
2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 27911431db tests: Rename DefaultWidth to DefaultSize 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh db6447ed79 floating: Support default-column-width in most cases
open-fullscreen + open-floating default width is still not supported in this
commit.
2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 99c0fabee6 layout: Use new helper function 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh fc99724aba Add open-focused window rule 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 88fbc62b1d wiki: Update Firefox window rules to match non-Flatpak 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh e8027d571f layout: Implement next-to + open-fullscreen 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh daaee43be3 layout: Refactor window opening targets 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 0d71cb93af Add window opening size client-server tests 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh e5e50e82d5 wiki: Clarify that preset width doesn't take borders into account only in tiling 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 7e852124a5 floating: Fix window position constraining with non-zero working area loc 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh f66a49bc42 floating: Constrain popups to working area 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh baf78ccda2 floating: Remove TODO on tile removing width 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 31f0e66f45 floating: Comment on toggle-full-width status 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 28b78a563b layout: Pass and store view_size on a Tile 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 2f380de73b floating: Take into account non-fixed min/max size window rule 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh e3a9a39c9a floating: Implement the rest of set-window-width/height 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 1710bb78df floating: Implement toggle-width/height actions 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 3e13fc3e70 floating: Change from getters to pub(super)
These fields are just data storage. They won't have any logic in
getters/setters.
2024-12-30 20:12:37 +03:00
Ivan Molodetskikh befc399506 default-config: Make Firefox PiP floating 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 88116b9fb1 Preserve tile when moving across monitors 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 53e1c58cc5 Remember floating window position 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 4b9ecdd11d Render fullscreen scrolling windows on top of floating 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh e31e409ee8 tests: Fix spelling mistake in wfs Display 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 5488aaf69f floating: Don't use fullscreen size as floating size 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 96e493d8b1 Restore floating size during interactive move 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh e409453fbd floating: Update stored size only on removal 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 309bf1348c floating: Improve expected size requests to avoid (0, 0) and duplicates 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 76a5635298 layout: Preserve the Tile when moving across workspaces 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh f4f2a1f6de floating: Remember and restore window size 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh a440805ea1 Add floating sizing tests 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh c359672bd2 floating: Request size only once
Let floating windows resize themselves and keep that size.
2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 38350935e6 layout: Rename update_interactive_resize() to on_commit() 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 421cd89a0f layout: Accept &mut self in request_fullscreen() 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 5ce3369aa6 layout: Support fullscreen for auto-floating windows 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh f38acfe988 layout: Remember whether to unfullscreen back into floating 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 965619d096 layout: Move toggle_fullscreen() impl to Workspace 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 9f017e834c wiki: Document new floating window rule and gesture 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 3c67b08488 floating: Implement directional move 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 4add755a4d layout/floating: Extract move_and_animate() 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 56e249aee6 floating: Implement center_window() 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 6a7c8fcfd5 floating: Implement directional focus 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 14b1003c62 layout: Implement focus_right_or_first() generically 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 43a4bae010 Extract center_preferring_top_left_in_area() 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 9c205f77a2 layout/floating: Move a function higher up
Let's group action functions together. Activate is an action and set
width/height too.
2024-12-30 20:12:37 +03:00
Ivan Molodetskikh c2e4cfd832 Stub out actions when floating is active
Make sure they don't go to the unfocused scrolling layout at least.
2024-12-30 20:12:37 +03:00
Ivan Molodetskikh c008e1c5bc floating: Implement smarter clamping for window location
A small part of the window always remains on-screen regardless of the working
area changes.

Interactive move lets the user position the window anywhere; automatic actions
like toggle-window-floating and dialog opening try to put the window fully
on-screen.

The size-fraction canonical floating window position remains unclamped, and
clamping happens when recomputing the logical position.
2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 1aa60f0da3 Make right click during move toggle floating 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh bd1fd8383c Stop move grab when the start button is released
Rather than when all buttons are released.
2024-12-30 20:12:37 +03:00
Ivan Molodetskikh aac54d0ea1 Implement floating child stacking above parents 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 4fe718581b layout: Extract TestWindowParams 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 71842f07bd Make interactive move keep in the same layout (floating/tiling) 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh f2bec1f82f Always honor min height in new window size 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 10460191b9 Honor min/max size in more places like initial configure 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh c5fffd6e2c Initial WIP floating window implementation 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 951f63b6fd temp: Use patched Smithay (fix VRR cursor-plane-only) 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh e6d8932b3b Update for Smithay VRR changes 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 70f96cca0a Update Smithay (presentation-time v2) 2024-12-30 20:12:37 +03:00
Ivan Molodetskikh 4e357e9659 config: Fix border rule on -> off merging 2024-12-27 15:42:56 +03:00
Ivan Molodetskikh 1f8aed6732 config: Add a test for border rule on/off merging 2024-12-27 15:42:55 +03:00
Maximilian Huber fa2bace3cd Fix nix flake for client-server tests (#896)
This was suggested by @sodiboo in
https://github.com/YaLTeR/niri/issues/894#issuecomment-2562153840 and
was copied from https://github.com/sodiboo/niri-flake/commit/350e6b68c70f5002a75e10521f5e66ace4b5eed1i

Signed-off-by: Maximilian Huber <gh@maxhbr.de>
2024-12-26 14:44:07 +00:00
Nathan 955039b5ea Update Configuration:-Key-Bindings.md (#893)
* Update Configuration:-Key-Bindings.md

Added Leve5 notes with scant instruction on how to use.

* Update wiki/Configuration:-Key-Bindings.md

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2024-12-23 21:08:56 +03:00
Ivan Molodetskikh 771ea1e815 Implement client-server test infra and window opening tests
These tests make a real Niri instance and real Wayland clients (via manual
wayland-rs implementation), both on the same event loop local to the test. This
allows testing the full Wayland interaction, including arbitrary event ordering
and delays.

To start off, add a massive powerset test for the settings that influence where
a window may open.
2024-12-22 15:19:46 +03:00
Ivan Molodetskikh d38bfc4aff Add test-only single-pixel-buffer support 2024-12-22 15:19:46 +03:00
Ivan Molodetskikh fbb0054232 Add a Headless backend for tests
Rendering and stuff is unimplemented.
2024-12-22 15:19:46 +03:00
Ivan Molodetskikh 2d3c36edae Switch from k9 to insta for snapshot testing
We'll need some advanced features from insta.
2024-12-22 15:19:46 +03:00
Ivan Molodetskikh 8dcc41a54d Initialize PipeWire lazily
This helps with:
- System setups starting PipeWire late (after niri startup, but before any
  screencast).
- Tests which don't even want to start PipeWire.
2024-12-22 15:19:46 +03:00
bbb651 ba3d2e36c8 Bump MSRV to 1.80
It should be old enough for most distros, and allows upgrading to `zbus 5.x`
2024-12-22 15:19:46 +03:00
bbb651 b51047ffcc Avoid implicit feature names 2024-12-22 15:19:46 +03:00
Rémi Labeyrie b1c40a9079 fix: check for layer surface under cursor when clicking 2024-12-22 15:13:17 +03:00
Ivan Molodetskikh b014c267ae README: Replace Matrix badge with static
The dynamic one broke recently.
2024-12-20 23:07:19 +03:00
Ivan Molodetskikh 6b16cc52db Add force-pipewire-invalid-modifier debug flag 2024-12-17 17:08:14 +03:00
Ivan Molodetskikh d35ad73e35 wiki: Change Since 0.1.11 to Since next release 2024-12-15 16:44:35 +03:00
Ivan Molodetskikh 2a1af3d9ae Add missing blank line 2024-12-15 10:40:09 +03:00
Ivan Molodetskikh 82e30246c1 Use gtk Notification portal
xdg-gnome 47 now implements notifications via GNOME Shell API which we don't
have. So force the gtk portal to make notifications work again.
2024-12-11 21:39:58 +03:00
Salman Farooq bb3a05bb3f Activate monitors on session unlock (#858)
So that e.g. unlocking by touching the fingerprint reader powers on the monitors.

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Co-authored-by: Salman Farooq <46742354+SalmanFarooqShiekh@users.noreply.github.com>
2024-12-11 03:53:41 -08:00
Ivan Molodetskikh 40fa82275c Extract rules.apply_{min,max}_size() 2024-12-09 13:25:52 +03:00
Ivan Molodetskikh 9824321fc9 layout: Return instead of breaking
There's no code past this, and we want to break out of all loops.
2024-12-08 09:25:39 +03:00
Ivan Molodetskikh 27e607ab82 layout: Return bool from activate_window()
Avoid an extra has_window() call.
2024-12-08 09:25:27 +03:00
Ivan Molodetskikh a2b27b8790 layout: Ignore more actions during interactive move
The interactively moved window is the active window, so this makes sense.
2024-12-07 19:38:48 +03:00
Ivan Molodetskikh 396089ef0e layout: Extract Tile::verify_invariants() 2024-12-07 19:38:48 +03:00
Ivan Molodetskikh df98b5021d layout: Mark accessors as cfg(test) 2024-12-07 19:38:48 +03:00
sodiboo 34ce6d0b02 nix: update flake.lock 2024-12-03 05:53:48 -08:00
sodiboo 7af937b08e nix: clang -> rustPlatform.bindgenHook 2024-12-03 05:53:48 -08:00
Ivan Molodetskikh 8665003269 layout: Extract ScrollingSpace
Leave the Workspace to do the workspace parts, and extract the scrolling parts
into a new file. This is a pre-requisite for things like the floating layer
(which will live in a workspace alongside the scrolling layer).

As part of this huge refactor, I found and fixed at least these issues:
- Wrong horizontal popup unconstraining for a smaller window in an
  always-centered column.
- Wrong workspace switch in focus_up_or_right().
2024-12-01 22:24:21 -08:00
Ivan Molodetskikh 1e76716819 layout: Add a test for windows on other workspace remaining activated 2024-12-01 22:24:21 -08:00
Ivan Molodetskikh 91a42fdf58 layout: Fix windows on other workspaces losing activated state
This erroneous check was introduced in interactive move.
2024-12-01 22:24:21 -08:00
Ivan Molodetskikh 5ed5243be6 layout: Fix possible crash when dropping move on different, animating output 2024-12-01 22:24:21 -08:00
Ivan Molodetskikh 4560251e64 layout: Correct variable names 2024-12-01 22:24:21 -08:00
Ivan Molodetskikh 2020dca3e0 layout: Use tiles_mut() in Workspace::clear_unmap_snapshot() 2024-12-01 22:24:21 -08:00
Ivan Molodetskikh 7fc2121454 layout: Extract Workspace::tiles() 2024-12-01 22:24:21 -08:00
Ivan Molodetskikh 8b84afbd38 Add strict-new-window-focus-policy debug flag 2024-11-29 21:57:36 -08:00
Christian Meissl 305fc3b557 Activate newly mapped windows with a valid activation token
most of the time the activation token is passed
while the window is still unmapped. in this case
store the intend to activate the window for
later retrieval on map.
2024-11-29 21:57:36 -08:00
Christian Meissl 61f2ac01d7 xdg: startup activation
pass an activation token to process spawned through actions
2024-11-29 21:57:36 -08:00
Ivan Molodetskikh 39a9f55205 Fix new warnings 2024-11-29 09:33:08 +03:00
FluxTape 11f351dbeb Implement empty-workspace-above-first (#745)
* Implement empty-workspace-above-first option

* add two failing tests

* fix interactive_move_onto_empty_output_ewaf and
interactive_move_onto_first_empty_workspace tests

* Add two failing ewaf option toggle tests

* Fix adding/removing first empty workspace on option toggle

* Don't remove first empty workspace if focused

* Stop workspace switch when enabling ewaf

* layout/monitor: Offset workspace switch on adding workspace above

* Fix some initial active workspace ids with ewaf

* wiki: Document empty-workspace-above-first

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2024-11-29 08:46:13 +03:00
Ivan Molodetskikh 815fa379ea layout: Stop workspace switch when moving workspaces to primary
Okay, this might be one of the oldest layout issues to have remained uncaught.
Well, maybe as I add more randomized tests, I'll catch even more of those.
2024-11-27 20:55:20 +03:00
Ivan Molodetskikh 4c480a1ea3 layout/tests: Add post option update to randomized test
Will help to catch cases where updating options doesn't update the state
correctly.
2024-11-26 22:02:46 +03:00
Ivan Molodetskikh fa4aa0e06d layout: Fix adjusting for scale for moved tile when reloading config 2024-11-26 22:01:26 +03:00
Ivan Molodetskikh e2a6374bf5 layout/tests: Return Layout from check_ops()
Cuts down on boilerplate in a few places.
2024-11-26 22:00:44 +03:00
Ivan Molodetskikh dc14554053 layout: Extract update_options() 2024-11-26 21:59:05 +03:00
Ivan Molodetskikh 985ca7b643 layout/tests: Allow AddWindowRightOf interactive moved window
Guess I forgot this.
2024-11-26 15:24:28 +03:00
Ivan Molodetskikh 60624d64fa layout/tests: Standardize on usize for output id in tests 2024-11-26 15:24:28 +03:00
Ivan Molodetskikh 2935dae89e wiki: Add animation timing page 2024-11-25 04:07:59 -08:00
Ivan Molodetskikh 4c22c3285d Refactor animation timing to use lazy clocks 2024-11-25 04:07:59 -08:00
Ivan Molodetskikh 93cee2994a Refactor animations to take explicit current time 2024-11-25 04:07:59 -08:00
Ivan Molodetskikh 9c7e8d04d2 Extract Niri::advance_animations() 2024-11-23 15:09:16 +03:00
Ivan Molodetskikh 1e6b8906e0 layout/monitor: Extract add_workspace_bottom() 2024-11-23 15:07:52 +03:00
Ivan Molodetskikh 6c5b92e5c0 Add interactive_move_onto_empty_output test
Tests the add_workspace_bottom() in Monitor::add_tile().
2024-11-23 15:07:35 +03:00
Ivan Molodetskikh 38c515e12e pw: Fix potential crash when disconnecting output 2024-11-23 15:07:09 +03:00
Ivan Molodetskikh c239937fac Focus target window/output on DnD
In sway, focus-follows-mouse keeps working during DnD, but not in niri.
So it can be surprising when you DnD something into another app, but it
doesn't get automatically focused. This commit fixes that.

Even if the DnD is not validated, or if there's no target surface (e.g.
dropped on the niri background), focus the target output, since that's
how Firefox's drag-tab-into-new-window works for example.
2024-11-22 09:37:26 +03:00
Ivan Molodetskikh bafa574784 wiki: Link layer rules from block-out-from window rules 2024-11-21 14:57:41 +03:00
Ivan Molodetskikh 199a5854a8 wiki: Add Since to layer rules 2024-11-21 14:57:41 +03:00
Ridan Vandenbergh a74a578198 Add focus-window-previous action (#811)
* Add `FocusWindowPrevious` action

* remove [`

* track previous focus in Niri instead of every window

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2024-11-21 14:48:51 +03:00
Ivan Molodetskikh 7de752ec56 Bump CI image versions 2024-11-20 13:16:02 +03:00
Ivan Molodetskikh 0a833171ac Update Smithay (popup grab fix) 2024-11-20 08:34:19 +03:00
Ivan Molodetskikh 1a0612cbfd Implement layer rules: opacity and block-out-from 2024-11-14 12:05:30 +03:00
Ivan Molodetskikh fbbd3ba349 niri: Extract render_layer() 2024-11-14 10:24:04 +03:00
Ivan Molodetskikh 1028639186 config: Add RegexEq util type instead of manual PartialEq 2024-11-14 09:44:07 +03:00
Ivan Molodetskikh 0e5e764c78 Add niri msg layers 2024-11-12 21:44:00 +03:00
Ivan Molodetskikh db1faecc95 Guard against closed screenshot UI in its binds
They can trigger with closed screenshot UI via key repeat.
2024-11-12 19:26:44 +03:00
Ivan Molodetskikh c2c415d2e8 wiki/sidebar: Update application issues title 2024-11-12 10:11:41 +03:00
Ivan Molodetskikh d193928f31 Add PID to Window IPC 2024-11-12 09:37:25 +03:00
Ivan Molodetskikh 17861e0003 Change expel-window-from-column to expel the bottom window
This way, expel becomes symmetric with consume. This is also how it
works in PaperWM. Though, in PaperWM if the expelled window was focused,
it will remain focused, while in this commit it is never focused, making
it the exact opposite of consume.

Use consume-or-expel-window-right for the old expel behavior.
2024-11-11 18:07:41 +03:00
Ivan Molodetskikh 97fe964e00 Make consume-or-expel binds more prominent
I find myself using them much more than regular consume or expel.
2024-11-11 17:56:35 +03:00
Ivan Molodetskikh 9debb5db23 wiki: Mention Ghidra in application issues 2024-11-11 10:06:23 +03:00
Ramses 494b438151 Unhide the pointer on scroll events (#797)
* Unhide the pointer on scroll events

Since we reset the surface under the pointer when we hide the pointer
(see update_pointer_contents), scroll events don't work when the pointer
is hidden.
So to make scrolling work, we make sure that we unhide the pointer when
a scrolling event occurs.

* Update src/input/mod.rs

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2024-11-11 06:08:29 +00:00
Ivan Molodetskikh 010a236882 Start interactive move on Mod+Touch 2024-11-10 09:47:03 +03:00
Ivan Molodetskikh 1951d2a9f2 Fix scrolling not working with missing mouse config 2024-11-10 09:14:22 +03:00
Ivan Molodetskikh 9d8f640503 niri-ipc: Document features 2024-11-09 17:57:52 +03:00
Ivan Molodetskikh b18cfbae23 niri-ipc: Add README and Cargo.toml metadata 2024-11-09 17:57:34 +03:00
Ivan Molodetskikh f64e7e14c3 Bump version to 0.1.10 2024-11-09 17:35:31 +03:00
Ivan Molodetskikh e8c9bfc06a wiki: Add scroll-button to mouse and touchpad overview 2024-11-09 17:23:59 +03:00
Ivan Molodetskikh 07452f50a8 Update dependencies 2024-11-09 15:57:17 +03:00
Ivan Molodetskikh 642c5acebb wiki: Remove outdated info from Application Issues 2024-11-09 11:04:39 +03:00
Ivan Molodetskikh 0886dedff1 wiki: Mention Xwayland on other pages 2024-11-09 11:04:39 +03:00
Ivan Molodetskikh cc88a7d42e default-config: Bind Ctrl-Alt-Del to quit
This seems to be a shared bind across compositors.
2024-11-09 10:29:13 +03:00
Ivan Molodetskikh c0829087da Lock session right away with no outputs 2024-11-08 16:25:06 +03:00
Ivan Molodetskikh b6f6d6a7c2 wiki: Update getting started 2024-11-08 09:43:43 +03:00
Ivan Molodetskikh 5ff8b89aaf Rework output connection to always go through on_output_config_changed()
This has the following benefits:
1. connector_connected() is now more closely mirroring
   connector_disconnected() in that it merely lights up the connector,
   and doesn't check if the connector should be off from the config.
2. We can use more complex on/off logic that depends on multiple
   connectors. For example, this commit adds logic to only disable the
   laptop panel on lid close if there are other connected outputs.

We don't want to disable the laptop panel on lid close if it's the only
connected output because it causes screen lockers to create their
surface from scratch on normal laptop unsuspend, which is undesirable
and also confuses some screen lockers.
2024-11-08 09:11:56 +03:00
Ivan Molodetskikh 927abad4b4 Only call on_output_config_changed() on lid switch
We don't need to reload the niri output config.
2024-11-08 09:11:28 +03:00
Ivan Molodetskikh 3d31f9860a Extract format_make_model_serial() 2024-11-08 09:10:54 +03:00
Ivan Molodetskikh 8867a4f84c Add disable-monitor-names debug flag 2024-11-06 08:42:22 +03:00
Ivan Molodetskikh 88f4c1d610 layout: Preserve active workspace for removed outputs 2024-11-05 21:52:02 +03:00
Ivan Molodetskikh ddcb5c5e10 layout: Move some types further down 2024-11-05 21:08:50 +03:00
Ivan Molodetskikh cd90dfc7be Disable laptop panel when the lid is closed 2024-11-05 10:03:51 +03:00
Ivan Molodetskikh a778ab3897 Extract is_laptop_panel() to utils 2024-11-05 09:40:12 +03:00
Ivan Molodetskikh 4c2f49d566 wiki: Add Since to switch events 2024-11-03 23:00:18 +03:00
Ivan Molodetskikh 49d7052bb3 wiki: Add trackball section to config overview 2024-11-03 22:58:18 +03:00
Ivan Molodetskikh 07be7e7eae wiki: Add Since to scroll-button 2024-11-03 22:56:49 +03:00
Ivan Molodetskikh 97c8717d1e wiki: Mention insert-hint config on the gestures page 2024-11-03 22:52:49 +03:00
Ivan Molodetskikh 3ac0a751fe wiki: Add Since to scroll-factor 2024-11-03 22:50:15 +03:00
elipp 8b39f986d9 Implement scroll_factor mouse and touchpad setting (#730)
* Implement scroll_factor mouse and touchpad setting

* Change to FloatOrInt, add docs

* Also change v120 values

---------

Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
2024-11-03 18:43:03 +00:00
Christian Meissl 354c365a03 xdg: cleanup activation tokens
valid tokens will stay around until explicitly cleaned-up.
remove the token after it has been successfully used
or we consider it timed out to prevent leaking the memory
used by the activation tokens
2024-11-03 09:13:41 -08:00
Ivan Molodetskikh e0ebf1bdff Remove pointer_grab_ongoing in favor of checking the actual grab 2024-11-03 10:23:21 +03:00
Ivan Molodetskikh 11633aef98 Use is() instead of downcast().is_some() 2024-11-03 10:15:19 +03:00
Ivan Molodetskikh 9193245871 Correct pointer constraint activation logic
Internally it uses the pointer focus, so make sure we have up-to-date
focus before setting it.
2024-11-03 10:15:19 +03:00
Ivan Molodetskikh 7baf10b751 Clarify redraw in refresh_pointer_focus() 2024-11-03 10:15:19 +03:00
Ivan Molodetskikh f5d91c5ecc Rename pointer_focus to pointer_contents, clarify comments
This is not pointer focus and it shouldn't be pointer focus, let's be
clear about it.
2024-11-03 10:15:19 +03:00
Ivan Molodetskikh 69e3edb5a3 Rename surface_under_and_global_space() to contents_under() 2024-11-03 08:50:17 +03:00
LoipesMas d58bb4eaa3 flake: set RUSTFLAGS instead of CARGO_BUILD_RUSTFLAGS 2024-11-02 12:35:04 -07:00
LoipesMas c5fe25f422 flake: libseat has been renamed to seatd 2024-11-02 12:35:04 -07:00
Ivan Molodetskikh 600cffb009 Update Smithay (lock leak fix) 2024-11-02 18:55:56 +03:00
Christian Meissl b9d14a9eda portal: prefer gtk for access portal
using gnome for the access portal does not work,
so just override by directly using the gtk one
2024-11-02 07:55:37 -07:00
Ivan Molodetskikh 0e7e398df3 Replace current_state() with with_toplevel_role()
Avoid microallocations that happen in current_state().
2024-11-02 10:53:55 +03:00
Ivan Molodetskikh 86bdc6898b Add with_toplevel_role() util function 2024-11-02 10:53:55 +03:00
Ivan Molodetskikh e5ca335115 Add Tracy allocation profiling feature flag 2024-11-02 10:53:55 +03:00
Ivan Molodetskikh fce5d66878 Follow window corner radius in insert hint 2024-11-02 10:53:55 +03:00
Ivan Molodetskikh 05d218113c Add gradient support for the insert hint
Implement it via FocusRing which already handles SolidColor vs. Border
render element.
2024-11-02 10:53:55 +03:00
Ivan Molodetskikh ef6af6adc1 Change TODO to FIXME 2024-11-02 10:53:55 +03:00
Ivan Molodetskikh 6632699e00 Remove obsolete TODO 2024-11-02 10:53:55 +03:00
Ivan Molodetskikh d3e72245b0 Don't show the cursor on programmatic movement
For keyboard-only use, especially with warp-mouse-to-focus, the
intention is that the cursor stays hidden from keyboard and other
automatic actions, and only shows up with an actual mouse movement.
2024-10-29 21:52:03 -07:00
Ivan Molodetskikh 13fe9c8ac3 [cfg-breaking] Rename hide-on-key-press to hide-when-typing
I originally preferred on-key-press, but when-typing feels more natural
and matches sway. This setting had not been in a stable release yet so
this is not stable release cfg breaking.
2024-10-29 21:52:03 -07:00
5200 changed files with 90719 additions and 10318 deletions
+22
View File
@@ -0,0 +1,22 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "daily"
groups:
smithay:
patterns:
- "smithay"
- "smithay-drm-extras"
rust-dependencies:
update-types:
- "minor"
- "patch"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "Andrew-Chen-Wang/github-wiki-action"
+61 -28
View File
@@ -9,6 +9,8 @@ on:
env:
RUN_SLOW_TESTS: 1
DEPS_APT: curl gcc clang libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev libwayland-dev libinput-dev libdbus-1-dev libsystemd-dev libseat-dev libpipewire-0.3-dev libpango1.0-dev libdisplay-info-dev
DEPS_DNF: cargo gcc clang libudev-devel libgbm-devel libxkbcommon-devel wayland-devel libinput-devel dbus-devel systemd-devel libseat-devel pipewire-devel pango-devel cairo-gobject-devel libdisplay-info-devel
jobs:
build:
@@ -23,8 +25,7 @@ jobs:
release-flag: '--release'
name: test - ${{ matrix.configuration }}
runs-on: ubuntu-22.04
container: ubuntu:23.10
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
@@ -33,8 +34,8 @@ jobs:
- name: Install dependencies
run: |
apt-get update -y
apt-get install -y curl gcc clang libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev libwayland-dev libinput-dev libdbus-1-dev libsystemd-dev libseat-dev libpipewire-0.3-dev libpango1.0-dev libdisplay-info-dev
sudo apt-get update -y
sudo apt-get install -y ${{ env.DEPS_APT }}
- uses: dtolnay/rust-toolchain@stable
@@ -63,19 +64,26 @@ jobs:
- name: Build (with profiling)
run: cargo build ${{ matrix.release-flag }} --features profile-with-tracy
- name: Build Tests
- name: Build tests
run: cargo test --no-run --all --exclude niri-visual-tests ${{ matrix.release-flag }}
- name: Test
run: cargo test --all --exclude niri-visual-tests ${{ matrix.release-flag }} -- --nocapture
visual-tests:
# Job that runs randomized tests for a longer period of time.
randomized-tests:
strategy:
fail-fast: false
name: visual tests
runs-on: ubuntu-22.04
container: ubuntu:23.10
name: randomized tests
runs-on: ubuntu-24.04
env:
RUST_BACKTRACE: 1
PROPTEST_CASES: 200000
PROPTEST_MAX_LOCAL_REJECTS: 200000
PROPTEST_MAX_GLOBAL_REJECTS: 200000
PROPTEST_MAX_SHRINK_ITERS: 200000
steps:
- uses: actions/checkout@v4
@@ -84,8 +92,35 @@ jobs:
- name: Install dependencies
run: |
apt-get update -y
apt-get install -y curl gcc clang libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev libwayland-dev libinput-dev libdbus-1-dev libsystemd-dev libseat-dev libpipewire-0.3-dev libpango1.0-dev libadwaita-1-dev libdisplay-info-dev
sudo apt-get update -y
sudo apt-get install -y ${{ env.DEPS_APT }}
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Build tests
run: cargo test --no-run --all --exclude niri-visual-tests --release
- name: Test
run: cargo test --all --exclude niri-visual-tests --release
visual-tests:
strategy:
fail-fast: false
name: visual tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y ${{ env.DEPS_APT }} libadwaita-1-dev
- uses: dtolnay/rust-toolchain@stable
@@ -98,9 +133,8 @@ jobs:
strategy:
fail-fast: false
name: 'msrv - 1.77.0'
runs-on: ubuntu-22.04
container: ubuntu:23.10
name: msrv
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
@@ -109,10 +143,10 @@ jobs:
- name: Install dependencies
run: |
apt-get update -y
apt-get install -y curl gcc clang libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev libwayland-dev libinput-dev libdbus-1-dev libsystemd-dev libseat-dev libpipewire-0.3-dev libpango1.0-dev libadwaita-1-dev libdisplay-info-dev
sudo apt-get update -y
sudo apt-get install -y ${{ env.DEPS_APT }} libadwaita-1-dev
- uses: dtolnay/rust-toolchain@1.77.0
- uses: dtolnay/rust-toolchain@1.80.1
- uses: Swatinem/rust-cache@v2
@@ -123,8 +157,7 @@ jobs:
fail-fast: false
name: clippy
runs-on: ubuntu-22.04
container: ubuntu:23.10
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
@@ -133,8 +166,8 @@ jobs:
- name: Install dependencies
run: |
apt-get update -y
apt-get install -y curl gcc clang libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev libwayland-dev libinput-dev libdbus-1-dev libsystemd-dev libseat-dev libpipewire-0.3-dev libpango1.0-dev libadwaita-1-dev libdisplay-info-dev
sudo apt-get update -y
sudo apt-get install -y ${{ env.DEPS_APT }} libadwaita-1-dev
- uses: dtolnay/rust-toolchain@stable
with:
@@ -146,7 +179,7 @@ jobs:
run: cargo clippy --all --all-targets
rustfmt:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
@@ -161,8 +194,8 @@ jobs:
run: cargo fmt --all -- --check
fedora:
runs-on: ubuntu-22.04
container: fedora:39
runs-on: ubuntu-24.04
container: fedora:41
steps:
- uses: actions/checkout@v4
@@ -172,13 +205,13 @@ jobs:
- name: Install dependencies
run: |
sudo dnf update -y
sudo dnf install -y cargo gcc libudev-devel libgbm-devel libxkbcommon-devel wayland-devel libinput-devel dbus-devel systemd-devel libseat-devel pipewire-devel pango-devel cairo-gobject-devel clang libadwaita-devel libdisplay-info-devel
sudo dnf install -y ${{ env.DEPS_DNF }} libadwaita-devel
- uses: Swatinem/rust-cache@v2
- run: cargo build --all
nix:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
@@ -200,7 +233,7 @@ jobs:
needs: build
permissions:
contents: write
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
@@ -212,7 +245,7 @@ jobs:
needs: build
permissions:
contents: write
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
+63
View File
@@ -0,0 +1,63 @@
name: Prepare release
on:
workflow_dispatch:
inputs:
version:
description: 'Public version'
required: true
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
env:
RUN_SLOW_TESTS: 1
jobs:
prepare-release:
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- name: Check for unreplaced "Since:" in the wiki
run: |
if grep --recursive 'Since: next release' wiki; then
exit 1
fi
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y curl gcc clang libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev libwayland-dev libinput-dev libdbus-1-dev libsystemd-dev libseat-dev libpipewire-0.3-dev libpango1.0-dev libdisplay-info-dev libadwaita-1-dev
- uses: dtolnay/rust-toolchain@stable
- name: Create vendored dependencies archive
run: |
mkdir .cargo
cargo vendor --locked > .cargo/config.toml
tar cJf niri-${{ github.event.inputs.version }}-vendored-dependencies.tar.xz vendor/
- name: Build
run: cargo build --all --frozen --release
- name: Build tests
run: cargo test --no-run --all --frozen --release
- name: Test
run: cargo test --all --frozen --release -- --nocapture
- name: Draft release
uses: softprops/action-gh-release@v2
with:
draft: true
tag_name: v${{ github.event.inputs.version }}
files: niri-${{ github.event.inputs.version }}-vendored-dependencies.tar.xz
fail_on_unmatched_files: true
Generated
+950 -1060
View File
File diff suppressed because it is too large Load Diff
+54 -40
View File
@@ -1,32 +1,38 @@
[workspace]
members = ["niri-visual-tests"]
members = [
"niri-config",
"niri-ipc",
"niri-visual-tests",
]
[workspace.package]
version = "0.1.9"
version = "25.2.0"
description = "A scrollable-tiling Wayland compositor"
authors = ["Ivan Molodetskikh <yalterz@gmail.com>"]
license = "GPL-3.0-or-later"
edition = "2021"
repository = "https://github.com/YaLTeR/niri"
rust-version = "1.77"
rust-version = "1.80.1"
[workspace.dependencies]
anyhow = "1.0.90"
bitflags = "2.6.0"
clap = { version = "4.5.20", features = ["derive"] }
k9 = "0.12.0"
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.132"
tracing = { version = "0.1.40", features = ["max_level_trace", "release_max_level_debug"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracy-client = { version = "0.17.4", default-features = false }
anyhow = "1.0.96"
bitflags = "2.8.0"
clap = { version = "4.5.30", features = ["derive"] }
insta = "1.42.1"
serde = { version = "1.0.218", features = ["derive"] }
serde_json = "1.0.139"
tracing = { version = "0.1.41", features = ["max_level_trace", "release_max_level_debug"] }
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
tracy-client = { version = "0.18.0", default-features = false }
[workspace.dependencies.smithay]
# version = "0.4.1"
git = "https://github.com/Smithay/smithay.git"
# path = "../smithay"
default-features = false
[workspace.dependencies.smithay-drm-extras]
# version = "0.1.0"
git = "https://github.com/Smithay/smithay.git"
# path = "../smithay/smithay-drm-extras"
@@ -47,45 +53,44 @@ keywords = ["wayland", "compositor", "tiling", "smithay", "wm"]
anyhow.workspace = true
arrayvec = "0.7.6"
async-channel = "2.3.1"
async-io = { version = "1.13.0", optional = true }
async-io = { version = "2.4.0", optional = true }
atomic = "0.6.0"
bitflags.workspace = true
bytemuck = { version = "1.19.0", features = ["derive"] }
calloop = { version = "0.14.1", features = ["executor", "futures-io"] }
bytemuck = { version = "1.21.0", features = ["derive"] }
calloop = { version = "0.14.2", features = ["executor", "futures-io"] }
clap = { workspace = true, features = ["string"] }
directories = "5.0.1"
directories = "6.0.0"
drm-ffi = "0.9.0"
fastrand = "2.1.1"
fastrand = "2.3.0"
futures-util = { version = "0.3.31", default-features = false, features = ["std", "io"] }
git-version = "0.3.9"
glam = "0.29.0"
glam = "0.30.0"
input = { version = "0.9.1", features = ["libinput_1_21"] }
keyframe = { version = "1.1.1", default-features = false }
libc = "0.2.161"
libdisplay-info = "0.1.0"
log = { version = "0.4.22", features = ["max_level_trace", "release_max_level_debug"] }
niri-config = { version = "0.1.9", path = "niri-config" }
niri-ipc = { version = "0.1.9", path = "niri-ipc", features = ["clap"] }
notify-rust = { version = "~4.10.0", optional = true }
ordered-float = "4.4.0"
pango = { version = "0.20.4", features = ["v1_44"] }
pangocairo = "0.20.4"
libc = "0.2.169"
libdisplay-info = "0.2.2"
log = { version = "0.4.25", features = ["max_level_trace", "release_max_level_debug"] }
niri-config = { version = "25.2.0", path = "niri-config" }
niri-ipc = { version = "25.2.0", path = "niri-ipc", features = ["clap"] }
ordered-float = "5.0.0"
pango = { version = "0.20.9", features = ["v1_44"] }
pangocairo = "0.20.7"
pipewire = { git = "https://gitlab.freedesktop.org/pipewire/pipewire-rs.git", optional = true, features = ["v0_3_33"] }
png = "0.17.14"
portable-atomic = { version = "1.9.0", default-features = false, features = ["float"] }
png = "0.17.16"
portable-atomic = { version = "1.10.0", default-features = false, features = ["float"] }
profiling = "1.0.16"
sd-notify = "0.4.3"
sd-notify = "0.4.5"
serde.workspace = true
serde_json.workspace = true
smithay-drm-extras.workspace = true
tracing-subscriber.workspace = true
tracing.workspace = true
tracy-client.workspace = true
url = { version = "2.5.2", optional = true }
wayland-backend = "0.3.7"
wayland-scanner = "0.31.5"
url = { version = "2.5.4", optional = true }
wayland-backend = "0.3.8"
wayland-scanner = "0.31.6"
xcursor = "0.3.8"
zbus = { version = "~3.15.2", optional = true }
zbus = { version = "5.5.0", optional = true }
[dependencies.smithay]
workspace = true
@@ -107,15 +112,18 @@ features = [
[dev-dependencies]
approx = "0.5.1"
k9.workspace = true
proptest = "1.5.0"
proptest-derive = { version = "0.5.0", features = ["boxed_union"] }
xshell = "0.2.6"
calloop-wayland-source = "0.4.0"
insta.workspace = true
proptest = "1.6.0"
proptest-derive = { version = "0.5.1", features = ["boxed_union"] }
rayon = "1.10.0"
wayland-client = "0.31.8"
xshell = "0.2.7"
[features]
default = ["dbus", "systemd", "xdp-gnome-screencast"]
# Enables D-Bus support (serve various freedesktop and GNOME interfaces, power button handling).
dbus = ["zbus", "async-io", "notify-rust", "url"]
dbus = ["dep:zbus", "dep:async-io", "dep:url"]
# Enables systemd integration (global environment, apps in transient scopes).
systemd = ["dbus"]
# Enables screencasting support through xdg-desktop-portal-gnome.
@@ -124,6 +132,8 @@ xdp-gnome-screencast = ["dbus", "pipewire"]
profile-with-tracy = ["profiling/profile-with-tracy", "tracy-client/default"]
# Enables the on-demand Tracy profiler instrumentation.
profile-with-tracy-ondemand = ["profile-with-tracy", "tracy-client/ondemand", "tracy-client/manual-lifetime"]
# Enables Tracy allocation profiling.
profile-with-tracy-allocations = ["profile-with-tracy"]
# Enables dinit integration (global environment).
dinit = []
@@ -136,8 +146,12 @@ lto = "thin"
# knuffel with chomsky generates a metric ton of debuginfo.
debug = false
[profile.dev.package]
insta.opt-level = 3
similar.opt-level = 3
[package.metadata.generate-rpm]
version = "0.1.9"
version = "25.02"
assets = [
{ source = "target/release/niri", dest = "/usr/bin/", mode = "755" },
{ source = "resources/niri-session", dest = "/usr/bin/", mode = "755" },
+33 -5
View File
@@ -1,7 +1,7 @@
<h1 align="center">niri</h1>
<p align="center">A scrollable-tiling Wayland compositor.</p>
<p align="center">
<a href="https://matrix.to/#/#niri:matrix.org"><img alt="Matrix" src="https://img.shields.io/matrix/niri%3Amatrix.org?logo=matrix&label=matrix"></a>
<a href="https://matrix.to/#/#niri:matrix.org"><img alt="Matrix" src="https://img.shields.io/badge/matrix-%23niri-blue?logo=matrix"></a>
<a href="https://github.com/YaLTeR/niri/blob/main/LICENSE"><img alt="GitHub License" src="https://img.shields.io/github/license/YaLTeR/niri"></a>
<a href="https://github.com/YaLTeR/niri/releases"><img alt="GitHub Release" src="https://img.shields.io/github/v/release/YaLTeR/niri?logo=github"></a>
</p>
@@ -10,7 +10,7 @@
<a href="https://github.com/YaLTeR/niri/wiki/Getting-Started">Getting Started</a> | <a href="https://github.com/YaLTeR/niri/wiki/Configuration:-Overview">Configuration</a> | <a href="https://github.com/YaLTeR/niri/discussions/325">Setup&nbsp;Showcase</a>
</p>
![](https://github.com/YaLTeR/niri/assets/1794388/52c799a1-77ec-455f-b4aa-f3236a144964)
![niri with a few windows open](https://github.com/user-attachments/assets/d142e57d-a25d-4ddb-ab46-311417458211)
## About
@@ -28,7 +28,7 @@ When a monitor disconnects, its workspaces will move to another monitor, but upo
## Features
- Scrollable tiling
- Built from the ground up for scrollable tiling
- Dynamic workspaces like in GNOME
- Built-in screenshot UI
- Monitor and window screencasting through xdg-desktop-portal-gnome
@@ -45,10 +45,35 @@ https://github.com/YaLTeR/niri/assets/1794388/bce834b0-f205-434e-a027-b373495f97
## Status
A lot of the essential functionality is implemented, plus some goodies on top.
Feel free to give niri a try: follow the instructions on the [Getting Started](https://github.com/YaLTeR/niri/wiki/Getting-Started) wiki page.
Niri is stable for day-to-day use and does most things expected of a Wayland compositor.
Many people are daily-driving niri, and are happy to help in our [Matrix channel].
Give it a try!
Follow the instructions on the [Getting Started](https://github.com/YaLTeR/niri/wiki/Getting-Started) wiki page.
Have your [waybar]s and [fuzzel]s ready: niri is not a complete desktop environment.
Here are some points you may have questions about:
- **Multi-monitor**: yes, a core part of the design from the very start. Mixed DPI works.
- **Fractional scaling**: yes, plus all niri UI stays pixel-perfect.
- **NVIDIA**: seems to work fine.
- **Floating windows**: yes, starting from niri 25.01.
- **Input devices**: niri supports tablets, touchpads, and touchscreens.
You can map the tablet to a specific monitor, or use [OpenTabletDriver].
We have touchpad gestures, but no touchscreen gestures yet.
- **Wlr protocols**: yes, we have most of the important ones like layer-shell, gamma-control, screencopy.
You can check on [wayland.app](https://wayland.app) at the bottom of each protocol's page.
- **Performance**: while I run niri on beefy machines, I try to stay conscious of performance.
I've seen someone use it fine on an Eee PC 900 from 2008, of all things.
- **Xwayland**: no built-in support, but xwayland-satellite is [easy to set up](https://github.com/YaLTeR/niri/wiki/Xwayland#using-xwayland-satellite) and works very well.
- Steam and games, including Proton: work perfectly through xwayland-satellite.
- JetBrains IDEs, Ghidra: work well through xwayland-satellite.
- Discord and other Electron apps: work well through xwayland-satellite.
- Chromium and VSCode: work perfectly natively on Wayland with the right flags.
- X11 apps that want to position windows or bars at specific screen coordinates: won't work well; you can run them in a nested compositor like [labwc](https://github.com/YaLTeR/niri/wiki/Xwayland#using-the-labwc-wayland-compositor) or [rootful Xwayland](https://github.com/YaLTeR/niri/wiki/Xwayland#directly-running-xwayland-in-rootful-mode).
- Display scaling (integer or fractional) will make X11 apps look blurry; this needs to be supported in xwayland-satellite.
For games, you can run them in [gamescope] at native resolution, even with display scaling.
## Inspiration
Niri is heavily inspired by [PaperWM] which implements scrollable tiling on top of GNOME Shell.
@@ -78,3 +103,6 @@ We have a Matrix chat, feel free to join and ask a question: https://matrix.to/#
[hyprscroller]: https://github.com/dawsers/hyprscroller
[hyprslidr]: https://gitlab.com/magus/hyprslidr
[PaperWM.spoon]: https://github.com/mogenson/PaperWM.spoon
[Matrix channel]: https://matrix.to/#/#niri:matrix.org
[OpenTabletDriver]: https://opentabletdriver.net/
[gamescope]: https://github.com/ValveSoftware/gamescope
Generated
+9 -9
View File
@@ -2,11 +2,11 @@
"nodes": {
"nix-filter": {
"locked": {
"lastModified": 1710156097,
"narHash": "sha256-1Wvk8UP7PXdf8bCCaEoMnOT1qe5/Duqgj+rL8sRQsSM=",
"lastModified": 1731533336,
"narHash": "sha256-oRam5PS1vcrr5UPgALW0eo1m/5/pls27Z/pabHNy2Ms=",
"owner": "numtide",
"repo": "nix-filter",
"rev": "3342559a24e85fc164b295c3444e8a139924675b",
"rev": "f7653272fd234696ae94229839a99b73c9ab7de0",
"type": "github"
},
"original": {
@@ -17,11 +17,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1726365531,
"narHash": "sha256-luAKNxWZ+ZN0kaHchx1OdLQ71n81Y31ryNPWP1YRDZc=",
"lastModified": 1733064805,
"narHash": "sha256-7NbtSLfZO0q7MXPl5hzA0sbVJt6pWxxtGWbaVUDDmjs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9299cdf978e15f448cf82667b0ffdd480b44ee48",
"rev": "31d66ae40417bb13765b0ad75dd200400e98de84",
"type": "github"
},
"original": {
@@ -45,11 +45,11 @@
]
},
"locked": {
"lastModified": 1727663505,
"narHash": "sha256-83j/GrHsx8GFUcQofKh+PRPz6pz8sxAsZyT/HCNdey8=",
"lastModified": 1733106880,
"narHash": "sha256-aJmAIjZfWfPSWSExwrYBLRgXVvgF5LP1vaeUGOOIQ98=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "c2099c6c7599ea1980151b8b6247a8f93e1806ee",
"rev": "e66c0d43abf5bdefb664c3583ca8994983c332ae",
"type": "github"
},
"original": {
+15 -12
View File
@@ -26,13 +26,11 @@
{
lib,
cairo,
clang,
dbus,
libGL,
libclang,
libdisplay-info,
libinput,
libseat,
seatd,
libxkbcommon,
mesa,
pango,
@@ -79,7 +77,7 @@
strictDeps = true;
nativeBuildInputs = [
clang
rustPlatform.bindgenHook
pkg-config
];
@@ -90,7 +88,7 @@
libGL
libdisplay-info
libinput
libseat
seatd
libxkbcommon
mesa # libgbm
pango
@@ -108,6 +106,15 @@
++ lib.optional withSystemd "systemd";
buildNoDefaultFeatures = true;
# ever since this commit:
# https://github.com/YaLTeR/niri/commit/771ea1e81557ffe7af9cbdbec161601575b64d81
# niri now runs an actual instance of the real compositor (with a mock backend) during tests
# and thus creates a real socket file in the runtime dir.
# this is fine for our build, we just need to make sure it has a directory to write to.
preCheck = ''
export XDG_RUNTIME_DIR="$(mktemp -d)"
'';
postInstall =
''
install -Dm644 resources/niri.desktop -t $out/share/wayland-sessions
@@ -119,11 +126,9 @@
'';
env = {
LIBCLANG_PATH = lib.getLib libclang + "/lib";
# Force linking with libEGL and libwayland-client
# so they can be discovered by `dlopen()`
CARGO_BUILD_RUSTFLAGS = toString (
RUSTFLAGS = toString (
map (arg: "-C link-arg=" + arg) [
"-Wl,--push-state,--no-as-needed"
"-lEGL"
@@ -191,7 +196,7 @@
];
nativeBuildInputs = [
pkgs.clang
pkgs.rustPlatform.bindgenHook
pkgs.pkg-config
pkgs.wrapGAppsHook4 # For `niri-visual-tests`
];
@@ -201,14 +206,12 @@
];
env = {
inherit (niri) LIBCLANG_PATH;
# WARN: Do not overwrite this variable in your shell!
# It is required for `dlopen()` to work on some libraries; see the comment
# in the package expression
#
# This should only be set with `CARGO_BUILD_RUSTFLAGS="$CARGO_BUILD_RUSTFLAGS -C your-flags"`
inherit (niri) CARGO_BUILD_RUSTFLAGS;
CARGO_BUILD_RUSTFLAGS = niri.RUSTFLAGS;
};
};
}
+4 -5
View File
@@ -11,14 +11,13 @@ repository.workspace = true
bitflags.workspace = true
csscolorparser = "0.7.0"
knuffel = "3.2.0"
miette = "5.10.0"
niri-ipc = { version = "0.1.9", path = "../niri-ipc" }
regex = "1.11.0"
miette = { version = "5.10.0", features = ["fancy-no-backtrace"] }
niri-ipc = { version = "25.2.0", path = "../niri-ipc" }
regex = "1.11.1"
smithay = { workspace = true, features = ["backend_libinput"] }
tracing.workspace = true
tracy-client.workspace = true
[dev-dependencies]
k9.workspace = true
miette = { version = "5.10.0", features = ["fancy"] }
insta.workspace = true
pretty_assertions = "1.4.1"
+26
View File
@@ -0,0 +1,26 @@
use crate::{BlockOutFrom, CornerRadius, RegexEq, ShadowRule};
#[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]
pub struct LayerRule {
#[knuffel(children(name = "match"))]
pub matches: Vec<Match>,
#[knuffel(children(name = "exclude"))]
pub excludes: Vec<Match>,
#[knuffel(child, unwrap(argument))]
pub opacity: Option<f32>,
#[knuffel(child, unwrap(argument))]
pub block_out_from: Option<BlockOutFrom>,
#[knuffel(child, default)]
pub shadow: ShadowRule,
#[knuffel(child)]
pub geometry_corner_radius: Option<CornerRadius>,
}
#[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]
pub struct Match {
#[knuffel(property, str)]
pub namespace: Option<RegexEq>,
#[knuffel(property)]
pub at_startup: Option<bool>,
}
+1666 -330
View File
File diff suppressed because it is too large Load Diff
+23
View File
@@ -0,0 +1,23 @@
use std::str::FromStr;
use regex::Regex;
/// `Regex` that implements `PartialEq` by its string form.
#[derive(Debug, Clone)]
pub struct RegexEq(pub Regex);
impl PartialEq for RegexEq {
fn eq(&self, other: &Self) -> bool {
self.0.as_str() == other.0.as_str()
}
}
impl Eq for RegexEq {}
impl FromStr for RegexEq {
type Err = <Regex as FromStr>::Err;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Regex::from_str(s).map(Self)
}
}
+5 -1
View File
@@ -1,12 +1,16 @@
[package]
name = "niri-ipc"
version.workspace = true
description.workspace = true
authors.workspace = true
license.workspace = true
edition.workspace = true
repository.workspace = true
description = "Types and helpers for interfacing with the niri Wayland compositor."
keywords = ["wayland"]
categories = ["api-bindings", "os"]
readme = "README.md"
[dependencies]
clap = { workspace = true, optional = true }
schemars = { version = "0.8.21", optional = true }
+16
View File
@@ -0,0 +1,16 @@
# niri-ipc
Types and helpers for interfacing with the [niri](https://github.com/YaLTeR/niri) Wayland compositor.
## Backwards compatibility
This crate follows the niri version.
It is **not** API-stable in terms of the Rust semver.
In particular, expect new struct fields and enum variants to be added in patch version bumps.
Use an exact version requirement to avoid breaking changes:
```toml
[dependencies]
niri-ipc = "=25.2.0"
```
+347 -4
View File
@@ -19,6 +19,20 @@
//!
//! This crate follows the niri version. It is **not** API-stable in terms of the Rust semver. In
//! particular, expect new struct fields and enum variants to be added in patch version bumps.
//!
//! Use an exact version requirement to avoid breaking changes:
//!
//! ```toml
//! [dependencies]
//! niri-ipc = "=25.2.0"
//! ```
//!
//! ## Features
//!
//! This crate defines the following features:
//! - `json-schema`: derives the [schemars](https://lib.rs/crates/schemars) `JsonSchema` trait for
//! the types.
//! - `clap`: derives the clap CLI parsing traits for some types. Used internally by niri itself.
#![warn(missing_docs)]
use std::collections::HashMap;
@@ -41,6 +55,8 @@ pub enum Request {
Workspaces,
/// Request information about open windows.
Windows,
/// Request information about layer-shell surfaces.
Layers,
/// Request information about the configured keyboard layouts.
KeyboardLayouts,
/// Request information about the focused output.
@@ -105,6 +121,8 @@ pub enum Response {
Workspaces(Vec<Workspace>),
/// Information about open windows.
Windows(Vec<Window>),
/// Information about layer-shell surfaces.
Layers(Vec<LayerSurface>),
/// Information about the keyboard layout.
KeyboardLayouts(KeyboardLayouts),
/// Information about the focused output.
@@ -149,7 +167,13 @@ pub enum Action {
/// Open the screenshot UI.
Screenshot {},
/// Screenshot the focused screen.
ScreenshotScreen {},
ScreenshotScreen {
/// Write the screenshot to disk in addition to putting it in your clipboard.
///
/// The screenshot is saved according to the `screenshot-path` config setting.
#[cfg_attr(feature = "clap", arg(short = 'd', long, action = clap::ArgAction::Set, default_value_t = true))]
write_to_disk: bool,
},
/// Screenshot a window.
#[cfg_attr(feature = "clap", clap(about = "Screenshot the focused window"))]
ScreenshotWindow {
@@ -158,6 +182,11 @@ pub enum Action {
/// If `None`, uses the focused window.
#[cfg_attr(feature = "clap", arg(long))]
id: Option<u64>,
/// Write the screenshot to disk in addition to putting it in your clipboard.
///
/// The screenshot is saved according to the `screenshot-path` config setting.
#[cfg_attr(feature = "clap", arg(short = 'd', long, action = clap::ArgAction::Set, default_value_t = true))]
write_to_disk: bool,
},
/// Close a window.
#[cfg_attr(feature = "clap", clap(about = "Close the focused window"))]
@@ -186,6 +215,16 @@ pub enum Action {
#[cfg_attr(feature = "clap", arg(long))]
id: u64,
},
/// Focus a window in the focused column by index.
FocusWindowInColumn {
/// Index of the window in the column.
///
/// The index starts from 1 for the topmost window.
#[cfg_attr(feature = "clap", arg())]
index: u8,
},
/// Focus the previously focused window.
FocusWindowPrevious {},
/// Focus the column to the left.
FocusColumnLeft {},
/// Focus the column to the right.
@@ -222,6 +261,14 @@ pub enum Action {
FocusWindowOrWorkspaceDown {},
/// Focus the window or the workspace above.
FocusWindowOrWorkspaceUp {},
/// Focus the topmost window.
FocusWindowTop {},
/// Focus the bottommost window.
FocusWindowBottom {},
/// Focus the window below or the topmost window.
FocusWindowDownOrTop {},
/// Focus the window above or the bottommost window.
FocusWindowUpOrBottom {},
/// Move the focused column to the left.
MoveColumnLeft {},
/// Move the focused column to the right.
@@ -270,8 +317,32 @@ pub enum Action {
ConsumeWindowIntoColumn {},
/// Expel the focused window from the column.
ExpelWindowFromColumn {},
/// Swap focused window with one to the right.
SwapWindowRight {},
/// Swap focused window with one to the left.
SwapWindowLeft {},
/// Toggle the focused column between normal and tabbed display.
ToggleColumnTabbedDisplay {},
/// Set the display mode of the focused column.
SetColumnDisplay {
/// Display mode to set.
#[cfg_attr(feature = "clap", arg())]
display: ColumnDisplay,
},
/// Center the focused column on the screen.
CenterColumn {},
/// Center a window on the screen.
#[cfg_attr(
feature = "clap",
clap(about = "Center the focused window on the screen")
)]
CenterWindow {
/// Id of the window to center.
///
/// If `None`, uses the focused window.
#[cfg_attr(feature = "clap", arg(long))]
id: Option<u64>,
},
/// Focus the workspace below.
FocusWorkspaceDown {},
/// Focus the workspace above.
@@ -318,6 +389,50 @@ pub enum Action {
MoveWorkspaceDown {},
/// Move the focused workspace up.
MoveWorkspaceUp {},
/// Move a workspace to a specific index on its monitor.
#[cfg_attr(
feature = "clap",
clap(about = "Move the focused workspace to a specific index on its monitor")
)]
MoveWorkspaceToIndex {
/// New index for the workspace.
#[cfg_attr(feature = "clap", arg())]
index: usize,
/// Reference (index or name) of the workspace to move.
///
/// If `None`, uses the focused workspace.
#[cfg_attr(feature = "clap", arg(long))]
reference: Option<WorkspaceReferenceArg>,
},
/// Set the name of a workspace.
#[cfg_attr(
feature = "clap",
clap(about = "Set the name of the focused workspace")
)]
SetWorkspaceName {
/// New name for the workspace.
#[cfg_attr(feature = "clap", arg())]
name: String,
/// Reference (index or name) of the workspace to name.
///
/// If `None`, uses the focused workspace.
#[cfg_attr(feature = "clap", arg(long))]
workspace: Option<WorkspaceReferenceArg>,
},
/// Unset the name of a workspace.
#[cfg_attr(
feature = "clap",
clap(about = "Unset the name of the focused workspace")
)]
UnsetWorkspaceName {
/// Reference (index or name) of the workspace to unname.
///
/// If `None`, uses the focused workspace.
#[cfg_attr(feature = "clap", arg())]
reference: Option<WorkspaceReferenceArg>,
},
/// Focus the monitor to the left.
FocusMonitorLeft {},
/// Focus the monitor to the right.
@@ -326,6 +441,10 @@ pub enum Action {
FocusMonitorDown {},
/// Focus the monitor above.
FocusMonitorUp {},
/// Focus the previous monitor.
FocusMonitorPrevious {},
/// Focus the next monitor.
FocusMonitorNext {},
/// Move the focused window to the monitor to the left.
MoveWindowToMonitorLeft {},
/// Move the focused window to the monitor to the right.
@@ -334,6 +453,10 @@ pub enum Action {
MoveWindowToMonitorDown {},
/// Move the focused window to the monitor above.
MoveWindowToMonitorUp {},
/// Move the focused window to the previous monitor.
MoveWindowToMonitorPrevious {},
/// Move the focused window to the next monitor.
MoveWindowToMonitorNext {},
/// Move the focused column to the monitor to the left.
MoveColumnToMonitorLeft {},
/// Move the focused column to the monitor to the right.
@@ -342,6 +465,26 @@ pub enum Action {
MoveColumnToMonitorDown {},
/// Move the focused column to the monitor above.
MoveColumnToMonitorUp {},
/// Move the focused column to the previous monitor.
MoveColumnToMonitorPrevious {},
/// Move the focused column to the next monitor.
MoveColumnToMonitorNext {},
/// Change the width of a window.
#[cfg_attr(
feature = "clap",
clap(about = "Change the width of the focused window")
)]
SetWindowWidth {
/// Id of the window whose width to set.
///
/// If `None`, uses the focused window.
#[cfg_attr(feature = "clap", arg(long))]
id: Option<u64>,
/// How to change the width.
#[cfg_attr(feature = "clap", arg(allow_hyphen_values = true))]
change: SizeChange,
},
/// Change the height of a window.
#[cfg_attr(
feature = "clap",
@@ -355,7 +498,7 @@ pub enum Action {
id: Option<u64>,
/// How to change the height.
#[cfg_attr(feature = "clap", arg())]
#[cfg_attr(feature = "clap", arg(allow_hyphen_values = true))]
change: SizeChange,
},
/// Reset the height of a window back to automatic.
@@ -372,6 +515,14 @@ pub enum Action {
},
/// Switch between preset column widths.
SwitchPresetColumnWidth {},
/// Switch between preset window widths.
SwitchPresetWindowWidth {
/// Id of the window whose width to switch.
///
/// If `None`, uses the focused window.
#[cfg_attr(feature = "clap", arg(long))]
id: Option<u64>,
},
/// Switch between preset window heights.
SwitchPresetWindowHeight {
/// Id of the window whose height to switch.
@@ -385,9 +536,11 @@ pub enum Action {
/// Change the width of the focused column.
SetColumnWidth {
/// How to change the width.
#[cfg_attr(feature = "clap", arg())]
#[cfg_attr(feature = "clap", arg(allow_hyphen_values = true))]
change: SizeChange,
},
/// Expand the focused column to space not taken up by other fully visible columns.
ExpandColumnToAvailableWidth {},
/// Switch between keyboard layouts.
SwitchLayout {
/// Layout to switch to.
@@ -404,12 +557,97 @@ pub enum Action {
MoveWorkspaceToMonitorDown {},
/// Move the focused workspace to the monitor above.
MoveWorkspaceToMonitorUp {},
/// Move the focused workspace to the previous monitor.
MoveWorkspaceToMonitorPrevious {},
/// Move the focused workspace to the next monitor.
MoveWorkspaceToMonitorNext {},
/// Move a workspace to a specific monitor.
#[cfg_attr(
feature = "clap",
clap(about = "Move the focused workspace to a specific monitor")
)]
MoveWorkspaceToMonitor {
/// The target output name.
#[cfg_attr(feature = "clap", arg())]
output: String,
// Reference (index or name) of the workspace to move.
///
/// If `None`, uses the focused workspace.
#[cfg_attr(feature = "clap", arg(long))]
reference: Option<WorkspaceReferenceArg>,
},
/// Toggle a debug tint on windows.
ToggleDebugTint {},
/// Toggle visualization of render element opaque regions.
DebugToggleOpaqueRegions {},
/// Toggle visualization of output damage.
DebugToggleDamage {},
/// Move the focused window between the floating and the tiling layout.
ToggleWindowFloating {
/// Id of the window to move.
///
/// If `None`, uses the focused window.
#[cfg_attr(feature = "clap", arg(long))]
id: Option<u64>,
},
/// Move the focused window to the floating layout.
MoveWindowToFloating {
/// Id of the window to move.
///
/// If `None`, uses the focused window.
#[cfg_attr(feature = "clap", arg(long))]
id: Option<u64>,
},
/// Move the focused window to the tiling layout.
MoveWindowToTiling {
/// Id of the window to move.
///
/// If `None`, uses the focused window.
#[cfg_attr(feature = "clap", arg(long))]
id: Option<u64>,
},
/// Switches focus to the floating layout.
FocusFloating {},
/// Switches focus to the tiling layout.
FocusTiling {},
/// Toggles the focus between the floating and the tiling layout.
SwitchFocusBetweenFloatingAndTiling {},
/// Move a floating window on screen.
#[cfg_attr(feature = "clap", clap(about = "Move the floating window on screen"))]
MoveFloatingWindow {
/// Id of the window to move.
///
/// If `None`, uses the focused window.
#[cfg_attr(feature = "clap", arg(long))]
id: Option<u64>,
/// How to change the X position.
#[cfg_attr(
feature = "clap",
arg(short, long, default_value = "+0", allow_negative_numbers = true)
)]
x: PositionChange,
/// How to change the Y position.
#[cfg_attr(
feature = "clap",
arg(short, long, default_value = "+0", allow_negative_numbers = true)
)]
y: PositionChange,
},
/// Toggle the opacity of a window.
#[cfg_attr(
feature = "clap",
clap(about = "Toggle the opacity of the focused window")
)]
ToggleWindowRuleOpacity {
/// Id of the window.
///
/// If `None`, uses the focused window.
#[cfg_attr(feature = "clap", arg(long))]
id: Option<u64>,
},
}
/// Change in window or column size.
@@ -426,6 +664,16 @@ pub enum SizeChange {
AdjustProportion(f64),
}
/// Change in floating window position.
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub enum PositionChange {
/// Set the position in logical pixels.
SetFixed(f64),
/// Add or subtract to the current position in logical pixels.
AdjustFixed(f64),
}
/// Workspace reference (id, index or name) to operate on.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
@@ -446,6 +694,18 @@ pub enum LayoutSwitchTarget {
Next,
/// The previous configured layout.
Prev,
/// The specific layout by index.
Index(u8),
}
/// How windows display in a column.
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub enum ColumnDisplay {
/// Windows are tiled vertically across the working area height.
Normal,
/// Windows are in tabs.
Tabbed,
}
/// Output actions that niri can perform.
@@ -681,12 +941,21 @@ pub struct Window {
pub title: Option<String>,
/// Application ID, if set.
pub app_id: Option<String>,
/// Process ID that created the Wayland connection for this window, if known.
///
/// Currently, windows created by xdg-desktop-portal-gnome will have a `None` PID, but this may
/// change in the future.
pub pid: Option<i32>,
/// Id of the workspace this window is on, if any.
pub workspace_id: Option<u64>,
/// Whether this window is currently focused.
///
/// There can be either one focused window or zero (e.g. when a layer-shell surface has focus).
pub is_focused: bool,
/// Whether this window is currently floating.
///
/// If the window isn't floating then it is in the tiling layout.
pub is_floating: bool,
}
/// Output configuration change result.
@@ -748,6 +1017,46 @@ pub struct KeyboardLayouts {
pub current_idx: u8,
}
/// A layer-shell layer.
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub enum Layer {
/// The background layer.
Background,
/// The bottom layer.
Bottom,
/// The top layer.
Top,
/// The overlay layer.
Overlay,
}
/// Keyboard interactivity modes for a layer-shell surface.
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub enum LayerSurfaceKeyboardInteractivity {
/// Surface cannot receive keyboard focus.
None,
/// Surface receives keyboard focus whenever possible.
Exclusive,
/// Surface receives keyboard focus on demand, e.g. when clicked.
OnDemand,
}
/// A layer-shell surface.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub struct LayerSurface {
/// Namespace provided by the layer-shell client.
pub namespace: String,
/// Name of the output the surface is on.
pub output: String,
/// Layer that the surface is on.
pub layer: Layer,
/// The surface's keyboard interactivity mode.
pub keyboard_interactivity: LayerSurfaceKeyboardInteractivity,
}
/// A compositor event.
#[derive(Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
@@ -877,6 +1186,25 @@ impl FromStr for SizeChange {
}
}
impl FromStr for PositionChange {
type Err = &'static str;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let value = s;
match value.bytes().next() {
Some(b'-' | b'+') => {
let value = value.parse().map_err(|_| "error parsing value")?;
Ok(Self::AdjustFixed(value))
}
Some(_) => {
let value = value.parse().map_err(|_| "error parsing value")?;
Ok(Self::SetFixed(value))
}
None => Err("value is missing"),
}
}
}
impl FromStr for LayoutSwitchTarget {
type Err = &'static str;
@@ -884,7 +1212,22 @@ impl FromStr for LayoutSwitchTarget {
match s {
"next" => Ok(Self::Next),
"prev" => Ok(Self::Prev),
_ => Err(r#"invalid layout action, can be "next" or "prev""#),
other => match other.parse() {
Ok(layout) => Ok(Self::Index(layout)),
_ => Err(r#"invalid layout action, can be "next", "prev" or a layout index"#),
},
}
}
}
impl FromStr for ColumnDisplay {
type Err = &'static str;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"normal" => Ok(Self::Normal),
"tabbed" => Ok(Self::Tabbed),
_ => Err(r#"invalid column display, can be "normal" or "tabbed""#),
}
}
}
+4 -4
View File
@@ -8,11 +8,11 @@ edition.workspace = true
repository.workspace = true
[dependencies]
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_4"] }
adw = { version = "0.7.1", package = "libadwaita", features = ["v1_4"] }
anyhow.workspace = true
gtk = { version = "0.9.2", package = "gtk4", features = ["v4_12"] }
niri = { version = "0.1.9", path = ".." }
niri-config = { version = "0.1.9", path = "../niri-config" }
gtk = { version = "0.9.6", package = "gtk4", features = ["v4_12"] }
niri = { version = "25.2.0", path = ".." }
niri-config = { version = "25.2.0", path = "../niri-config" }
smithay.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
+8 -16
View File
@@ -1,15 +1,13 @@
use std::f32::consts::{FRAC_PI_2, PI};
use std::sync::atomic::Ordering;
use std::time::Duration;
use niri::animation::ANIMATION_SLOWDOWN;
use niri::render_helpers::border::BorderRenderElement;
use niri_config::{Color, CornerRadius, GradientInterpolation};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientAngle {
angle: f32,
@@ -17,7 +15,7 @@ pub struct GradientAngle {
}
impl GradientAngle {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
Self {
angle: 0.,
prev_time: Duration::ZERO,
@@ -31,20 +29,13 @@ impl TestCase for GradientAngle {
}
fn advance_animations(&mut self, current_time: Duration) {
let mut delta = if self.prev_time.is_zero() {
let delta = if self.prev_time.is_zero() {
Duration::ZERO
} else {
current_time.saturating_sub(self.prev_time)
};
self.prev_time = current_time;
let slowdown = ANIMATION_SLOWDOWN.load(Ordering::SeqCst);
if slowdown == 0. {
delta = Duration::ZERO
} else {
delta = delta.div_f64(slowdown);
}
self.angle += delta.as_secs_f32() * PI;
if self.angle >= PI * 2. {
@@ -59,19 +50,20 @@ impl TestCase for GradientAngle {
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 4, size.h / 4);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
GradientInterpolation::default(),
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 1.),
self.angle - FRAC_PI_2,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
+10 -17
View File
@@ -1,16 +1,14 @@
use std::f32::consts::{FRAC_PI_4, PI};
use std::sync::atomic::Ordering;
use std::time::Duration;
use niri::animation::ANIMATION_SLOWDOWN;
use niri::layout::focus_ring::FocusRing;
use niri::render_helpers::border::BorderRenderElement;
use niri_config::{Color, CornerRadius, FloatOrInt, GradientInterpolation};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Point, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientArea {
progress: f32,
@@ -19,7 +17,7 @@ pub struct GradientArea {
}
impl GradientArea {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
let border = FocusRing::new(niri_config::FocusRing {
off: false,
width: FloatOrInt(1.),
@@ -43,20 +41,13 @@ impl TestCase for GradientArea {
}
fn advance_animations(&mut self, current_time: Duration) {
let mut delta = if self.prev_time.is_zero() {
let delta = if self.prev_time.is_zero() {
Duration::ZERO
} else {
current_time.saturating_sub(self.prev_time)
};
self.prev_time = current_time;
let slowdown = ANIMATION_SLOWDOWN.load(Ordering::SeqCst);
if slowdown == 0. {
delta = Duration::ZERO
} else {
delta = delta.div_f64(slowdown);
}
self.progress += delta.as_secs_f32() * PI;
if self.progress >= PI * 2. {
@@ -74,8 +65,8 @@ impl TestCase for GradientArea {
let f = (self.progress.sin() + 1.) / 2.;
let (a, b) = (size.w / 4, size.h / 4);
let rect_size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), rect_size).to_f64();
let rect_size = Size::from((size.w - a * 2, size.h - b * 2));
let area = Rectangle::new(Point::from((a, b)), rect_size).to_f64();
let g_size = Size::from((
(size.w as f32 / 8. + size.w as f32 / 8. * 7. * f).round() as i32,
@@ -83,7 +74,7 @@ impl TestCase for GradientArea {
));
let g_loc = Point::from(((size.w - g_size.w) / 2, (size.h - g_size.h) / 2)).to_f64();
let g_size = g_size.to_f64();
let mut g_area = Rectangle::from_loc_and_size(g_loc, g_size);
let mut g_area = Rectangle::new(g_loc, g_size);
g_area.loc -= area.loc;
self.border.update_render_elements(
@@ -93,6 +84,7 @@ impl TestCase for GradientArea {
Rectangle::default(),
CornerRadius::default(),
1.,
1.,
);
rv.extend(
self.border
@@ -108,10 +100,11 @@ impl TestCase for GradientArea {
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 1.),
FRAC_PI_4,
Rectangle::from_loc_and_size((0, 0), rect_size).to_f64(),
Rectangle::from_size(rect_size).to_f64(),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
@@ -4,16 +4,16 @@ use niri_config::{
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientOklab {
gradient_format: GradientInterpolation,
}
impl GradientOklab {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
Self {
gradient_format: GradientInterpolation {
color_space: GradientColorSpace::Oklab,
@@ -31,19 +31,20 @@ impl TestCase for GradientOklab {
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 6, size.h / 3);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
self.gradient_format,
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 1.),
0.,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
@@ -2,16 +2,16 @@ use niri::render_helpers::border::BorderRenderElement;
use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientOklabAlpha {
gradient_format: GradientInterpolation,
}
impl GradientOklabAlpha {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
Self {
gradient_format: GradientInterpolation {
color_space: GradientColorSpace::Oklab,
@@ -29,19 +29,20 @@ impl TestCase for GradientOklabAlpha {
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 6, size.h / 3);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
self.gradient_format,
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 0.),
0.,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
@@ -4,16 +4,16 @@ use niri_config::{
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientOklchAlpha {
gradient_format: GradientInterpolation,
}
impl GradientOklchAlpha {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
Self {
gradient_format: GradientInterpolation {
color_space: GradientColorSpace::Oklch,
@@ -31,19 +31,20 @@ impl TestCase for GradientOklchAlpha {
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 6, size.h / 3);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
self.gradient_format,
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 0.),
0.,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
@@ -4,16 +4,16 @@ use niri_config::{
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientOklchDecreasing {
gradient_format: GradientInterpolation,
}
impl GradientOklchDecreasing {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
Self {
gradient_format: GradientInterpolation {
color_space: GradientColorSpace::Oklch,
@@ -31,19 +31,20 @@ impl TestCase for GradientOklchDecreasing {
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 6, size.h / 3);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
self.gradient_format,
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 1.),
0.,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
@@ -4,16 +4,16 @@ use niri_config::{
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientOklchIncreasing {
gradient_format: GradientInterpolation,
}
impl GradientOklchIncreasing {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
Self {
gradient_format: GradientInterpolation {
color_space: GradientColorSpace::Oklch,
@@ -31,19 +31,20 @@ impl TestCase for GradientOklchIncreasing {
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 6, size.h / 3);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
self.gradient_format,
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 1.),
0.,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
@@ -4,16 +4,16 @@ use niri_config::{
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientOklchLonger {
gradient_format: GradientInterpolation,
}
impl GradientOklchLonger {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
Self {
gradient_format: GradientInterpolation {
color_space: GradientColorSpace::Oklch,
@@ -31,19 +31,20 @@ impl TestCase for GradientOklchLonger {
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 6, size.h / 3);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
self.gradient_format,
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 1.),
0.,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
@@ -4,16 +4,16 @@ use niri_config::{
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientOklchShorter {
gradient_format: GradientInterpolation,
}
impl GradientOklchShorter {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
Self {
gradient_format: GradientInterpolation {
color_space: GradientColorSpace::Oklch,
@@ -31,19 +31,20 @@ impl TestCase for GradientOklchShorter {
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 6, size.h / 3);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
self.gradient_format,
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 1.),
0.,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
+7 -6
View File
@@ -4,16 +4,16 @@ use niri_config::{
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientSrgb {
gradient_format: GradientInterpolation,
}
impl GradientSrgb {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
Self {
gradient_format: GradientInterpolation {
color_space: GradientColorSpace::Srgb,
@@ -31,19 +31,20 @@ impl TestCase for GradientSrgb {
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 6, size.h / 3);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
self.gradient_format,
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 1.),
0.,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
@@ -2,16 +2,16 @@ use niri::render_helpers::border::BorderRenderElement;
use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientSrgbAlpha {
gradient_format: GradientInterpolation,
}
impl GradientSrgbAlpha {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
Self {
gradient_format: GradientInterpolation {
color_space: GradientColorSpace::Srgb,
@@ -29,19 +29,20 @@ impl TestCase for GradientSrgbAlpha {
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 6, size.h / 3);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
self.gradient_format,
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 0.),
0.,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
@@ -4,16 +4,16 @@ use niri_config::{
};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientSrgbLinear {
gradient_format: GradientInterpolation,
}
impl GradientSrgbLinear {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
Self {
gradient_format: GradientInterpolation {
color_space: GradientColorSpace::SrgbLinear,
@@ -31,19 +31,20 @@ impl TestCase for GradientSrgbLinear {
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 6, size.h / 3);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
self.gradient_format,
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 1.),
0.,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
@@ -2,16 +2,16 @@ use niri::render_helpers::border::BorderRenderElement;
use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Rectangle, Size};
use smithay::utils::{Physical, Point, Rectangle, Size};
use super::TestCase;
use super::{Args, TestCase};
pub struct GradientSrgbLinearAlpha {
gradient_format: GradientInterpolation,
}
impl GradientSrgbLinearAlpha {
pub fn new(_size: Size<i32, Logical>) -> Self {
pub fn new(_args: Args) -> Self {
Self {
gradient_format: GradientInterpolation {
color_space: GradientColorSpace::SrgbLinear,
@@ -29,19 +29,20 @@ impl TestCase for GradientSrgbLinearAlpha {
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
let (a, b) = (size.w / 6, size.h / 3);
let size = (size.w - a * 2, size.h - b * 2);
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
[BorderRenderElement::new(
area.size,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
self.gradient_format,
Color::new_unpremul(1., 0., 0., 1.),
Color::new_unpremul(0., 1., 0., 0.),
0.,
Rectangle::from_loc_and_size((0., 0.), area.size),
Rectangle::from_size(area.size),
0.,
CornerRadius::default(),
1.,
1.,
)
.with_location(area.loc)]
.into_iter()
+81 -46
View File
@@ -1,18 +1,17 @@
use std::collections::HashMap;
use std::time::Duration;
use niri::layout::workspace::ColumnWidth;
use niri::layout::{LayoutElement as _, Options};
use niri::animation::Clock;
use niri::layout::{ActivateWindow, AddWindowTarget, LayoutElement as _, Options};
use niri::render_helpers::RenderTarget;
use niri::utils::get_monotonic_time;
use niri_config::{Color, FloatOrInt, OutputName};
use niri_config::{Color, FloatOrInt, OutputName, PresetSize};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::desktop::layer_map_for_output;
use smithay::output::{Mode, Output, PhysicalProperties, Subpixel};
use smithay::utils::{Logical, Physical, Size};
use smithay::utils::{Physical, Size};
use super::TestCase;
use super::{Args, TestCase};
use crate::test_window::TestWindow;
type DynStepFn = Box<dyn FnOnce(&mut Layout)>;
@@ -20,13 +19,16 @@ type DynStepFn = Box<dyn FnOnce(&mut Layout)>;
pub struct Layout {
output: Output,
windows: Vec<TestWindow>,
clock: Clock,
layout: niri::layout::Layout<TestWindow>,
start_time: Duration,
steps: HashMap<Duration, DynStepFn>,
}
impl Layout {
pub fn new(size: Size<i32, Logical>) -> Self {
pub fn new(args: Args) -> Self {
let Args { size, clock } = args;
let output = Output::new(
String::new(),
PhysicalProperties {
@@ -63,41 +65,44 @@ impl Layout {
},
..Default::default()
};
let mut layout = niri::layout::Layout::with_options(options);
let mut layout = niri::layout::Layout::with_options(clock.clone(), options);
layout.add_output(output.clone());
let start_time = clock.now_unadjusted();
Self {
output,
windows: Vec::new(),
clock,
layout,
start_time: get_monotonic_time(),
start_time,
steps: HashMap::new(),
}
}
pub fn open_in_between(size: Size<i32, Logical>) -> Self {
let mut rv = Self::new(size);
pub fn open_in_between(args: Args) -> Self {
let mut rv = Self::new(args);
rv.add_window(TestWindow::freeform(0), Some(ColumnWidth::Proportion(0.3)));
rv.add_window(TestWindow::freeform(1), Some(ColumnWidth::Proportion(0.3)));
rv.add_window(TestWindow::freeform(0), Some(PresetSize::Proportion(0.3)));
rv.add_window(TestWindow::freeform(1), Some(PresetSize::Proportion(0.3)));
rv.layout.activate_window(&0);
rv.add_step(500, |l| {
let win = TestWindow::freeform(2);
l.add_window(win.clone(), Some(ColumnWidth::Proportion(0.3)));
l.add_window(win.clone(), Some(PresetSize::Proportion(0.3)));
l.layout.start_open_animation_for_window(win.id());
});
rv
}
pub fn open_multiple_quickly(size: Size<i32, Logical>) -> Self {
let mut rv = Self::new(size);
pub fn open_multiple_quickly(args: Args) -> Self {
let mut rv = Self::new(args);
for delay in [100, 200, 300] {
rv.add_step(delay, move |l| {
let win = TestWindow::freeform(delay as usize);
l.add_window(win.clone(), Some(ColumnWidth::Proportion(0.3)));
l.add_window(win.clone(), Some(PresetSize::Proportion(0.3)));
l.layout.start_open_animation_for_window(win.id());
});
}
@@ -105,13 +110,13 @@ impl Layout {
rv
}
pub fn open_multiple_quickly_big(size: Size<i32, Logical>) -> Self {
let mut rv = Self::new(size);
pub fn open_multiple_quickly_big(args: Args) -> Self {
let mut rv = Self::new(args);
for delay in [100, 200, 300] {
rv.add_step(delay, move |l| {
let win = TestWindow::freeform(delay as usize);
l.add_window(win.clone(), Some(ColumnWidth::Proportion(0.5)));
l.add_window(win.clone(), Some(PresetSize::Proportion(0.5)));
l.layout.start_open_animation_for_window(win.id());
});
}
@@ -119,44 +124,58 @@ impl Layout {
rv
}
pub fn open_to_the_left(size: Size<i32, Logical>) -> Self {
let mut rv = Self::new(size);
pub fn open_to_the_left(args: Args) -> Self {
let mut rv = Self::new(args);
rv.add_window(TestWindow::freeform(0), Some(ColumnWidth::Proportion(0.3)));
rv.add_window(TestWindow::freeform(1), Some(ColumnWidth::Proportion(0.3)));
rv.add_window(TestWindow::freeform(0), Some(PresetSize::Proportion(0.3)));
rv.add_window(TestWindow::freeform(1), Some(PresetSize::Proportion(0.3)));
rv.add_step(500, |l| {
let win = TestWindow::freeform(2);
let right_of = l.windows[0].clone();
l.add_window_right_of(&right_of, win.clone(), Some(ColumnWidth::Proportion(0.3)));
l.add_window_right_of(&right_of, win.clone(), Some(PresetSize::Proportion(0.3)));
l.layout.start_open_animation_for_window(win.id());
});
rv
}
pub fn open_to_the_left_big(size: Size<i32, Logical>) -> Self {
let mut rv = Self::new(size);
pub fn open_to_the_left_big(args: Args) -> Self {
let mut rv = Self::new(args);
rv.add_window(TestWindow::freeform(0), Some(ColumnWidth::Proportion(0.3)));
rv.add_window(TestWindow::freeform(1), Some(ColumnWidth::Proportion(0.8)));
rv.add_window(TestWindow::freeform(0), Some(PresetSize::Proportion(0.3)));
rv.add_window(TestWindow::freeform(1), Some(PresetSize::Proportion(0.8)));
rv.add_step(500, |l| {
let win = TestWindow::freeform(2);
let right_of = l.windows[0].clone();
l.add_window_right_of(&right_of, win.clone(), Some(ColumnWidth::Proportion(0.5)));
l.add_window_right_of(&right_of, win.clone(), Some(PresetSize::Proportion(0.5)));
l.layout.start_open_animation_for_window(win.id());
});
rv
}
fn add_window(&mut self, mut window: TestWindow, width: Option<ColumnWidth>) {
fn add_window(&mut self, mut window: TestWindow, width: Option<PresetSize>) {
let ws = self.layout.active_workspace().unwrap();
window.request_size(ws.new_window_size(width, window.rules()), false, None);
let min_size = window.min_size();
let max_size = window.max_size();
window.request_size(
ws.new_window_size(width, None, false, window.rules(), (min_size, max_size)),
false,
None,
);
window.communicate();
self.layout.add_window(window.clone(), width, false);
self.layout.add_window(
window.clone(),
AddWindowTarget::Auto,
width,
None,
false,
false,
ActivateWindow::default(),
);
self.windows.push(window);
}
@@ -164,14 +183,27 @@ impl Layout {
&mut self,
right_of: &TestWindow,
mut window: TestWindow,
width: Option<ColumnWidth>,
width: Option<PresetSize>,
) {
let ws = self.layout.active_workspace().unwrap();
window.request_size(ws.new_window_size(width, window.rules()), false, None);
let min_size = window.min_size();
let max_size = window.max_size();
window.request_size(
ws.new_window_size(width, None, false, window.rules(), (min_size, max_size)),
false,
None,
);
window.communicate();
self.layout
.add_window_right_of(right_of.id(), window.clone(), width, false);
self.layout.add_window(
window.clone(),
AddWindowTarget::NextTo(right_of.id()),
width,
None,
false,
false,
ActivateWindow::default(),
);
self.windows.push(window);
}
@@ -201,22 +233,25 @@ impl TestCase for Layout {
self.layout.are_animations_ongoing(Some(&self.output)) || !self.steps.is_empty()
}
fn advance_animations(&mut self, mut current_time: Duration) {
fn advance_animations(&mut self, _current_time: Duration) {
let now_unadjusted = self.clock.now_unadjusted();
let run = self
.steps
.keys()
.copied()
.filter(|delay| self.start_time + *delay <= current_time)
.filter(|delay| self.start_time + *delay <= now_unadjusted)
.collect::<Vec<_>>();
for key in &run {
let f = self.steps.remove(key).unwrap();
for delay in &run {
let now = self.start_time + *delay;
self.clock.set_unadjusted(now);
self.layout.advance_animations();
let f = self.steps.remove(delay).unwrap();
f(self);
}
if !run.is_empty() {
current_time = get_monotonic_time();
}
self.layout.advance_animations(current_time);
self.clock.set_unadjusted(now_unadjusted);
self.layout.advance_animations();
}
fn render(
@@ -228,7 +263,7 @@ impl TestCase for Layout {
self.layout
.monitor_for_output(&self.output)
.unwrap()
.render_elements(renderer, RenderTarget::Output)
.render_elements(renderer, RenderTarget::Output, true)
.map(|elem| Box::new(elem) as _)
.collect()
}
+7 -1
View File
@@ -1,8 +1,9 @@
use std::time::Duration;
use niri::animation::Clock;
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Physical, Size};
use smithay::utils::{Logical, Physical, Size};
pub mod gradient_angle;
pub mod gradient_area;
@@ -21,6 +22,11 @@ pub mod layout;
pub mod tile;
pub mod window;
pub struct Args {
pub size: Size<i32, Logical>,
pub clock: Clock,
}
pub trait TestCase {
fn resize(&mut self, _width: i32, _height: i32) {}
fn are_animations_ongoing(&self) -> bool {
+36 -30
View File
@@ -6,9 +6,9 @@ use niri::render_helpers::RenderTarget;
use niri_config::{Color, FloatOrInt};
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Point, Rectangle, Scale, Size};
use smithay::utils::{Physical, Point, Rectangle, Scale, Size};
use super::TestCase;
use super::{Args, TestCase};
use crate::test_window::TestWindow;
pub struct Tile {
@@ -17,53 +17,46 @@ pub struct Tile {
}
impl Tile {
pub fn freeform(size: Size<i32, Logical>) -> Self {
pub fn freeform(args: Args) -> Self {
let window = TestWindow::freeform(0);
let mut rv = Self::with_window(window);
rv.tile.request_tile_size(size.to_f64(), false, None);
rv.window.communicate();
rv
Self::with_window(args, window)
}
pub fn fixed_size(size: Size<i32, Logical>) -> Self {
pub fn fixed_size(args: Args) -> Self {
let window = TestWindow::fixed_size(0);
let mut rv = Self::with_window(window);
rv.tile.request_tile_size(size.to_f64(), false, None);
rv.window.communicate();
rv
Self::with_window(args, window)
}
pub fn fixed_size_with_csd_shadow(size: Size<i32, Logical>) -> Self {
pub fn fixed_size_with_csd_shadow(args: Args) -> Self {
let window = TestWindow::fixed_size(0);
window.set_csd_shadow_width(64);
let mut rv = Self::with_window(window);
rv.tile.request_tile_size(size.to_f64(), false, None);
rv.window.communicate();
rv
Self::with_window(args, window)
}
pub fn freeform_open(size: Size<i32, Logical>) -> Self {
let mut rv = Self::freeform(size);
pub fn freeform_open(args: Args) -> Self {
let mut rv = Self::freeform(args);
rv.window.set_color([0.1, 0.1, 0.1, 1.]);
rv.tile.start_open_animation();
rv
}
pub fn fixed_size_open(size: Size<i32, Logical>) -> Self {
let mut rv = Self::fixed_size(size);
pub fn fixed_size_open(args: Args) -> Self {
let mut rv = Self::fixed_size(args);
rv.window.set_color([0.1, 0.1, 0.1, 1.]);
rv.tile.start_open_animation();
rv
}
pub fn fixed_size_with_csd_shadow_open(size: Size<i32, Logical>) -> Self {
let mut rv = Self::fixed_size_with_csd_shadow(size);
pub fn fixed_size_with_csd_shadow_open(args: Args) -> Self {
let mut rv = Self::fixed_size_with_csd_shadow(args);
rv.window.set_color([0.1, 0.1, 0.1, 1.]);
rv.tile.start_open_animation();
rv
}
pub fn with_window(window: TestWindow) -> Self {
pub fn with_window(args: Args, window: TestWindow) -> Self {
let Args { size, clock } = args;
let options = Options {
focus_ring: niri_config::FocusRing {
off: true,
@@ -77,15 +70,28 @@ impl Tile {
},
..Default::default()
};
let tile = niri::layout::tile::Tile::new(window.clone(), 1., Rc::new(options));
let mut tile = niri::layout::tile::Tile::new(
window.clone(),
size.to_f64(),
1.,
clock,
Rc::new(options),
);
tile.request_tile_size(size.to_f64(), false, None);
window.communicate();
Self { window, tile }
}
}
impl TestCase for Tile {
fn resize(&mut self, width: i32, height: i32) {
let size = Size::from((width, height)).to_f64();
self.tile
.request_tile_size(Size::from((width, height)).to_f64(), false, None);
.update_config(size, 1., self.tile.options().clone());
self.tile.request_tile_size(size, false, None);
self.window.communicate();
}
@@ -93,8 +99,8 @@ impl TestCase for Tile {
self.tile.are_animations_ongoing()
}
fn advance_animations(&mut self, current_time: Duration) {
self.tile.advance_animations(current_time);
fn advance_animations(&mut self, _current_time: Duration) {
self.tile.advance_animations();
}
fn render(
@@ -106,9 +112,9 @@ impl TestCase for Tile {
let tile_size = self.tile.tile_size().to_physical(1.);
let location = Point::from((size.w - tile_size.w, size.h - tile_size.h)).downscale(2.);
self.tile.update(
self.tile.update_render_elements(
true,
Rectangle::from_loc_and_size((-location.x, -location.y), size.to_logical(1.)),
Rectangle::new(Point::from((-location.x, -location.y)), size.to_logical(1.)),
);
self.tile
.render(
+8 -8
View File
@@ -2,9 +2,9 @@ use niri::layout::LayoutElement;
use niri::render_helpers::RenderTarget;
use smithay::backend::renderer::element::RenderElement;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::utils::{Logical, Physical, Point, Scale, Size};
use smithay::utils::{Physical, Point, Scale, Size};
use super::TestCase;
use super::{Args, TestCase};
use crate::test_window::TestWindow;
pub struct Window {
@@ -12,24 +12,24 @@ pub struct Window {
}
impl Window {
pub fn freeform(size: Size<i32, Logical>) -> Self {
pub fn freeform(args: Args) -> Self {
let mut window = TestWindow::freeform(0);
window.request_size(size, false, None);
window.request_size(args.size, false, None);
window.communicate();
Self { window }
}
pub fn fixed_size(size: Size<i32, Logical>) -> Self {
pub fn fixed_size(args: Args) -> Self {
let mut window = TestWindow::fixed_size(0);
window.request_size(size, false, None);
window.request_size(args.size, false, None);
window.communicate();
Self { window }
}
pub fn fixed_size_with_csd_shadow(size: Size<i32, Logical>) -> Self {
pub fn fixed_size_with_csd_shadow(args: Args) -> Self {
let mut window = TestWindow::fixed_size(0);
window.set_csd_shadow_width(64);
window.request_size(size, false, None);
window.request_size(args.size, false, None);
window.communicate();
Self { window }
}
+7 -15
View File
@@ -2,15 +2,11 @@
extern crate tracing;
use std::env;
use std::sync::atomic::Ordering;
use adw::prelude::{AdwApplicationWindowExt, NavigationPageExt};
use gtk::prelude::{
AdjustmentExt, ApplicationExt, ApplicationExtManual, BoxExt, GtkWindowExt, WidgetExt,
};
use cases::Args;
use gtk::prelude::{ApplicationExt, ApplicationExtManual, BoxExt, GtkWindowExt, WidgetExt};
use gtk::{gdk, gio, glib};
use niri::animation::ANIMATION_SLOWDOWN;
use smithay::utils::{Logical, Size};
use smithay_view::SmithayView;
use tracing_subscriber::EnvFilter;
@@ -66,24 +62,23 @@ fn on_startup(_app: &adw::Application) {
fn build_ui(app: &adw::Application) {
let stack = gtk::Stack::new();
let anim_adjustment = gtk::Adjustment::new(1., 0., 10., 0.1, 0.5, 0.);
struct S {
stack: gtk::Stack,
anim_adjustment: gtk::Adjustment,
}
impl S {
fn add<T: TestCase + 'static>(
&self,
make: impl Fn(Size<i32, Logical>) -> T + 'static,
title: &str,
) {
let view = SmithayView::new(make);
fn add<T: TestCase + 'static>(&self, make: impl Fn(Args) -> T + 'static, title: &str) {
let view = SmithayView::new(make, &self.anim_adjustment);
self.stack.add_titled(&view, None, title);
}
}
let s = S {
stack: stack.clone(),
anim_adjustment: anim_adjustment.clone(),
};
s.add(Window::freeform, "Freeform Window");
@@ -137,9 +132,6 @@ fn build_ui(app: &adw::Application) {
let content_headerbar = adw::HeaderBar::new();
let anim_adjustment = gtk::Adjustment::new(1., 0., 10., 0.1, 0.5, 0.);
anim_adjustment
.connect_value_changed(|adj| ANIMATION_SLOWDOWN.store(adj.value(), Ordering::SeqCst));
let anim_scale = gtk::Scale::new(gtk::Orientation::Horizontal, Some(&anim_adjustment));
anim_scale.set_hexpand(true);
+38 -9
View File
@@ -1,18 +1,20 @@
use gtk::glib;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use smithay::utils::{Logical, Size};
use smithay::utils::Size;
use crate::cases::TestCase;
use crate::cases::{Args, TestCase};
mod imp {
use std::cell::{Cell, OnceCell, RefCell};
use std::ptr::null;
use std::time::Duration;
use anyhow::{ensure, Context};
use gtk::gdk;
use gtk::prelude::*;
use niri::animation::Clock;
use niri::render_helpers::{resources, shaders};
use niri::utils::get_monotonic_time;
use smithay::backend::egl::ffi::egl;
use smithay::backend::egl::EGLContext;
use smithay::backend::renderer::gles::GlesRenderer;
@@ -21,7 +23,7 @@ mod imp {
use super::*;
type DynMakeTestCase = Box<dyn Fn(Size<i32, Logical>) -> Box<dyn TestCase>>;
type DynMakeTestCase = Box<dyn Fn(Args) -> Box<dyn TestCase>>;
#[derive(Default)]
pub struct SmithayView {
@@ -30,6 +32,7 @@ mod imp {
renderer: RefCell<Option<Result<GlesRenderer, ()>>>,
pub make_test_case: OnceCell<DynMakeTestCase>,
test_case: RefCell<Option<Box<dyn TestCase>>>,
pub clock: RefCell<Clock>,
}
#[glib::object_subclass]
@@ -125,16 +128,24 @@ mod imp {
let size = self.size.get();
let frame_clock = self.obj().frame_clock().unwrap();
let time = Duration::from_micros(frame_clock.frame_time() as u64);
self.clock.borrow_mut().set_unadjusted(time);
// Create the test case if missing.
let mut case = self.test_case.borrow_mut();
let case = case.get_or_insert_with(|| {
let make = self.make_test_case.get().unwrap();
make(Size::from(size))
let args = Args {
size: Size::from(size),
clock: self.clock.borrow().clone(),
};
make(args)
});
case.advance_animations(get_monotonic_time());
case.advance_animations(self.clock.borrow_mut().now());
let rect: Rectangle<i32, Physical> = Rectangle::from_loc_and_size((0, 0), size);
let rect: Rectangle<i32, Physical> = Rectangle::from_size(Size::from(size));
let elements = unsafe {
with_framebuffer_save_restore(renderer, |renderer| {
@@ -233,14 +244,32 @@ glib::wrapper! {
impl SmithayView {
pub fn new<T: TestCase + 'static>(
make_test_case: impl Fn(Size<i32, Logical>) -> T + 'static,
make_test_case: impl Fn(Args) -> T + 'static,
anim_adjustment: &gtk::Adjustment,
) -> Self {
let obj: Self = glib::Object::builder().build();
let make = move |size| Box::new(make_test_case(size)) as Box<dyn TestCase>;
let make = move |args| Box::new(make_test_case(args)) as Box<dyn TestCase>;
let make_test_case = Box::new(make) as _;
let _ = obj.imp().make_test_case.set(make_test_case);
anim_adjustment.connect_value_changed({
let obj = obj.downgrade();
move |adj| {
if let Some(obj) = obj.upgrade() {
let mut clock = obj.imp().clock.borrow_mut();
let instantly = adj.value() == 0.0;
let rate = if instantly {
1.0
} else {
1.0 / adj.value().max(0.001)
};
clock.set_rate(rate);
clock.set_complete_instantly(instantly);
}
}
});
obj
}
}
+12 -2
View File
@@ -188,7 +188,7 @@ impl LayoutElement for TestWindow {
self.inner.borrow_mut().pending_fullscreen = false;
}
fn request_fullscreen(&self, _size: Size<i32, Logical>) {
fn request_fullscreen(&mut self, _size: Size<i32, Logical>) {
self.inner.borrow_mut().pending_fullscreen = true;
}
@@ -220,8 +220,14 @@ impl LayoutElement for TestWindow {
fn set_active_in_column(&mut self, _active: bool) {}
fn set_floating(&mut self, _floating: bool) {}
fn set_bounds(&self, _bounds: Size<i32, Logical>) {}
fn is_ignoring_opacity_window_rule(&self) -> bool {
false
}
fn configure_intent(&self) -> ConfigureIntent {
ConfigureIntent::CanSend
}
@@ -240,6 +246,10 @@ impl LayoutElement for TestWindow {
self.inner.borrow().requested_size
}
fn is_child_of(&self, _parent: &Self) -> bool {
false
}
fn refresh(&self) {}
fn rules(&self) -> &ResolvedWindowRules {
@@ -259,7 +269,7 @@ impl LayoutElement for TestWindow {
fn cancel_interactive_resize(&mut self) {}
fn update_interactive_resize(&mut self, _serial: Serial) {}
fn on_commit(&mut self, _serial: Serial) {}
fn interactive_resize_data(&self) -> Option<InteractiveResizeData> {
None
+8 -7
View File
@@ -33,7 +33,6 @@ Summary: Scrollable-tiling Wayland compositor
SourceLicense: GPL-3.0-or-later
# (MIT OR Apache-2.0) AND BSD-3-Clause
# 0BSD OR MIT OR Apache-2.0
# Apache-2.0
# Apache-2.0 OR BSL-1.0
@@ -41,18 +40,21 @@ SourceLicense: GPL-3.0-or-later
# Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
# BSD-2-Clause
# BSD-2-Clause OR Apache-2.0 OR MIT
# BSD-3-Clause
# BSD-3-Clause OR MIT OR Apache-2.0
# GPL-3.0-or-later
# ISC
# MIT
# MIT AND (MIT OR Apache-2.0)
# MIT OR Apache-2.0
# (MIT OR Apache-2.0) AND BSD-3-Clause
# (MIT OR Apache-2.0) AND Unicode-3.0
# MIT OR Apache-2.0 OR Zlib
# MIT OR Zlib OR Apache-2.0
# MPL-2.0
# Unicode-3.0
# Unlicense OR MIT
# Zlib OR Apache-2.0 OR MIT
License: ((MIT OR Apache-2.0) AND BSD-3-Clause) AND (0BSD OR MIT OR Apache-2.0) AND (Apache-2.0) AND (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND (BSD-2-Clause) AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND (BSD-3-Clause) AND (BSD-3-Clause OR MIT OR Apache-2.0) AND (GPL-3.0-or-later) AND (ISC) AND (MIT) AND (MIT OR Apache-2.0) AND (MIT OR Apache-2.0 OR Zlib) AND (MIT OR Zlib OR Apache-2.0) AND (MPL-2.0) AND (Unlicense OR MIT) AND (Zlib OR Apache-2.0 OR MIT)
License: (0BSD OR MIT OR Apache-2.0) AND (Apache-2.0) AND (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND (BSD-2-Clause) AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND (BSD-3-Clause OR MIT OR Apache-2.0) AND (GPL-3.0-or-later) AND (ISC) AND (MIT) AND (MIT AND (MIT OR Apache-2.0)) AND (MIT OR Apache-2.0) AND ((MIT OR Apache-2.0) AND BSD-3-Clause) AND ((MIT OR Apache-2.0) AND Unicode-3.0) AND (MIT OR Apache-2.0 OR Zlib) AND (MIT OR Zlib OR Apache-2.0) AND (MPL-2.0) AND (Unicode-3.0) AND (Unlicense OR MIT) AND (Zlib OR Apache-2.0 OR MIT) License: ((MIT OR Apache-2.0) AND BSD-3-Clause) AND (0BSD OR MIT OR Apache-2.0) AND (Apache-2.0) AND (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND (BSD-2-Clause) AND (BSD-2-Clause OR Apache-2.0 OR MIT) AND (BSD-3-Clause) AND (BSD-3-Clause OR MIT OR Apache-2.0) AND (GPL-3.0-or-later) AND (ISC) AND (MIT) AND (MIT AND (MIT OR Apache-2.0)) AND (MIT OR Apache-2.0) AND (MIT OR Apache-2.0 OR Zlib) AND (MIT OR Zlib OR Apache-2.0) AND (MPL-2.0) AND (Unicode-3.0) AND (Unlicense OR MIT) AND (Zlib OR Apache-2.0 OR MIT)
# LICENSE.dependencies contains a full license breakdown
URL: https://github.com/YaLTeR/niri
@@ -101,10 +103,6 @@ Opening a new window never causes existing windows to resize.
%prep
{{{ git_dir_setup_macro }}}
# Make the version log message look nicer: since we're building not from niri's git repository,
# the git version macro will show its fallback string.
sed -i 's/"unknown commit"/"%{version}"/' src/utils/mod.rs
%cargo_prep -N
# We're doing an online build.
@@ -113,6 +111,9 @@ sed -i 's/^offline = true$//' .cargo/config.toml
# Final step in leaving alone our debug settings.
sed -i 's/.*please-remove-me$//' .cargo/config.toml
# Set the commit string.
sed -i 's/\[env\]/[env]\nNIRI_BUILD_COMMIT="%{version}"/' .cargo/config.toml
%build
%cargo_build
+80 -6
View File
@@ -25,6 +25,7 @@ input {
tap
// dwt
// dwtp
// drag-lock
natural-scroll
// accel-speed 0.2
// accel-profile "flat"
@@ -191,6 +192,43 @@ layout {
// inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
}
// You can enable drop shadows for windows.
shadow {
// Uncomment the next line to enable shadows.
// on
// By default, the shadow draws only around its window, and not behind it.
// Uncomment this setting to make the shadow draw behind its window.
//
// Note that niri has no way of knowing about the CSD window corner
// radius. It has to assume that windows have square corners, leading to
// shadow artifacts inside the CSD rounded corners. This setting fixes
// those artifacts.
//
// However, instead you may want to set prefer-no-csd and/or
// geometry-corner-radius. Then, niri will know the corner radius and
// draw the shadow correctly, without having to draw it behind the
// window. These will also remove client-side shadows if the window
// draws any.
//
// draw-behind-window true
// You can change how shadows look. The values below are in logical
// pixels and match the CSS box-shadow properties.
// Softness controls the shadow blur radius.
softness 30
// Spread expands the shadow.
spread 5
// Offset moves the shadow relative to the window.
offset x=0 y=5
// You can also change the shadow color and opacity.
color "#0007"
}
// Struts shrink the area occupied by windows, similarly to layer-shell panels.
// You can think of them as a kind of outer gaps. They are set in logical pixels.
// Left and right struts will cause the next window to the side to always be visible.
@@ -250,6 +288,15 @@ window-rule {
default-column-width {}
}
// Open the Firefox picture-in-picture player as floating by default.
window-rule {
// This app-id regular expression will work for both:
// - host Firefox (app-id is "firefox")
// - Flatpak Firefox (app-id is "org.mozilla.firefox")
match app-id=r#"firefox$"# title="^Picture-in-Picture$"
open-floating true
}
// Example: block out two password managers from screen capture.
// (This example rule is commented out with a "/-" in front.)
/-window-rule {
@@ -441,20 +488,27 @@ binds {
// Switches focus between the current and the previous workspace.
// Mod+Tab { focus-workspace-previous; }
// Consume one window from the right into the focused column.
Mod+Comma { consume-window-into-column; }
// Expel one window from the focused column to the right.
Mod+Period { expel-window-from-column; }
// There are also commands that consume or expel a single window to the side.
// The following binds move the focused window in and out of a column.
// If the window is alone, they will consume it into the nearby column to the side.
// If the window is already in a column, they will expel it out.
Mod+BracketLeft { consume-or-expel-window-left; }
Mod+BracketRight { consume-or-expel-window-right; }
// Consume one window from the right to the bottom of the focused column.
Mod+Comma { consume-window-into-column; }
// Expel the bottom window from the focused column to the right.
Mod+Period { expel-window-from-column; }
Mod+R { switch-preset-column-width; }
Mod+Shift+R { switch-preset-window-height; }
Mod+Ctrl+R { reset-window-height; }
Mod+F { maximize-column; }
Mod+Shift+F { fullscreen-window; }
// Expand the focused column to space not taken up by other fully visible columns.
// Makes the column "fill the rest of the space".
Mod+Ctrl+F { expand-column-to-available-width; }
Mod+C { center-column; }
// Finer width adjustments.
@@ -472,6 +526,15 @@ binds {
Mod+Shift+Minus { set-window-height "-10%"; }
Mod+Shift+Equal { set-window-height "+10%"; }
// Move the focused window between the floating and the tiling layout.
Mod+V { toggle-window-floating; }
Mod+Shift+V { switch-focus-between-floating-and-tiling; }
// Toggle tabbed column display mode.
// Windows in this column will appear as vertical tabs,
// rather than stacked on top of each other.
Mod+W { toggle-column-tabbed-display; }
// Actions to switch layouts.
// Note: if you uncomment these, make sure you do NOT have
// a matching layout switch hotkey configured in xkb options above.
@@ -484,8 +547,19 @@ binds {
Ctrl+Print { screenshot-screen; }
Alt+Print { screenshot-window; }
// Applications such as remote-desktop clients and software KVM switches may
// request that niri stops processing the keyboard shortcuts defined here
// so they may, for example, forward the key presses as-is to a remote machine.
// It's a good idea to bind an escape hatch to toggle the inhibitor,
// so a buggy application can't hold your session hostage.
//
// The allow-inhibiting=false property can be applied to other binds as well,
// which ensures niri always processes them, even when an inhibitor is active.
Mod+Escape allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; }
// The quit action will show a confirmation dialog to avoid accidental exits.
Mod+Shift+E { quit; }
Ctrl+Alt+Delete { quit; }
// Powers off the monitors. To turn them back on, do any input like
// moving the mouse or pressing any other key.
+2
View File
@@ -1,3 +1,5 @@
[preferred]
default=gnome;gtk;
org.freedesktop.impl.portal.Access=gtk;
org.freedesktop.impl.portal.Notification=gtk;
org.freedesktop.impl.portal.Secret=gnome-keyring;
+4 -4
View File
@@ -12,7 +12,7 @@ if [ -n "$SHELL" ] &&
fi
# Try to detect the service manager that is being used
if hash systemctl &> /dev/null; then
if hash systemctl >/dev/null 2>&1; then
# Make sure there's no already running session.
if systemctl --user -q is-active niri.service; then
echo 'A niri session is already running.'
@@ -41,15 +41,15 @@ if hash systemctl &> /dev/null; then
# Unset environment that we've set.
systemctl --user unset-environment WAYLAND_DISPLAY XDG_SESSION_TYPE XDG_CURRENT_DESKTOP NIRI_SOCKET
elif hash dinitctl &> /dev/null; then
elif hash dinitctl >/dev/null 2>&1; then
# Check that the user dinit daemon is running
if ! pgrep -u $(id -u) dinit &> /dev/null; then
if ! pgrep -u "$(id -u)" dinit >/dev/null 2>&1; then
echo "dinit user daemon is not running."
exit 1
fi
# Make sure there's no already running session.
if dinitctl --user is-started niri &> /dev/null; then
if dinitctl --user is-started niri >/dev/null 2>&1; then
echo 'A niri session is already running.'
exit 1
fi
+202
View File
@@ -0,0 +1,202 @@
use std::cell::RefCell;
use std::rc::Rc;
use std::time::Duration;
use crate::utils::get_monotonic_time;
/// Shareable lazy clock that can change rate.
///
/// The clock will fetch the time once and then retain it until explicitly cleared with
/// [`Clock::clear`].
#[derive(Debug, Default, Clone)]
pub struct Clock {
inner: Rc<RefCell<AdjustableClock>>,
}
#[derive(Debug, Default)]
struct LazyClock {
time: Option<Duration>,
}
/// Clock that can adjust its rate.
#[derive(Debug)]
struct AdjustableClock {
inner: LazyClock,
current_time: Duration,
last_seen_time: Duration,
rate: f64,
complete_instantly: bool,
}
impl Clock {
/// Creates a new clock with the given time.
pub fn with_time(time: Duration) -> Self {
let clock = AdjustableClock::new(LazyClock::with_time(time));
Self {
inner: Rc::new(RefCell::new(clock)),
}
}
/// Returns the current time.
pub fn now(&self) -> Duration {
self.inner.borrow_mut().now()
}
/// Returns the underlying time not adjusted for rate change.
pub fn now_unadjusted(&self) -> Duration {
self.inner.borrow_mut().inner.now()
}
/// Sets the unadjusted clock time.
pub fn set_unadjusted(&mut self, time: Duration) {
self.inner.borrow_mut().inner.set(time);
}
/// Clears the stored time so it's re-fetched again next.
pub fn clear(&mut self) {
self.inner.borrow_mut().inner.clear();
}
/// Gets the clock rate.
pub fn rate(&self) -> f64 {
self.inner.borrow().rate()
}
/// Sets the clock rate.
pub fn set_rate(&mut self, rate: f64) {
self.inner.borrow_mut().set_rate(rate);
}
/// Returns whether animations should complete instantly.
pub fn should_complete_instantly(&self) -> bool {
self.inner.borrow().should_complete_instantly()
}
/// Sets whether animations should complete instantly.
pub fn set_complete_instantly(&mut self, value: bool) {
self.inner.borrow_mut().set_complete_instantly(value);
}
}
impl PartialEq for Clock {
fn eq(&self, other: &Self) -> bool {
Rc::ptr_eq(&self.inner, &other.inner)
}
}
impl Eq for Clock {}
impl LazyClock {
pub fn with_time(time: Duration) -> Self {
Self { time: Some(time) }
}
pub fn clear(&mut self) {
self.time = None;
}
pub fn set(&mut self, time: Duration) {
self.time = Some(time);
}
pub fn now(&mut self) -> Duration {
*self.time.get_or_insert_with(get_monotonic_time)
}
}
impl AdjustableClock {
pub fn new(mut inner: LazyClock) -> Self {
let time = inner.now();
Self {
inner,
current_time: time,
last_seen_time: time,
rate: 1.,
complete_instantly: false,
}
}
pub fn rate(&self) -> f64 {
self.rate
}
pub fn set_rate(&mut self, rate: f64) {
self.rate = rate.clamp(0., 1000.);
}
pub fn should_complete_instantly(&self) -> bool {
self.complete_instantly
}
pub fn set_complete_instantly(&mut self, value: bool) {
self.complete_instantly = value;
}
pub fn now(&mut self) -> Duration {
let time = self.inner.now();
if self.last_seen_time == time {
return self.current_time;
}
if self.last_seen_time < time {
let delta = time - self.last_seen_time;
let delta = delta.mul_f64(self.rate);
self.current_time = self.current_time.saturating_add(delta);
} else {
let delta = self.last_seen_time - time;
let delta = delta.mul_f64(self.rate);
self.current_time = self.current_time.saturating_sub(delta);
}
self.last_seen_time = time;
self.current_time
}
}
impl Default for AdjustableClock {
fn default() -> Self {
Self::new(LazyClock::default())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn frozen_clock() {
let mut clock = Clock::with_time(Duration::ZERO);
assert_eq!(clock.now(), Duration::ZERO);
clock.set_unadjusted(Duration::from_millis(100));
assert_eq!(clock.now(), Duration::from_millis(100));
clock.set_unadjusted(Duration::from_millis(200));
assert_eq!(clock.now(), Duration::from_millis(200));
}
#[test]
fn rate_change() {
let mut clock = Clock::with_time(Duration::ZERO);
clock.set_rate(0.5);
clock.set_unadjusted(Duration::from_millis(100));
assert_eq!(clock.now_unadjusted(), Duration::from_millis(100));
assert_eq!(clock.now(), Duration::from_millis(50));
clock.set_unadjusted(Duration::from_millis(200));
assert_eq!(clock.now_unadjusted(), Duration::from_millis(200));
assert_eq!(clock.now(), Duration::from_millis(100));
clock.set_unadjusted(Duration::from_millis(150));
assert_eq!(clock.now_unadjusted(), Duration::from_millis(150));
assert_eq!(clock.now(), Duration::from_millis(75));
clock.set_rate(2.0);
clock.set_unadjusted(Duration::from_millis(250));
assert_eq!(clock.now_unadjusted(), Duration::from_millis(250));
assert_eq!(clock.now(), Duration::from_millis(275));
}
}
+53 -98
View File
@@ -2,14 +2,12 @@ use std::time::Duration;
use keyframe::functions::{EaseOutCubic, EaseOutQuad};
use keyframe::EasingFunction;
use portable_atomic::{AtomicF64, Ordering};
use crate::utils::get_monotonic_time;
mod spring;
pub use spring::{Spring, SpringParams};
pub static ANIMATION_SLOWDOWN: AtomicF64 = AtomicF64::new(1.);
mod clock;
pub use clock::Clock;
#[derive(Debug, Clone)]
pub struct Animation {
@@ -23,7 +21,7 @@ pub struct Animation {
/// Best effort; not always exactly precise.
clamped_duration: Duration,
start_time: Duration,
current_time: Duration,
clock: Clock,
kind: Kind,
}
@@ -48,11 +46,17 @@ pub enum Curve {
}
impl Animation {
pub fn new(from: f64, to: f64, initial_velocity: f64, config: niri_config::Animation) -> Self {
// Scale the velocity by slowdown to keep the touchpad gestures feeling right.
let initial_velocity = initial_velocity * ANIMATION_SLOWDOWN.load(Ordering::Relaxed);
pub fn new(
clock: Clock,
from: f64,
to: f64,
initial_velocity: f64,
config: niri_config::Animation,
) -> Self {
// Scale the velocity by rate to keep the touchpad gestures feeling right.
let initial_velocity = initial_velocity / clock.rate().max(0.001);
let mut rv = Self::ease(from, to, initial_velocity, 0, Curve::EaseOutCubic);
let mut rv = Self::ease(clock, from, to, initial_velocity, 0, Curve::EaseOutCubic);
if config.off {
rv.is_off = true;
return rv;
@@ -71,7 +75,6 @@ impl Animation {
}
let start_time = self.start_time;
let current_time = self.current_time;
match config.kind {
niri_config::AnimationKind::Spring(p) => {
@@ -83,10 +86,11 @@ impl Animation {
initial_velocity: self.initial_velocity,
params,
};
*self = Self::spring(spring);
*self = Self::spring(self.clock.clone(), spring);
}
niri_config::AnimationKind::Easing(p) => {
*self = Self::ease(
self.clock.clone(),
self.from,
self.to,
self.initial_velocity,
@@ -97,7 +101,6 @@ impl Animation {
}
self.start_time = start_time;
self.current_time = current_time;
}
/// Restarts the animation using the previous config.
@@ -106,11 +109,12 @@ impl Animation {
return self.clone();
}
// Scale the velocity by slowdown to keep the touchpad gestures feeling right.
let initial_velocity = initial_velocity * ANIMATION_SLOWDOWN.load(Ordering::Relaxed);
// Scale the velocity by rate to keep the touchpad gestures feeling right.
let initial_velocity = initial_velocity / self.clock.rate().max(0.001);
match self.kind {
Kind::Easing { curve } => Self::ease(
self.clock.clone(),
from,
to,
initial_velocity,
@@ -124,23 +128,32 @@ impl Animation {
initial_velocity: self.initial_velocity,
params: spring.params,
};
Self::spring(spring)
Self::spring(self.clock.clone(), spring)
}
Kind::Deceleration {
initial_velocity,
deceleration_rate,
} => {
let threshold = 0.001; // FIXME
Self::decelerate(from, initial_velocity, deceleration_rate, threshold)
Self::decelerate(
self.clock.clone(),
from,
initial_velocity,
deceleration_rate,
threshold,
)
}
}
}
pub fn ease(from: f64, to: f64, initial_velocity: f64, duration_ms: u64, curve: Curve) -> Self {
// FIXME: ideally we shouldn't use current time here because animations started within the
// same frame cycle should have the same start time to be synchronized.
let now = get_monotonic_time();
pub fn ease(
clock: Clock,
from: f64,
to: f64,
initial_velocity: f64,
duration_ms: u64,
curve: Curve,
) -> Self {
let duration = Duration::from_millis(duration_ms);
let kind = Kind::Easing { curve };
@@ -152,19 +165,15 @@ impl Animation {
duration,
// Our current curves never overshoot.
clamped_duration: duration,
start_time: now,
current_time: now,
start_time: clock.now(),
clock,
kind,
}
}
pub fn spring(spring: Spring) -> Self {
pub fn spring(clock: Clock, spring: Spring) -> Self {
let _span = tracy_client::span!("Animation::spring");
// FIXME: ideally we shouldn't use current time here because animations started within the
// same frame cycle should have the same start time to be synchronized.
let now = get_monotonic_time();
let duration = spring.duration();
let clamped_duration = spring.clamped_duration().unwrap_or(duration);
let kind = Kind::Spring(spring);
@@ -176,22 +185,19 @@ impl Animation {
is_off: false,
duration,
clamped_duration,
start_time: now,
current_time: now,
start_time: clock.now(),
clock,
kind,
}
}
pub fn decelerate(
clock: Clock,
from: f64,
initial_velocity: f64,
deceleration_rate: f64,
threshold: f64,
) -> Self {
// FIXME: ideally we shouldn't use current time here because animations started within the
// same frame cycle should have the same start time to be synchronized.
let now = get_monotonic_time();
let duration_s = if initial_velocity == 0. {
0.
} else {
@@ -214,77 +220,26 @@ impl Animation {
is_off: false,
duration,
clamped_duration: duration,
start_time: now,
current_time: now,
start_time: clock.now(),
clock,
kind,
}
}
pub fn set_current_time(&mut self, time: Duration) {
if self.duration.is_zero() {
self.current_time = time;
return;
}
let end_time = self.start_time + self.duration;
if end_time <= self.current_time {
return;
}
let slowdown = ANIMATION_SLOWDOWN.load(Ordering::Relaxed);
if slowdown <= f64::EPSILON {
// Zero slowdown will cause the animation to end right away.
self.current_time = end_time;
return;
}
// We can't change current_time (since the incoming time values are always real-time), so
// apply the slowdown by shifting the start time to compensate.
if self.current_time <= time {
let delta = time - self.current_time;
let max_delta = end_time - self.current_time;
let min_slowdown = delta.as_secs_f64() / max_delta.as_secs_f64();
if slowdown <= min_slowdown {
// Our slowdown value will cause the animation to end right away.
self.current_time = end_time;
return;
}
let adjusted_delta = delta.div_f64(slowdown);
if adjusted_delta >= delta {
self.start_time -= adjusted_delta - delta;
} else {
self.start_time += delta - adjusted_delta;
}
} else {
let delta = self.current_time - time;
let min_slowdown = delta.as_secs_f64() / self.current_time.as_secs_f64();
if slowdown <= min_slowdown {
// Current time was about to jump to before the animation had started; let's just
// cancel the animation in this case.
self.current_time = end_time;
return;
}
let adjusted_delta = delta.div_f64(slowdown);
if adjusted_delta >= delta {
self.start_time += adjusted_delta - delta;
} else {
self.start_time -= delta - adjusted_delta;
}
}
self.current_time = time;
}
pub fn is_done(&self) -> bool {
self.current_time >= self.start_time + self.duration
if self.clock.should_complete_instantly() {
return true;
}
self.clock.now() >= self.start_time + self.duration
}
pub fn is_clamped_done(&self) -> bool {
self.current_time >= self.start_time + self.clamped_duration
if self.clock.should_complete_instantly() {
return true;
}
self.clock.now() >= self.start_time + self.clamped_duration
}
pub fn value(&self) -> f64 {
@@ -292,7 +247,7 @@ impl Animation {
return self.to;
}
let passed = self.current_time.saturating_sub(self.start_time);
let passed = self.clock.now().saturating_sub(self.start_time);
match self.kind {
Kind::Easing { curve } => {
+22
View File
@@ -54,6 +54,10 @@ impl Spring {
return Duration::MAX;
}
if (self.to - self.from).abs() <= f64::EPSILON {
return Duration::ZERO;
}
let omega0 = (self.params.stiffness / self.params.mass).sqrt();
// As first ansatz for the overdamped solution,
@@ -166,3 +170,21 @@ impl Spring {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn overdamped_spring_equal_from_to_nan() {
let spring = Spring {
from: 0.,
to: 0.,
initial_velocity: 0.,
params: SpringParams::new(1.15, 850., 0.0001),
};
let _ = spring.duration();
let _ = spring.clamped_duration();
let _ = spring.value_at(Duration::ZERO);
}
}
+140
View File
@@ -0,0 +1,140 @@
//! Headless backend for tests.
//!
//! This can eventually grow into a more complete backend if needed, but for now it's missing some
//! crucial parts like rendering.
use std::mem;
use std::sync::{Arc, Mutex};
use niri_config::OutputName;
use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::renderer::element::RenderElementStates;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::output::{Mode, Output, PhysicalProperties, Subpixel};
use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;
use smithay::utils::Size;
use smithay::wayland::presentation::Refresh;
use super::{IpcOutputMap, OutputId, RenderResult};
use crate::niri::{Niri, RedrawState};
use crate::utils::{get_monotonic_time, logical_output};
pub struct Headless {
ipc_outputs: Arc<Mutex<IpcOutputMap>>,
}
impl Headless {
pub fn new() -> Self {
Self {
ipc_outputs: Default::default(),
}
}
pub fn init(&mut self, _niri: &mut Niri) {}
pub fn add_output(&mut self, niri: &mut Niri, n: u8, size: (u16, u16)) {
let connector = format!("headless-{n}");
let make = "niri".to_string();
let model = "headless".to_string();
let serial = n.to_string();
let output = Output::new(
connector.clone(),
PhysicalProperties {
size: (0, 0).into(),
subpixel: Subpixel::Unknown,
make: make.clone(),
model: model.clone(),
},
);
let mode = Mode {
size: Size::from((i32::from(size.0), i32::from(size.1))),
refresh: 60_000,
};
output.change_current_state(Some(mode), None, None, None);
output.set_preferred(mode);
output.user_data().insert_if_missing(|| OutputName {
connector,
make: Some(make),
model: Some(model),
serial: Some(serial),
});
let physical_properties = output.physical_properties();
self.ipc_outputs.lock().unwrap().insert(
OutputId::next(),
niri_ipc::Output {
name: output.name(),
make: physical_properties.make,
model: physical_properties.model,
serial: None,
physical_size: None,
modes: vec![niri_ipc::Mode {
width: size.0,
height: size.1,
refresh_rate: 60_000,
is_preferred: true,
}],
current_mode: Some(0),
vrr_supported: false,
vrr_enabled: false,
logical: Some(logical_output(&output)),
},
);
niri.add_output(output, None, false);
}
pub fn seat_name(&self) -> String {
"headless".to_owned()
}
pub fn with_primary_renderer<T>(
&mut self,
_f: impl FnOnce(&mut GlesRenderer) -> T,
) -> Option<T> {
None
}
pub fn render(&mut self, niri: &mut Niri, output: &Output) -> RenderResult {
let states = RenderElementStates::default();
let mut presentation_feedbacks = niri.take_presentation_feedbacks(output, &states);
presentation_feedbacks.presented::<_, smithay::utils::Monotonic>(
get_monotonic_time(),
Refresh::Unknown,
0,
wp_presentation_feedback::Kind::empty(),
);
let output_state = niri.output_state.get_mut(output).unwrap();
match mem::replace(&mut output_state.redraw_state, RedrawState::Idle) {
RedrawState::Idle => unreachable!(),
RedrawState::Queued => (),
RedrawState::WaitingForVBlank { .. } => unreachable!(),
RedrawState::WaitingForEstimatedVBlank(_) => unreachable!(),
RedrawState::WaitingForEstimatedVBlankAndQueued(_) => unreachable!(),
}
output_state.frame_callback_sequence = output_state.frame_callback_sequence.wrapping_add(1);
// FIXME: request redraw on unfinished animations remain
RenderResult::Submitted
}
pub fn import_dmabuf(&mut self, _dmabuf: &Dmabuf) -> bool {
unimplemented!()
}
pub fn ipc_outputs(&self) -> Arc<Mutex<IpcOutputMap>> {
self.ipc_outputs.clone()
}
}
impl Default for Headless {
fn default() -> Self {
Self::new()
}
}
+27 -7
View File
@@ -17,9 +17,13 @@ pub use tty::Tty;
pub mod winit;
pub use winit::Winit;
pub mod headless;
pub use headless::Headless;
pub enum Backend {
Tty(Tty),
Winit(Winit),
Headless(Headless),
}
#[derive(PartialEq, Eq)]
@@ -54,6 +58,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.init(niri),
Backend::Winit(winit) => winit.init(niri),
Backend::Headless(headless) => headless.init(niri),
}
}
@@ -61,6 +66,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.seat_name(),
Backend::Winit(winit) => winit.seat_name(),
Backend::Headless(headless) => headless.seat_name(),
}
}
@@ -71,6 +77,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.with_primary_renderer(f),
Backend::Winit(winit) => winit.with_primary_renderer(f),
Backend::Headless(headless) => headless.with_primary_renderer(f),
}
}
@@ -83,6 +90,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.render(niri, output, target_presentation_time),
Backend::Winit(winit) => winit.render(niri, output),
Backend::Headless(headless) => headless.render(niri, output),
}
}
@@ -90,6 +98,7 @@ impl Backend {
match self {
Backend::Tty(_) => CompositorMod::Super,
Backend::Winit(_) => CompositorMod::Alt,
Backend::Headless(_) => CompositorMod::Super,
}
}
@@ -97,6 +106,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.change_vt(vt),
Backend::Winit(_) => (),
Backend::Headless(_) => (),
}
}
@@ -104,6 +114,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.suspend(),
Backend::Winit(_) => (),
Backend::Headless(_) => (),
}
}
@@ -111,6 +122,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.toggle_debug_tint(),
Backend::Winit(winit) => winit.toggle_debug_tint(),
Backend::Headless(_) => (),
}
}
@@ -118,6 +130,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.import_dmabuf(dmabuf),
Backend::Winit(winit) => winit.import_dmabuf(dmabuf),
Backend::Headless(headless) => headless.import_dmabuf(dmabuf),
}
}
@@ -125,6 +138,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.early_import(surface),
Backend::Winit(_) => (),
Backend::Headless(_) => (),
}
}
@@ -132,6 +146,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.ipc_outputs(),
Backend::Winit(winit) => winit.ipc_outputs(),
Backend::Headless(headless) => headless.ipc_outputs(),
}
}
@@ -143,6 +158,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.primary_gbm_device(),
Backend::Winit(_) => None,
Backend::Headless(_) => None,
}
}
@@ -150,6 +166,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.set_monitors_active(active),
Backend::Winit(_) => (),
Backend::Headless(_) => (),
}
}
@@ -157,6 +174,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.set_output_on_demand_vrr(niri, output, enable_vrr),
Backend::Winit(_) => (),
Backend::Headless(_) => (),
}
}
@@ -164,13 +182,7 @@ impl Backend {
match self {
Backend::Tty(tty) => tty.on_output_config_changed(niri),
Backend::Winit(_) => (),
}
}
pub fn on_debug_config_changed(&mut self) {
match self {
Backend::Tty(tty) => tty.on_debug_config_changed(),
Backend::Winit(_) => (),
Backend::Headless(_) => (),
}
}
@@ -197,4 +209,12 @@ impl Backend {
panic!("backend is not Winit")
}
}
pub fn headless(&mut self) -> &mut Headless {
if let Self::Headless(v) = self {
v
} else {
panic!("backend is not Headless")
}
}
}
+293 -242
View File
@@ -18,9 +18,9 @@ use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::allocator::format::FormatSet;
use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice};
use smithay::backend::allocator::Fourcc;
use smithay::backend::drm::compositor::{DrmCompositor, PrimaryPlaneElement};
use smithay::backend::drm::compositor::{DrmCompositor, FrameFlags, PrimaryPlaneElement};
use smithay::backend::drm::{
DrmDevice, DrmDeviceFd, DrmEvent, DrmEventMetadata, DrmEventTime, DrmNode, NodeType,
DrmDevice, DrmDeviceFd, DrmEvent, DrmEventMetadata, DrmEventTime, DrmNode, NodeType, VrrSupport,
};
use smithay::backend::egl::context::ContextPriority;
use smithay::backend::egl::{EGLDevice, EGLDisplay};
@@ -50,6 +50,7 @@ use smithay::wayland::dmabuf::{DmabufFeedback, DmabufFeedbackBuilder, DmabufGlob
use smithay::wayland::drm_lease::{
DrmLease, DrmLeaseBuilder, DrmLeaseRequest, DrmLeaseState, LeaseRejected,
};
use smithay::wayland::presentation::Refresh;
use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};
use wayland_protocols::wp::linux_dmabuf::zv1::server::zwp_linux_dmabuf_feedback_v1::TrancheFlags;
use wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;
@@ -61,9 +62,14 @@ use crate::niri::{Niri, RedrawState, State};
use crate::render_helpers::debug::draw_damage;
use crate::render_helpers::renderer::AsGlesRenderer;
use crate::render_helpers::{resources, shaders, RenderTarget};
use crate::utils::{get_monotonic_time, logical_output};
use crate::utils::{get_monotonic_time, is_laptop_panel, logical_output};
const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888];
const SUPPORTED_COLOR_FORMATS: [Fourcc; 4] = [
Fourcc::Xrgb8888,
Fourcc::Xbgr8888,
Fourcc::Argb8888,
Fourcc::Abgr8888,
];
pub struct Tty {
config: Rc<RefCell<Config>>,
@@ -117,7 +123,7 @@ pub struct OutputDevice {
render_node: DrmNode,
drm_scanner: DrmScanner,
surfaces: HashMap<crtc::Handle, Surface>,
output_ids: HashMap<crtc::Handle, OutputId>,
known_crtcs: HashMap<crtc::Handle, CrtcInfo>,
// SAFETY: drop after all the objects used with them are dropped.
// See https://github.com/Smithay/smithay/issues/1102.
drm: DrmDevice,
@@ -128,6 +134,13 @@ pub struct OutputDevice {
active_leases: Vec<DrmLease>,
}
// A connected, but not necessarily enabled, crtc.
#[derive(Debug, Clone)]
pub struct CrtcInfo {
id: OutputId,
name: OutputName,
}
impl OutputDevice {
pub fn lease_request(
&self,
@@ -167,6 +180,35 @@ impl OutputDevice {
pub fn remove_lease(&mut self, lease_id: u32) {
self.active_leases.retain(|l| l.id() != lease_id);
}
pub fn known_crtc_name(
&self,
crtc: &crtc::Handle,
conn: &connector::Info,
disable_monitor_names: bool,
) -> OutputName {
if disable_monitor_names {
let conn_name = format_connector_name(conn);
return OutputName {
connector: conn_name,
make: None,
model: None,
serial: None,
};
}
let Some(info) = self.known_crtcs.get(crtc) else {
let conn_name = format_connector_name(conn);
error!("crtc for connector {conn_name} missing from known");
return OutputName {
connector: conn_name,
make: None,
model: None,
serial: None,
};
};
info.name.clone()
}
}
#[derive(Debug, Clone, Copy)]
@@ -183,7 +225,6 @@ struct Surface {
gamma_props: Option<GammaProps>,
/// Gamma change to apply upon session resume.
pending_gamma_change: Option<Option<Vec<u16>>>,
vrr_enabled: bool,
/// Tracy frame that goes from vblank to vblank.
vblank_frame: Option<tracy_client::Frame>,
/// Frame name for the VBlank frame.
@@ -404,8 +445,6 @@ impl Tty {
self.device_changed(node.dev_id(), niri);
// Apply pending gamma changes and restore our existing gamma.
//
// Also, restore our VRR.
let device = self.devices.get_mut(&node).unwrap();
for (crtc, surface) in device.surfaces.iter_mut() {
if let Some(ramp) = surface.pending_gamma_change.take() {
@@ -423,33 +462,6 @@ impl Tty {
warn!("error restoring gamma: {err:?}");
}
}
// Restore VRR.
let output = niri
.global_space
.outputs()
.find(|output| {
let tty_state: &TtyOutputState = output.user_data().get().unwrap();
tty_state.node == node && tty_state.crtc == *crtc
})
.cloned();
let Some(output) = output else {
error!("missing output for crtc: {crtc:?}");
continue;
};
let Some(output_state) = niri.output_state.get_mut(&output) else {
error!("missing state for output {:?}", surface.name.connector);
continue;
};
try_to_change_vrr(
&device.drm,
surface.connector,
*crtc,
surface,
output_state,
surface.vrr_enabled,
);
}
}
@@ -466,7 +478,7 @@ impl Tty {
self.refresh_ipc_outputs(niri);
niri.idle_notifier_state.notify_activity(&niri.seat);
niri.notify_activity();
niri.monitors_active = true;
self.set_monitors_active(true);
niri.queue_redraw_all();
@@ -535,7 +547,7 @@ impl Tty {
}
drop(config);
niri.layout.update_shaders();
niri.update_shaders();
// Create the dmabuf global.
let primary_formats = renderer.dmabuf_formats();
@@ -596,7 +608,7 @@ impl Tty {
gbm,
drm_scanner: DrmScanner::new(),
surfaces: HashMap::new(),
output_ids: HashMap::new(),
known_crtcs: HashMap::new(),
drm_lease_state,
active_leases: Vec::new(),
non_desktop_connectors: HashSet::new(),
@@ -629,6 +641,7 @@ impl Tty {
}
};
let mut added = Vec::new();
let mut removed = Vec::new();
for event in scan_result {
match event {
@@ -636,34 +649,79 @@ impl Tty {
connector,
crtc: Some(crtc),
} => {
if let Err(err) = self.connector_connected(niri, node, connector, crtc) {
warn!("error connecting connector: {err:?}");
}
let connector_name = format_connector_name(&connector);
let name = make_output_name(&device.drm, connector.handle(), connector_name);
debug!(
"new connector: {} \"{}\"",
&name.connector,
name.format_make_model_serial(),
);
// Assign an id to this crtc.
let id = OutputId::next();
added.push((crtc, CrtcInfo { id, name }));
}
DrmScanEvent::Disconnected {
crtc: Some(crtc), ..
} => {
self.connector_disconnected(niri, node, crtc);
removed.push(crtc);
}
_ => (),
}
}
// FIXME: this is better done in connector_disconnected(), but currently we call that to
// turn off outputs temporarily, too. So we can't do this there.
for crtc in &removed {
self.connector_disconnected(niri, node, *crtc);
}
let Some(device) = self.devices.get_mut(&node) else {
error!("device disappeared");
return;
};
for crtc in removed {
if device.output_ids.remove(&crtc).is_none() {
if device.known_crtcs.remove(&crtc).is_none() {
error!("output ID missing for disconnected crtc: {crtc:?}");
}
}
self.refresh_ipc_outputs(niri);
for (crtc, mut info) in added {
// Make/model/serial can match exactly between different physical monitors. This doesn't
// happen often, but our Layout does not support such duplicates and will panic.
//
// As a workaround, search for duplicates, and unname the new connectors if one is
// found. Connector names are always unique.
let name = &mut info.name;
let formatted = name.format_make_model_serial_or_connector();
for info in self.devices.values().flat_map(|d| d.known_crtcs.values()) {
if info.name.matches(&formatted) {
let connector = mem::take(&mut name.connector);
warn!(
"new connector {connector} duplicates make/model/serial \
of existing connector {}, unnaming",
info.name.connector,
);
*name = OutputName {
connector,
make: None,
model: None,
serial: None,
};
break;
}
}
// Insert it right away so next added connector will check against this one too.
let device = self.devices.get_mut(&node).unwrap();
device.known_crtcs.insert(crtc, info);
}
// This will connect any new connectors if needed, and apply other changes, such as
// connecting back the internal laptop monitor once it becomes the only monitor left.
//
// It will also call refresh_ipc_outputs(), which will catch the disconnected connectors
// above.
self.on_output_config_changed(niri);
}
fn device_removed(&mut self, device_id: dev_t, niri: &mut Niri) {
@@ -749,7 +807,8 @@ impl Tty {
let device = self.devices.get_mut(&node).context("missing device")?;
let output_name = make_output_name(&device.drm, connector.handle(), connector_name.clone());
let disable_monitor_names = self.config.borrow().debug.disable_monitor_names;
let output_name = device.known_crtc_name(&crtc, &connector, disable_monitor_names);
let non_desktop = find_drm_property(&device.drm, connector.handle(), "non-desktop")
.and_then(|(_, info, value)| info.value_type().convert_value(value).as_boolean())
@@ -767,10 +826,6 @@ impl Tty {
return Ok(());
}
// This should be unique per CRTC connection, however currently we can call
// connector_connected() multiple times for turning the output off and on.
device.output_ids.entry(crtc).or_insert_with(OutputId::next);
let config = self
.config
.borrow()
@@ -779,11 +834,6 @@ impl Tty {
.cloned()
.unwrap_or_default();
if config.off {
debug!("output is disabled in the config");
return Ok(());
}
for m in connector.modes() {
trace!("{m:?}");
}
@@ -811,45 +861,6 @@ impl Tty {
Err(err) => debug!("error setting max bpc: {err:?}"),
}
// Try to enable VRR if requested.
let mut vrr_enabled = false;
if let Some(capable) = is_vrr_capable(&device.drm, connector.handle()) {
if capable {
// Even if on-demand, we still disable it until later checks.
let vrr = config.is_vrr_always_on();
let word = if vrr { "enabling" } else { "disabling" };
match set_vrr_enabled(&device.drm, crtc, vrr) {
Ok(enabled) => {
if enabled != vrr {
warn!("failed {} VRR", word);
}
vrr_enabled = enabled;
}
Err(err) => {
warn!("error {} VRR: {err:?}", word);
}
}
} else {
if !config.is_vrr_always_off() {
warn!("cannot enable VRR because connector is not vrr_capable");
}
// Try to disable it anyway to work around a bug where resetting DRM state causes
// vrr_capable to be reset to 0, potentially leaving VRR_ENABLED at 1.
let res = set_vrr_enabled(&device.drm, crtc, false);
if matches!(res, Ok(true)) {
warn!("error disabling VRR");
// So that we can try it again later.
vrr_enabled = true;
}
}
} else if !config.is_vrr_always_off() {
warn!("cannot enable VRR because connector is not vrr_capable");
}
let mut gamma_props = GammaProps::new(&device.drm, crtc)
.map_err(|err| debug!("error getting gamma properties: {err:?}"))
.ok();
@@ -868,6 +879,31 @@ impl Tty {
.drm
.create_surface(crtc, mode, &[connector.handle()])?;
// Try to enable VRR if requested.
match surface.vrr_supported(connector.handle()) {
Ok(VrrSupport::Supported | VrrSupport::RequiresModeset) => {
// Even if on-demand, we still disable it until later checks.
let vrr = config.is_vrr_always_on();
let word = if vrr { "enabling" } else { "disabling" };
if let Err(err) = surface.use_vrr(vrr) {
warn!("error {} VRR: {err:?}", word);
}
}
Ok(VrrSupport::NotSupported) => {
if !config.is_vrr_always_off() {
warn!("cannot enable VRR because connector does not support it");
}
// Try to disable it anyway to work around a bug where resetting DRM state causes
// vrr_capable to be reset to 0, potentially leaving VRR_ENABLED at 1.
let _ = surface.use_vrr(false);
}
Err(err) => {
warn!("error querying for VRR support: {err:?}");
}
}
// Create GBM allocator.
let gbm_flags = GbmBufferFlags::RENDERING | GbmBufferFlags::SCANOUT;
let allocator = GbmAllocator::new(device.gbm.clone(), gbm_flags);
@@ -894,23 +930,6 @@ impl Tty {
.insert_if_missing(|| TtyOutputState { node, crtc });
output.user_data().insert_if_missing(|| output_name.clone());
let mut planes = surface.planes().clone();
let config = self.config.borrow();
// Overlay planes are disabled by default as they cause weird performance issues on my
// system.
if !config.debug.enable_overlay_planes {
planes.overlay.clear();
}
// Cursor planes have bugs on some systems.
let cursor_plane_gbm = if config.debug.disable_cursor_plane {
None
} else {
Some(device.gbm.clone())
};
let renderer = self.gpu_manager.single_renderer(&device.render_node)?;
let egl_context = renderer.as_ref().egl_context();
let render_formats = egl_context.dmabuf_render_formats();
@@ -949,7 +968,7 @@ impl Tty {
let res = DrmCompositor::new(
OutputModeSource::Auto(output.clone()),
surface,
Some(planes),
None,
allocator.clone(),
device.gbm.clone(),
SUPPORTED_COLOR_FORMATS,
@@ -957,7 +976,7 @@ impl Tty {
// formats, even though we only ever render on the primary GPU.
render_formats.clone(),
device.drm.cursor_size(),
cursor_plane_gbm.clone(),
Some(device.gbm.clone()),
);
let mut compositor = match res {
@@ -975,21 +994,17 @@ impl Tty {
let surface = device
.drm
.create_surface(crtc, mode, &[connector.handle()])?;
let mut planes = surface.planes().clone();
if !config.debug.enable_overlay_planes {
planes.overlay.clear();
}
DrmCompositor::new(
OutputModeSource::Auto(output.clone()),
surface,
Some(planes),
None,
allocator,
device.gbm.clone(),
SUPPORTED_COLOR_FORMATS,
render_formats,
device.drm.cursor_size(),
cursor_plane_gbm,
Some(device.gbm.clone()),
)
.context("error creating DRM compositor")?
}
@@ -998,7 +1013,6 @@ impl Tty {
if self.debug_tint {
compositor.set_debug_flags(DebugFlags::TINT);
}
compositor.use_direct_scanout(!config.debug.disable_direct_scanout);
let mut dmabuf_feedback = None;
if let Ok(primary_renderer) = self.gpu_manager.single_renderer(&self.primary_render_node) {
@@ -1027,6 +1041,8 @@ impl Tty {
}
}
let vrr_enabled = compositor.vrr_enabled();
let vblank_frame_name =
tracy_client::FrameName::new_leak(format!("vblank on {connector_name}"));
let time_since_presentation_plot_name = tracy_client::PlotName::new_leak(format!(
@@ -1044,7 +1060,6 @@ impl Tty {
compositor,
dmabuf_feedback,
gamma_props,
vrr_enabled,
pending_gamma_change: None,
vblank_frame: None,
vblank_frame_name,
@@ -1223,10 +1238,17 @@ impl Tty {
// Mark the last frame as submitted.
match surface.compositor.frame_submitted() {
Ok(Some((mut feedback, target_presentation_time))) => {
let refresh = output_state
.frame_clock
.refresh_interval()
.unwrap_or(Duration::ZERO);
let refresh = match output_state.frame_clock.refresh_interval() {
Some(refresh) => {
if output_state.frame_clock.vrr() {
Refresh::Variable(refresh)
} else {
Refresh::Fixed(refresh)
}
}
None => Refresh::Unknown,
};
// FIXME: ideally should be monotonically increasing for a surface.
let seq = meta.sequence as u64;
let mut flags = wp_presentation_feedback::Kind::Vsync
@@ -1376,9 +1398,35 @@ impl Tty {
draw_damage(&mut output_state.debug_damage_tracker, &mut elements);
}
// Overlay planes are disabled by default as they cause weird performance issues on my
// system.
let flags = {
let debug = &self.config.borrow().debug;
let primary_scanout_flag = if debug.restrict_primary_scanout_to_matching_format {
FrameFlags::ALLOW_PRIMARY_PLANE_SCANOUT
} else {
FrameFlags::ALLOW_PRIMARY_PLANE_SCANOUT_ANY
};
let mut flags = primary_scanout_flag | FrameFlags::ALLOW_CURSOR_PLANE_SCANOUT;
if debug.enable_overlay_planes {
flags.insert(FrameFlags::ALLOW_OVERLAY_PLANE_SCANOUT);
}
if debug.disable_direct_scanout {
flags.remove(primary_scanout_flag);
flags.remove(FrameFlags::ALLOW_OVERLAY_PLANE_SCANOUT);
}
if debug.disable_cursor_plane {
flags.remove(FrameFlags::ALLOW_CURSOR_PLANE_SCANOUT);
}
flags
};
// Hand them over to the DRM.
let drm_compositor = &mut surface.compositor;
match drm_compositor.render_frame::<_, _>(&mut renderer, &elements, [0.; 4]) {
match drm_compositor.render_frame::<_, _>(&mut renderer, &elements, [0.; 4], flags) {
Ok(res) => {
let needs_sync = res.needs_sync()
|| self
@@ -1559,13 +1607,13 @@ impl Tty {
let _span = tracy_client::span!("Tty::refresh_ipc_outputs");
let mut ipc_outputs = HashMap::new();
let disable_monitor_names = self.config.borrow().debug.disable_monitor_names;
for (node, device) in &self.devices {
for (connector, crtc) in device.drm_scanner.crtcs() {
let connector_name = format_connector_name(connector);
let physical_size = connector.size();
let output_name =
make_output_name(&device.drm, connector.handle(), connector_name.clone());
let output_name = device.known_crtc_name(&crtc, connector, disable_monitor_names);
let surface = device.surfaces.get(&crtc);
let current_crtc_mode = surface.map(|surface| surface.compositor.pending_mode());
@@ -1600,8 +1648,17 @@ impl Tty {
}
}
let vrr_supported = is_vrr_capable(&device.drm, connector.handle()) == Some(true);
let vrr_enabled = surface.map_or(false, |surface| surface.vrr_enabled);
let vrr_supported = surface
.map(|surface| {
matches!(
surface.compositor.vrr_supported(connector.handle()),
Ok(VrrSupport::Supported | VrrSupport::RequiresModeset)
)
})
.unwrap_or_else(|| {
is_vrr_capable(&device.drm, connector.handle()) == Some(true)
});
let vrr_enabled = surface.is_some_and(|surface| surface.compositor.vrr_enabled());
let logical = niri
.global_space
@@ -1612,6 +1669,12 @@ impl Tty {
})
.map(logical_output);
let id = device.known_crtcs.get(&crtc).map(|info| info.id);
let id = id.unwrap_or_else(|| {
error!("crtc for connector {connector_name} missing from known");
OutputId::next()
});
let ipc_output = niri_ipc::Output {
name: connector_name,
make: output_name.make.unwrap_or_else(|| "Unknown".into()),
@@ -1625,10 +1688,6 @@ impl Tty {
logical,
};
let id = device.output_ids.get(&crtc).copied().unwrap_or_else(|| {
error!("output ID missing for crtc: {crtc:?}");
OutputId::next()
});
ipc_outputs.insert(id, ipc_output);
}
}
@@ -1686,14 +1745,17 @@ impl Tty {
for (&crtc, surface) in device.surfaces.iter_mut() {
let tty_state: &TtyOutputState = output.user_data().get().unwrap();
if tty_state.node == node && tty_state.crtc == crtc {
try_to_change_vrr(
&device.drm,
surface.connector,
crtc,
surface,
output_state,
enable_vrr,
);
let word = if enable_vrr { "enabling" } else { "disabling" };
if let Err(err) = surface.compositor.use_vrr(enable_vrr) {
warn!(
"output {:?}: error {} VRR: {err:?}",
surface.name.connector, word
);
}
output_state
.frame_clock
.set_vrr(surface.compositor.vrr_enabled());
self.refresh_ipc_outputs(niri);
return;
}
@@ -1711,6 +1773,24 @@ impl Tty {
}
self.update_output_config_on_resume = false;
// Figure out if we should disable laptop panels.
let mut disable_laptop_panels = false;
if niri.is_lid_closed {
let config = self.config.borrow();
if !config.debug.keep_laptop_panel_on_when_lid_is_closed {
// Check if any external monitor is connected.
'outer: for device in self.devices.values() {
for (connector, _crtc) in device.drm_scanner.crtcs() {
if !is_laptop_panel(&format_connector_name(connector)) {
disable_laptop_panels = true;
break 'outer;
}
}
}
}
}
let should_disable = |connector: &str| disable_laptop_panels && is_laptop_panel(connector);
let mut to_disconnect = vec![];
let mut to_connect = vec![];
@@ -1723,7 +1803,7 @@ impl Tty {
.find(&surface.name)
.cloned()
.unwrap_or_default();
if config.off {
if config.off || should_disable(&surface.name.connector) {
to_disconnect.push((node, crtc));
continue;
}
@@ -1741,8 +1821,11 @@ impl Tty {
};
let change_mode = surface.compositor.pending_mode() != mode;
let change_always_vrr = surface.vrr_enabled != config.is_vrr_always_on();
let vrr_enabled = surface.compositor.vrr_enabled();
let change_always_vrr = vrr_enabled != config.is_vrr_always_on();
let is_on_demand_vrr = config.is_vrr_on_demand();
if !change_mode && !change_always_vrr && !is_on_demand_vrr {
continue;
}
@@ -1764,17 +1847,20 @@ impl Tty {
continue;
};
if (is_on_demand_vrr && surface.vrr_enabled != output_state.on_demand_vrr_enabled)
if (is_on_demand_vrr && vrr_enabled != output_state.on_demand_vrr_enabled)
|| (!is_on_demand_vrr && change_always_vrr)
{
try_to_change_vrr(
&device.drm,
connector.handle(),
crtc,
surface,
output_state,
!surface.vrr_enabled,
);
let vrr = !vrr_enabled;
let word = if vrr { "enabling" } else { "disabling" };
if let Err(err) = surface.compositor.use_vrr(vrr) {
warn!(
"output {:?}: error {} VRR: {err:?}",
surface.name.connector, word
);
}
output_state
.frame_clock
.set_vrr(surface.compositor.vrr_enabled());
}
if change_mode {
@@ -1806,12 +1892,17 @@ impl Tty {
let wl_mode = Mode::from(mode);
output.change_current_state(Some(wl_mode), None, None, None);
output.set_preferred(wl_mode);
output_state.frame_clock =
FrameClock::new(Some(refresh_interval(mode)), surface.vrr_enabled);
output_state.frame_clock = FrameClock::new(
Some(refresh_interval(mode)),
surface.compositor.vrr_enabled(),
);
niri.output_resized(&output);
}
}
let config = self.config.borrow();
let disable_monitor_names = config.debug.disable_monitor_names;
for (connector, crtc) in device.drm_scanner.crtcs() {
// Check if connected.
if connector.state() != connector::State::Connected {
@@ -1819,22 +1910,24 @@ impl Tty {
}
// Check if already enabled.
if device.surfaces.contains_key(&crtc) {
if device.surfaces.contains_key(&crtc)
|| device
.non_desktop_connectors
.contains(&(connector.handle(), crtc))
{
continue;
}
let connector_name = format_connector_name(connector);
let output_name = make_output_name(&device.drm, connector.handle(), connector_name);
let config = self
.config
.borrow()
let output_name = device.known_crtc_name(&crtc, connector, disable_monitor_names);
let config = config
.outputs
.find(&output_name)
.cloned()
.unwrap_or_default();
if !config.off {
to_connect.push((node, connector.clone(), crtc));
if !(config.off || should_disable(&output_name.connector)) {
to_connect.push((node, connector.clone(), crtc, output_name));
}
}
}
@@ -1843,7 +1936,11 @@ impl Tty {
self.connector_disconnected(niri, node, crtc);
}
for (node, connector, crtc) in to_connect {
// Sort by output name to get more predictable first focused output at initial compositor
// startup, when multiple connectors appear at once.
to_connect.sort_unstable_by(|a, b| a.3.compare(&b.3));
for (node, connector, crtc, _name) in to_connect {
if let Err(err) = self.connector_connected(niri, node, connector, crtc) {
warn!("error connecting connector: {err:?}");
}
@@ -1852,24 +1949,12 @@ impl Tty {
self.refresh_ipc_outputs(niri);
}
pub fn on_debug_config_changed(&mut self) {
let config = self.config.borrow();
let debug = &config.debug;
let use_direct_scanout = !debug.disable_direct_scanout;
// FIXME: reload other flags if possible?
for device in self.devices.values_mut() {
for surface in device.surfaces.values_mut() {
surface.compositor.use_direct_scanout(use_direct_scanout);
}
}
}
pub fn get_device_from_node(&mut self, node: DrmNode) -> Option<&mut OutputDevice> {
self.devices.get_mut(&node)
}
pub fn disconnected_connector_name_by_name_match(&self, target: &str) -> Option<OutputName> {
let disable_monitor_names = self.config.borrow().debug.disable_monitor_names;
for device in self.devices.values() {
for (connector, crtc) in device.drm_scanner.crtcs() {
// Check if connected.
@@ -1878,12 +1963,15 @@ impl Tty {
}
// Check if already enabled.
if device.surfaces.contains_key(&crtc) {
if device.surfaces.contains_key(&crtc)
|| device
.non_desktop_connectors
.contains(&(connector.handle(), crtc))
{
continue;
}
let connector_name = format_connector_name(connector);
let output_name = make_output_name(&device.drm, connector.handle(), connector_name);
let output_name = device.known_crtc_name(&crtc, connector, disable_monitor_names);
if output_name.matches(target) {
return Some(output_name);
}
@@ -2078,9 +2166,8 @@ fn surface_dmabuf_feedback(
let surface = compositor.surface();
let planes = surface.planes();
let plane_formats = surface
.plane_info()
.formats
let primary_plane_formats = surface.plane_info().formats.clone();
let primary_or_overlay_plane_formats = primary_plane_formats
.iter()
.chain(planes.overlay.iter().flat_map(|p| p.formats.iter()))
.copied()
@@ -2088,7 +2175,11 @@ fn surface_dmabuf_feedback(
// We limit the scan-out trache to formats we can also render from so that there is always a
// fallback render path available in case the supplied buffer can not be scanned out directly.
let mut scanout_formats = plane_formats
let mut primary_scanout_formats = primary_plane_formats
.intersection(&primary_formats)
.copied()
.collect::<Vec<_>>();
let mut primary_or_overlay_scanout_formats = primary_or_overlay_plane_formats
.intersection(&primary_formats)
.copied()
.collect::<Vec<_>>();
@@ -2096,17 +2187,32 @@ fn surface_dmabuf_feedback(
// HACK: AMD iGPU + dGPU systems share some modifiers between the two, and yet cross-device
// buffers produce a glitched scanout if the modifier is not Linear...
if primary_render_node != surface_render_node {
scanout_formats.retain(|f| f.modifier == Modifier::Linear);
primary_scanout_formats.retain(|f| f.modifier == Modifier::Linear);
primary_or_overlay_scanout_formats.retain(|f| f.modifier == Modifier::Linear);
}
let builder = DmabufFeedbackBuilder::new(primary_render_node.dev_id(), primary_formats);
trace!(
"primary scanout formats: {}, overlay adds: {}",
primary_scanout_formats.len(),
primary_or_overlay_scanout_formats.len() - primary_scanout_formats.len(),
);
// Prefer the primary-plane-only formats, then primary-or-overlay-plane formats. This will
// increase the chance of scanning out a client even with our disabled-by-default overlay
// planes.
let scanout = builder
.clone()
.add_preference_tranche(
surface_render_node.dev_id(),
Some(TrancheFlags::Scanout),
scanout_formats,
primary_scanout_formats,
)
.add_preference_tranche(
surface_render_node.dev_id(),
Some(TrancheFlags::Scanout),
primary_or_overlay_scanout_formats,
)
.build()?;
@@ -2369,24 +2475,6 @@ fn is_vrr_capable(device: &DrmDevice, connector: connector::Handle) -> Option<bo
info.value_type().convert_value(value).as_boolean()
}
fn set_vrr_enabled(device: &DrmDevice, crtc: crtc::Handle, enabled: bool) -> anyhow::Result<bool> {
let (prop, info, _) =
find_drm_property(device, crtc, "VRR_ENABLED").context("VRR_ENABLED property missing")?;
let value = property::Value::UnsignedRange(if enabled { 1 } else { 0 });
device
.set_property(crtc, prop, value.into())
.context("error setting VRR_ENABLED property")?;
let value = get_drm_property(device, crtc, prop)
.context("VRR_ENABLED property missing after setting")?;
match info.value_type().convert_value(value) {
property::Value::UnsignedRange(value) => Ok(value == 1),
property::Value::Boolean(value) => Ok(value),
_ => bail!("wrong VRR_ENABLED property type"),
}
}
pub fn set_gamma_for_crtc(
device: &DrmDevice,
crtc: crtc::Handle,
@@ -2432,43 +2520,6 @@ pub fn set_gamma_for_crtc(
Ok(())
}
fn try_to_change_vrr(
device: &DrmDevice,
connector: connector::Handle,
crtc: crtc::Handle,
surface: &mut Surface,
output_state: &mut crate::niri::OutputState,
enable_vrr: bool,
) {
let _span = tracy_client::span!("try_to_change_vrr");
if is_vrr_capable(device, connector) == Some(true) {
let word = if enable_vrr { "enabling" } else { "disabling" };
match set_vrr_enabled(device, crtc, enable_vrr) {
Ok(enabled) => {
if enabled != enable_vrr {
warn!("output {:?}: failed {} VRR", surface.name.connector, word);
}
surface.vrr_enabled = enabled;
output_state.frame_clock.set_vrr(enabled);
}
Err(err) => {
warn!(
"output {:?}: error {} VRR: {err:?}",
surface.name.connector, word
);
}
}
} else if enable_vrr {
warn!(
"output {:?}: cannot enable VRR because connector is not vrr_capable",
surface.name.connector
);
}
}
fn format_connector_name(connector: &connector::Info) -> String {
format!(
"{}-{}",
+3 -5
View File
@@ -3,7 +3,6 @@ use std::collections::HashMap;
use std::mem;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use niri_config::{Config, OutputName};
use smithay::backend::allocator::dmabuf::Dmabuf;
@@ -16,6 +15,7 @@ use smithay::reexports::calloop::LoopHandle;
use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;
use smithay::reexports::winit::dpi::LogicalSize;
use smithay::reexports::winit::window::Window;
use smithay::wayland::presentation::Refresh;
use super::{IpcOutputMap, OutputId, RenderResult};
use crate::niri::{Niri, RedrawState, State};
@@ -156,7 +156,7 @@ impl Winit {
}
drop(config);
niri.layout.update_shaders();
niri.update_shaders();
niri.add_output(self.output.clone(), None, false);
}
@@ -216,11 +216,9 @@ impl Winit {
self.backend.submit(Some(damage)).unwrap();
let mut presentation_feedbacks = niri.take_presentation_feedbacks(output, &res.states);
let mode = output.current_mode().unwrap();
let refresh = Duration::from_secs_f64(1_000f64 / mode.refresh as f64);
presentation_feedbacks.presented::<_, smithay::utils::Monotonic>(
get_monotonic_time(),
refresh,
Refresh::Unknown,
0,
wp_presentation_feedback::Kind::empty(),
);
+2
View File
@@ -64,6 +64,8 @@ pub enum Msg {
Workspaces,
/// List open windows.
Windows,
/// List open layer-shell surfaces.
Layers,
/// Get the configured keyboard layouts.
KeyboardLayouts,
/// Print information about the focused output.
+2 -3
View File
@@ -4,12 +4,11 @@ use std::env;
use std::fs::File;
use std::io::Read;
use std::rc::Rc;
use std::sync::Mutex;
use anyhow::{anyhow, Context};
use smithay::backend::allocator::Fourcc;
use smithay::backend::renderer::element::memory::MemoryRenderBuffer;
use smithay::input::pointer::{CursorIcon, CursorImageAttributes, CursorImageStatus};
use smithay::input::pointer::{CursorIcon, CursorImageStatus, CursorImageSurfaceData};
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
use smithay::utils::{IsAlive, Logical, Physical, Point, Transform};
use smithay::wayland::compositor::with_states;
@@ -67,7 +66,7 @@ impl CursorManager {
let hotspot = with_states(&surface, |states| {
states
.data_map
.get::<Mutex<CursorImageAttributes>>()
.get::<CursorImageSurfaceData>()
.unwrap()
.lock()
.unwrap()
+5 -4
View File
@@ -6,9 +6,10 @@ use std::sync::{Arc, Mutex, OnceLock};
use anyhow::Context;
use futures_util::StreamExt;
use zbus::fdo::{self, RequestNameFlags};
use zbus::message::Header;
use zbus::names::{OwnedUniqueName, UniqueName};
use zbus::zvariant::NoneValue;
use zbus::{dbus_interface, MessageHeader, Task};
use zbus::{interface, Task};
use super::Start;
@@ -20,11 +21,11 @@ pub struct ScreenSaver {
monitor_task: Arc<OnceLock<Task<()>>>,
}
#[dbus_interface(name = "org.freedesktop.ScreenSaver")]
#[interface(name = "org.freedesktop.ScreenSaver")]
impl ScreenSaver {
async fn inhibit(
&mut self,
#[zbus(header)] hdr: MessageHeader<'_>,
#[zbus(header)] hdr: Header<'_>,
application_name: &str,
reason_for_inhibit: &str,
) -> fdo::Result<u32> {
@@ -33,7 +34,7 @@ impl ScreenSaver {
hdr.sender()
);
let Ok(Some(name)) = hdr.sender() else {
let Some(name) = hdr.sender() else {
return Err(fdo::Error::Failed(String::from("no sender")));
};
let name = OwnedUniqueName::from(name.to_owned());
+5 -4
View File
@@ -1,8 +1,9 @@
use std::collections::HashMap;
use zbus::fdo::{self, RequestNameFlags};
use zbus::interface;
use zbus::object_server::SignalEmitter;
use zbus::zvariant::{SerializeDict, Type, Value};
use zbus::{dbus_interface, SignalContext};
use super::Start;
@@ -33,7 +34,7 @@ pub struct WindowProperties {
pub app_id: String,
}
#[dbus_interface(name = "org.gnome.Shell.Introspect")]
#[interface(name = "org.gnome.Shell.Introspect")]
impl Introspect {
async fn get_windows(&self) -> fdo::Result<HashMap<u64, WindowProperties>> {
if let Err(err) = self.to_niri.send(IntrospectToNiri::GetWindows) {
@@ -52,8 +53,8 @@ impl Introspect {
// FIXME: call this upon window changes, once more of the infrastructure is there (will be
// needed for the event stream IPC anyway).
#[dbus_interface(signal)]
pub async fn windows_changed(ctxt: &SignalContext<'_>) -> zbus::Result<()>;
#[zbus(signal)]
pub async fn windows_changed(ctxt: &SignalEmitter<'_>) -> zbus::Result<()>;
}
impl Introspect {
+2 -2
View File
@@ -1,7 +1,7 @@
use std::path::PathBuf;
use zbus::dbus_interface;
use zbus::fdo::{self, RequestNameFlags};
use zbus::interface;
use super::Start;
@@ -18,7 +18,7 @@ pub enum NiriToScreenshot {
ScreenshotResult(Option<PathBuf>),
}
#[dbus_interface(name = "org.gnome.Shell.Screenshot")]
#[interface(name = "org.gnome.Shell.Screenshot")]
impl Screenshot {
async fn screenshot(
&self,
+31 -6
View File
@@ -1,5 +1,5 @@
use zbus::blocking::Connection;
use zbus::Interface;
use zbus::object_server::Interface;
use crate::niri::State;
@@ -45,12 +45,39 @@ impl DBusServers {
let mut dbus = Self::default();
if is_session_instance {
let service_channel = ServiceChannel::new(niri.display_handle.clone());
let (to_niri, from_service_channel) = calloop::channel::channel();
let service_channel = ServiceChannel::new(to_niri);
niri.event_loop
.insert_source(from_service_channel, move |event, _, state| match event {
calloop::channel::Event::Msg(new_client) => {
state.niri.insert_client(new_client);
}
calloop::channel::Event::Closed => (),
})
.unwrap();
dbus.conn_service_channel = try_start(service_channel);
}
if is_session_instance || config.debug.dbus_interfaces_in_non_session_instances {
let display_config = DisplayConfig::new(backend.ipc_outputs());
let (to_niri, from_display_config) = calloop::channel::channel();
let display_config = DisplayConfig::new(to_niri, backend.ipc_outputs());
niri.event_loop
.insert_source(from_display_config, move |event, _, state| match event {
calloop::channel::Event::Msg(new_conf) => {
for (name, conf) in new_conf {
state.modify_output_config(&name, move |output| {
if let Some(new_output) = conf {
*output = new_output;
} else {
output.off = true;
}
});
}
state.reload_output_config();
}
calloop::channel::Event::Closed => (),
})
.unwrap();
dbus.conn_display_config = try_start(display_config);
let screen_saver = ScreenSaver::new(niri.is_fdo_idle_inhibited.clone());
@@ -83,7 +110,7 @@ impl DBusServers {
dbus.conn_introspect = try_start(introspect);
#[cfg(feature = "xdp-gnome-screencast")]
if niri.pipewire.is_some() {
{
let (to_niri, from_screen_cast) = calloop::channel::channel();
niri.event_loop
.insert_source(from_screen_cast, {
@@ -95,8 +122,6 @@ impl DBusServers {
.unwrap();
let screen_cast = ScreenCast::new(backend.ipc_outputs(), to_niri);
dbus.conn_screen_cast = try_start(screen_cast);
} else {
warn!("disabling screencast support because we couldn't start PipeWire");
}
}
+209 -81
View File
@@ -1,15 +1,21 @@
use std::collections::HashMap;
use std::str::FromStr;
use std::sync::{Arc, Mutex};
use serde::Serialize;
use serde::{Deserialize, Serialize};
use smithay::utils::Size;
use zbus::fdo::RequestNameFlags;
use zbus::object_server::SignalEmitter;
use zbus::zvariant::{self, OwnedValue, Type};
use zbus::{dbus_interface, fdo, SignalContext};
use zbus::{fdo, interface};
use super::Start;
use crate::backend::IpcOutputMap;
use crate::utils::is_laptop_panel;
use crate::utils::scale::supported_scales;
pub struct DisplayConfig {
to_niri: calloop::channel::Sender<HashMap<String, Option<niri_config::Output>>>,
ipc_outputs: Arc<Mutex<IpcOutputMap>>,
}
@@ -42,7 +48,18 @@ pub struct LogicalMonitor {
properties: HashMap<String, OwnedValue>,
}
#[dbus_interface(name = "org.gnome.Mutter.DisplayConfig")]
// ApplyMonitorsConfig
#[derive(Deserialize, Type)]
pub struct LogicalMonitorConfiguration {
x: i32,
y: i32,
scale: f64,
transform: u32,
_is_primary: bool,
monitors: Vec<(String, String, HashMap<String, OwnedValue>)>,
}
#[interface(name = "org.gnome.Mutter.DisplayConfig")]
impl DisplayConfig {
async fn get_current_state(
&self,
@@ -53,75 +70,70 @@ impl DisplayConfig {
HashMap<String, OwnedValue>,
)> {
// Construct the DBus response.
let mut monitors: Vec<(Monitor, LogicalMonitor)> = self
.ipc_outputs
.lock()
.unwrap()
.values()
// Take only enabled outputs.
.filter(|output| output.current_mode.is_some() && output.logical.is_some())
.map(|output| {
// Loosely matches the check in Mutter.
let c = &output.name;
let is_laptop_panel = matches!(c.get(..4), Some("eDP-" | "LVDS" | "DSI-"));
let display_name = make_display_name(output, is_laptop_panel);
let mut monitors = Vec::new();
let mut logical_monitors = Vec::new();
let mut properties = HashMap::new();
properties.insert(
String::from("display-name"),
OwnedValue::from(zvariant::Str::from(display_name)),
);
properties.insert(
String::from("is-builtin"),
OwnedValue::from(is_laptop_panel),
);
for output in self.ipc_outputs.lock().unwrap().values() {
// Loosely matches the check in Mutter.
let c = &output.name;
let is_laptop_panel = is_laptop_panel(c);
let display_name = make_display_name(output, is_laptop_panel);
let mut modes: Vec<Mode> = output
.modes
.iter()
.map(|m| {
let niri_ipc::Mode {
width,
height,
refresh_rate,
is_preferred,
} = *m;
let refresh = refresh_rate as f64 / 1000.;
let mut properties = HashMap::new();
properties.insert(
String::from("display-name"),
OwnedValue::from(zvariant::Str::from(display_name)),
);
properties.insert(
String::from("is-builtin"),
OwnedValue::from(is_laptop_panel),
);
Mode {
id: format!("{width}x{height}@{refresh:.3}"),
width: i32::from(width),
height: i32::from(height),
refresh_rate: refresh,
preferred_scale: 1.,
supported_scales: vec![1., 2., 3.],
properties: HashMap::from([(
String::from("is-preferred"),
OwnedValue::from(is_preferred),
)]),
}
})
.collect();
modes[output.current_mode.unwrap()]
let mut modes: Vec<Mode> = output
.modes
.iter()
.map(|m| {
let niri_ipc::Mode {
width,
height,
refresh_rate,
is_preferred,
} = *m;
let width = i32::from(width);
let height = i32::from(height);
let refresh_rate = refresh_rate as f64 / 1000.;
Mode {
id: format!("{width}x{height}@{refresh_rate:.3}"),
width,
height,
refresh_rate,
preferred_scale: 1.,
supported_scales: supported_scales(Size::from((width, height))).collect(),
properties: HashMap::from([(
String::from("is-preferred"),
OwnedValue::from(is_preferred),
)]),
}
})
.collect();
if let Some(mode) = output.current_mode {
modes[mode]
.properties
.insert(String::from("is-current"), OwnedValue::from(true));
}
let connector = c.clone();
let model = output.model.clone();
let make = output.make.clone();
let connector = c.clone();
let model = output.model.clone();
let make = output.make.clone();
// Serial is used for session restore, so fall back to the connector name if it's
// not available.
let serial = output.serial.as_ref().unwrap_or(&connector).clone();
// Serial is used for session restore, so fall back to the connector name if it's
// not available.
let serial = output.serial.as_ref().unwrap_or(&connector).clone();
let monitor = Monitor {
names: (connector, make, model, serial),
modes,
properties,
};
let logical = output.logical.as_ref().unwrap();
let names = (connector, make, model, serial);
if let Some(logical) = output.logical.as_ref() {
let transform = match logical.transform {
niri_ipc::Transform::Normal => 0,
niri_ipc::Transform::_90 => 1,
@@ -133,35 +145,151 @@ impl DisplayConfig {
niri_ipc::Transform::Flipped270 => 7,
};
let logical_monitor = LogicalMonitor {
logical_monitors.push(LogicalMonitor {
x: logical.x,
y: logical.y,
scale: logical.scale,
transform,
is_primary: false,
monitors: vec![monitor.names.clone()],
monitors: vec![names.clone()],
properties: HashMap::new(),
};
});
}
(monitor, logical_monitor)
})
.collect();
monitors.push(Monitor {
names,
modes,
properties,
});
}
// Sort by connector.
monitors.sort_unstable_by(|a, b| a.0.names.0.cmp(&b.0.names.0));
monitors.sort_unstable_by(|a, b| a.names.0.cmp(&b.names.0));
logical_monitors.sort_unstable_by(|a, b| a.monitors[0].0.cmp(&b.monitors[0].0));
let (monitors, logical_monitors) = monitors.into_iter().unzip();
let properties = HashMap::from([(String::from("layout-mode"), OwnedValue::from(1u32))]);
Ok((0, monitors, logical_monitors, properties))
}
#[dbus_interface(signal)]
pub async fn monitors_changed(ctxt: &SignalContext<'_>) -> zbus::Result<()>;
async fn apply_monitors_config(
&self,
_serial: u32,
method: u32,
logical_monitor_configs: Vec<LogicalMonitorConfiguration>,
_properties: HashMap<String, OwnedValue>,
) -> fdo::Result<()> {
let current_conf = self.ipc_outputs.lock().unwrap();
let mut new_conf = HashMap::new();
for requested_config in logical_monitor_configs {
if requested_config.monitors.len() > 1 {
return Err(zbus::fdo::Error::Failed(
"Mirroring is not yet supported".to_owned(),
));
}
for (connector, mode, _props) in requested_config.monitors {
if !current_conf.values().any(|o| o.name == connector) {
return Err(zbus::fdo::Error::Failed(format!(
"Connector '{}' not found",
connector
)));
}
new_conf.insert(
connector.clone(),
Some(niri_config::Output {
off: false,
name: connector,
scale: Some(niri_config::FloatOrInt(requested_config.scale)),
transform: match requested_config.transform {
0 => niri_ipc::Transform::Normal,
1 => niri_ipc::Transform::_90,
2 => niri_ipc::Transform::_180,
3 => niri_ipc::Transform::_270,
4 => niri_ipc::Transform::Flipped,
5 => niri_ipc::Transform::Flipped90,
6 => niri_ipc::Transform::Flipped180,
7 => niri_ipc::Transform::Flipped270,
x => {
return Err(zbus::fdo::Error::Failed(format!(
"Unknown transform {}",
x
)))
}
},
position: Some(niri_config::Position {
x: requested_config.x,
y: requested_config.y,
}),
mode: Some(niri_ipc::ConfiguredMode::from_str(&mode).map_err(|e| {
zbus::fdo::Error::Failed(format!(
"Could not parse mode '{}': {}",
mode, e
))
})?),
// FIXME: VRR
..Default::default()
}),
);
}
}
if new_conf.is_empty() {
return Err(zbus::fdo::Error::Failed(
"At least one output must be enabled".to_owned(),
));
}
for output in current_conf.values() {
if !new_conf.contains_key(&output.name) {
new_conf.insert(output.name.clone(), None);
}
}
if method == 0 {
// 0 means "verify", so don't actually apply here
return Ok(());
}
if let Err(err) = self.to_niri.send(new_conf) {
warn!("error sending message to niri: {err:?}");
return Err(fdo::Error::Failed("internal error".to_owned()));
}
Ok(())
}
#[zbus(signal)]
pub async fn monitors_changed(ctxt: &SignalEmitter<'_>) -> zbus::Result<()>;
#[zbus(property)]
fn power_save_mode(&self) -> i32 {
-1
}
#[zbus(property)]
fn set_power_save_mode(&self, _mode: i32) -> zbus::Result<()> {
Err(zbus::Error::Unsupported)
}
#[zbus(property)]
fn panel_orientation_managed(&self) -> bool {
false
}
#[zbus(property)]
fn apply_monitors_config_allowed(&self) -> bool {
true
}
#[zbus(property)]
fn night_light_supported(&self) -> bool {
false
}
}
impl DisplayConfig {
pub fn new(ipc_outputs: Arc<Mutex<IpcOutputMap>>) -> Self {
Self { ipc_outputs }
pub fn new(
to_niri: calloop::channel::Sender<HashMap<String, Option<niri_config::Output>>>,
ipc_outputs: Arc<Mutex<IpcOutputMap>>,
) -> Self {
Self {
to_niri,
ipc_outputs,
}
}
}
@@ -211,16 +339,16 @@ fn format_diagonal(diagonal_inches: f64) -> String {
#[cfg(test)]
mod tests {
use k9::snapshot;
use insta::assert_snapshot;
use super::*;
#[test]
fn test_format_diagonal() {
snapshot!(format_diagonal(12.11), "12.1″");
snapshot!(format_diagonal(13.28), "13.3″");
snapshot!(format_diagonal(15.6), "15.6″");
snapshot!(format_diagonal(23.2), "23″");
snapshot!(format_diagonal(24.8), "25″");
assert_snapshot!(format_diagonal(12.11), @"12.1″");
assert_snapshot!(format_diagonal(13.28), @"13.3″");
assert_snapshot!(format_diagonal(15.6), @"15.6″");
assert_snapshot!(format_diagonal(23.2), @"23″");
assert_snapshot!(format_diagonal(24.8), @"25″");
}
}
+16 -15
View File
@@ -5,8 +5,9 @@ use std::sync::{Arc, Mutex};
use serde::Deserialize;
use zbus::fdo::RequestNameFlags;
use zbus::object_server::{InterfaceRef, SignalEmitter};
use zbus::zvariant::{DeserializeDict, OwnedObjectPath, SerializeDict, Type, Value};
use zbus::{dbus_interface, fdo, InterfaceRef, ObjectServer, SignalContext};
use zbus::{fdo, interface, ObjectServer};
use super::Start;
use crate::backend::IpcOutputMap;
@@ -94,14 +95,14 @@ pub enum ScreenCastToNiri {
session_id: usize,
target: StreamTargetId,
cursor_mode: CursorMode,
signal_ctx: SignalContext<'static>,
signal_ctx: SignalEmitter<'static>,
},
StopCast {
session_id: usize,
},
}
#[dbus_interface(name = "org.gnome.Mutter.ScreenCast")]
#[interface(name = "org.gnome.Mutter.ScreenCast")]
impl ScreenCast {
async fn create_session(
&self,
@@ -136,26 +137,26 @@ impl ScreenCast {
Ok(path)
}
#[dbus_interface(property)]
#[zbus(property)]
async fn version(&self) -> i32 {
4
}
}
#[dbus_interface(name = "org.gnome.Mutter.ScreenCast.Session")]
#[interface(name = "org.gnome.Mutter.ScreenCast.Session")]
impl Session {
async fn start(&self) {
debug!("start");
for (stream, iface) in &*self.streams.lock().unwrap() {
stream.start(self.id, iface.signal_context().clone());
stream.start(self.id, iface.signal_emitter().clone());
}
}
pub async fn stop(
&self,
#[zbus(object_server)] server: &ObjectServer,
#[zbus(signal_context)] ctxt: SignalContext<'_>,
#[zbus(signal_context)] ctxt: SignalEmitter<'_>,
) {
debug!("stop");
@@ -175,7 +176,7 @@ impl Session {
let streams = mem::take(&mut *self.streams.lock().unwrap());
for (_, iface) in streams.iter() {
server
.remove::<Stream, _>(iface.signal_context().path())
.remove::<Stream, _>(iface.signal_emitter().path())
.await
.unwrap();
}
@@ -264,17 +265,17 @@ impl Session {
Ok(path)
}
#[dbus_interface(signal)]
async fn closed(ctxt: &SignalContext<'_>) -> zbus::Result<()>;
#[zbus(signal)]
async fn closed(ctxt: &SignalEmitter<'_>) -> zbus::Result<()>;
}
#[dbus_interface(name = "org.gnome.Mutter.ScreenCast.Stream")]
#[interface(name = "org.gnome.Mutter.ScreenCast.Stream")]
impl Stream {
#[dbus_interface(signal)]
pub async fn pipe_wire_stream_added(ctxt: &SignalContext<'_>, node_id: u32)
#[zbus(signal)]
pub async fn pipe_wire_stream_added(ctxt: &SignalEmitter<'_>, node_id: u32)
-> zbus::Result<()>;
#[dbus_interface(property)]
#[zbus(property)]
async fn parameters(&self) -> StreamParameters {
match &self.target {
StreamTarget::Output(output) => {
@@ -361,7 +362,7 @@ impl Stream {
}
}
fn start(&self, session_id: usize, ctxt: SignalContext<'static>) {
fn start(&self, session_id: usize, ctxt: SignalEmitter<'static>) {
if self.was_started.load(Ordering::SeqCst) {
return;
}
+20 -19
View File
@@ -1,50 +1,51 @@
use std::os::fd::{FromRawFd, IntoRawFd};
use std::os::unix::net::UnixStream;
use std::sync::Arc;
use smithay::reexports::wayland_server::DisplayHandle;
use zbus::dbus_interface;
use zbus::{fdo, interface, zvariant};
use super::Start;
use crate::niri::ClientState;
use crate::niri::NewClient;
pub struct ServiceChannel {
display: DisplayHandle,
to_niri: calloop::channel::Sender<NewClient>,
}
#[dbus_interface(name = "org.gnome.Mutter.ServiceChannel")]
#[interface(name = "org.gnome.Mutter.ServiceChannel")]
impl ServiceChannel {
async fn open_wayland_service_connection(
&mut self,
service_client_type: u32,
) -> zbus::fdo::Result<zbus::zvariant::OwnedFd> {
) -> fdo::Result<zvariant::OwnedFd> {
if service_client_type != 1 {
return Err(zbus::fdo::Error::InvalidArgs(
return Err(fdo::Error::InvalidArgs(
"Invalid service client type".to_owned(),
));
}
let (sock1, sock2) = UnixStream::pair().unwrap();
let data = Arc::new(ClientState {
compositor_state: Default::default(),
// Would be nice to thread config here but for now it's fine.
can_view_decoration_globals: false,
let client = NewClient {
client: sock2,
restricted: false,
});
self.display.insert_client(sock2, data).unwrap();
Ok(unsafe { zbus::zvariant::OwnedFd::from_raw_fd(sock1.into_raw_fd()) })
// FIXME: maybe you can get the PID from D-Bus somehow?
credentials_unknown: true,
};
if let Err(err) = self.to_niri.send(client) {
warn!("error sending message to niri: {err:?}");
return Err(fdo::Error::Failed("internal error".to_owned()));
}
Ok(zvariant::OwnedFd::from(std::os::fd::OwnedFd::from(sock1)))
}
}
impl ServiceChannel {
pub fn new(display: DisplayHandle) -> Self {
Self { display }
pub fn new(to_niri: calloop::channel::Sender<NewClient>) -> Self {
Self { to_niri }
}
}
impl Start for ServiceChannel {
fn start(self) -> anyhow::Result<zbus::blocking::Connection> {
let conn = zbus::blocking::ConnectionBuilder::session()?
let conn = zbus::blocking::connection::Builder::session()?
.name("org.gnome.Mutter.ServiceChannel")?
.serve_at("/org/gnome/Mutter/ServiceChannel", self)?
.build()?;
+108 -37
View File
@@ -1,5 +1,6 @@
use std::collections::hash_map::Entry;
use niri_ipc::PositionChange;
use smithay::backend::renderer::utils::{on_commit_buffer_handler, with_renderer_surface_state};
use smithay::input::pointer::{CursorImageStatus, CursorImageSurfaceData};
use smithay::reexports::calloop::Interest;
@@ -18,6 +19,8 @@ use smithay::wayland::shm::{ShmHandler, ShmState};
use smithay::{delegate_compositor, delegate_shm};
use super::xdg_shell::add_mapped_toplevel_pre_commit_hook;
use crate::handlers::XDG_ACTIVATION_TOKEN_TIMEOUT;
use crate::layout::{ActivateWindow, AddWindowTarget};
use crate::niri::{ClientState, State};
use crate::utils::send_scale_transform;
use crate::utils::transaction::Transaction;
@@ -84,16 +87,23 @@ impl CompositorHandler for State {
if is_mapped {
// The toplevel got mapped.
let Unmapped { window, state } = entry.remove();
let Unmapped {
window,
state,
activation_token_data,
} = entry.remove();
window.on_commit();
let toplevel = window.toplevel().expect("no X11 support");
let (rules, width, is_full_width, output, workspace_name) =
let (rules, width, height, is_full_width, output, workspace_id) =
if let InitialConfigureState::Configured {
rules,
width,
height,
floating_width: _,
floating_height: _,
is_full_width,
output,
workspace_name,
@@ -104,15 +114,48 @@ impl CompositorHandler for State {
output.filter(|o| self.niri.layout.monitor_for_output(o).is_some());
// Check that the workspace still exists.
let workspace_name = workspace_name
.filter(|n| self.niri.layout.find_workspace_by_name(n).is_some());
let workspace_id = workspace_name
.as_deref()
.and_then(|n| self.niri.layout.find_workspace_by_name(n))
.map(|(_, ws)| ws.id());
(rules, width, is_full_width, output, workspace_name)
(rules, width, height, is_full_width, output, workspace_id)
} else {
error!("window map must happen after initial configure");
(ResolvedWindowRules::empty(), None, false, None, None)
(ResolvedWindowRules::empty(), None, None, false, None, None)
};
// The GTK about dialog sets min/max size after the initial configure but
// before mapping, so we need to compute open_floating at the last possible
// moment, that is here.
let is_floating = rules.compute_open_floating(toplevel);
// Figure out if we should activate the window.
let activate = rules.open_focused.map(|focus| {
if focus {
ActivateWindow::Yes
} else {
ActivateWindow::No
}
});
let activate = activate.unwrap_or_else(|| {
// Check the token timestamp again in case the window took a while between
// requesting activation and mapping.
let token = activation_token_data.filter(|token| {
token.timestamp.elapsed() < XDG_ACTIVATION_TOKEN_TIMEOUT
});
if token.is_some() {
ActivateWindow::Yes
} else {
let config = self.niri.config.borrow();
if config.debug.strict_new_window_focus_policy {
ActivateWindow::No
} else {
ActivateWindow::Smart
}
}
});
let parent = toplevel
.parent()
.and_then(|parent| self.niri.layout.find_window_and_output(&parent))
@@ -123,7 +166,9 @@ impl CompositorHandler for State {
// None. If the configured output is set, that means it was set explicitly
// by a window rule or a fullscreen request.
.filter(|(_, parent_output)| {
output.is_none() || output.as_ref() == Some(*parent_output)
parent_output.is_none()
|| output.is_none()
|| output.as_ref() == *parent_output
})
.map(|(mapped, _)| mapped.window.clone());
@@ -133,34 +178,34 @@ impl CompositorHandler for State {
let mapped = Mapped::new(window, rules, hook);
let window = mapped.window.clone();
let output = if let Some(p) = parent {
// Open dialogs immediately to the right of their parent window.
self.niri
.layout
.add_window_right_of(&p, mapped, width, is_full_width)
} else if let Some(workspace_name) = &workspace_name {
self.niri.layout.add_window_to_named_workspace(
workspace_name,
mapped,
width,
is_full_width,
)
let target = if let Some(p) = &parent {
// Open dialogs next to their parent window.
AddWindowTarget::NextTo(p)
} else if let Some(id) = workspace_id {
AddWindowTarget::Workspace(id)
} else if let Some(output) = &output {
self.niri
.layout
.add_window_on_output(output, mapped, width, is_full_width);
Some(output)
AddWindowTarget::Output(output)
} else {
self.niri.layout.add_window(mapped, width, is_full_width)
AddWindowTarget::Auto
};
let output = self.niri.layout.add_window(
mapped,
target,
width,
height,
is_full_width,
is_floating,
activate,
);
if let Some(output) = output.cloned() {
self.niri.layout.start_open_animation_for_window(&window);
let new_active_window =
self.niri.layout.active_window().map(|(m, _)| &m.window);
if new_active_window == Some(&window) {
let new_focus = self.niri.layout.focus().map(|m| &m.window);
if new_focus == Some(&window) {
// We activated the newly opened window.
self.maybe_warp_cursor_to_focus();
self.niri.layer_shell_on_demand_focus = None;
}
self.niri.queue_redraw(&output);
@@ -180,7 +225,7 @@ impl CompositorHandler for State {
// This is a commit of a previously-mapped root or a non-toplevel root.
if let Some((mapped, output)) = self.niri.layout.find_window_and_output(surface) {
let window = mapped.window.clone();
let output = output.clone();
let output = output.cloned();
#[cfg(feature = "xdp-gnome-screencast")]
let id = mapped.id();
@@ -210,7 +255,7 @@ impl CompositorHandler for State {
// The toplevel got unmapped.
//
// Test client: wleird-unmap.
let active_window = self.niri.layout.active_window().map(|(m, _)| &m.window);
let active_window = self.niri.layout.focus().map(|m| &m.window);
let was_active = active_window == Some(&window);
#[cfg(feature = "xdp-gnome-screencast")]
@@ -237,18 +282,27 @@ impl CompositorHandler for State {
let unmapped = Unmapped::new(window);
self.niri.unmapped_windows.insert(surface.clone(), unmapped);
self.niri.queue_redraw(&output);
if let Some(output) = output {
self.niri.queue_redraw(&output);
}
return;
}
let serial = with_states(surface, |states| {
let (serial, buffer_delta) = with_states(surface, |states| {
let buffer_delta = states
.cached_state
.get::<SurfaceAttributes>()
.current()
.buffer_delta
.take();
let role = states
.data_map
.get::<XdgToplevelSurfaceData>()
.unwrap()
.lock()
.unwrap();
role.configure_serial
(role.configure_serial, buffer_delta)
});
if serial.is_none() {
error!("commit on a mapped surface without a configured serial");
@@ -257,10 +311,25 @@ impl CompositorHandler for State {
// The toplevel remains mapped.
self.niri.layout.update_window(&window, serial);
// Popup placement depends on window size which might have changed.
self.update_reactive_popups(&window, &output);
// Move the toplevel according to the attach offset.
if let Some(delta) = buffer_delta {
if delta.x != 0 || delta.y != 0 {
let (x, y) = delta.to_f64().into();
self.niri.layout.move_floating_window(
Some(&window),
PositionChange::AdjustFixed(x),
PositionChange::AdjustFixed(y),
false,
);
}
}
self.niri.queue_redraw(&output);
// Popup placement depends on window size which might have changed.
self.update_reactive_popups(&window);
if let Some(output) = output {
self.niri.queue_redraw(&output);
}
return;
}
@@ -271,10 +340,12 @@ impl CompositorHandler for State {
let root_window_output = self.niri.layout.find_window_and_output(&root_surface);
if let Some((mapped, output)) = root_window_output {
let window = mapped.window.clone();
let output = output.clone();
let output = output.cloned();
window.on_commit();
self.niri.layout.update_window(&window, None);
self.niri.queue_redraw(&output);
if let Some(output) = output {
self.niri.queue_redraw(&output);
}
return;
}
+19
View File
@@ -11,6 +11,7 @@ use smithay::wayland::shell::wlr_layer::{
};
use smithay::wayland::shell::xdg::PopupSurface;
use crate::layer::{MappedLayer, ResolvedLayerRules};
use crate::niri::State;
use crate::utils::send_scale_transform;
@@ -60,6 +61,7 @@ impl WlrLayerShellHandler for State {
layer.map(|layer| (o.clone(), map, layer))
}) {
map.unmap_layer(&layer);
self.niri.mapped_layer_surfaces.remove(&layer);
Some(output)
} else {
None
@@ -128,6 +130,22 @@ impl State {
if is_mapped {
let was_unmapped = self.niri.unmapped_layer_surfaces.remove(surface);
// Resolve rules for newly mapped layer surfaces.
if was_unmapped {
let config = self.niri.config.borrow();
let rules = &config.layer_rules;
let rules =
ResolvedLayerRules::compute(rules, layer, self.niri.is_at_startup);
let mapped = MappedLayer::new(layer.clone(), rules, &config);
let prev = self
.niri
.mapped_layer_surfaces
.insert(layer.clone(), mapped);
if prev.is_some() {
error!("MappedLayer was present for an unmapped surface");
}
}
// Give focus to newly mapped on-demand surfaces. Some launchers like
// lxqt-runner rely on this behavior. While this behavior doesn't make much
// sense for other clients like panels, the consensus seems to be that it's not
@@ -151,6 +169,7 @@ impl State {
self.niri.layer_shell_on_demand_focus = Some(layer.clone());
}
} else {
self.niri.mapped_layer_surfaces.remove(layer);
self.niri.unmapped_layer_surfaces.insert(surface.clone());
}
} else {
+157 -47
View File
@@ -7,10 +7,11 @@ use std::io::Write;
use std::os::fd::OwnedFd;
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::drm::DrmNode;
use smithay::backend::input::TabletToolDescriptor;
use smithay::backend::input::{InputEvent, TabletToolDescriptor};
use smithay::desktop::{PopupKind, PopupManager};
use smithay::input::pointer::{
CursorIcon, CursorImageStatus, CursorImageSurfaceData, PointerHandle,
@@ -34,6 +35,9 @@ use smithay::wayland::fractional_scale::FractionalScaleHandler;
use smithay::wayland::idle_inhibit::IdleInhibitHandler;
use smithay::wayland::idle_notify::{IdleNotifierHandler, IdleNotifierState};
use smithay::wayland::input_method::{InputMethodHandler, PopupSurface};
use smithay::wayland::keyboard_shortcuts_inhibit::{
KeyboardShortcutsInhibitHandler, KeyboardShortcutsInhibitState, KeyboardShortcutsInhibitor,
};
use smithay::wayland::output::OutputHandler;
use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraintsHandler};
use smithay::wayland::security_context::{
@@ -43,10 +47,15 @@ use smithay::wayland::selection::data_device::{
set_data_device_focus, ClientDndGrabHandler, DataDeviceHandler, DataDeviceState,
ServerDndGrabHandler,
};
use smithay::wayland::selection::ext_data_control::{
DataControlHandler as ExtDataControlHandler, DataControlState as ExtDataControlState,
};
use smithay::wayland::selection::primary_selection::{
set_primary_focus, PrimarySelectionHandler, PrimarySelectionState,
};
use smithay::wayland::selection::wlr_data_control::{DataControlHandler, DataControlState};
use smithay::wayland::selection::wlr_data_control::{
DataControlHandler as WlrDataControlHandler, DataControlState as WlrDataControlState,
};
use smithay::wayland::selection::{SelectionHandler, SelectionTarget};
use smithay::wayland::session_lock::{
LockSurface, SessionLockHandler, SessionLockManagerState, SessionLocker,
@@ -57,16 +66,17 @@ use smithay::wayland::xdg_activation::{
};
use smithay::{
delegate_cursor_shape, delegate_data_control, delegate_data_device, delegate_dmabuf,
delegate_drm_lease, delegate_fractional_scale, delegate_idle_inhibit, delegate_idle_notify,
delegate_input_method_manager, delegate_output, delegate_pointer_constraints,
delegate_drm_lease, delegate_ext_data_control, delegate_fractional_scale,
delegate_idle_inhibit, delegate_idle_notify, delegate_input_method_manager,
delegate_keyboard_shortcuts_inhibit, delegate_output, delegate_pointer_constraints,
delegate_pointer_gestures, delegate_presentation, delegate_primary_selection,
delegate_relative_pointer, delegate_seat, delegate_security_context, delegate_session_lock,
delegate_tablet_manager, delegate_text_input_manager, delegate_viewporter,
delegate_virtual_keyboard_manager, delegate_xdg_activation,
delegate_single_pixel_buffer, delegate_tablet_manager, delegate_text_input_manager,
delegate_viewporter, delegate_virtual_keyboard_manager, delegate_xdg_activation,
};
pub use crate::handlers::xdg_shell::KdeDecorationsModeState;
use crate::niri::{ClientState, DndIcon, State};
use crate::niri::{DndIcon, NewClient, State};
use crate::protocols::foreign_toplevel::{
self, ForeignToplevelHandler, ForeignToplevelManagerState,
};
@@ -74,12 +84,19 @@ use crate::protocols::gamma_control::{GammaControlHandler, GammaControlManagerSt
use crate::protocols::mutter_x11_interop::MutterX11InteropHandler;
use crate::protocols::output_management::{OutputManagementHandler, OutputManagementManagerState};
use crate::protocols::screencopy::{Screencopy, ScreencopyHandler, ScreencopyManagerState};
use crate::utils::{output_size, send_scale_transform};
use crate::protocols::virtual_pointer::{
VirtualPointerAxisEvent, VirtualPointerButtonEvent, VirtualPointerHandler,
VirtualPointerInputBackend, VirtualPointerManagerState, VirtualPointerMotionAbsoluteEvent,
VirtualPointerMotionEvent,
};
use crate::utils::{output_size, send_scale_transform, with_toplevel_role};
use crate::{
delegate_foreign_toplevel, delegate_gamma_control, delegate_mutter_x11_interop,
delegate_output_management, delegate_screencopy,
delegate_output_management, delegate_screencopy, delegate_virtual_pointer,
};
pub const XDG_ACTIVATION_TOKEN_TIMEOUT: Duration = Duration::from_secs(10);
impl SeatHandler for State {
type KeyboardFocus = WlSurface;
type PointerFocus = WlSurface;
@@ -137,11 +154,12 @@ impl TabletSeatHandler for State {
delegate_tablet_manager!(State);
impl PointerConstraintsHandler for State {
fn new_constraint(&mut self, _surface: &WlSurface, pointer: &PointerHandle<Self>) {
self.niri.maybe_activate_pointer_constraint(
pointer.current_location(),
&self.niri.pointer_focus,
);
fn new_constraint(&mut self, _surface: &WlSurface, _pointer: &PointerHandle<Self>) {
// Pointer constraints track pointer focus internally, so make sure it's up to date before
// activating a new one.
self.refresh_pointer_contents();
self.niri.maybe_activate_pointer_constraint();
}
fn cursor_position_hint(
@@ -151,26 +169,27 @@ impl PointerConstraintsHandler for State {
location: Point<f64, Logical>,
) {
let is_constraint_active = with_pointer_constraint(surface, pointer, |constraint| {
constraint.map_or(false, |c| c.is_active())
constraint.is_some_and(|c| c.is_active())
});
if !is_constraint_active {
return;
}
// Logically the following two checks should always succeed (so, they should print
// error!()s if they fail). However, currently both can fail because niri's pointer focus
// doesn't take pointer grabs into account. So if you start, say, a middle-drag in Blender,
// then touchpad-swipe the window away, the niri pointer focus will change, even though the
// real pointer focus remains on the Blender surface due to the click grab.
// Note: this is surface under pointer, not pointer focus. So if you start, say, a
// middle-drag in Blender, then touchpad-swipe the window away, the surface under pointer
// will change, even though the real pointer focus remains on the Blender surface due to
// the click grab.
//
// FIXME: add error!()s when niri pointer focus takes grabs into account. Alternatively,
// recompute the surface origin here (but that is a bit clunky).
let Some((ref focused_surface, origin)) = self.niri.pointer_focus.surface else {
// Ideally we would just use the constraint surface, but we need its origin. So this is
// more of a hack because pointer contents has the surface origin available.
//
// FIXME: use the constraint surface somehow, don't use pointer contents.
let Some((ref surface_under_pointer, origin)) = self.niri.pointer_contents.surface else {
return;
};
if focused_surface != surface {
if surface_under_pointer != surface {
return;
}
@@ -238,7 +257,28 @@ impl InputMethodHandler for State {
}
}
impl KeyboardShortcutsInhibitHandler for State {
fn keyboard_shortcuts_inhibit_state(&mut self) -> &mut KeyboardShortcutsInhibitState {
&mut self.niri.keyboard_shortcuts_inhibit_state
}
fn new_inhibitor(&mut self, inhibitor: KeyboardShortcutsInhibitor) {
// FIXME: show a confirmation dialog with a "remember for this application" kind of toggle.
inhibitor.activate();
self.niri
.keyboard_shortcuts_inhibiting_surfaces
.insert(inhibitor.wl_surface().clone(), inhibitor);
}
fn inhibitor_destroyed(&mut self, inhibitor: KeyboardShortcutsInhibitor) {
self.niri
.keyboard_shortcuts_inhibiting_surfaces
.remove(&inhibitor.wl_surface().clone());
}
}
delegate_input_method_manager!(State);
delegate_keyboard_shortcuts_inhibit!(State);
delegate_virtual_keyboard_manager!(State);
impl SelectionHandler for State {
@@ -301,7 +341,42 @@ impl ClientDndGrabHandler for State {
self.niri.queue_redraw_all();
}
fn dropped(&mut self, _seat: Seat<Self>) {
fn dropped(&mut self, target: Option<WlSurface>, validated: bool, _seat: Seat<Self>) {
trace!("client dropped, target: {target:?}, validated: {validated}");
// End DnD before activating a specific window below so that it takes precedence.
self.niri.layout.dnd_end();
// Activate the target output, since that's how Firefox drag-tab-into-new-window works for
// example. On successful drop, additionally activate the target window.
let mut activate_output = true;
if let Some(target) = validated.then_some(target).flatten() {
let root = self.niri.find_root_shell_surface(&target);
if let Some((mapped, _)) = self.niri.layout.find_window_and_output(&root) {
let window = mapped.window.clone();
self.niri.layout.activate_window(&window);
self.niri.layer_shell_on_demand_focus = None;
activate_output = false;
}
}
if activate_output {
// Find the output from cursor coordinates.
//
// FIXME: uhhh, we can't actually properly tell if the DnD comes from pointer or touch,
// and if it comes from touch, then what the coordinates are. Need to pass more
// parameters from Smithay I guess.
//
// Assume that hidden pointer means touch DnD.
if !self.niri.pointer_hidden {
// We can't even get the current pointer location because it's locked (we're deep
// in the grab call stack here). So use the last known one.
if let Some(output) = &self.niri.pointer_contents.output {
self.niri.layout.activate_output(output);
}
}
}
self.niri.dnd_icon = None;
// FIXME: more granular
self.niri.queue_redraw_all();
@@ -319,14 +394,22 @@ impl PrimarySelectionHandler for State {
}
delegate_primary_selection!(State);
impl DataControlHandler for State {
fn data_control_state(&self) -> &DataControlState {
&self.niri.data_control_state
impl WlrDataControlHandler for State {
fn data_control_state(&self) -> &WlrDataControlState {
&self.niri.wlr_data_control_state
}
}
delegate_data_control!(State);
impl ExtDataControlHandler for State {
fn data_control_state(&self) -> &ExtDataControlState {
&self.niri.ext_data_control_state
}
}
delegate_ext_data_control!(State);
impl OutputHandler for State {
fn output_bound(&mut self, output: Output, wl_output: WlOutput) {
foreign_toplevel::on_output_bound(self, &output, &wl_output);
@@ -367,6 +450,8 @@ impl SessionLockHandler for State {
fn unlock(&mut self) {
self.niri.unlock();
self.niri.activate_monitors(&mut self.backend);
self.niri.notify_activity();
}
fn new_surface(&mut self, surface: LockSurface, output: WlOutput) {
@@ -400,18 +485,12 @@ impl SecurityContextHandler for State {
self.niri
.event_loop
.insert_source(source, move |client, _, state| {
let config = state.niri.config.borrow();
let data = Arc::new(ClientState {
compositor_state: Default::default(),
can_view_decoration_globals: config.prefer_no_csd,
trace!("inserting a new restricted client, context={context:?}");
state.niri.insert_client(NewClient {
client,
restricted: true,
credentials_unknown: false,
});
if let Err(err) = state.niri.display_handle.insert_client(client, data) {
warn!("error inserting client: {err}");
} else {
trace!("inserted a new restricted client, context={context:?}");
}
})
.unwrap();
}
@@ -459,19 +538,19 @@ impl ForeignToplevelHandler for State {
fn set_fullscreen(&mut self, wl_surface: WlSurface, wl_output: Option<WlOutput>) {
if let Some((mapped, current_output)) = self.niri.layout.find_window_and_output(&wl_surface)
{
if !mapped
.toplevel()
.current_state()
.capabilities
.contains(xdg_toplevel::WmCapabilities::Fullscreen)
{
let has_fullscreen_cap = with_toplevel_role(mapped.toplevel(), |role| {
role.current
.capabilities
.contains(xdg_toplevel::WmCapabilities::Fullscreen)
});
if !has_fullscreen_cap {
return;
}
let window = mapped.window.clone();
if let Some(requested_output) = wl_output.as_ref().and_then(Output::from_resource) {
if &requested_output != current_output {
if Some(&requested_output) != current_output {
self.niri
.layout
.move_to_output(Some(&window), &requested_output, None);
@@ -519,6 +598,31 @@ impl ScreencopyHandler for State {
}
delegate_screencopy!(State);
impl VirtualPointerHandler for State {
fn virtual_pointer_manager_state(&mut self) -> &mut VirtualPointerManagerState {
&mut self.niri.virtual_pointer_state
}
fn on_virtual_pointer_motion(&mut self, event: VirtualPointerMotionEvent) {
self.process_input_event(InputEvent::<VirtualPointerInputBackend>::PointerMotion { event });
}
fn on_virtual_pointer_motion_absolute(&mut self, event: VirtualPointerMotionAbsoluteEvent) {
self.process_input_event(
InputEvent::<VirtualPointerInputBackend>::PointerMotionAbsolute { event },
);
}
fn on_virtual_pointer_button(&mut self, event: VirtualPointerButtonEvent) {
self.process_input_event(InputEvent::<VirtualPointerInputBackend>::PointerButton { event });
}
fn on_virtual_pointer_axis(&mut self, event: VirtualPointerAxisEvent) {
self.process_input_event(InputEvent::<VirtualPointerInputBackend>::PointerAxis { event });
}
}
delegate_virtual_pointer!(State);
impl DrmLeaseHandler for State {
fn drm_lease_state(&mut self, node: DrmNode) -> &mut DrmLeaseState {
self.backend
@@ -622,18 +726,22 @@ impl XdgActivationHandler for State {
fn request_activation(
&mut self,
_token: XdgActivationToken,
token: XdgActivationToken,
token_data: XdgActivationTokenData,
surface: WlSurface,
) {
if token_data.timestamp.elapsed().as_secs() < 10 {
if token_data.timestamp.elapsed() < XDG_ACTIVATION_TOKEN_TIMEOUT {
if let Some((mapped, _)) = self.niri.layout.find_window_and_output(&surface) {
let window = mapped.window.clone();
self.niri.layout.activate_window(&window);
self.niri.layer_shell_on_demand_focus = None;
self.niri.queue_redraw_all();
} else if let Some(unmapped) = self.niri.unmapped_windows.get_mut(&surface) {
unmapped.activation_token_data = Some(token_data);
}
}
self.niri.activation_state.remove_token(&token);
}
}
delegate_xdg_activation!(State);
@@ -655,3 +763,5 @@ delegate_output_management!(State);
impl MutterX11InteropHandler for State {}
delegate_mutter_x11_interop!(State);
delegate_single_pixel_buffer!(State);
+157 -66
View File
@@ -1,6 +1,7 @@
use std::cell::Cell;
use calloop::Interest;
use niri_config::PresetSize;
use smithay::desktop::{
find_popup_root_surface, get_popup_toplevel_coords, layer_map_for_output, utils, LayerSurface,
PopupKeyboardGrab, PopupKind, PopupManager, PopupPointerGrab, PopupUngrabStrategy, Window,
@@ -42,7 +43,6 @@ use crate::input::resize_grab::ResizeGrab;
use crate::input::touch_move_grab::TouchMoveGrab;
use crate::input::touch_resize_grab::TouchResizeGrab;
use crate::input::{PointerOrTouchStartData, DOUBLE_CLICK_TIME};
use crate::layout::workspace::ColumnWidth;
use crate::niri::{PopupGrabState, State};
use crate::utils::transaction::Transaction;
use crate::utils::{get_monotonic_time, output_matches_name, send_scale_transform, ResizeEdge};
@@ -83,7 +83,7 @@ impl XdgShellHandler for State {
if focus.id().same_client_as(&wl_surface.id()) {
// Deny move requests from DnD grabs to work around
// https://gitlab.gnome.org/GNOME/gtk/-/issues/7113
let is_dnd_grab = grab.as_any().downcast_ref::<DnDGrab<Self>>().is_some();
let is_dnd_grab = grab.as_any().is::<DnDGrab<Self>>();
if !is_dnd_grab {
grab_start_data =
@@ -103,8 +103,7 @@ impl XdgShellHandler for State {
if focus.id().same_client_as(&wl_surface.id()) {
// Deny move requests from DnD grabs to work around
// https://gitlab.gnome.org/GNOME/gtk/-/issues/7113
let is_dnd_grab =
grab.as_any().downcast_ref::<DnDGrab<Self>>().is_some();
let is_dnd_grab = grab.as_any().is::<DnDGrab<Self>>();
if !is_dnd_grab {
grab_start_data =
@@ -124,6 +123,10 @@ impl XdgShellHandler for State {
return;
};
let Some(output) = output else {
return;
};
let window = mapped.window.clone();
let output = output.clone();
@@ -149,7 +152,6 @@ impl XdgShellHandler for State {
PointerOrTouchStartData::Pointer(start_data) => {
let grab = MoveGrab::new(start_data, window);
pointer.set_grab(self, grab, serial, Focus::Clear);
self.niri.pointer_grab_ongoing = true;
}
PointerOrTouchStartData::Touch(start_data) => {
let touch = self.niri.seat.get_touch().unwrap();
@@ -211,8 +213,16 @@ impl XdgShellHandler for State {
// See if we got a double resize-click gesture.
let time = get_monotonic_time();
let last_cell = mapped.last_interactive_resize_start();
let last = last_cell.get();
let mut last = last_cell.get();
last_cell.set(Some((time, edges)));
// Floating windows don't have either of the double-resize-click gestures, so just allow it
// to resize.
if mapped.is_floating() {
last = None;
last_cell.set(None);
}
if let Some((last_time, last_edges)) = last {
if time.saturating_sub(last_time) <= DOUBLE_CLICK_TIME {
// Allow quick resize after a triple click.
@@ -247,7 +257,6 @@ impl XdgShellHandler for State {
PointerOrTouchStartData::Pointer(start_data) => {
let grab = ResizeGrab::new(start_data, window);
pointer.set_grab(self, grab, serial, Focus::Clear);
self.niri.pointer_grab_ongoing = true;
}
PointerOrTouchStartData::Touch(start_data) => {
let touch = self.niri.seat.get_touch().unwrap();
@@ -284,6 +293,7 @@ impl XdgShellHandler for State {
let popup = PopupKind::Xdg(surface);
let Ok(root) = find_popup_root_surface(&popup) else {
trace!("ignoring popup grab because no root surface");
return;
};
@@ -292,30 +302,30 @@ impl XdgShellHandler for State {
// keyboard focus being at the wrong place.
if self.niri.is_locked() {
if Some(&root) != self.niri.lock_surface_focus().as_ref() {
trace!("ignoring popup grab because the session is locked");
let _ = PopupManager::dismiss_popup(&root, &popup);
return;
}
} else if self.niri.screenshot_ui.is_open() {
trace!("ignoring popup grab because the screenshot UI is open");
let _ = PopupManager::dismiss_popup(&root, &popup);
return;
} else if let Some(output) = self.niri.layout.active_output() {
let layers = layer_map_for_output(output);
if let Some(layer_surface) =
layers.layer_for_surface(&root, WindowSurfaceType::TOPLEVEL)
if layers
.layer_for_surface(&root, WindowSurfaceType::TOPLEVEL)
.is_none()
{
if !matches!(layer_surface.layer(), Layer::Overlay | Layer::Top) {
let _ = PopupManager::dismiss_popup(&root, &popup);
return;
}
// This is a grab for a regular window; check that there's no layer surface with a
// higher input priority.
// FIXME: popup grabs for on-demand bottom and background layers.
} else {
if layers.layers_on(Layer::Overlay).any(|l| {
l.cached_state().keyboard_interactivity
== wlr_layer::KeyboardInteractivity::Exclusive
|| Some(l) == self.niri.layer_shell_on_demand_focus.as_ref()
}) {
trace!("ignoring toplevel popup grab because the overlay layer has focus");
let _ = PopupManager::dismiss_popup(&root, &popup);
return;
}
@@ -328,33 +338,51 @@ impl XdgShellHandler for State {
|| Some(l) == self.niri.layer_shell_on_demand_focus.as_ref()
})
{
trace!("ignoring toplevel popup grab because the top layer has focus");
let _ = PopupManager::dismiss_popup(&root, &popup);
return;
}
let layout_focus = self.niri.layout.focus();
if Some(&root) != layout_focus.map(|win| win.toplevel().wl_surface()) {
trace!("ignoring toplevel popup grab because another window has focus");
let _ = PopupManager::dismiss_popup(&root, &popup);
return;
}
}
} else {
trace!("ignoring popup grab because no output is active");
let _ = PopupManager::dismiss_popup(&root, &popup);
return;
}
let seat = &self.niri.seat;
let Ok(mut grab) = self
let mut grab = match self
.niri
.popups
.grab_popup(root.clone(), popup, seat, serial)
else {
return;
{
Ok(grab) => grab,
Err(err) => {
trace!("ignoring popup grab: {err:?}");
return;
}
};
let keyboard = seat.get_keyboard().unwrap();
let pointer = seat.get_pointer().unwrap();
let can_receive_keyboard_focus = self
.niri
.layout
.active_output()
.and_then(|output| {
layer_map_for_output(output)
.layer_for_surface(&root, WindowSurfaceType::TOPLEVEL)
.map(|layer_surface| layer_surface.can_receive_keyboard_focus())
})
.unwrap_or(true);
let keyboard_grab_mismatches = keyboard.is_grabbed()
&& !(keyboard.has_grab(serial)
|| grab
@@ -363,16 +391,22 @@ impl XdgShellHandler for State {
let pointer_grab_mismatches = pointer.is_grabbed()
&& !(pointer.has_grab(serial)
|| grab.previous_serial().map_or(true, |s| pointer.has_grab(s)));
if keyboard_grab_mismatches || pointer_grab_mismatches {
if (can_receive_keyboard_focus && keyboard_grab_mismatches) || pointer_grab_mismatches {
trace!("ignoring popup grab because of current grab mismatch");
grab.ungrab(PopupUngrabStrategy::All);
return;
}
trace!("new grab for root {:?}", root);
keyboard.set_focus(self, grab.current_grab(), serial);
keyboard.set_grab(self, PopupKeyboardGrab::new(&grab), serial);
if can_receive_keyboard_focus {
keyboard.set_grab(self, PopupKeyboardGrab::new(&grab), serial);
}
pointer.set_grab(self, PopupPointerGrab::new(&grab), serial, Focus::Keep);
self.niri.popup_grab = Some(PopupGrabState { root, grab });
self.niri.popup_grab = Some(PopupGrabState {
root,
grab,
has_keyboard_grab: can_receive_keyboard_focus,
});
}
fn maximize_request(&mut self, surface: ToplevelSurface) {
@@ -399,12 +433,16 @@ impl XdgShellHandler for State {
if let Some((mapped, current_output)) = self
.niri
.layout
.find_window_and_output(toplevel.wl_surface())
.find_window_and_output_mut(toplevel.wl_surface())
{
// A configure is required in response to this event regardless if there are pending
// changes.
mapped.set_needs_configure();
let window = mapped.window.clone();
if let Some(requested_output) = requested_output {
if &requested_output != current_output {
if Some(&requested_output) != current_output {
self.niri
.layout
.move_to_output(Some(&window), &requested_output, None);
@@ -412,10 +450,6 @@ impl XdgShellHandler for State {
}
self.niri.layout.set_fullscreen(&window, true);
// A configure is required in response to this event regardless if there are pending
// changes.
toplevel.send_configure();
} else if let Some(unmapped) = self.niri.unmapped_windows.get_mut(toplevel.wl_surface()) {
match &mut unmapped.state {
InitialConfigureState::NotConfigured { wants_fullscreen } => {
@@ -437,7 +471,7 @@ impl XdgShellHandler for State {
toplevel
.parent()
.and_then(|parent| self.niri.layout.find_window_and_output(&parent))
.map(|(_win, output)| output)
.and_then(|(_win, output)| output)
.and_then(|o| self.niri.layout.monitor_for_output(o))
.map(|mon| (mon, true))
})
@@ -462,7 +496,7 @@ impl XdgShellHandler for State {
toplevel.with_pending_state(|state| {
state.states.set(xdg_toplevel::State::Fullscreen);
});
ws.configure_new_window(&unmapped.window, None, rules);
ws.configure_new_window(&unmapped.window, None, None, false, rules);
}
// We already sent the initial configure, so we need to reconfigure.
@@ -479,14 +513,14 @@ impl XdgShellHandler for State {
if let Some((mapped, _)) = self
.niri
.layout
.find_window_and_output(toplevel.wl_surface())
.find_window_and_output_mut(toplevel.wl_surface())
{
let window = mapped.window.clone();
self.niri.layout.set_fullscreen(&window, false);
// A configure is required in response to this event regardless if there are pending
// changes.
toplevel.send_configure();
mapped.set_needs_configure();
let window = mapped.window.clone();
self.niri.layout.set_fullscreen(&window, false);
} else if let Some(unmapped) = self.niri.unmapped_windows.get_mut(toplevel.wl_surface()) {
match &mut unmapped.state {
InitialConfigureState::NotConfigured { wants_fullscreen } => {
@@ -497,6 +531,9 @@ impl XdgShellHandler for State {
InitialConfigureState::Configured {
rules,
width,
height,
floating_width,
floating_height,
is_full_width,
output,
workspace_name,
@@ -520,7 +557,7 @@ impl XdgShellHandler for State {
.and_then(|parent| {
self.niri.layout.find_window_and_output(&parent)
})
.map(|(_win, output)| output)
.and_then(|(_win, output)| output)
.and_then(|o| self.niri.layout.monitor_for_output(o))
.map(|mon| (mon, true))
})
@@ -551,12 +588,26 @@ impl XdgShellHandler for State {
state.states.unset(xdg_toplevel::State::Fullscreen);
});
let configure_width = if *is_full_width {
Some(ColumnWidth::Proportion(1.))
let is_floating = rules.compute_open_floating(&toplevel);
let configure_width = if is_floating {
*floating_width
} else if *is_full_width {
Some(PresetSize::Proportion(1.))
} else {
*width
};
ws.configure_new_window(&unmapped.window, configure_width, rules);
let configure_height = if is_floating {
*floating_height
} else {
*height
};
ws.configure_new_window(
&unmapped.window,
configure_width,
configure_height,
is_floating,
rules,
);
}
// We already sent the initial configure, so we need to reconfigure.
@@ -592,7 +643,7 @@ impl XdgShellHandler for State {
return;
};
let window = mapped.window.clone();
let output = output.clone();
let output = output.cloned();
#[cfg(feature = "xdp-gnome-screencast")]
self.niri
@@ -612,7 +663,7 @@ impl XdgShellHandler for State {
.start_close_animation_for_window(renderer, &window, blocker);
});
let active_window = self.niri.layout.active_window().map(|(m, _)| &m.window);
let active_window = self.niri.layout.focus().map(|m| &m.window);
let was_active = active_window == Some(&window);
self.niri.layout.remove_window(&window, transaction.clone());
@@ -628,7 +679,9 @@ impl XdgShellHandler for State {
self.maybe_warp_cursor_to_focus();
}
self.niri.queue_redraw(&output);
if let Some(output) = output {
self.niri.queue_redraw(&output);
}
}
fn popup_destroyed(&mut self, surface: PopupSurface) {
@@ -644,6 +697,22 @@ impl XdgShellHandler for State {
fn title_changed(&mut self, toplevel: ToplevelSurface) {
self.update_window_rules(&toplevel);
}
fn parent_changed(&mut self, toplevel: ToplevelSurface) {
let Some(parent) = toplevel.parent() else {
return;
};
if let Some((mapped, output)) = self.niri.layout.find_window_and_output_mut(&parent) {
let output = output.cloned();
let window = mapped.window.clone();
if self.niri.layout.descendants_added(&window) {
if let Some(output) = output {
self.niri.queue_redraw(&output);
}
}
}
}
}
delegate_xdg_shell!(State);
@@ -672,7 +741,13 @@ impl XdgDecorationHandler for State {
// A configure is required in response to this event. However, if an initial configure
// wasn't sent, then we will send this as part of the initial configure later.
if toplevel.is_initial_configure_sent() {
toplevel.send_configure();
// If this is a mapped window, flag it as needs configure to avoid duplicate configures.
let surface = toplevel.wl_surface();
if let Some((mapped, _)) = self.niri.layout.find_window_and_output_mut(surface) {
mapped.set_needs_configure();
} else {
toplevel.send_configure();
}
}
}
@@ -685,7 +760,13 @@ impl XdgDecorationHandler for State {
// A configure is required in response to this event. However, if an initial configure
// wasn't sent, then we will send this as part of the initial configure later.
if toplevel.is_initial_configure_sent() {
toplevel.send_configure();
// If this is a mapped window, flag it as needs configure to avoid duplicate configures.
let surface = toplevel.wl_surface();
if let Some((mapped, _)) = self.niri.layout.find_window_and_output_mut(surface) {
mapped.set_needs_configure();
} else {
toplevel.send_configure();
}
}
}
}
@@ -755,7 +836,7 @@ impl State {
self.niri.is_at_startup,
);
let Unmapped { window, state } = unmapped;
let Unmapped { window, state, .. } = unmapped;
let InitialConfigureState::NotConfigured { wants_fullscreen } = state else {
error!("window must not be already configured in send_initial_configure()");
@@ -796,7 +877,7 @@ impl State {
toplevel
.parent()
.and_then(|parent| self.niri.layout.find_window_and_output(&parent))
.map(|(_win, output)| output)
.and_then(|(_win, output)| output)
.and_then(|o| self.niri.layout.monitor_for_output(o))
.map(|mon| (mon, true))
});
@@ -817,7 +898,11 @@ impl State {
let mon = mon.map(|(mon, _)| mon);
let mut width = None;
let mut floating_width = None;
let mut height = None;
let mut floating_height = None;
let is_full_width = rules.open_maximized.unwrap_or(false);
let is_floating = rules.compute_open_floating(toplevel);
// Tell the surface the preferred size and bounds for its likely output.
let ws = rules
@@ -839,14 +924,26 @@ impl State {
});
}
width = ws.resolve_default_width(rules.default_width);
width = ws.resolve_default_width(rules.default_width, false);
floating_width = ws.resolve_default_width(rules.default_width, true);
height = ws.resolve_default_height(rules.default_height, false);
floating_height = ws.resolve_default_height(rules.default_height, true);
let configure_width = if is_full_width {
Some(ColumnWidth::Proportion(1.))
let configure_width = if is_floating {
floating_width
} else if is_full_width {
Some(PresetSize::Proportion(1.))
} else {
width
};
ws.configure_new_window(window, configure_width, &rules);
let configure_height = if is_floating { floating_height } else { height };
ws.configure_new_window(
window,
configure_width,
configure_height,
is_floating,
&rules,
);
}
// If the user prefers no CSD, it's a reasonable assumption that they would prefer to get
@@ -864,6 +961,9 @@ impl State {
*state = InitialConfigureState::Configured {
rules,
width,
height,
floating_width,
floating_height,
is_full_width,
output,
workspace_name: ws.and_then(|w| w.name().cloned()),
@@ -931,8 +1031,8 @@ impl State {
};
// Figure out if the root is a window or a layer surface.
if let Some((mapped, output)) = self.niri.layout.find_window_and_output(&root) {
self.unconstrain_window_popup(popup, &mapped.window, output);
if let Some((mapped, _)) = self.niri.layout.find_window_and_output(&root) {
self.unconstrain_window_popup(popup, &mapped.window);
} else if let Some((layer_surface, output)) = self.niri.layout.outputs().find_map(|o| {
let map = layer_map_for_output(o);
let layer_surface = map.layer_for_surface(&root, WindowSurfaceType::TOPLEVEL)?;
@@ -942,19 +1042,10 @@ impl State {
}
}
fn unconstrain_window_popup(&self, popup: &PopupKind, window: &Window, output: &Output) {
let window_geo = window.geometry();
let output_geo = self.niri.global_space.output_geometry(output).unwrap();
fn unconstrain_window_popup(&self, popup: &PopupKind, window: &Window) {
// The target geometry for the positioner should be relative to its parent's geometry, so
// we will compute that here.
//
// We try to keep regular window popups within the window itself horizontally (since the
// window can be scrolled to both edges of the screen), but within the whole monitor's
// height.
let mut target =
Rectangle::from_loc_and_size((0, 0), (window_geo.size.w, output_geo.size.h)).to_f64();
target.loc -= self.niri.layout.window_loc(window).unwrap();
let mut target = self.niri.layout.popup_target_rect(window);
target.loc -= get_popup_toplevel_coords(popup).to_f64();
self.position_popup_within_rect(popup, target);
@@ -974,7 +1065,7 @@ impl State {
// The target geometry for the positioner should be relative to its parent's geometry, so
// we will compute that here.
let mut target = Rectangle::from_loc_and_size((0, 0), output_geo.size);
let mut target = Rectangle::from_size(output_geo.size);
target.loc -= layer_geo.loc;
target.loc -= get_popup_toplevel_coords(popup);
@@ -1019,7 +1110,7 @@ impl State {
}
}
pub fn update_reactive_popups(&self, window: &Window, output: &Output) {
pub fn update_reactive_popups(&self, window: &Window) {
let _span = tracy_client::span!("Niri::update_reactive_popups");
for (popup, _) in PopupManager::popups_for_surface(
@@ -1028,7 +1119,7 @@ impl State {
match &popup {
xdg_popup @ PopupKind::Xdg(popup) => {
if popup.with_pending_state(|state| state.positioner.reactive) {
self.unconstrain_window_popup(xdg_popup, window, output);
self.unconstrain_window_popup(xdg_popup, window);
if let Err(err) = popup.send_pending_configure() {
warn!("error re-configuring reactive popup: {err:?}");
}
+51
View File
@@ -0,0 +1,51 @@
use ::input as libinput;
use smithay::backend::input;
use smithay::backend::winit::WinitVirtualDevice;
use smithay::output::Output;
use crate::niri::State;
use crate::protocols::virtual_pointer::VirtualPointer;
pub trait NiriInputBackend: input::InputBackend<Device = Self::NiriDevice> {
type NiriDevice: NiriInputDevice;
}
impl<T: input::InputBackend> NiriInputBackend for T
where
Self::Device: NiriInputDevice,
{
type NiriDevice = Self::Device;
}
pub trait NiriInputDevice: input::Device {
// FIXME: this should maybe be per-event, not per-device,
// but it's not clear that this matters in practice?
// it might be more obvious once we implement it for libinput
fn output(&self, state: &State) -> Option<Output>;
}
impl NiriInputDevice for libinput::Device {
fn output(&self, _state: &State) -> Option<Output> {
// FIXME: Allow specifying the output per-device?
None
}
}
impl NiriInputDevice for WinitVirtualDevice {
fn output(&self, _state: &State) -> Option<Output> {
// FIXME: we should be returning the single output that the winit backend creates,
// but for now, that will cause issues because the output is normally upside down,
// so we apply Transform::Flipped180 to it and that would also cause
// the cursor position to be flipped, which is not what we want.
//
// instead, we just return None and rely on the fact that it has only one output.
// doing so causes the cursor to be placed in *global* output coordinates,
// which are not flipped, and happen to be what we want.
None
}
}
impl NiriInputDevice for VirtualPointer {
fn output(&self, _: &State) -> Option<Output> {
self.output().cloned()
}
}
+811 -136
View File
File diff suppressed because it is too large Load Diff
+10 -32
View File
@@ -1,5 +1,3 @@
use std::time::Duration;
use smithay::backend::input::ButtonState;
use smithay::desktop::Window;
use smithay::input::pointer::{
@@ -17,7 +15,6 @@ pub struct MoveGrab {
start_data: PointerGrabStartData<State>,
last_location: Point<f64, Logical>,
window: Window,
is_moving: bool,
}
impl MoveGrab {
@@ -26,7 +23,6 @@ impl MoveGrab {
last_location: start_data.location,
start_data,
window,
is_moving: false,
}
}
@@ -34,7 +30,6 @@ impl MoveGrab {
state.niri.layout.interactive_move_end(&self.window);
// FIXME: only redraw the window output.
state.niri.queue_redraw_all();
state.niri.pointer_grab_ongoing = false;
state
.niri
.cursor_manager
@@ -65,14 +60,6 @@ impl PointerGrab<State> for MoveGrab {
pos_within_output,
);
if ongoing {
let timestamp = Duration::from_millis(u64::from(event.time));
if self.is_moving {
data.niri.layout.view_offset_gesture_update(
-event_delta.x,
timestamp,
false,
);
}
// FIXME: only redraw the previous and the new output.
data.niri.queue_redraw_all();
return;
@@ -105,27 +92,18 @@ impl PointerGrab<State> for MoveGrab {
) {
handle.button(data, event);
// MouseButton::Middle
if event.button == 0x112 {
if event.state == ButtonState::Pressed {
let output = data
.niri
.output_under(handle.current_location())
.map(|(output, _)| output)
.cloned();
// TODO: workspace switch gesture.
if let Some(output) = output {
self.is_moving = true;
data.niri.layout.view_offset_gesture_begin(&output, false);
}
} else if event.state == ButtonState::Released {
self.is_moving = false;
data.niri.layout.view_offset_gesture_end(false, None);
}
// When moving with the left button, right toggles floating, and vice versa.
let toggle_floating_button = if self.start_data.button == 0x110 {
0x111
} else {
0x110
};
if event.button == toggle_floating_button && event.state == ButtonState::Pressed {
data.niri.layout.toggle_window_floating(Some(&self.window));
}
if handle.current_pressed().is_empty() {
// No more buttons are pressed, release the grab.
if !handle.current_pressed().contains(&self.start_data.button) {
// The button that initiated the grab was released.
handle.unset_grab(self, data, event.serial, event.time, true);
}
}
-1
View File
@@ -22,7 +22,6 @@ impl ResizeGrab {
fn on_ungrab(&mut self, state: &mut State) {
state.niri.layout.interactive_resize_end(&self.window);
state.niri.pointer_grab_ongoing = false;
state
.niri
.cursor_manager
-1
View File
@@ -50,7 +50,6 @@ impl SpatialMovementGrab {
state.niri.queue_redraw(&output);
}
state.niri.pointer_grab_ongoing = false;
state
.niri
.cursor_manager
+78
View File
@@ -1,3 +1,6 @@
use std::iter::Peekable;
use std::slice;
use anyhow::{anyhow, bail, Context};
use niri_config::OutputName;
use niri_ipc::socket::Socket;
@@ -23,6 +26,7 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> {
},
Msg::Workspaces => Request::Workspaces,
Msg::Windows => Request::Windows,
Msg::Layers => Request::Layers,
Msg::KeyboardLayouts => Request::KeyboardLayouts,
Msg::EventStream => Request::EventStream,
Msg::RequestError => Request::ReturnError,
@@ -168,6 +172,69 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> {
println!();
}
}
Msg::Layers => {
let Response::Layers(mut layers) = response else {
bail!("unexpected response: expected Layers, got {response:?}");
};
if json {
let layers = serde_json::to_string(&layers).context("error formatting response")?;
println!("{layers}");
return Ok(());
}
layers.sort_by(|a, b| {
Ord::cmp(&a.output, &b.output)
.then_with(|| Ord::cmp(&a.layer, &b.layer))
.then_with(|| Ord::cmp(&a.namespace, &b.namespace))
});
let mut iter = layers.iter().peekable();
let print = |surface: &niri_ipc::LayerSurface| {
println!(" Surface:");
println!(" Namespace: \"{}\"", &surface.namespace);
let interactivity = match surface.keyboard_interactivity {
niri_ipc::LayerSurfaceKeyboardInteractivity::None => "none",
niri_ipc::LayerSurfaceKeyboardInteractivity::Exclusive => "exclusive",
niri_ipc::LayerSurfaceKeyboardInteractivity::OnDemand => "on-demand",
};
println!(" Keyboard interactivity: {interactivity}");
};
let print_layer = |iter: &mut Peekable<slice::Iter<niri_ipc::LayerSurface>>,
output: &str,
layer| {
let mut empty = true;
while let Some(surface) = iter.next_if(|s| s.output == output && s.layer == layer) {
empty = false;
println!();
print(surface);
}
if empty {
println!(" (empty)\n");
} else {
println!();
}
};
while let Some(surface) = iter.peek() {
let output = &surface.output;
println!("Output \"{output}\":");
print!(" Background layer:");
print_layer(&mut iter, output, niri_ipc::Layer::Background);
print!(" Bottom layer:");
print_layer(&mut iter, output, niri_ipc::Layer::Bottom);
print!(" Top layer:");
print_layer(&mut iter, output, niri_ipc::Layer::Top);
print!(" Overlay layer:");
print_layer(&mut iter, output, niri_ipc::Layer::Overlay);
}
}
Msg::FocusedOutput => {
let Response::FocusedOutput(output) = response else {
bail!("unexpected response: expected FocusedOutput, got {response:?}");
@@ -449,6 +516,17 @@ fn print_window(window: &Window) {
println!(" App ID: (unset)");
}
println!(
" Is floating: {}",
if window.is_floating { "yes" } else { "no" }
);
if let Some(pid) = window.pid {
println!(" PID: {pid}");
} else {
println!(" PID: (unknown)");
}
if let Some(workspace_id) = window.workspace_id {
println!(" Workspace ID: {workspace_id}");
} else {
+94 -52
View File
@@ -1,5 +1,6 @@
use std::cell::RefCell;
use std::collections::HashSet;
use std::ffi::OsStr;
use std::os::unix::net::{UnixListener, UnixStream};
use std::path::PathBuf;
use std::rc::Rc;
@@ -16,16 +17,16 @@ use futures_util::{select_biased, AsyncBufReadExt, AsyncWrite, AsyncWriteExt, Fu
use niri_config::OutputName;
use niri_ipc::state::{EventStreamState, EventStreamStatePart as _};
use niri_ipc::{Event, KeyboardLayouts, OutputConfigChanged, Reply, Request, Response, Workspace};
use smithay::desktop::layer_map_for_output;
use smithay::reexports::calloop::generic::Generic;
use smithay::reexports::calloop::{Interest, LoopHandle, Mode, PostAction};
use smithay::reexports::rustix::fs::unlink;
use smithay::wayland::compositor::with_states;
use smithay::wayland::shell::xdg::XdgToplevelSurfaceData;
use smithay::wayland::shell::wlr_layer::{KeyboardInteractivity, Layer};
use crate::backend::IpcOutputMap;
use crate::layout::workspace::WorkspaceId;
use crate::niri::State;
use crate::utils::version;
use crate::utils::{version, with_toplevel_role};
use crate::window::Mapped;
// If an event stream client fails to read events fast enough that we accumulate more than this
@@ -33,7 +34,10 @@ use crate::window::Mapped;
const EVENT_STREAM_BUFFER_SIZE: usize = 64;
pub struct IpcServer {
pub socket_path: PathBuf,
/// Path to the IPC socket.
///
/// This is `None` when creating `IpcServer` without a socket.
pub socket_path: Option<PathBuf>,
event_streams: Rc<RefCell<Vec<EventStreamSender>>>,
event_stream_state: Rc<RefCell<EventStreamState>>,
}
@@ -60,31 +64,38 @@ struct EventStreamSender {
impl IpcServer {
pub fn start(
event_loop: &LoopHandle<'static, State>,
wayland_socket_name: &str,
wayland_socket_name: Option<&OsStr>,
) -> anyhow::Result<Self> {
let _span = tracy_client::span!("Ipc::start");
let socket_name = format!("niri.{wayland_socket_name}.{}.sock", process::id());
let mut socket_path = socket_dir();
socket_path.push(socket_name);
let socket_path = if let Some(wayland_socket_name) = wayland_socket_name {
let wayland_socket_name = wayland_socket_name.to_string_lossy();
let socket_name = format!("niri.{wayland_socket_name}.{}.sock", process::id());
let mut socket_path = socket_dir();
socket_path.push(socket_name);
let listener = UnixListener::bind(&socket_path).context("error binding socket")?;
listener
.set_nonblocking(true)
.context("error setting socket to non-blocking")?;
let listener = UnixListener::bind(&socket_path).context("error binding socket")?;
listener
.set_nonblocking(true)
.context("error setting socket to non-blocking")?;
let source = Generic::new(listener, Interest::READ, Mode::Level);
event_loop
.insert_source(source, |_, socket, state| {
match socket.accept() {
Ok((stream, _)) => on_new_ipc_client(state, stream),
Err(e) if e.kind() == io::ErrorKind::WouldBlock => (),
Err(e) => return Err(e),
}
let source = Generic::new(listener, Interest::READ, Mode::Level);
event_loop
.insert_source(source, |_, socket, state| {
match socket.accept() {
Ok((stream, _)) => on_new_ipc_client(state, stream),
Err(e) if e.kind() == io::ErrorKind::WouldBlock => (),
Err(e) => return Err(e),
}
Ok(PostAction::Continue)
})
.unwrap();
Ok(PostAction::Continue)
})
.unwrap();
Some(socket_path)
} else {
None
};
Ok(Self {
socket_path,
@@ -119,7 +130,9 @@ impl IpcServer {
impl Drop for IpcServer {
fn drop(&mut self) {
let _ = unlink(&self.socket_path);
if let Some(socket_path) = &self.socket_path {
let _ = unlink(socket_path);
}
}
}
@@ -256,6 +269,47 @@ async fn process(ctx: &ClientCtx, request: Request) -> Reply {
let windows = state.windows.windows.values().cloned().collect();
Response::Windows(windows)
}
Request::Layers => {
let (tx, rx) = async_channel::bounded(1);
ctx.event_loop.insert_idle(move |state| {
let mut layers = Vec::new();
for output in state.niri.global_space.outputs() {
let name = output.name();
for surface in layer_map_for_output(output).layers() {
let layer = match surface.layer() {
Layer::Background => niri_ipc::Layer::Background,
Layer::Bottom => niri_ipc::Layer::Bottom,
Layer::Top => niri_ipc::Layer::Top,
Layer::Overlay => niri_ipc::Layer::Overlay,
};
let keyboard_interactivity =
match surface.cached_state().keyboard_interactivity {
KeyboardInteractivity::None => {
niri_ipc::LayerSurfaceKeyboardInteractivity::None
}
KeyboardInteractivity::Exclusive => {
niri_ipc::LayerSurfaceKeyboardInteractivity::Exclusive
}
KeyboardInteractivity::OnDemand => {
niri_ipc::LayerSurfaceKeyboardInteractivity::OnDemand
}
};
layers.push(niri_ipc::LayerSurface {
namespace: surface.namespace().to_owned(),
output: name.clone(),
layer,
keyboard_interactivity,
});
}
}
let _ = tx.send_blocking(layers);
});
let result = rx.recv().await;
let layers = result.map_err(|_| String::from("error getting layers info"))?;
Response::Layers(layers)
}
Request::KeyboardLayouts => {
let state = ctx.event_stream_state.borrow();
let layout = state.keyboard_layouts.keyboard_layouts.clone();
@@ -273,6 +327,9 @@ async fn process(ctx: &ClientCtx, request: Request) -> Reply {
let action = niri_config::Action::from(action);
ctx.event_loop.insert_idle(move |state| {
// Make sure some logic like workspace clean-up has a chance to run before doing
// actions.
state.niri.advance_animations();
state.do_action(action, false);
let _ = tx.send_blocking(());
});
@@ -361,22 +418,14 @@ async fn handle_event_stream_client(client: EventStreamClient) -> anyhow::Result
}
fn make_ipc_window(mapped: &Mapped, workspace_id: Option<WorkspaceId>) -> niri_ipc::Window {
let wl_surface = mapped.toplevel().wl_surface();
with_states(wl_surface, |states| {
let role = states
.data_map
.get::<XdgToplevelSurfaceData>()
.unwrap()
.lock()
.unwrap();
niri_ipc::Window {
id: mapped.id().get(),
title: role.title.clone(),
app_id: role.app_id.clone(),
workspace_id: workspace_id.map(|id| id.get()),
is_focused: mapped.is_focused(),
}
with_toplevel_role(mapped.toplevel(), |role| niri_ipc::Window {
id: mapped.id().get(),
title: role.title.clone(),
app_id: role.app_id.clone(),
pid: mapped.credentials().map(|c| c.pid),
workspace_id: workspace_id.map(|id| id.get()),
is_focused: mapped.is_focused(),
is_floating: mapped.is_floating(),
})
}
@@ -487,7 +536,7 @@ impl State {
}
// Check if this workspace became active.
let is_active = mon.map_or(false, |mon| mon.active_workspace_idx() == ws_idx);
let is_active = mon.is_some_and(|mon| mon.active_workspace_idx() == ws_idx);
if is_active && !ipc_ws.is_active {
events.push(Event::WorkspaceActivated { id, focused: false });
}
@@ -510,7 +559,7 @@ impl State {
idx: u8::try_from(ws_idx + 1).unwrap_or(u8::MAX),
name: ws.name().cloned(),
output: mon.map(|mon| mon.output_name().clone()),
is_active: mon.map_or(false, |mon| mon.active_workspace_idx() == ws_idx),
is_active: mon.is_some_and(|mon| mon.active_workspace_idx() == ws_idx),
is_focused: Some(id) == focused_ws_id,
active_window_id: ws.active_window().map(|win| win.id().get()),
}
@@ -557,17 +606,10 @@ impl State {
};
let workspace_id = ws_id.map(|id| id.get());
let mut changed = ipc_win.workspace_id != workspace_id;
let wl_surface = mapped.toplevel().wl_surface();
changed |= with_states(wl_surface, |states| {
let role = states
.data_map
.get::<XdgToplevelSurfaceData>()
.unwrap()
.lock()
.unwrap();
let mut changed =
ipc_win.workspace_id != workspace_id || ipc_win.is_floating != mapped.is_floating();
changed |= with_toplevel_role(mapped.toplevel(), |role| {
ipc_win.title != role.title || ipc_win.app_id != role.app_id
});
+157
View File
@@ -0,0 +1,157 @@
use niri_config::layer_rule::LayerRule;
use niri_config::Config;
use smithay::backend::renderer::element::surface::{
render_elements_from_surface_tree, WaylandSurfaceRenderElement,
};
use smithay::backend::renderer::element::Kind;
use smithay::desktop::{LayerSurface, PopupManager};
use smithay::utils::{Logical, Point, Scale, Size};
use super::ResolvedLayerRules;
use crate::layout::shadow::Shadow;
use crate::niri_render_elements;
use crate::render_helpers::renderer::NiriRenderer;
use crate::render_helpers::shadow::ShadowRenderElement;
use crate::render_helpers::solid_color::{SolidColorBuffer, SolidColorRenderElement};
use crate::render_helpers::{RenderTarget, SplitElements};
#[derive(Debug)]
pub struct MappedLayer {
/// The surface itself.
surface: LayerSurface,
/// Up-to-date rules.
rules: ResolvedLayerRules,
/// Buffer to draw instead of the surface when it should be blocked out.
block_out_buffer: SolidColorBuffer,
/// The shadow around the surface.
shadow: Shadow,
}
niri_render_elements! {
LayerSurfaceRenderElement<R> => {
Wayland = WaylandSurfaceRenderElement<R>,
SolidColor = SolidColorRenderElement,
Shadow = ShadowRenderElement,
}
}
impl MappedLayer {
pub fn new(surface: LayerSurface, rules: ResolvedLayerRules, config: &Config) -> Self {
let mut shadow_config = config.layout.shadow;
// Shadows for layer surfaces need to be explicitly enabled.
shadow_config.on = false;
let shadow_config = rules.shadow.resolve_against(shadow_config);
Self {
surface,
rules,
block_out_buffer: SolidColorBuffer::new((0., 0.), [0., 0., 0., 1.]),
shadow: Shadow::new(shadow_config),
}
}
pub fn update_config(&mut self, config: &Config) {
let mut shadow_config = config.layout.shadow;
// Shadows for layer surfaces need to be explicitly enabled.
shadow_config.on = false;
let shadow_config = self.rules.shadow.resolve_against(shadow_config);
self.shadow.update_config(shadow_config);
}
pub fn update_shaders(&mut self) {
self.shadow.update_shaders();
}
pub fn update_render_elements(&mut self, size: Size<f64, Logical>, scale: Scale<f64>) {
// Round to physical pixels.
let size = size.to_physical_precise_round(scale).to_logical(scale);
self.block_out_buffer.resize(size);
let radius = self.rules.geometry_corner_radius.unwrap_or_default();
// FIXME: is_active based on keyboard focus?
self.shadow
.update_render_elements(size, true, radius, scale.x, 1.);
}
pub fn surface(&self) -> &LayerSurface {
&self.surface
}
pub fn rules(&self) -> &ResolvedLayerRules {
&self.rules
}
/// Recomputes the resolved layer rules and returns whether they changed.
pub fn recompute_layer_rules(&mut self, rules: &[LayerRule], is_at_startup: bool) -> bool {
let new_rules = ResolvedLayerRules::compute(rules, &self.surface, is_at_startup);
if new_rules == self.rules {
return false;
}
self.rules = new_rules;
true
}
pub fn render<R: NiriRenderer>(
&self,
renderer: &mut R,
location: Point<f64, Logical>,
scale: Scale<f64>,
target: RenderTarget,
) -> SplitElements<LayerSurfaceRenderElement<R>> {
let mut rv = SplitElements::default();
let alpha = self.rules.opacity.unwrap_or(1.).clamp(0., 1.);
if target.should_block_out(self.rules.block_out_from) {
// Round to physical pixels.
let location = location.to_physical_precise_round(scale).to_logical(scale);
// FIXME: take geometry-corner-radius into account.
let elem = SolidColorRenderElement::from_buffer(
&self.block_out_buffer,
location,
alpha,
Kind::Unspecified,
);
rv.normal.push(elem.into());
} else {
// Layer surfaces don't have extra geometry like windows.
let buf_pos = location;
let surface = self.surface.wl_surface();
for (popup, popup_offset) in PopupManager::popups_for_surface(surface) {
// Layer surfaces don't have extra geometry like windows.
let offset = popup_offset - popup.geometry().loc;
rv.popups.extend(render_elements_from_surface_tree(
renderer,
popup.wl_surface(),
(buf_pos + offset.to_f64()).to_physical_precise_round(scale),
scale,
alpha,
Kind::Unspecified,
));
}
rv.normal = render_elements_from_surface_tree(
renderer,
surface,
buf_pos.to_physical_precise_round(scale),
scale,
alpha,
Kind::Unspecified,
);
}
let location = location.to_physical_precise_round(scale).to_logical(scale);
rv.normal
.extend(self.shadow.render(renderer, location).map(Into::into));
rv
}
}
+92
View File
@@ -0,0 +1,92 @@
use niri_config::layer_rule::{LayerRule, Match};
use niri_config::{BlockOutFrom, CornerRadius, ShadowRule};
use smithay::desktop::LayerSurface;
pub mod mapped;
pub use mapped::MappedLayer;
/// Rules fully resolved for a layer-shell surface.
#[derive(Debug, PartialEq)]
pub struct ResolvedLayerRules {
/// Extra opacity to draw this layer surface with.
pub opacity: Option<f32>,
/// Whether to block out this layer surface from certain render targets.
pub block_out_from: Option<BlockOutFrom>,
/// Shadow overrides.
pub shadow: ShadowRule,
/// Corner radius to assume this layer surface has.
pub geometry_corner_radius: Option<CornerRadius>,
}
impl ResolvedLayerRules {
pub const fn empty() -> Self {
Self {
opacity: None,
block_out_from: None,
shadow: ShadowRule {
off: false,
on: false,
offset: None,
softness: None,
spread: None,
draw_behind_window: None,
color: None,
inactive_color: None,
},
geometry_corner_radius: None,
}
}
pub fn compute(rules: &[LayerRule], surface: &LayerSurface, is_at_startup: bool) -> Self {
let _span = tracy_client::span!("ResolvedLayerRules::compute");
let mut resolved = ResolvedLayerRules::empty();
for rule in rules {
let matches = |m: &Match| {
if let Some(at_startup) = m.at_startup {
if at_startup != is_at_startup {
return false;
}
}
surface_matches(surface, m)
};
if !(rule.matches.is_empty() || rule.matches.iter().any(matches)) {
continue;
}
if rule.excludes.iter().any(matches) {
continue;
}
if let Some(x) = rule.opacity {
resolved.opacity = Some(x);
}
if let Some(x) = rule.block_out_from {
resolved.block_out_from = Some(x);
}
if let Some(x) = rule.geometry_corner_radius {
resolved.geometry_corner_radius = Some(x);
}
resolved.shadow.merge_with(&rule.shadow);
}
resolved
}
}
fn surface_matches(surface: &LayerSurface, m: &Match) -> bool {
if let Some(namespace_re) = &m.namespace {
if !namespace_re.0.is_match(surface.namespace()) {
return false;
}
}
true
}
+3 -5
View File
@@ -1,5 +1,4 @@
use std::collections::HashMap;
use std::time::Duration;
use anyhow::Context as _;
use glam::{Mat3, Vec2};
@@ -138,16 +137,15 @@ impl ClosingWindow {
})
}
pub fn advance_animations(&mut self, current_time: Duration) {
pub fn advance_animations(&mut self) {
match &mut self.anim_state {
AnimationState::Waiting { blocker, anim } => {
if blocker.state() != BlockerState::Pending {
let mut anim = anim.restarted(0., 1., 0.);
anim.set_current_time(current_time);
let anim = anim.restarted(0., 1., 0.);
self.anim_state = AnimationState::Animating(anim);
}
}
AnimationState::Animating(anim) => anim.set_current_time(current_time),
AnimationState::Animating(_anim) => (),
}
}
File diff suppressed because it is too large Load Diff
+19 -18
View File
@@ -1,8 +1,8 @@
use std::iter::zip;
use arrayvec::ArrayVec;
use niri_config::{CornerRadius, Gradient, GradientInterpolation, GradientRelativeTo};
use smithay::backend::renderer::element::Kind;
use niri_config::{CornerRadius, Gradient, GradientRelativeTo};
use smithay::backend::renderer::element::{Element as _, Kind};
use smithay::utils::{Logical, Point, Rectangle, Size};
use crate::niri_render_elements;
@@ -53,6 +53,7 @@ impl FocusRing {
}
}
#[allow(clippy::too_many_arguments)]
pub fn update_render_elements(
&mut self,
win_size: Size<f64, Logical>,
@@ -61,6 +62,7 @@ impl FocusRing {
view_rect: Rectangle<f64, Logical>,
radius: CornerRadius,
scale: f64,
alpha: f32,
) {
let width = self.config.width.0;
self.full_size = win_size + Size::from((width, width)).upscale(2.);
@@ -86,15 +88,9 @@ impl FocusRing {
self.use_border_shader = radius != CornerRadius::default() || gradient.is_some();
// Set the defaults for solid color + rounded corners.
let gradient = gradient.unwrap_or(Gradient {
from: color,
to: color,
angle: 0,
relative_to: GradientRelativeTo::Window,
in_: GradientInterpolation::default(),
});
let gradient = gradient.unwrap_or_else(|| Gradient::from(color));
let full_rect = Rectangle::from_loc_and_size((-width, -width), self.full_size);
let full_rect = Rectangle::new(Point::from((-width, -width)), self.full_size);
let gradient_area = match gradient.relative_to {
GradientRelativeTo::Window => full_rect,
GradientRelativeTo::WorkspaceView => view_rect,
@@ -178,15 +174,16 @@ impl FocusRing {
for (border, (loc, size)) in zip(&mut self.borders, zip(self.locations, self.sizes)) {
border.update(
size,
Rectangle::from_loc_and_size(gradient_area.loc - loc, gradient_area.size),
Rectangle::new(gradient_area.loc - loc, gradient_area.size),
gradient.in_,
gradient.from,
gradient.to,
((gradient.angle as f32) - 90.).to_radians(),
Rectangle::from_loc_and_size(full_rect.loc - loc, full_rect.size),
Rectangle::new(full_rect.loc - loc, full_rect.size),
rounded_corner_border_width,
radius,
scale as f32,
alpha,
);
}
} else {
@@ -196,18 +193,16 @@ impl FocusRing {
self.borders[0].update(
self.sizes[0],
Rectangle::from_loc_and_size(
gradient_area.loc - self.locations[0],
gradient_area.size,
),
Rectangle::new(gradient_area.loc - self.locations[0], gradient_area.size),
gradient.in_,
gradient.from,
gradient.to,
((gradient.angle as f32) - 90.).to_radians(),
Rectangle::from_loc_and_size(full_rect.loc - self.locations[0], full_rect.size),
Rectangle::new(full_rect.loc - self.locations[0], full_rect.size),
rounded_corner_border_width,
radius,
scale as f32,
alpha,
);
}
@@ -238,7 +233,9 @@ impl FocusRing {
let elem = if self.use_border_shader && has_border_shader {
border.clone().with_location(location).into()
} else {
SolidColorRenderElement::from_buffer(buffer, location, 1., Kind::Unspecified).into()
let alpha = border.alpha();
SolidColorRenderElement::from_buffer(buffer, location, alpha, Kind::Unspecified)
.into()
};
rv.push(elem);
};
@@ -265,4 +262,8 @@ impl FocusRing {
pub fn is_off(&self) -> bool {
self.config.off
}
pub fn config(&self) -> &niri_config::FocusRing {
&self.config
}
}
+61
View File
@@ -0,0 +1,61 @@
use niri_config::{CornerRadius, FloatOrInt};
use smithay::utils::{Logical, Point, Rectangle, Size};
use super::focus_ring::{FocusRing, FocusRingRenderElement};
use crate::render_helpers::renderer::NiriRenderer;
#[derive(Debug)]
pub struct InsertHintElement {
inner: FocusRing,
}
pub type InsertHintRenderElement = FocusRingRenderElement;
impl InsertHintElement {
pub fn new(config: niri_config::InsertHint) -> Self {
Self {
inner: FocusRing::new(niri_config::FocusRing {
off: config.off,
width: FloatOrInt(0.),
active_color: config.color,
inactive_color: config.color,
active_gradient: config.gradient,
inactive_gradient: config.gradient,
}),
}
}
pub fn update_config(&mut self, config: niri_config::InsertHint) {
self.inner.update_config(niri_config::FocusRing {
off: config.off,
width: FloatOrInt(0.),
active_color: config.color,
inactive_color: config.color,
active_gradient: config.gradient,
inactive_gradient: config.gradient,
});
}
pub fn update_shaders(&mut self) {
self.inner.update_shaders();
}
pub fn update_render_elements(
&mut self,
size: Size<f64, Logical>,
view_rect: Rectangle<f64, Logical>,
radius: CornerRadius,
scale: f64,
) {
self.inner
.update_render_elements(size, true, false, view_rect, radius, scale, 1.);
}
pub fn render(
&self,
renderer: &mut impl NiriRenderer,
location: Point<f64, Logical>,
) -> impl Iterator<Item = FocusRingRenderElement> {
self.inner.render(renderer, location)
}
}
+1641 -2850
View File
File diff suppressed because it is too large Load Diff
+374 -279
View File
File diff suppressed because it is too large Load Diff
+2 -5
View File
@@ -1,5 +1,4 @@
use std::collections::HashMap;
use std::time::Duration;
use anyhow::Context as _;
use glam::{Mat3, Vec2};
@@ -41,9 +40,7 @@ impl OpenAnimation {
}
}
pub fn advance_animations(&mut self, current_time: Duration) {
self.anim.set_current_time(current_time);
}
pub fn advance_animations(&mut self) {}
pub fn is_done(&self) -> bool {
self.anim.is_done()
@@ -75,7 +72,7 @@ impl OpenAnimation {
let texture_size = geo.size.to_f64().to_logical(scale);
if Shaders::get(renderer).program(ProgramType::Open).is_some() {
let mut area = Rectangle::from_loc_and_size(location + offset, texture_size);
let mut area = Rectangle::new(location + offset, texture_size);
// Expand the area a bit to allow for more varied effects.
let mut target_size = area.size.upscale(1.5);
File diff suppressed because it is too large Load Diff
+178
View File
@@ -0,0 +1,178 @@
use std::iter::zip;
use niri_config::CornerRadius;
use smithay::utils::{Logical, Point, Rectangle, Size};
use crate::render_helpers::renderer::NiriRenderer;
use crate::render_helpers::shadow::ShadowRenderElement;
#[derive(Debug)]
pub struct Shadow {
shader_rects: Vec<Rectangle<f64, Logical>>,
shaders: Vec<ShadowRenderElement>,
config: niri_config::Shadow,
}
impl Shadow {
pub fn new(config: niri_config::Shadow) -> Self {
Self {
shader_rects: Vec::new(),
shaders: Vec::new(),
config,
}
}
pub fn update_config(&mut self, config: niri_config::Shadow) {
self.config = config;
}
pub fn update_shaders(&mut self) {
for elem in &mut self.shaders {
elem.damage_all();
}
}
pub fn update_render_elements(
&mut self,
win_size: Size<f64, Logical>,
is_active: bool,
radius: CornerRadius,
scale: f64,
alpha: f32,
) {
let ceil = |logical: f64| (logical * scale).ceil() / scale;
// All of this stuff should end up aligned to physical pixels because:
// * Window size is rounded to physical pixels before being passed to this function.
// * We will ceil the corner radii below.
// * We do not divide anything, only add, subtract and multiply by integers.
// * At rendering time, tile positions are rounded to physical pixels.
let width = self.config.softness.0;
// Like in CSS box-shadow.
let sigma = width / 2.;
// Adjust width to draw all necessary pixels.
let width = ceil(sigma * 3.);
let offset = self.config.offset;
let offset = Point::from((ceil(offset.x.0), ceil(offset.y.0)));
let spread = ceil(self.config.spread.0);
let offset = offset - Point::from((spread, spread));
let win_radius = radius.fit_to(win_size.w as f32, win_size.h as f32);
let box_size = win_size + Size::from((spread, spread)).upscale(2.);
let radius = win_radius.expanded_by(spread as f32);
let shader_size = box_size + Size::from((width, width)).upscale(2.);
let color = if is_active {
self.config.color
} else {
// Default to slightly more transparent.
self.config
.inactive_color
.unwrap_or(self.config.color * 0.75)
};
let shader_geo = Rectangle::new(Point::from((-width, -width)), shader_size);
// This is actually offset relative to shader_geo, this is handled below.
let window_geo = Rectangle::new(Point::from((0., 0.)), win_size);
if !self.config.draw_behind_window {
let top_left = ceil(f64::from(win_radius.top_left));
let top_right = f64::min(win_size.w - top_left, ceil(f64::from(win_radius.top_right)));
let bottom_left = f64::min(
win_size.h - top_left,
ceil(f64::from(win_radius.bottom_left)),
);
let bottom_right = f64::min(
win_size.h - top_right,
f64::min(
win_size.w - bottom_left,
ceil(f64::from(win_radius.bottom_right)),
),
);
let top_left = Rectangle::new(Point::from((0., 0.)), Size::from((top_left, top_left)));
let top_right = Rectangle::new(
Point::from((win_size.w - top_right, 0.)),
Size::from((top_right, top_right)),
);
let bottom_right = Rectangle::new(
Point::from((win_size.w - bottom_right, win_size.h - bottom_right)),
Size::from((bottom_right, bottom_right)),
);
let bottom_left = Rectangle::new(
Point::from((0., win_size.h - bottom_left)),
Size::from((bottom_left, bottom_left)),
);
let mut background =
window_geo.subtract_rects([top_left, top_right, bottom_right, bottom_left]);
for rect in &mut background {
rect.loc -= offset;
}
self.shader_rects = shader_geo.subtract_rects(background);
self.shaders
.resize_with(self.shader_rects.len(), Default::default);
for (shader, rect) in zip(&mut self.shaders, &mut self.shader_rects) {
shader.update(
rect.size,
Rectangle::new(rect.loc.upscale(-1.), box_size),
color,
sigma as f32,
radius,
scale as f32,
Rectangle::new(window_geo.loc - offset - rect.loc, window_geo.size),
win_radius,
alpha,
);
rect.loc += offset;
}
} else {
self.shader_rects.resize_with(1, Default::default);
self.shader_rects[0] = shader_geo;
self.shaders.resize_with(1, Default::default);
self.shaders[0].update(
shader_geo.size,
Rectangle::new(shader_geo.loc.upscale(-1.), box_size),
color,
sigma as f32,
radius,
scale as f32,
Rectangle::zero(),
Default::default(),
alpha,
);
self.shader_rects[0].loc += offset;
}
}
pub fn render(
&self,
renderer: &mut impl NiriRenderer,
location: Point<f64, Logical>,
) -> impl Iterator<Item = ShadowRenderElement> + '_ {
if !self.config.on {
return None.into_iter().flatten();
}
let has_shadow_shader = ShadowRenderElement::has_shader(renderer);
if !has_shadow_shader {
return None.into_iter().flatten();
}
let rv = zip(&self.shaders, &self.shader_rects)
.map(move |(shader, rect)| shader.clone().with_location(location + rect.loc));
Some(rv).into_iter().flatten()
}
}
+401
View File
@@ -0,0 +1,401 @@
use std::iter::zip;
use std::mem;
use niri_config::{CornerRadius, Gradient, GradientRelativeTo, TabIndicatorPosition};
use smithay::utils::{Logical, Point, Rectangle, Size};
use super::tile::Tile;
use super::LayoutElement;
use crate::animation::{Animation, Clock};
use crate::niri_render_elements;
use crate::render_helpers::border::BorderRenderElement;
use crate::render_helpers::renderer::NiriRenderer;
use crate::utils::{floor_logical_in_physical_max1, round_logical_in_physical};
#[derive(Debug)]
pub struct TabIndicator {
shader_locs: Vec<Point<f64, Logical>>,
shaders: Vec<BorderRenderElement>,
open_anim: Option<Animation>,
config: niri_config::TabIndicator,
}
#[derive(Debug)]
pub struct TabInfo {
/// Gradient for the tab indicator.
pub gradient: Gradient,
/// Tab geometry in the same coordinate system as the area.
pub geometry: Rectangle<f64, Logical>,
}
niri_render_elements! {
TabIndicatorRenderElement => {
Gradient = BorderRenderElement,
}
}
impl TabIndicator {
pub fn new(config: niri_config::TabIndicator) -> Self {
Self {
shader_locs: Vec::new(),
shaders: Vec::new(),
open_anim: None,
config,
}
}
pub fn update_config(&mut self, config: niri_config::TabIndicator) {
self.config = config;
}
pub fn update_shaders(&mut self) {
for elem in &mut self.shaders {
elem.damage_all();
}
}
pub fn advance_animations(&mut self) {
if let Some(anim) = &mut self.open_anim {
if anim.is_done() {
self.open_anim = None;
}
}
}
pub fn are_animations_ongoing(&self) -> bool {
self.open_anim.is_some()
}
pub fn start_open_animation(&mut self, clock: Clock, config: niri_config::Animation) {
self.open_anim = Some(Animation::new(clock, 0., 1., 0., config));
}
fn tab_rects(
&self,
area: Rectangle<f64, Logical>,
count: usize,
scale: f64,
) -> impl Iterator<Item = Rectangle<f64, Logical>> {
let round = |logical: f64| round_logical_in_physical(scale, logical);
let progress = self.open_anim.as_ref().map_or(1., |a| a.value().max(0.));
let width = round(self.config.width.0);
let gap = round(self.config.gap.0);
let gaps_between = round(self.config.gaps_between_tabs.0);
let position = self.config.position;
let side = match position {
TabIndicatorPosition::Left | TabIndicatorPosition::Right => area.size.h,
TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => area.size.w,
};
let total_prop = self.config.length.total_proportion.unwrap_or(0.5);
let min_length = round(side * total_prop.clamp(0., 2.));
// Compute px_per_tab before applying the animation to gaps_between in order to avoid it
// growing and shrinking over the duration of the animation.
let pixel = 1. / scale;
let shortest_length = count as f64 * (pixel + gaps_between) - gaps_between;
let length = f64::max(min_length, shortest_length);
let px_per_tab = (length + gaps_between) / count as f64 - gaps_between;
let px_per_tab = px_per_tab * progress;
let gaps_between = round(self.config.gaps_between_tabs.0 * progress);
let length = count as f64 * (px_per_tab + gaps_between) - gaps_between;
let px_per_tab = floor_logical_in_physical_max1(scale, px_per_tab);
let floored_length = count as f64 * (px_per_tab + gaps_between) - gaps_between;
let mut ones_left = ((length - floored_length) / pixel).round() as usize;
let mut shader_loc = Point::from((-gap - width, round((side - length) / 2.)));
match position {
TabIndicatorPosition::Left => (),
TabIndicatorPosition::Right => shader_loc.x = area.size.w + gap,
TabIndicatorPosition::Top => mem::swap(&mut shader_loc.x, &mut shader_loc.y),
TabIndicatorPosition::Bottom => {
shader_loc.x = shader_loc.y;
shader_loc.y = area.size.h + gap;
}
}
shader_loc += area.loc;
(0..count).map(move |_| {
let mut px_per_tab = px_per_tab;
if ones_left > 0 {
ones_left -= 1;
px_per_tab += pixel;
}
let loc = shader_loc;
match position {
TabIndicatorPosition::Left | TabIndicatorPosition::Right => {
shader_loc.y += px_per_tab + gaps_between
}
TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => {
shader_loc.x += px_per_tab + gaps_between
}
}
let size = match position {
TabIndicatorPosition::Left | TabIndicatorPosition::Right => {
Size::from((width, px_per_tab))
}
TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => {
Size::from((px_per_tab, width))
}
};
Rectangle::new(loc, size)
})
}
#[allow(clippy::too_many_arguments)]
pub fn update_render_elements(
&mut self,
enabled: bool,
// Geometry of the tabs area.
area: Rectangle<f64, Logical>,
// View rect relative to the tabs area.
area_view_rect: Rectangle<f64, Logical>,
// Tab count, should match the tabs iterator length.
tab_count: usize,
tabs: impl Iterator<Item = TabInfo>,
is_active: bool,
scale: f64,
) {
if !enabled || self.config.off {
self.shader_locs.clear();
self.shaders.clear();
return;
}
let count = tab_count;
if self.config.hide_when_single_tab && count == 1 {
self.shader_locs.clear();
self.shaders.clear();
return;
}
self.shaders.resize_with(count, Default::default);
self.shader_locs.resize_with(count, Default::default);
let position = self.config.position;
let radius = self.config.corner_radius.0 as f32;
let shared_rounded_corners = self.config.gaps_between_tabs.0 == 0.;
let mut tabs_left = tab_count;
let rects = self.tab_rects(area, count, scale);
for ((shader, loc), (tab, rect)) in zip(
zip(&mut self.shaders, &mut self.shader_locs),
zip(tabs, rects),
) {
*loc = rect.loc;
let mut gradient_area = match tab.gradient.relative_to {
GradientRelativeTo::Window => tab.geometry,
GradientRelativeTo::WorkspaceView => area_view_rect,
};
gradient_area.loc -= *loc;
let mut color_from = tab.gradient.from;
let mut color_to = tab.gradient.to;
if !is_active {
color_from *= 0.5;
color_to *= 0.5;
}
let radius = if shared_rounded_corners && tab_count > 1 {
if tabs_left == tab_count {
// First tab.
match position {
TabIndicatorPosition::Left | TabIndicatorPosition::Right => CornerRadius {
top_left: radius,
top_right: radius,
bottom_right: 0.,
bottom_left: 0.,
},
TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => CornerRadius {
top_left: radius,
top_right: 0.,
bottom_right: 0.,
bottom_left: radius,
},
}
} else if tabs_left == 1 {
// Last tab.
match position {
TabIndicatorPosition::Left | TabIndicatorPosition::Right => CornerRadius {
top_left: 0.,
top_right: 0.,
bottom_right: radius,
bottom_left: radius,
},
TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => CornerRadius {
top_left: 0.,
top_right: radius,
bottom_right: radius,
bottom_left: 0.,
},
}
} else {
// Tab in the middle.
CornerRadius::default()
}
} else {
// Separate tabs, or the only tab.
CornerRadius::from(radius)
};
let radius = radius.fit_to(rect.size.w as f32, rect.size.h as f32);
tabs_left -= 1;
shader.update(
rect.size,
gradient_area,
tab.gradient.in_,
color_from,
color_to,
((tab.gradient.angle as f32) - 90.).to_radians(),
Rectangle::from_size(rect.size),
0.,
radius,
scale as f32,
1.,
);
}
}
pub fn hit(
&self,
area: Rectangle<f64, Logical>,
tab_count: usize,
scale: f64,
point: Point<f64, Logical>,
) -> Option<usize> {
if self.config.off {
return None;
}
let count = tab_count;
if self.config.hide_when_single_tab && count == 1 {
return None;
}
self.tab_rects(area, count, scale)
.enumerate()
.find_map(|(idx, rect)| rect.contains(point).then_some(idx))
}
pub fn render(
&self,
renderer: &mut impl NiriRenderer,
pos: Point<f64, Logical>,
) -> impl Iterator<Item = TabIndicatorRenderElement> + '_ {
let has_border_shader = BorderRenderElement::has_shader(renderer);
if !has_border_shader {
return None.into_iter().flatten();
}
let rv = zip(&self.shaders, &self.shader_locs)
.map(move |(shader, loc)| shader.clone().with_location(pos + *loc))
.map(TabIndicatorRenderElement::from);
Some(rv).into_iter().flatten()
}
/// Extra size occupied by the tab indicator.
pub fn extra_size(&self, tab_count: usize, scale: f64) -> Size<f64, Logical> {
if self.config.off
|| !self.config.place_within_column
|| (self.config.hide_when_single_tab && tab_count == 1)
{
return Size::from((0., 0.));
}
let round = |logical: f64| round_logical_in_physical(scale, logical);
let width = round(self.config.width.0);
let gap = round(self.config.gap.0);
// No, I am *not* falling into the rabbit hole of "what if the tab indicator is wide enough
// that it peeks from the other side of the window".
let size = f64::max(0., width + gap);
match self.config.position {
TabIndicatorPosition::Left | TabIndicatorPosition::Right => Size::from((size, 0.)),
TabIndicatorPosition::Top | TabIndicatorPosition::Bottom => Size::from((0., size)),
}
}
/// Offset of the tabbed content due to space occupied by the tab indicator.
pub fn content_offset(&self, tab_count: usize, scale: f64) -> Point<f64, Logical> {
match self.config.position {
TabIndicatorPosition::Left | TabIndicatorPosition::Top => {
self.extra_size(tab_count, scale).to_point()
}
TabIndicatorPosition::Right | TabIndicatorPosition::Bottom => Point::from((0., 0.)),
}
}
pub fn config(&self) -> niri_config::TabIndicator {
self.config
}
}
impl TabInfo {
pub fn from_tile<W: LayoutElement>(
tile: &Tile<W>,
position: Point<f64, Logical>,
is_active: bool,
config: &niri_config::TabIndicator,
) -> Self {
let rules = tile.window().rules();
let rule = rules.tab_indicator;
let gradient_from_rule = || {
let (color, gradient) = if is_active {
(rule.active_color, rule.active_gradient)
} else {
(rule.inactive_color, rule.inactive_gradient)
};
let color = color.map(Gradient::from);
gradient.or(color)
};
let gradient_from_config = || {
let (color, gradient) = if is_active {
(config.active_color, config.active_gradient)
} else {
(config.inactive_color, config.inactive_gradient)
};
let color = color.map(Gradient::from);
gradient.or(color)
};
let gradient_from_border = || {
// Come up with tab indicator gradient matching the focus ring or the border, whichever
// one is enabled.
let focus_ring_config = tile.focus_ring().config();
let border_config = tile.border().config();
let config = if focus_ring_config.off {
border_config
} else {
focus_ring_config
};
let (color, gradient) = if is_active {
(config.active_color, config.active_gradient)
} else {
(config.inactive_color, config.inactive_gradient)
};
gradient.unwrap_or_else(|| Gradient::from(color))
};
let gradient = gradient_from_rule()
.or_else(gradient_from_config)
.unwrap_or_else(gradient_from_border);
let geometry = Rectangle::new(position, tile.animated_tile_size());
TabInfo { gradient, geometry }
}
}
+3350
View File
File diff suppressed because it is too large Load Diff
+290 -72
View File
@@ -1,5 +1,5 @@
use core::f64;
use std::rc::Rc;
use std::time::Duration;
use niri_config::{Color, CornerRadius, GradientInterpolation};
use smithay::backend::allocator::Fourcc;
@@ -9,20 +9,23 @@ use smithay::utils::{Logical, Point, Rectangle, Scale, Size, Transform};
use super::focus_ring::{FocusRing, FocusRingRenderElement};
use super::opening_window::{OpenAnimation, OpeningWindowRenderElement};
use super::shadow::Shadow;
use super::{
LayoutElement, LayoutElementRenderElement, LayoutElementRenderSnapshot, Options,
RESIZE_ANIMATION_THRESHOLD,
HitType, LayoutElement, LayoutElementRenderElement, LayoutElementRenderSnapshot, Options,
SizeFrac, RESIZE_ANIMATION_THRESHOLD,
};
use crate::animation::Animation;
use crate::animation::{Animation, Clock};
use crate::niri_render_elements;
use crate::render_helpers::border::BorderRenderElement;
use crate::render_helpers::clipped_surface::{ClippedSurfaceRenderElement, RoundedCornerDamage};
use crate::render_helpers::damage::ExtraDamage;
use crate::render_helpers::renderer::NiriRenderer;
use crate::render_helpers::resize::ResizeRenderElement;
use crate::render_helpers::shadow::ShadowRenderElement;
use crate::render_helpers::snapshot::RenderSnapshot;
use crate::render_helpers::solid_color::{SolidColorBuffer, SolidColorRenderElement};
use crate::render_helpers::{render_to_encompassing_texture, RenderTarget};
use crate::utils::round_logical_in_physical;
use crate::utils::transaction::Transaction;
/// Toplevel window with decorations.
@@ -35,11 +38,11 @@ pub struct Tile<W: LayoutElement> {
border: FocusRing,
/// The focus ring around the window.
///
/// It's supposed to be on the Workspace, but for the sake of a nicer open animation it's
/// currently here.
focus_ring: FocusRing,
/// The shadow around the window.
shadow: Shadow,
/// Whether this tile is fullscreen.
///
/// This will update only when the `window` actually goes fullscreen, rather than right away,
@@ -49,8 +52,27 @@ pub struct Tile<W: LayoutElement> {
/// The black backdrop for fullscreen windows.
fullscreen_backdrop: SolidColorBuffer,
/// The size we were requested to fullscreen into.
fullscreen_size: Size<f64, Logical>,
/// Whether the tile should float upon unfullscreening.
pub(super) unfullscreen_to_floating: bool,
/// The size that the window should assume when going floating.
///
/// This is generally the last size the window had when it was floating. It can be unknown if
/// the window starts out in the tiling layout or fullscreen.
pub(super) floating_window_size: Option<Size<i32, Logical>>,
/// The position that the tile should assume when going floating, relative to the floating
/// space working area.
///
/// This is generally the last position the tile had when it was floating. It can be unknown if
/// the window starts out in the tiling layout.
pub(super) floating_pos: Option<Point<f64, SizeFrac>>,
/// Currently selected preset width index when this tile is floating.
pub(super) floating_preset_width_idx: Option<usize>,
/// Currently selected preset height index when this tile is floating.
pub(super) floating_preset_height_idx: Option<usize>,
/// The animation upon opening a window.
open_animation: Option<OpenAnimation>,
@@ -64,6 +86,9 @@ pub struct Tile<W: LayoutElement> {
/// The animation of a tile visually moving vertically.
move_y_animation: Option<MoveAnimation>,
/// The animation of the tile's opacity.
pub(super) alpha_animation: Option<Animation>,
/// Offset during the initial interactive move rubberband.
pub(super) interactive_move_offset: Point<f64, Logical>,
@@ -73,9 +98,17 @@ pub struct Tile<W: LayoutElement> {
/// Extra damage for clipped surface corner radius changes.
rounded_corner_damage: RoundedCornerDamage,
/// The view size for the tile's workspace.
///
/// Used as the fullscreen target size.
view_size: Size<f64, Logical>,
/// Scale of the output the tile is on (and rounds its sizes to).
scale: f64,
/// Clock for driving animations.
pub(super) clock: Clock,
/// Configurable properties of the layout.
pub(super) options: Rc<Options>,
}
@@ -88,6 +121,7 @@ niri_render_elements! {
Opening = OpeningWindowRenderElement,
Resize = ResizeRenderElement,
Border = BorderRenderElement,
Shadow = ShadowRenderElement,
ClippedSurface = ClippedSurfaceRenderElement<R>,
ExtraDamage = ExtraDamage,
}
@@ -110,31 +144,61 @@ struct MoveAnimation {
}
impl<W: LayoutElement> Tile<W> {
pub fn new(window: W, scale: f64, options: Rc<Options>) -> Self {
pub fn new(
window: W,
view_size: Size<f64, Logical>,
scale: f64,
clock: Clock,
options: Rc<Options>,
) -> Self {
let rules = window.rules();
let border_config = rules.border.resolve_against(options.border);
let focus_ring_config = rules.focus_ring.resolve_against(options.focus_ring.into());
let shadow_config = rules.shadow.resolve_against(options.shadow);
let is_fullscreen = window.is_fullscreen();
Self {
window,
border: FocusRing::new(border_config.into()),
focus_ring: FocusRing::new(focus_ring_config.into()),
is_fullscreen: false, // FIXME: up-to-date fullscreen right away, but we need size.
fullscreen_backdrop: SolidColorBuffer::new((0., 0.), [0., 0., 0., 1.]),
fullscreen_size: Default::default(),
shadow: Shadow::new(shadow_config),
is_fullscreen,
fullscreen_backdrop: SolidColorBuffer::new(view_size, [0., 0., 0., 1.]),
unfullscreen_to_floating: false,
floating_window_size: None,
floating_pos: None,
floating_preset_width_idx: None,
floating_preset_height_idx: None,
open_animation: None,
resize_animation: None,
move_x_animation: None,
move_y_animation: None,
alpha_animation: None,
interactive_move_offset: Point::from((0., 0.)),
unmap_snapshot: None,
rounded_corner_damage: Default::default(),
view_size,
scale,
clock,
options,
}
}
pub fn update_config(&mut self, scale: f64, options: Rc<Options>) {
pub fn update_config(
&mut self,
view_size: Size<f64, Logical>,
scale: f64,
options: Rc<Options>,
) {
// If preset widths or heights changed, clear our stored preset index.
if self.options.preset_column_widths != options.preset_column_widths {
self.floating_preset_width_idx = None;
}
if self.options.preset_window_heights != options.preset_window_heights {
self.floating_preset_height_idx = None;
}
self.view_size = view_size;
self.scale = scale;
self.options = options;
@@ -147,18 +211,21 @@ impl<W: LayoutElement> Tile<W> {
.focus_ring
.resolve_against(self.options.focus_ring.into());
self.focus_ring.update_config(focus_ring_config.into());
let shadow_config = rules.shadow.resolve_against(self.options.shadow);
self.shadow.update_config(shadow_config);
self.fullscreen_backdrop.resize(view_size);
}
pub fn update_shaders(&mut self) {
self.border.update_shaders();
self.focus_ring.update_shaders();
self.shadow.update_shaders();
}
pub fn update_window(&mut self) {
// FIXME: remove when we can get a fullscreen size right away.
if self.fullscreen_size != Size::from((0., 0.)) {
self.is_fullscreen = self.window.is_fullscreen();
}
self.is_fullscreen = self.window.is_fullscreen();
if let Some(animate_from) = self.window.take_animation_snapshot() {
let size_from = if let Some(resize) = self.resize_animation.take() {
@@ -180,7 +247,13 @@ impl<W: LayoutElement> Tile<W> {
let change = self.window.size().to_f64().to_point() - size_from.to_point();
let change = f64::max(change.x.abs(), change.y.abs());
if change > RESIZE_ANIMATION_THRESHOLD {
let anim = Animation::new(0., 1., 0., self.options.animations.window_resize.anim);
let anim = Animation::new(
self.clock.clone(),
0.,
1.,
0.,
self.options.animations.window_resize.anim,
);
self.resize_animation = Some(ResizeAnimation {
anim,
size_from,
@@ -199,6 +272,9 @@ impl<W: LayoutElement> Tile<W> {
.resolve_against(self.options.focus_ring.into());
self.focus_ring.update_config(focus_ring_config.into());
let shadow_config = rules.shadow.resolve_against(self.options.shadow);
self.shadow.update_config(shadow_config);
let window_size = self.window_size();
let radius = rules
.geometry_corner_radius
@@ -208,44 +284,52 @@ impl<W: LayoutElement> Tile<W> {
self.rounded_corner_damage.set_size(window_size);
}
pub fn advance_animations(&mut self, current_time: Duration) {
pub fn advance_animations(&mut self) {
if let Some(open) = &mut self.open_animation {
open.advance_animations(current_time);
if open.is_done() {
self.open_animation = None;
}
}
if let Some(resize) = &mut self.resize_animation {
resize.anim.set_current_time(current_time);
if resize.anim.is_done() {
self.resize_animation = None;
}
}
if let Some(move_) = &mut self.move_x_animation {
move_.anim.set_current_time(current_time);
if move_.anim.is_done() {
self.move_x_animation = None;
}
}
if let Some(move_) = &mut self.move_y_animation {
move_.anim.set_current_time(current_time);
if move_.anim.is_done() {
self.move_y_animation = None;
}
}
if let Some(alpha) = &mut self.alpha_animation {
if alpha.is_done() {
self.alpha_animation = None;
}
}
}
pub fn are_animations_ongoing(&self) -> bool {
self.are_transitions_ongoing() || self.window.rules().baba_is_float == Some(true)
}
pub fn are_transitions_ongoing(&self) -> bool {
self.open_animation.is_some()
|| self.resize_animation.is_some()
|| self.move_x_animation.is_some()
|| self.move_y_animation.is_some()
|| self.alpha_animation.is_some()
}
pub fn update(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) {
pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) {
let rules = self.window.rules();
let alpha = self.tile_alpha();
let draw_border_with_background = rules
.draw_border_with_background
@@ -264,12 +348,28 @@ impl<W: LayoutElement> Tile<W> {
self.animated_window_size(),
is_active,
!draw_border_with_background,
Rectangle::from_loc_and_size(
Rectangle::new(
view_rect.loc - Point::from((border_width, border_width)),
view_rect.size,
),
radius,
self.scale,
alpha,
);
let radius = if self.is_fullscreen {
CornerRadius::default()
} else if self.effective_border_width().is_some() {
radius
} else {
rules.geometry_corner_radius.unwrap_or_default()
};
self.shadow.update_render_elements(
self.animated_tile_size(),
is_active,
radius,
self.scale,
alpha,
);
let draw_focus_ring_with_background = if self.effective_border_width().is_some() {
@@ -277,14 +377,7 @@ impl<W: LayoutElement> Tile<W> {
} else {
draw_border_with_background
};
let radius = if self.is_fullscreen {
CornerRadius::default()
} else if self.effective_border_width().is_some() {
radius
} else {
rules.geometry_corner_radius.unwrap_or_default()
}
.expanded_by(self.focus_ring.width() as f32);
let radius = radius.expanded_by(self.focus_ring.width() as f32);
self.focus_ring.update_render_elements(
self.animated_tile_size(),
is_active,
@@ -292,6 +385,7 @@ impl<W: LayoutElement> Tile<W> {
view_rect,
radius,
self.scale,
alpha,
);
}
@@ -316,6 +410,7 @@ impl<W: LayoutElement> Tile<W> {
pub fn start_open_animation(&mut self) {
self.open_animation = Some(OpenAnimation::new(Animation::new(
self.clock.clone(),
0.,
1.,
0.,
@@ -343,7 +438,7 @@ impl<W: LayoutElement> Tile<W> {
let anim = self.move_x_animation.take().map(|move_| move_.anim);
let anim = anim
.map(|anim| anim.restarted(1., 0., 0.))
.unwrap_or_else(|| Animation::new(1., 0., 0., config));
.unwrap_or_else(|| Animation::new(self.clock.clone(), 1., 0., 0., config));
self.move_x_animation = Some(MoveAnimation {
anim,
@@ -362,7 +457,7 @@ impl<W: LayoutElement> Tile<W> {
let anim = self.move_y_animation.take().map(|move_| move_.anim);
let anim = anim
.map(|anim| anim.restarted(1., 0., 0.))
.unwrap_or_else(|| Animation::new(1., 0., 0., config));
.unwrap_or_else(|| Animation::new(self.clock.clone(), 1., 0., 0., config));
self.move_y_animation = Some(MoveAnimation {
anim,
@@ -375,6 +470,31 @@ impl<W: LayoutElement> Tile<W> {
self.move_y_animation = None;
}
pub fn animate_alpha(&mut self, from: f64, to: f64, config: niri_config::Animation) {
let from = from.clamp(0., 1.);
let to = to.clamp(0., 1.);
let current = self.alpha_animation.take().map(|anim| anim.clamped_value());
let current = current.unwrap_or(from);
self.alpha_animation = Some(Animation::new(self.clock.clone(), current, to, 0., config));
}
pub fn ensure_alpha_animates_to_1(&mut self) {
if let Some(anim) = &self.alpha_animation {
if anim.to() != 1. {
// Cancel animation instead of starting a new one because the user likely wants to
// see the tile right away.
self.alpha_animation = None;
}
}
}
/// Opacity that applies to both window and decorations.
fn tile_alpha(&self) -> f32 {
self.alpha_animation
.as_ref()
.map_or(1., |anim| anim.clamped_value()) as f32
}
pub fn window(&self) -> &W {
&self.window
}
@@ -383,16 +503,12 @@ impl<W: LayoutElement> Tile<W> {
&mut self.window
}
pub fn into_window(self) -> W {
self.window
}
pub fn is_fullscreen(&self) -> bool {
self.is_fullscreen
}
/// Returns `None` if the border is hidden and `Some(width)` if it should be shown.
fn effective_border_width(&self) -> Option<f64> {
pub fn effective_border_width(&self) -> Option<f64> {
if self.is_fullscreen {
return None;
}
@@ -411,7 +527,7 @@ impl<W: LayoutElement> Tile<W> {
// In fullscreen, center the window in the given size.
if self.is_fullscreen {
let window_size = self.window_size();
let target_size = self.fullscreen_size;
let target_size = self.view_size;
// Windows aren't supposed to be larger than the fullscreen size, but in case we get
// one, leave it at the top-left as usual.
@@ -441,8 +557,27 @@ impl<W: LayoutElement> Tile<W> {
if self.is_fullscreen {
// Normally we'd just return the fullscreen size here, but this makes things a bit
// nicer if a fullscreen window is bigger than the fullscreen size for some reason.
size.w = f64::max(size.w, self.fullscreen_size.w);
size.h = f64::max(size.h, self.fullscreen_size.h);
size.w = f64::max(size.w, self.view_size.w);
size.h = f64::max(size.h, self.view_size.h);
return size;
}
if let Some(width) = self.effective_border_width() {
size.w += width * 2.;
size.h += width * 2.;
}
size
}
pub fn tile_expected_or_current_size(&self) -> Size<f64, Logical> {
let mut size = self.window_expected_or_current_size();
if self.is_fullscreen {
// Normally we'd just return the fullscreen size here, but this makes things a bit
// nicer if a fullscreen window is bigger than the fullscreen size for some reason.
size.w = f64::max(size.w, self.view_size.w);
size.h = f64::max(size.h, self.view_size.h);
return size;
}
@@ -462,7 +597,16 @@ impl<W: LayoutElement> Tile<W> {
size
}
fn animated_window_size(&self) -> Size<f64, Logical> {
pub fn window_expected_or_current_size(&self) -> Size<f64, Logical> {
let size = self.window.expected_size();
let mut size = size.unwrap_or_else(|| self.window.size()).to_f64();
size = size
.to_physical_precise_round(self.scale)
.to_logical(self.scale);
size
}
pub fn animated_window_size(&self) -> Size<f64, Logical> {
let mut size = self.window_size();
if let Some(resize) = &self.resize_animation {
@@ -479,14 +623,14 @@ impl<W: LayoutElement> Tile<W> {
size
}
fn animated_tile_size(&self) -> Size<f64, Logical> {
pub fn animated_tile_size(&self) -> Size<f64, Logical> {
let mut size = self.animated_window_size();
if self.is_fullscreen {
// Normally we'd just return the fullscreen size here, but this makes things a bit
// nicer if a fullscreen window is bigger than the fullscreen size for some reason.
size.w = f64::max(size.w, self.fullscreen_size.w);
size.h = f64::max(size.h, self.fullscreen_size.h);
size.w = f64::max(size.w, self.view_size.w);
size.h = f64::max(size.h, self.view_size.h);
return size;
}
@@ -505,16 +649,32 @@ impl<W: LayoutElement> Tile<W> {
loc
}
pub fn is_in_input_region(&self, mut point: Point<f64, Logical>) -> bool {
fn is_in_input_region(&self, mut point: Point<f64, Logical>) -> bool {
point -= self.window_loc().to_f64();
self.window.is_in_input_region(point)
}
pub fn is_in_activation_region(&self, point: Point<f64, Logical>) -> bool {
let activation_region = Rectangle::from_loc_and_size((0., 0.), self.tile_size());
fn is_in_activation_region(&self, point: Point<f64, Logical>) -> bool {
let activation_region = Rectangle::from_size(self.tile_size());
activation_region.contains(point)
}
pub fn hit(&self, point: Point<f64, Logical>) -> Option<HitType> {
let offset = self.bob_offset();
let point = point - offset;
if self.is_in_input_region(point) {
let win_pos = self.buf_loc() + offset;
Some(HitType::Input { win_pos })
} else if self.is_in_activation_region(point) {
Some(HitType::Activate {
is_tab_indicator: false,
})
} else {
None
}
}
pub fn request_tile_size(
&mut self,
mut size: Size<f64, Logical>,
@@ -567,10 +727,9 @@ impl<W: LayoutElement> Tile<W> {
}
}
pub fn request_fullscreen(&mut self, size: Size<f64, Logical>) {
self.fullscreen_backdrop.resize(size);
self.fullscreen_size = size;
self.window.request_fullscreen(size.to_i32_round());
pub fn request_fullscreen(&mut self) {
self.window
.request_fullscreen(self.view_size.to_i32_round());
}
pub fn min_size(&self) -> Size<f64, Logical> {
@@ -602,6 +761,18 @@ impl<W: LayoutElement> Tile<W> {
size
}
pub fn bob_offset(&self) -> Point<f64, Logical> {
if self.window.rules().baba_is_float != Some(true) {
return Point::from((0., 0.));
}
let now = self.clock.now().as_secs_f64();
let amplitude = self.view_size.h / 96.;
let y = amplitude * ((f64::consts::TAU * now / 3.6).sin() - 1.);
let y = round_logical_in_physical(self.scale, y);
Point::from((0., y))
}
pub fn draw_border_with_background(&self) -> bool {
if self.effective_border_width().is_some() {
return false;
@@ -613,27 +784,40 @@ impl<W: LayoutElement> Tile<W> {
.unwrap_or_else(|| !self.window.has_ssd())
}
fn render_inner<R: NiriRenderer>(
&self,
fn render_inner<'a, R: NiriRenderer + 'a>(
&'a self,
renderer: &mut R,
location: Point<f64, Logical>,
scale: Scale<f64>,
focus_ring: bool,
target: RenderTarget,
) -> impl Iterator<Item = TileRenderElement<R>> {
) -> impl Iterator<Item = TileRenderElement<R>> + 'a {
let _span = tracy_client::span!("Tile::render_inner");
let alpha = if self.is_fullscreen {
let win_alpha = if self.is_fullscreen || self.window.is_ignoring_opacity_window_rule() {
1.
} else {
self.window.rules().opacity.unwrap_or(1.).clamp(0., 1.)
};
let tile_alpha = self.tile_alpha();
let win_alpha = win_alpha * tile_alpha;
// This is here rather than in render_offset() because render_offset() is currently assumed
// by the code to be temporary. So, for example, interactive move will try to "grab" the
// tile at its current render offset and reset the render offset to zero by cancelling the
// tile move animations. On the other hand, bob_offset() is not resettable, so adding it in
// render_offset() would cause obvious animation glitches.
//
// This isn't to say that adding it here is perfect; indeed, it kind of breaks view_rect
// passed to update_render_elements(). But, it works well enough for what it is.
let location = location + self.bob_offset();
let window_loc = self.window_loc();
let window_size = self.window_size().to_f64();
let animated_window_size = self.animated_window_size();
let window_render_loc = location + window_loc;
let area = Rectangle::from_loc_and_size(window_render_loc, animated_window_size);
let area = Rectangle::new(window_render_loc, animated_window_size);
let rules = self.window.rules();
let clip_to_geometry = !self.is_fullscreen && rules.clip_to_geometry == Some(true);
@@ -647,7 +831,7 @@ impl<W: LayoutElement> Tile<W> {
if let Some(resize) = &self.resize_animation {
resize_popups = Some(
self.window
.render_popups(renderer, window_render_loc, scale, alpha, target)
.render_popups(renderer, window_render_loc, scale, win_alpha, target)
.into_iter()
.map(Into::into),
);
@@ -697,7 +881,7 @@ impl<W: LayoutElement> Tile<W> {
resize.anim.clamped_value().clamp(0., 1.) as f32,
radius,
clip_to_geometry,
alpha,
win_alpha,
);
// FIXME: with split popups, this will use the resize element ID for
// popups, but we want the real IDs.
@@ -714,7 +898,7 @@ impl<W: LayoutElement> Tile<W> {
SolidColorRenderElement::from_buffer(
&fallback_buffer,
area.loc,
alpha,
win_alpha,
Kind::Unspecified,
)
.into(),
@@ -730,9 +914,9 @@ impl<W: LayoutElement> Tile<W> {
if resize_shader.is_none() && resize_fallback.is_none() {
let window = self
.window
.render(renderer, window_render_loc, scale, alpha, target);
.render(renderer, window_render_loc, scale, win_alpha, target);
let geo = Rectangle::from_loc_and_size(window_render_loc, window_size);
let geo = Rectangle::new(window_render_loc, window_size);
let radius = radius.fit_to(window_size.w as f32, window_size.h as f32);
let clip_shader = ClippedSurfaceRenderElement::shader(renderer).cloned();
@@ -774,15 +958,16 @@ impl<W: LayoutElement> Tile<W> {
if radius != CornerRadius::default() && has_border_shader {
return BorderRenderElement::new(
geo.size,
Rectangle::from_loc_and_size((0., 0.), geo.size),
Rectangle::from_size(geo.size),
GradientInterpolation::default(),
Color::from_color32f(elem.color()),
Color::from_color32f(elem.color()),
0.,
Rectangle::from_loc_and_size((0., 0.), geo.size),
Rectangle::from_size(geo.size),
0.,
radius,
scale.x as f32,
1.,
)
.with_location(geo.loc)
.into();
@@ -809,7 +994,7 @@ impl<W: LayoutElement> Tile<W> {
SolidColorRenderElement::from_buffer(
&self.fullscreen_backdrop,
location,
1.,
tile_alpha,
Kind::Unspecified,
)
.into()
@@ -824,17 +1009,19 @@ impl<W: LayoutElement> Tile<W> {
let rv = rv.chain(elem.into_iter().flatten());
let elem = focus_ring.then(|| self.focus_ring.render(renderer, location).map(Into::into));
rv.chain(elem.into_iter().flatten())
let rv = rv.chain(elem.into_iter().flatten());
rv.chain(self.shadow.render(renderer, location).map(Into::into))
}
pub fn render<R: NiriRenderer>(
&self,
pub fn render<'a, R: NiriRenderer + 'a>(
&'a self,
renderer: &mut R,
location: Point<f64, Logical>,
scale: Scale<f64>,
focus_ring: bool,
target: RenderTarget,
) -> impl Iterator<Item = TileRenderElement<R>> {
) -> impl Iterator<Item = TileRenderElement<R>> + 'a {
let _span = tracy_client::span!("Tile::render");
let mut open_anim_elem = None;
@@ -916,4 +1103,35 @@ impl<W: LayoutElement> Tile<W> {
pub fn take_unmap_snapshot(&mut self) -> Option<TileRenderSnapshot> {
self.unmap_snapshot.take()
}
pub fn border(&self) -> &FocusRing {
&self.border
}
pub fn focus_ring(&self) -> &FocusRing {
&self.focus_ring
}
pub fn options(&self) -> &Rc<Options> {
&self.options
}
#[cfg(test)]
pub fn view_size(&self) -> Size<f64, Logical> {
self.view_size
}
#[cfg(test)]
pub fn verify_invariants(&self) {
use approx::assert_abs_diff_eq;
assert_eq!(self.is_fullscreen, self.window.is_fullscreen());
assert_eq!(self.fullscreen_backdrop.size(), self.view_size);
let scale = self.scale;
let size = self.tile_size();
let rounded = size.to_physical_precise_round(scale).to_logical(scale);
assert_abs_diff_eq!(size.w, rounded.w, epsilon = 1e-5);
assert_abs_diff_eq!(size.h, rounded.h, epsilon = 1e-5);
}
}
+1198 -3672
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -11,6 +11,7 @@ pub mod frame_clock;
pub mod handlers;
pub mod input;
pub mod ipc;
pub mod layer;
pub mod layout;
pub mod niri;
pub mod protocols;
@@ -27,3 +28,6 @@ pub mod pw_utils;
#[cfg(not(feature = "xdp-gnome-screencast"))]
pub use dummy_pw_utils as pw_utils;
#[cfg(test)]
mod tests;
+38 -29
View File
@@ -5,13 +5,12 @@ use std::fmt::Write as _;
use std::fs::{self, File};
use std::io::{self, Write};
use std::os::fd::FromRawFd;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::{env, mem};
use clap::Parser;
use directories::ProjectDirs;
use niri::animation;
use niri::cli::{Cli, Sub};
#[cfg(feature = "dbus")]
use niri::dbus;
@@ -33,6 +32,11 @@ use tracing_subscriber::EnvFilter;
const DEFAULT_LOG_FILTER: &str = "niri=debug,smithay::backend::renderer::gles=error";
#[cfg(feature = "profile-with-tracy-allocations")]
#[global_allocator]
static GLOBAL: tracy_client::ProfiledAllocator<std::alloc::System> =
tracy_client::ProfiledAllocator::new(std::alloc::System, 100);
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Set backtrace defaults if not set.
if env::var_os("RUST_BACKTRACE").is_none() {
@@ -44,6 +48,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
REMOVE_ENV_RUST_LIB_BACKTRACE.store(true, Ordering::Relaxed);
}
let directives = env::var("RUST_LOG").unwrap_or_else(|_| DEFAULT_LOG_FILTER.to_owned());
let env_filter = EnvFilter::builder().parse_lossy(directives);
tracing_subscriber::fmt()
.compact()
.with_env_filter(env_filter)
.init();
if env::var_os("NOTIFY_SOCKET").is_some() {
IS_SYSTEMD_SERVICE.store(true, Ordering::Relaxed);
@@ -54,19 +65,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
);
}
let directives = env::var("RUST_LOG").unwrap_or_else(|_| DEFAULT_LOG_FILTER.to_owned());
let env_filter = EnvFilter::builder().parse_lossy(directives);
tracing_subscriber::fmt()
.compact()
.with_env_filter(env_filter)
.init();
let cli = Cli::parse();
if cli.session {
// If we're starting as a session, assume that the intention is to start on a TTY. Remove
// DISPLAY or WAYLAND_DISPLAY from our environment if they are set, since they will cause
// the winit backend to be selected instead.
// DISPLAY, WAYLAND_DISPLAY or WAYLAND_SOCKET from our environment if they are set, since
// they will cause the winit backend to be selected instead.
if env::var_os("DISPLAY").is_some() {
warn!("running as a session but DISPLAY is set, removing it");
env::remove_var("DISPLAY");
@@ -75,6 +79,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
warn!("running as a session but WAYLAND_DISPLAY is set, removing it");
env::remove_var("WAYLAND_DISPLAY");
}
if env::var_os("WAYLAND_SOCKET").is_some() {
warn!("running as a session but WAYLAND_SOCKET is set, removing it");
env::remove_var("WAYLAND_SOCKET");
}
// Set the current desktop for xdg-desktop-portal.
env::set_var("XDG_CURRENT_DESKTOP", "niri");
@@ -82,9 +90,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
env::set_var("XDG_SESSION_TYPE", "wayland");
}
// Set a better error printer for config loading.
niri_config::set_miette_hook().unwrap();
// Handle subcommands.
if let Some(subcommand) = cli.subcommand {
match subcommand {
@@ -159,13 +164,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
})
.unwrap_or_default();
let slowdown = if config.animations.off {
0.
} else {
config.animations.slowdown.clamp(0., 100.)
};
animation::ANIMATION_SLOWDOWN.store(slowdown, Ordering::Relaxed);
let spawn_at_startup = mem::take(&mut config.spawn_at_startup);
*CHILD_ENV.write().unwrap() = mem::take(&mut config.environment);
@@ -179,11 +177,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
event_loop.handle(),
event_loop.get_signal(),
display,
false,
true,
)
.unwrap();
// Set WAYLAND_DISPLAY for children.
let socket_name = &state.niri.socket_name;
let socket_name = state.niri.socket_name.as_deref().unwrap();
env::set_var("WAYLAND_DISPLAY", socket_name);
info!(
"listening on Wayland socket: {}",
@@ -192,8 +192,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Set NIRI_SOCKET for children.
if let Some(ipc) = &state.niri.ipc_server {
env::set_var(SOCKET_PATH_ENV, &ipc.socket_path);
info!("IPC listening on: {}", ipc.socket_path.to_string_lossy());
let socket_path = ipc.socket_path.as_deref().unwrap();
env::set_var(SOCKET_PATH_ENV, socket_path);
info!("IPC listening on: {}", socket_path.to_string_lossy());
}
if cli.session {
@@ -226,12 +227,20 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Set up config file watcher.
let _watcher = {
// Parsing the config actually takes > 20 ms on my beefy machine, so let's do it on the
// watcher thread.
let process = |path: &Path| {
Config::load(path).map_err(|err| {
warn!("{:?}", err.context("error loading config"));
})
};
let (tx, rx) = calloop::channel::sync_channel(1);
let watcher = Watcher::new(watch_path.clone(), tx);
let watcher = Watcher::new(watch_path.clone(), process, tx);
event_loop
.handle()
.insert_source(rx, move |event, _, state| match event {
calloop::channel::Event::Msg(()) => state.reload_config(watch_path.clone()),
.insert_source(rx, |event, _, state| match event {
calloop::channel::Event::Msg(config) => state.reload_config(config),
calloop::channel::Event::Closed => (),
})
.unwrap();
@@ -239,10 +248,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
};
// Spawn commands from cli and auto-start.
spawn(cli.command);
spawn(cli.command, None);
for elem in spawn_at_startup {
spawn(elem.command);
spawn(elem.command, None);
}
// Show the config error notification right away if needed.
+917 -388
View File
File diff suppressed because it is too large Load Diff
+10 -26
View File
@@ -11,10 +11,7 @@ use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
use smithay::reexports::wayland_server::{
Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource,
};
use smithay::wayland::compositor::with_states;
use smithay::wayland::shell::xdg::{
ToplevelStateSet, XdgToplevelSurfaceData, XdgToplevelSurfaceRoleAttributes,
};
use smithay::wayland::shell::xdg::{ToplevelStateSet, XdgToplevelSurfaceRoleAttributes};
use wayland_protocols_wlr::foreign_toplevel::v1::server::{
zwlr_foreign_toplevel_handle_v1, zwlr_foreign_toplevel_manager_v1,
};
@@ -22,6 +19,7 @@ use zwlr_foreign_toplevel_handle_v1::ZwlrForeignToplevelHandleV1;
use zwlr_foreign_toplevel_manager_v1::ZwlrForeignToplevelManagerV1;
use crate::niri::State;
use crate::utils::with_toplevel_role;
const VERSION: u32 = 3;
@@ -96,37 +94,23 @@ pub fn refresh(state: &mut State) {
// the previous window and only then activate the newly focused window.
let mut focused = None;
state.niri.layout.with_windows(|mapped, output, _| {
let wl_surface = mapped.toplevel().wl_surface();
with_states(wl_surface, |states| {
let role = states
.data_map
.get::<XdgToplevelSurfaceData>()
.unwrap()
.lock()
.unwrap();
let toplevel = mapped.toplevel();
let wl_surface = toplevel.wl_surface();
with_toplevel_role(toplevel, |role| {
if state.niri.keyboard_focus.surface() == Some(wl_surface) {
focused = Some((mapped.window.clone(), output.cloned()));
} else {
refresh_toplevel(protocol_state, wl_surface, &role, output, false);
refresh_toplevel(protocol_state, wl_surface, role, output, false);
}
});
});
// Finally, refresh the focused window.
if let Some((window, output)) = focused {
let wl_surface = window.toplevel().expect("no x11 support").wl_surface();
with_states(wl_surface, |states| {
let role = states
.data_map
.get::<XdgToplevelSurfaceData>()
.unwrap()
.lock()
.unwrap();
refresh_toplevel(protocol_state, wl_surface, &role, output.as_ref(), true);
let toplevel = window.toplevel().expect("no X11 support");
let wl_surface = toplevel.wl_surface();
with_toplevel_role(toplevel, |role| {
refresh_toplevel(protocol_state, wl_surface, role, output.as_ref(), true);
});
}
}
-1
View File
@@ -177,7 +177,6 @@ where
}
// Verify that there's no more data.
#[allow(clippy::unused_io_amount)] // False positive on 1.77.0
{
match file.read(&mut [0]) {
Ok(0) => (),
+1
View File
@@ -3,5 +3,6 @@ pub mod gamma_control;
pub mod mutter_x11_interop;
pub mod output_management;
pub mod screencopy;
pub mod virtual_pointer;
pub mod raw;
+2 -2
View File
@@ -206,9 +206,9 @@ where
let output_transform = output.current_transform();
let output_physical_size =
output_transform.transform_size(output.current_mode().unwrap().size);
let output_rect = Rectangle::from_loc_and_size((0, 0), output_physical_size);
let output_rect = Rectangle::from_size(output_physical_size);
let rect = Rectangle::from_loc_and_size((x, y), (width, height));
let rect = Rectangle::new(Point::from((x, y)), Size::from((width, height)));
let output_scale = output.current_scale().fractional_scale();
let physical_rect = rect.to_physical_precise_round(output_scale);
+563
View File
@@ -0,0 +1,563 @@
use std::collections::HashSet;
use std::sync::Mutex;
use smithay::backend::input::{
AbsolutePositionEvent, Axis, AxisRelativeDirection, AxisSource, ButtonState, Device,
DeviceCapability, Event, InputBackend, PointerAxisEvent, PointerButtonEvent,
PointerMotionAbsoluteEvent, PointerMotionEvent, UnusedEvent,
};
use smithay::input::pointer::AxisFrame;
use smithay::output::Output;
use smithay::reexports::wayland_protocols_wlr;
use smithay::reexports::wayland_server::protocol::wl_pointer;
use smithay::reexports::wayland_server::protocol::wl_seat::WlSeat;
use smithay::reexports::wayland_server::{
Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource,
};
use wayland_backend::protocol::WEnum;
use wayland_protocols_wlr::virtual_pointer::v1::server::{
zwlr_virtual_pointer_manager_v1, zwlr_virtual_pointer_v1,
};
use zwlr_virtual_pointer_manager_v1::ZwlrVirtualPointerManagerV1;
use zwlr_virtual_pointer_v1::ZwlrVirtualPointerV1;
const VERSION: u32 = 2;
pub struct VirtualPointerManagerState {
virtual_pointers: HashSet<ZwlrVirtualPointerV1>,
}
pub struct VirtualPointerManagerGlobalData {
filter: Box<dyn for<'c> Fn(&'c Client) -> bool + Send + Sync>,
}
pub struct VirtualPointerInputBackend;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct VirtualPointer {
pointer: ZwlrVirtualPointerV1,
}
#[derive(Debug)]
pub struct VirtualPointerUserData {
seat: Option<WlSeat>,
output: Option<Output>,
axis_frame: Mutex<Option<AxisFrame>>,
}
impl VirtualPointer {
fn data(&self) -> &VirtualPointerUserData {
self.pointer.data().unwrap()
}
pub fn seat(&self) -> Option<&WlSeat> {
self.data().seat.as_ref()
}
pub fn output(&self) -> Option<&Output> {
self.data().output.as_ref()
}
fn finish_axis_frame(&self) -> Option<AxisFrame> {
self.data().axis_frame.lock().unwrap().take()
}
fn mutate_axis_frame(&self, time: Option<u32>, f: impl FnOnce(AxisFrame) -> AxisFrame) {
let mut frame = self.data().axis_frame.lock().unwrap();
*frame = frame.or(time.map(AxisFrame::new)).map(f);
}
}
impl Device for VirtualPointer {
fn id(&self) -> String {
format!("wlr virtual pointer {}", self.pointer.id())
}
fn name(&self) -> String {
String::from("virtual pointer")
}
fn has_capability(&self, capability: DeviceCapability) -> bool {
matches!(capability, DeviceCapability::Pointer)
}
fn usb_id(&self) -> Option<(u32, u32)> {
None
}
fn syspath(&self) -> Option<std::path::PathBuf> {
None
}
}
pub struct VirtualPointerMotionEvent {
pointer: VirtualPointer,
time: u32,
dx: f64,
dy: f64,
}
impl Event<VirtualPointerInputBackend> for VirtualPointerMotionEvent {
fn time(&self) -> u64 {
self.time as u64 * 1000 // millis to micros
}
fn device(&self) -> VirtualPointer {
self.pointer.clone()
}
}
impl PointerMotionEvent<VirtualPointerInputBackend> for VirtualPointerMotionEvent {
fn delta_x(&self) -> f64 {
self.dx
}
fn delta_y(&self) -> f64 {
self.dy
}
fn delta_x_unaccel(&self) -> f64 {
self.dx
}
fn delta_y_unaccel(&self) -> f64 {
self.dy
}
}
pub struct VirtualPointerMotionAbsoluteEvent {
pointer: VirtualPointer,
time: u32,
x: u32,
y: u32,
x_extent: u32,
y_extent: u32,
}
impl Event<VirtualPointerInputBackend> for VirtualPointerMotionAbsoluteEvent {
fn time(&self) -> u64 {
self.time as u64 * 1000 // millis to micros
}
fn device(&self) -> VirtualPointer {
self.pointer.clone()
}
}
impl AbsolutePositionEvent<VirtualPointerInputBackend> for VirtualPointerMotionAbsoluteEvent {
fn x(&self) -> f64 {
self.x as f64 / self.x_extent as f64
}
fn y(&self) -> f64 {
self.y as f64 / self.y_extent as f64
}
fn x_transformed(&self, width: i32) -> f64 {
(self.x as i64 * width as i64) as f64 / self.x_extent as f64
}
fn y_transformed(&self, height: i32) -> f64 {
(self.y as i64 * height as i64) as f64 / self.y_extent as f64
}
}
pub struct VirtualPointerButtonEvent {
pointer: VirtualPointer,
time: u32,
button: u32,
state: ButtonState,
}
impl Event<VirtualPointerInputBackend> for VirtualPointerButtonEvent {
fn time(&self) -> u64 {
self.time as u64 * 1000 // millis to micros
}
fn device(&self) -> VirtualPointer {
self.pointer.clone()
}
}
impl PointerButtonEvent<VirtualPointerInputBackend> for VirtualPointerButtonEvent {
fn button_code(&self) -> u32 {
self.button
}
fn state(&self) -> ButtonState {
self.state
}
}
pub struct VirtualPointerAxisEvent {
pointer: VirtualPointer,
frame: AxisFrame,
}
impl Event<VirtualPointerInputBackend> for VirtualPointerAxisEvent {
fn time(&self) -> u64 {
self.frame.time as u64 * 1000 // millis to micros
}
fn device(&self) -> VirtualPointer {
self.pointer.clone()
}
}
fn tuple_axis<T>(tuple: (T, T), axis: Axis) -> T {
match axis {
Axis::Horizontal => tuple.0,
Axis::Vertical => tuple.1,
}
}
impl PointerAxisEvent<VirtualPointerInputBackend> for VirtualPointerAxisEvent {
fn amount(&self, axis: Axis) -> Option<f64> {
Some(tuple_axis(self.frame.axis, axis))
}
fn amount_v120(&self, axis: Axis) -> Option<f64> {
self.frame.v120.map(|v120| tuple_axis(v120, axis) as f64)
}
fn source(&self) -> AxisSource {
self.frame.source.unwrap_or_else(|| {
warn!("AxisSource: no source set, giving bogus value");
AxisSource::Continuous
})
}
fn relative_direction(&self, axis: Axis) -> AxisRelativeDirection {
tuple_axis(self.frame.relative_direction, axis)
}
}
impl PointerMotionAbsoluteEvent<VirtualPointerInputBackend> for VirtualPointerMotionAbsoluteEvent {}
impl InputBackend for VirtualPointerInputBackend {
type Device = VirtualPointer;
type KeyboardKeyEvent = UnusedEvent;
type PointerAxisEvent = VirtualPointerAxisEvent;
type PointerButtonEvent = VirtualPointerButtonEvent;
type PointerMotionEvent = VirtualPointerMotionEvent;
type PointerMotionAbsoluteEvent = VirtualPointerMotionAbsoluteEvent;
type GestureSwipeBeginEvent = UnusedEvent;
type GestureSwipeUpdateEvent = UnusedEvent;
type GestureSwipeEndEvent = UnusedEvent;
type GesturePinchBeginEvent = UnusedEvent;
type GesturePinchUpdateEvent = UnusedEvent;
type GesturePinchEndEvent = UnusedEvent;
type GestureHoldBeginEvent = UnusedEvent;
type GestureHoldEndEvent = UnusedEvent;
type TouchDownEvent = UnusedEvent;
type TouchUpEvent = UnusedEvent;
type TouchMotionEvent = UnusedEvent;
type TouchCancelEvent = UnusedEvent;
type TouchFrameEvent = UnusedEvent;
type TabletToolAxisEvent = UnusedEvent;
type TabletToolProximityEvent = UnusedEvent;
type TabletToolTipEvent = UnusedEvent;
type TabletToolButtonEvent = UnusedEvent;
type SwitchToggleEvent = UnusedEvent;
type SpecialEvent = UnusedEvent;
}
pub trait VirtualPointerHandler {
fn virtual_pointer_manager_state(&mut self) -> &mut VirtualPointerManagerState;
fn create_virtual_pointer(&mut self, pointer: VirtualPointer) {
let _ = pointer;
}
fn destroy_virtual_pointer(&mut self, pointer: VirtualPointer) {
let _ = pointer;
}
fn on_virtual_pointer_motion(&mut self, event: VirtualPointerMotionEvent);
fn on_virtual_pointer_motion_absolute(&mut self, event: VirtualPointerMotionAbsoluteEvent);
fn on_virtual_pointer_button(&mut self, event: VirtualPointerButtonEvent);
fn on_virtual_pointer_axis(&mut self, event: VirtualPointerAxisEvent);
}
impl VirtualPointerManagerState {
pub fn new<D, F>(display: &DisplayHandle, filter: F) -> Self
where
D: GlobalDispatch<ZwlrVirtualPointerManagerV1, VirtualPointerManagerGlobalData>,
D: Dispatch<ZwlrVirtualPointerManagerV1, ()>,
D: Dispatch<ZwlrVirtualPointerV1, VirtualPointerUserData>,
D: VirtualPointerHandler,
D: 'static,
F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static,
{
let global_data = VirtualPointerManagerGlobalData {
filter: Box::new(filter),
};
display.create_global::<D, ZwlrVirtualPointerManagerV1, _>(VERSION, global_data);
Self {
virtual_pointers: HashSet::new(),
}
}
}
impl<D> GlobalDispatch<ZwlrVirtualPointerManagerV1, VirtualPointerManagerGlobalData, D>
for VirtualPointerManagerState
where
D: GlobalDispatch<ZwlrVirtualPointerManagerV1, VirtualPointerManagerGlobalData>,
D: Dispatch<ZwlrVirtualPointerManagerV1, ()>,
D: Dispatch<ZwlrVirtualPointerV1, VirtualPointerUserData>,
D: VirtualPointerHandler,
D: 'static,
{
fn bind(
_state: &mut D,
_handle: &DisplayHandle,
_client: &Client,
manager: New<ZwlrVirtualPointerManagerV1>,
_manager_state: &VirtualPointerManagerGlobalData,
data_init: &mut DataInit<'_, D>,
) {
data_init.init(manager, ());
}
fn can_view(client: Client, global_data: &VirtualPointerManagerGlobalData) -> bool {
(global_data.filter)(&client)
}
}
impl<D> Dispatch<ZwlrVirtualPointerManagerV1, (), D> for VirtualPointerManagerState
where
D: Dispatch<ZwlrVirtualPointerManagerV1, ()>,
D: Dispatch<ZwlrVirtualPointerV1, VirtualPointerUserData>,
D: VirtualPointerHandler,
D: 'static,
{
fn request(
state: &mut D,
_client: &Client,
_resource: &ZwlrVirtualPointerManagerV1,
request: <ZwlrVirtualPointerManagerV1 as Resource>::Request,
_data: &(),
_dhandle: &DisplayHandle,
data_init: &mut DataInit<'_, D>,
) {
let (id, seat, output) = match request {
zwlr_virtual_pointer_manager_v1::Request::CreateVirtualPointer { seat, id } => {
(id, seat, None)
}
zwlr_virtual_pointer_manager_v1::Request::CreateVirtualPointerWithOutput {
seat,
output,
id,
} => (id, seat, output.as_ref().and_then(Output::from_resource)),
zwlr_virtual_pointer_manager_v1::Request::Destroy => return,
_ => unreachable!(),
};
let pointer = data_init.init(
id,
VirtualPointerUserData {
seat,
output,
axis_frame: Mutex::new(None),
},
);
state
.virtual_pointer_manager_state()
.virtual_pointers
.insert(pointer.clone());
state.create_virtual_pointer(VirtualPointer { pointer });
}
}
impl<D> Dispatch<ZwlrVirtualPointerV1, VirtualPointerUserData, D> for VirtualPointerManagerState
where
D: Dispatch<ZwlrVirtualPointerV1, VirtualPointerUserData>,
D: VirtualPointerHandler,
D: 'static,
{
fn request(
handler: &mut D,
_client: &Client,
resource: &ZwlrVirtualPointerV1,
request: <ZwlrVirtualPointerV1 as Resource>::Request,
_data: &VirtualPointerUserData,
_dhandle: &DisplayHandle,
_data_init: &mut DataInit<'_, D>,
) {
let pointer = VirtualPointer {
pointer: resource.clone(),
};
match request {
zwlr_virtual_pointer_v1::Request::Motion { time, dx, dy } => {
let event = VirtualPointerMotionEvent {
pointer,
time,
dx,
dy,
};
handler.on_virtual_pointer_motion(event);
}
zwlr_virtual_pointer_v1::Request::MotionAbsolute {
time,
x,
y,
x_extent,
y_extent,
} => {
let event = VirtualPointerMotionAbsoluteEvent {
pointer,
time,
x,
y,
x_extent,
y_extent,
};
handler.on_virtual_pointer_motion_absolute(event);
}
zwlr_virtual_pointer_v1::Request::Button {
time,
button,
state,
} => {
// state is an enum but wlroots treats it as a C boolean (zero or nonzero)
// so we emulate that behaviour too. ButtonState::Pressed and any invalid value
// counts as pressed.
// https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/3187479c07c34a4de82c06a316a763a36a0499da/types/wlr_virtual_pointer_v1.c#L74
let state = match state {
WEnum::Value(wl_pointer::ButtonState::Released) => ButtonState::Released,
_ => ButtonState::Pressed,
};
let event = VirtualPointerButtonEvent {
pointer,
time,
button,
state,
};
handler.on_virtual_pointer_button(event);
}
zwlr_virtual_pointer_v1::Request::Axis { time, axis, value } => {
let axis = match axis {
WEnum::Value(wl_pointer::Axis::VerticalScroll) => Axis::Vertical,
WEnum::Value(wl_pointer::Axis::HorizontalScroll) => Axis::Horizontal,
_ => {
warn!("Axis: invalid axis");
resource.post_error(
zwlr_virtual_pointer_v1::Error::InvalidAxis,
"invalid axis",
);
return;
}
};
pointer.mutate_axis_frame(Some(time), |frame| frame.value(axis, value));
}
zwlr_virtual_pointer_v1::Request::Frame => {
if let Some(frame) = pointer.finish_axis_frame() {
let event = VirtualPointerAxisEvent { pointer, frame };
handler.on_virtual_pointer_axis(event);
}
}
zwlr_virtual_pointer_v1::Request::AxisSource { axis_source } => {
let axis_source = match axis_source {
WEnum::Value(wl_pointer::AxisSource::Wheel) => AxisSource::Wheel,
WEnum::Value(wl_pointer::AxisSource::Finger) => AxisSource::Finger,
WEnum::Value(wl_pointer::AxisSource::Continuous) => AxisSource::Continuous,
WEnum::Value(wl_pointer::AxisSource::WheelTilt) => AxisSource::WheelTilt,
_ => {
warn!("AxisSource: invalid axis source");
resource.post_error(
zwlr_virtual_pointer_v1::Error::InvalidAxisSource,
"invalid axis source",
);
return;
}
};
pointer.mutate_axis_frame(None, |frame| frame.source(axis_source));
}
zwlr_virtual_pointer_v1::Request::AxisStop { time, axis } => {
let axis = match axis {
WEnum::Value(wl_pointer::Axis::VerticalScroll) => Axis::Vertical,
WEnum::Value(wl_pointer::Axis::HorizontalScroll) => Axis::Horizontal,
_ => {
warn!("AxisStop: invalid axis");
resource.post_error(
zwlr_virtual_pointer_v1::Error::InvalidAxis,
"invalid axis",
);
return;
}
};
pointer.mutate_axis_frame(Some(time), |frame| frame.stop(axis));
}
zwlr_virtual_pointer_v1::Request::AxisDiscrete {
time,
axis,
value,
discrete,
} => {
let axis = match axis {
WEnum::Value(wl_pointer::Axis::VerticalScroll) => Axis::Vertical,
WEnum::Value(wl_pointer::Axis::HorizontalScroll) => Axis::Horizontal,
_ => {
warn!("AxisDiscrete: invalid axis");
resource.post_error(
zwlr_virtual_pointer_v1::Error::InvalidAxis,
"invalid axis",
);
return;
}
};
pointer.mutate_axis_frame(Some(time), |frame| {
frame.value(axis, value).v120(axis, discrete)
});
}
zwlr_virtual_pointer_v1::Request::Destroy => {}
_ => unreachable!(),
}
}
fn destroyed(
handler: &mut D,
_client: wayland_backend::server::ClientId,
resource: &ZwlrVirtualPointerV1,
_data: &VirtualPointerUserData,
) {
let pointer = VirtualPointer {
pointer: resource.clone(),
};
handler.destroy_virtual_pointer(pointer);
handler
.virtual_pointer_manager_state()
.virtual_pointers
.remove(resource);
}
}
#[macro_export]
macro_rules! delegate_virtual_pointer {
($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => {
smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
smithay::reexports::wayland_protocols_wlr::virtual_pointer::v1::server::zwlr_virtual_pointer_manager_v1::ZwlrVirtualPointerManagerV1: $crate::protocols::virtual_pointer::VirtualPointerManagerGlobalData
] => $crate::protocols::virtual_pointer::VirtualPointerManagerState);
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
smithay::reexports::wayland_protocols_wlr::virtual_pointer::v1::server::zwlr_virtual_pointer_manager_v1::ZwlrVirtualPointerManagerV1: ()
] => $crate::protocols::virtual_pointer::VirtualPointerManagerState);
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
smithay::reexports::wayland_protocols_wlr::virtual_pointer::v1::server::zwlr_virtual_pointer_v1::ZwlrVirtualPointerV1: $crate::protocols::virtual_pointer::VirtualPointerUserData
] => $crate::protocols::virtual_pointer::VirtualPointerManagerState);
};
}
+29 -22
View File
@@ -11,7 +11,7 @@ use anyhow::Context as _;
use calloop::timer::{TimeoutAction, Timer};
use calloop::RegistrationToken;
use pipewire::context::Context;
use pipewire::core::Core;
use pipewire::core::{Core, PW_ID_CORE};
use pipewire::main_loop::MainLoop;
use pipewire::properties::Properties;
use pipewire::spa::buffer::DataType;
@@ -41,7 +41,7 @@ use smithay::reexports::calloop::generic::Generic;
use smithay::reexports::calloop::{Interest, LoopHandle, Mode, PostAction};
use smithay::reexports::gbm::Modifier;
use smithay::utils::{Physical, Scale, Size, Transform};
use zbus::SignalContext;
use zbus::object_server::SignalEmitter;
use crate::dbus::mutter_screen_cast::{self, CursorMode};
use crate::niri::State;
@@ -54,12 +54,14 @@ const CAST_DELAY_ALLOWANCE: Duration = Duration::from_micros(100);
pub struct PipeWire {
_context: Context,
pub core: Core,
pub token: RegistrationToken,
to_niri: calloop::channel::Sender<PwToNiri>,
}
pub enum PwToNiri {
StopCast { session_id: usize },
Redraw(CastTarget),
FatalError,
}
pub struct Cast {
@@ -134,15 +136,26 @@ macro_rules! make_params {
}
impl PipeWire {
pub fn new(event_loop: &LoopHandle<'static, State>) -> anyhow::Result<Self> {
pub fn new(
event_loop: &LoopHandle<'static, State>,
to_niri: calloop::channel::Sender<PwToNiri>,
) -> anyhow::Result<Self> {
let main_loop = MainLoop::new(None).context("error creating MainLoop")?;
let context = Context::new(&main_loop).context("error creating Context")?;
let core = context.connect(None).context("error creating Core")?;
let to_niri_ = to_niri.clone();
let listener = core
.add_listener_local()
.error(|id, seq, res, message| {
.error(move |id, seq, res, message| {
warn!(id, seq, res, message, "pw error");
// Reset PipeWire on connection errors.
if id == PW_ID_CORE && res == -32 {
if let Err(err) = to_niri_.send(PwToNiri::FatalError) {
warn!("error sending FatalError to niri: {err:?}");
}
}
})
.register();
mem::forget(listener);
@@ -154,7 +167,7 @@ impl PipeWire {
}
}
let generic = Generic::new(AsFdWrapper(main_loop), Interest::READ, Mode::Level);
event_loop
let token = event_loop
.insert_source(generic, move |_, wrapper, _| {
let _span = tracy_client::span!("pipewire iteration");
wrapper.0.loop_().iterate(Duration::ZERO);
@@ -162,17 +175,10 @@ impl PipeWire {
})
.unwrap();
let (to_niri, from_pipewire) = calloop::channel::channel();
event_loop
.insert_source(from_pipewire, move |event, _, state| match event {
calloop::channel::Event::Msg(msg) => state.on_pw_msg(msg),
calloop::channel::Event::Closed => (),
})
.unwrap();
Ok(Self {
_context: context,
core,
token,
to_niri,
})
}
@@ -188,7 +194,7 @@ impl PipeWire {
refresh: u32,
alpha: bool,
cursor_mode: CursorMode,
signal_ctx: SignalContext<'static>,
signal_ctx: SignalEmitter<'static>,
) -> anyhow::Result<Cast> {
let _span = tracy_client::span!("PipeWire::start_cast");
@@ -769,7 +775,11 @@ impl Cast {
let timer = Timer::from_duration(duration);
let token = event_loop
.insert_source(timer, move |_, _, state| {
state.niri.queue_redraw(&output);
// Guard against output disconnecting before the timer has a chance to run.
if state.niri.output_state.contains_key(&output) {
state.niri.queue_redraw(&output);
}
TimeoutAction::Drop
})
.unwrap();
@@ -834,12 +844,9 @@ impl Cast {
return false;
}
let mut buffer = match self.stream.dequeue_buffer() {
Some(buffer) => buffer,
None => {
warn!("no available buffer in pw stream, skipping frame");
return false;
}
let Some(mut buffer) = self.stream.dequeue_buffer() else {
warn!("no available buffer in pw stream, skipping frame");
return false;
};
let fd = buffer.datas_mut()[0].as_raw().fd;
@@ -1023,7 +1030,7 @@ fn allocate_buffer(
.create_buffer_object_with_modifiers2::<()>(w, h, fourcc, modifiers, flags)
.context("error creating GBM buffer object")?;
let modifier = bo.modifier().unwrap();
let modifier = bo.modifier();
let buffer = GbmBuffer::from_bo(bo, false);
Ok((buffer, modifier))
}
+8
View File
@@ -39,6 +39,7 @@ struct Parameters {
corner_radius: CornerRadius,
// Should only be used for visual improvements, i.e. corner radius anti-aliasing.
scale: f32,
alpha: f32,
}
impl BorderRenderElement {
@@ -54,6 +55,7 @@ impl BorderRenderElement {
border_width: f32,
corner_radius: CornerRadius,
scale: f32,
alpha: f32,
) -> Self {
let inner = ShaderRenderElement::empty(ProgramType::Border, Kind::Unspecified);
let mut rv = Self {
@@ -69,6 +71,7 @@ impl BorderRenderElement {
border_width,
corner_radius,
scale,
alpha,
},
};
rv.update_inner();
@@ -90,6 +93,7 @@ impl BorderRenderElement {
border_width: 0.,
corner_radius: Default::default(),
scale: 1.,
alpha: 1.,
},
}
}
@@ -111,6 +115,7 @@ impl BorderRenderElement {
border_width: f32,
corner_radius: CornerRadius,
scale: f32,
alpha: f32,
) {
let params = Parameters {
size,
@@ -123,6 +128,7 @@ impl BorderRenderElement {
border_width,
corner_radius,
scale,
alpha,
};
if self.params == params {
return;
@@ -144,6 +150,7 @@ impl BorderRenderElement {
border_width,
corner_radius,
scale,
alpha,
} = self.params;
let grad_offset = geometry.loc - gradient_area.loc;
@@ -189,6 +196,7 @@ impl BorderRenderElement {
size,
None,
scale,
alpha,
vec![
Uniform::new("colorspace", colorspace),
Uniform::new("hue_interpolation", hue_interpolation),
+25 -40
View File
@@ -6,7 +6,7 @@ use smithay::backend::renderer::gles::{
GlesError, GlesFrame, GlesRenderer, GlesTexProgram, Uniform,
};
use smithay::backend::renderer::utils::{CommitCounter, DamageSet, OpaqueRegions};
use smithay::utils::{Buffer, Logical, Physical, Rectangle, Scale, Size, Transform};
use smithay::utils::{Buffer, Logical, Physical, Point, Rectangle, Scale, Size, Transform};
use super::damage::ExtraDamage;
use super::renderer::{AsGlesFrame as _, NiriRenderer};
@@ -19,9 +19,7 @@ pub struct ClippedSurfaceRenderElement<R: NiriRenderer> {
program: GlesTexProgram,
corner_radius: CornerRadius,
geometry: Rectangle<f64, Logical>,
input_to_geo: Mat3,
// Should only be used for visual improvements, i.e. corner radius anti-aliasing.
scale: f32,
uniforms: Vec<Uniform<'static>>,
}
#[derive(Debug, Default, Clone)]
@@ -72,13 +70,19 @@ impl<R: NiriRenderer> ClippedSurfaceRenderElement<R> {
* Mat3::from_scale(buf_size / src_size)
* Mat3::from_translation(-src_loc / buf_size);
let uniforms = vec![
Uniform::new("niri_scale", scale.x as f32),
Uniform::new("geo_size", (geometry.size.w as f32, geometry.size.h as f32)),
Uniform::new("corner_radius", <[f32; 4]>::from(corner_radius)),
mat3_uniform("input_to_geo", input_to_geo),
];
Self {
inner: elem,
program,
corner_radius,
geometry,
input_to_geo,
scale: scale.x as f32,
uniforms,
}
}
@@ -117,21 +121,21 @@ impl<R: NiriRenderer> ClippedSurfaceRenderElement<R> {
let bottom_left = corner_radius.bottom_left as f64;
[
Rectangle::from_loc_and_size(geo.loc, (top_left, top_left)),
Rectangle::from_loc_and_size(
(geo.loc.x + geo.size.w - top_right, geo.loc.y),
(top_right, top_right),
Rectangle::new(geo.loc, Size::from((top_left, top_left))),
Rectangle::new(
Point::from((geo.loc.x + geo.size.w - top_right, geo.loc.y)),
Size::from((top_right, top_right)),
),
Rectangle::from_loc_and_size(
(
Rectangle::new(
Point::from((
geo.loc.x + geo.size.w - bottom_right,
geo.loc.y + geo.size.h - bottom_right,
),
(bottom_right, bottom_right),
)),
Size::from((bottom_right, bottom_right)),
),
Rectangle::from_loc_and_size(
(geo.loc.x, geo.loc.y + geo.size.h - bottom_left),
(bottom_left, bottom_left),
Rectangle::new(
Point::from((geo.loc.x, geo.loc.y + geo.size.h - bottom_left)),
Size::from((bottom_left, bottom_left)),
),
]
}
@@ -220,18 +224,7 @@ impl RenderElement<GlesRenderer> for ClippedSurfaceRenderElement<GlesRenderer> {
damage: &[Rectangle<i32, Physical>],
opaque_regions: &[Rectangle<i32, Physical>],
) -> Result<(), GlesError> {
frame.override_default_tex_program(
self.program.clone(),
vec![
Uniform::new("niri_scale", self.scale),
Uniform::new(
"geo_size",
(self.geometry.size.w as f32, self.geometry.size.h as f32),
),
Uniform::new("corner_radius", <[f32; 4]>::from(self.corner_radius)),
mat3_uniform("input_to_geo", self.input_to_geo),
],
);
frame.override_default_tex_program(self.program.clone(), self.uniforms.clone());
RenderElement::<GlesRenderer>::draw(&self.inner, frame, src, dst, damage, opaque_regions)?;
frame.clear_tex_program_override();
Ok(())
@@ -255,17 +248,9 @@ impl<'render> RenderElement<TtyRenderer<'render>>
damage: &[Rectangle<i32, Physical>],
opaque_regions: &[Rectangle<i32, Physical>],
) -> Result<(), TtyRendererError<'render>> {
frame.as_gles_frame().override_default_tex_program(
self.program.clone(),
vec![
Uniform::new(
"geo_size",
(self.geometry.size.w as f32, self.geometry.size.h as f32),
),
Uniform::new("corner_radius", <[f32; 4]>::from(self.corner_radius)),
mat3_uniform("input_to_geo", self.input_to_geo),
],
);
frame
.as_gles_frame()
.override_default_tex_program(self.program.clone(), self.uniforms.clone());
RenderElement::draw(&self.inner, frame, src, dst, damage, opaque_regions)?;
frame.as_gles_frame().clear_tex_program_override();
Ok(())
+1 -1
View File
@@ -54,7 +54,7 @@ impl Element for ExtraDamage {
}
fn src(&self) -> Rectangle<f64, Buffer> {
Rectangle::from_loc_and_size((0., 0.), (1., 1.))
Rectangle::from_size(Size::from((1., 1.)))
}
fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> {
+8 -2
View File
@@ -31,6 +31,7 @@ pub mod resize;
pub mod resources;
pub mod shader_element;
pub mod shaders;
pub mod shadow;
pub mod snapshot;
pub mod solid_color;
pub mod surface;
@@ -113,6 +114,11 @@ impl<E> SplitElements<E> {
popups.extend(normal);
popups
}
pub fn extend(&mut self, other: SplitElements<E>) {
self.popups.extend(other.popups);
self.normal.extend(other.normal);
}
}
impl ToRenderElement for BakedBuffer<TextureBuffer<GlesTexture>> {
@@ -211,7 +217,7 @@ pub fn render_and_download(
let buffer_size = size.to_logical(1).to_buffer(1, Transform::Normal);
let mapping = renderer
.copy_framebuffer(Rectangle::from_loc_and_size((0, 0), buffer_size), fourcc)
.copy_framebuffer(Rectangle::from_size(buffer_size), fourcc)
.context("error copying framebuffer")?;
Ok(mapping)
}
@@ -295,7 +301,7 @@ fn render_elements(
elements: impl Iterator<Item = impl RenderElement<GlesRenderer>>,
) -> anyhow::Result<SyncPoint> {
let transform = transform.invert();
let output_rect = Rectangle::from_loc_and_size((0, 0), transform.transform_size(size));
let output_rect = Rectangle::from_size(transform.transform_size(size));
let mut frame = renderer
.render(size, transform)
+2 -2
View File
@@ -46,7 +46,7 @@ impl AsGlesRenderer for GlesRenderer {
}
}
impl<'render> AsGlesRenderer for TtyRenderer<'render> {
impl AsGlesRenderer for TtyRenderer<'_> {
fn as_gles_renderer(&mut self) -> &mut GlesRenderer {
self.as_mut()
}
@@ -66,7 +66,7 @@ impl<'frame> AsGlesFrame<'frame> for GlesFrame<'frame> {
}
}
impl<'render, 'frame> AsGlesFrame<'frame> for TtyFrame<'render, 'frame> {
impl<'frame> AsGlesFrame<'frame> for TtyFrame<'_, 'frame> {
fn as_gles_frame(&mut self) -> &mut GlesFrame<'frame> {
self.as_mut()
}
+1 -1
View File
@@ -43,7 +43,7 @@ impl ResizeRenderElement {
let tex_next_geo_scaled = tex_next_geo.to_f64().upscale(scale_next);
let combined_geo = tex_prev_geo_scaled.merge(tex_next_geo_scaled).to_i32_up();
let area = Rectangle::from_loc_and_size(
let area = Rectangle::new(
area.loc + combined_geo.loc.to_logical(scale),
combined_geo.size.to_logical(scale),
);
+9 -7
View File
@@ -193,7 +193,7 @@ impl ShaderRenderElement {
program,
id: Id::new(),
commit_counter: CommitCounter::default(),
area: Rectangle::from_loc_and_size((0., 0.), size),
area: Rectangle::from_size(size),
opaque_regions: opaque_regions.unwrap_or_default(),
scale,
alpha,
@@ -227,12 +227,14 @@ impl ShaderRenderElement {
size: Size<f64, Logical>,
opaque_regions: Option<Vec<Rectangle<f64, Logical>>>,
scale: f32,
alpha: f32,
uniforms: Vec<Uniform<'static>>,
textures: HashMap<String, GlesTexture>,
) {
self.area.size = size;
self.opaque_regions = opaque_regions.unwrap_or_default();
self.scale = scale;
self.alpha = alpha;
self.additional_uniforms = uniforms;
self.textures = textures;
@@ -255,7 +257,7 @@ impl Element for ShaderRenderElement {
}
fn src(&self) -> Rectangle<f64, Buffer> {
Rectangle::from_loc_and_size((0., 0.), (1., 1.))
Rectangle::from_size(Size::from((1., 1.)))
}
fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> {
@@ -270,7 +272,7 @@ impl Element for ShaderRenderElement {
}
fn alpha(&self) -> f32 {
1.0
self.alpha
}
fn kind(&self) -> Kind {
@@ -308,13 +310,13 @@ impl RenderElement<GlesRenderer> for ShaderRenderElement {
let rect_constrained_loc = rect
.loc
.constrain(Rectangle::from_extemities((0, 0), dest_size.to_point()));
.constrain(Rectangle::from_extremities((0, 0), dest_size.to_point()));
let rect_clamped_size = rect.size.clamp(
(0, 0),
(dest_size.to_point() - rect_constrained_loc).to_size(),
);
let rect = Rectangle::from_loc_and_size(rect_constrained_loc, rect_clamped_size);
let rect = Rectangle::new(rect_constrained_loc, rect_clamped_size);
[
rect.loc.x as f32,
rect.loc.y as f32,
@@ -328,13 +330,13 @@ impl RenderElement<GlesRenderer> for ShaderRenderElement {
let rect_constrained_loc = rect
.loc
.constrain(Rectangle::from_extemities((0, 0), dest_size.to_point()));
.constrain(Rectangle::from_extremities((0, 0), dest_size.to_point()));
let rect_clamped_size = rect.size.clamp(
(0, 0),
(dest_size.to_point() - rect_constrained_loc).to_size(),
);
let rect = Rectangle::from_loc_and_size(rect_constrained_loc, rect_clamped_size);
let rect = Rectangle::new(rect_constrained_loc, rect_clamped_size);
// Add the 4 f32s per damage rectangle for each of the 6 vertices.
(0..6).flat_map(move |_| {
[
+24
View File
@@ -11,6 +11,7 @@ use super::shader_element::ShaderProgram;
pub struct Shaders {
pub border: Option<ShaderProgram>,
pub shadow: Option<ShaderProgram>,
pub clipped_surface: Option<GlesTexProgram>,
pub resize: Option<ShaderProgram>,
pub custom_resize: RefCell<Option<ShaderProgram>>,
@@ -21,6 +22,7 @@ pub struct Shaders {
#[derive(Debug, Clone, Copy)]
pub enum ProgramType {
Border,
Shadow,
Resize,
Close,
Open,
@@ -53,6 +55,26 @@ impl Shaders {
})
.ok();
let shadow = ShaderProgram::compile(
renderer,
include_str!("shadow.frag"),
&[
UniformName::new("shadow_color", UniformType::_4f),
UniformName::new("sigma", UniformType::_1f),
UniformName::new("input_to_geo", UniformType::Matrix3x3),
UniformName::new("geo_size", UniformType::_2f),
UniformName::new("corner_radius", UniformType::_4f),
UniformName::new("window_input_to_geo", UniformType::Matrix3x3),
UniformName::new("window_geo_size", UniformType::_2f),
UniformName::new("window_corner_radius", UniformType::_4f),
],
&[],
)
.map_err(|err| {
warn!("error compiling shadow shader: {err:?}");
})
.ok();
let clipped_surface = renderer
.compile_custom_texture_shader(
include_str!("clipped_surface.frag"),
@@ -76,6 +98,7 @@ impl Shaders {
Self {
border,
shadow,
clipped_surface,
resize,
custom_resize: RefCell::new(None),
@@ -121,6 +144,7 @@ impl Shaders {
pub fn program(&self, program: ProgramType) -> Option<ShaderProgram> {
match program {
ProgramType::Border => self.border.clone(),
ProgramType::Shadow => self.shadow.clone(),
ProgramType::Resize => self
.custom_resize
.borrow()
+142
View File
@@ -0,0 +1,142 @@
precision highp float;
#if defined(DEBUG_FLAGS)
uniform float niri_tint;
#endif
uniform float niri_alpha;
uniform float niri_scale;
uniform vec2 niri_size;
varying vec2 niri_v_coords;
uniform vec4 shadow_color;
uniform float sigma;
uniform mat3 input_to_geo;
uniform vec2 geo_size;
uniform vec4 corner_radius;
uniform mat3 window_input_to_geo;
uniform vec2 window_geo_size;
uniform vec4 window_corner_radius;
// Based on: https://madebyevan.com/shaders/fast-rounded-rectangle-shadows/
//
// License: CC0 (http://creativecommons.org/publicdomain/zero/1.0/)
// A standard gaussian function, used for weighting samples
float gaussian(float x, float sigma) {
const float pi = 3.141592653589793;
return exp(-(x * x) / (2.0 * sigma * sigma)) / (sqrt(2.0 * pi) * sigma);
}
// This approximates the error function, needed for the gaussian integral
vec2 erf(vec2 x) {
vec2 s = sign(x), a = abs(x);
x = 1.0 + (0.278393 + (0.230389 + 0.078108 * (a * a)) * a) * a;
x *= x;
return s - s / (x * x);
}
// Return the blurred mask along the x dimension
float roundedBoxShadowX(float x, float y, float sigma, float corner, vec2 halfSize) {
float delta = min(halfSize.y - corner - abs(y), 0.0);
float curved = halfSize.x - corner + sqrt(max(0.0, corner * corner - delta * delta));
vec2 integral = 0.5 + 0.5 * erf((x + vec2(-curved, curved)) * (sqrt(0.5) / sigma));
return integral.y - integral.x;
}
// Return the mask for the shadow of a box from lower to upper
float roundedBoxShadow(vec2 lower, vec2 upper, vec2 point, float sigma, float corner) {
// Center everything to make the math easier
vec2 center = (lower + upper) * 0.5;
vec2 halfSize = (upper - lower) * 0.5;
point -= center;
// The signal is only non-zero in a limited range, so don't waste samples
float low = point.y - halfSize.y;
float high = point.y + halfSize.y;
float start = clamp(-3.0 * sigma, low, high);
float end = clamp(3.0 * sigma, low, high);
// Accumulate samples (we can get away with surprisingly few samples)
float step = (end - start) / 4.0;
float y = start + step * 0.5;
float value = 0.0;
for (int i = 0; i < 4; i++) {
value += roundedBoxShadowX(point.x, point.y - y, sigma, corner, halfSize) * gaussian(y, sigma) * step;
y += step;
}
return value;
}
float rounding_alpha(vec2 coords, vec2 size, vec4 corner_radius) {
vec2 center;
float radius;
if (coords.x < corner_radius.x && coords.y < corner_radius.x) {
radius = corner_radius.x;
center = vec2(radius, radius);
} else if (size.x - corner_radius.y < coords.x && coords.y < corner_radius.y) {
radius = corner_radius.y;
center = vec2(size.x - radius, radius);
} else if (size.x - corner_radius.z < coords.x && size.y - corner_radius.z < coords.y) {
radius = corner_radius.z;
center = vec2(size.x - radius, size.y - radius);
} else if (coords.x < corner_radius.w && size.y - corner_radius.w < coords.y) {
radius = corner_radius.w;
center = vec2(radius, size.y - radius);
} else {
return 1.0;
}
float dist = distance(coords, center);
float half_px = 0.5 / niri_scale;
return 1.0 - smoothstep(radius - half_px, radius + half_px, dist);
}
void main() {
vec3 coords_geo = input_to_geo * vec3(niri_v_coords, 1.0);
vec3 coords_window_geo = window_input_to_geo * vec3(niri_v_coords, 1.0);
vec4 color = shadow_color;
float shadow_value;
if (sigma < 0.1) {
// With low enough sigma just draw a rounded rectangle.
shadow_value = rounding_alpha(coords_geo.xy, geo_size, corner_radius);
} else {
shadow_value = roundedBoxShadow(
vec2(0.0, 0.0),
geo_size,
coords_geo.xy,
sigma,
// FIXME: figure out how to blur with different corner radii.
//
// GTK seems to call blurring separately for the rect and for the 4 corners:
// https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-4-16/gsk/gpu/shaders/gskgpuboxshadow.glsl
corner_radius.x
);
}
color = color * shadow_value;
// Cut out the inside of the window geometry if requested.
if (window_geo_size != vec2(0.0, 0.0)) {
if (0.0 <= coords_window_geo.x && coords_window_geo.x <= window_geo_size.x
&& 0.0 <= coords_window_geo.y && coords_window_geo.y <= window_geo_size.y) {
float alpha = rounding_alpha(coords_window_geo.xy, window_geo_size, window_corner_radius);
color = color * (1.0 - alpha);
}
}
color = color * niri_alpha;
#if defined(DEBUG_FLAGS)
if (niri_tint == 1.0)
color = vec4(0.0, 0.2, 0.0, 0.2) + color * 0.8;
#endif
gl_FragColor = color;
}

Some files were not shown because too many files have changed in this diff Show More