Skip to content

Commit eb30d15

Browse files
committed
Merge remote-tracking branch 'upstream/wip/branch' into feat/blur
2 parents 953828d + 3d1cf38 commit eb30d15

66 files changed

Lines changed: 3867 additions & 3023 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 11 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ tracy-client = { version = "0.18.4", default-features = false }
3030

3131
[workspace.dependencies.smithay]
3232
# version = "0.4.1"
33-
git = "https://github.com/Smithay/smithay.git"
33+
git = "https://github.com/YaLTeR/smithay.git"
3434
# path = "../smithay"
35+
rev = "5f784c9ad6ae619c880e4713e120b281e2ce5383"
3536
default-features = false
3637

3738
[workspace.dependencies.smithay-drm-extras]
@@ -93,6 +94,7 @@ tracing-subscriber.workspace = true
9394
tracing.workspace = true
9495
tracy-client.workspace = true
9596
wayland-backend = "0.3.12"
97+
wayland-protocols-plasma = { version = "0.3.10", features = ["server"] }
9698
wayland-scanner = "0.31.8"
9799
xcursor = "0.3.10"
98100
zbus = { version = "5.13.0", optional = true }

niri-config/src/appearance.rs

Lines changed: 118 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -314,36 +314,64 @@ impl From<FocusRing> for Border {
314314

315315
#[derive(Debug, Clone, Copy, PartialEq)]
316316
pub struct Blur {
317-
pub on: bool,
318-
pub passes: u32,
319-
pub radius: FloatOrInt<0, 1024>,
320-
pub noise: FloatOrInt<0, 1024>,
317+
pub off: bool,
318+
pub passes: u8,
319+
pub offset: f64,
320+
pub noise: f64,
321+
pub saturation: f64,
321322
pub ignore_alpha: FloatOrInt<0, 1>,
322323
pub blur_when_keyboard_focused: bool,
323324
}
324325

326+
#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)]
327+
pub struct BlurPart {
328+
#[knuffel(child)]
329+
pub off: bool,
330+
#[knuffel(child)]
331+
pub on: bool,
332+
#[knuffel(child, unwrap(argument))]
333+
pub passes: Option<u8>,
334+
#[knuffel(child, unwrap(argument))]
335+
pub offset: Option<FloatOrInt<0, 100>>,
336+
#[knuffel(child, unwrap(argument))]
337+
pub noise: Option<FloatOrInt<0, 1000>>,
338+
#[knuffel(child, unwrap(argument))]
339+
pub saturation: Option<FloatOrInt<0, 1000>>,
340+
#[knuffel(child, unwrap(argument))]
341+
pub ignore_alpha: Option<FloatOrInt<0, 1>>,
342+
#[knuffel(child, unwrap(argument))]
343+
pub blur_when_keyboard_focused: Option<bool>,
344+
}
345+
325346
impl Default for Blur {
326347
fn default() -> Self {
327348
Self {
328-
// off: false,
329-
on: false,
349+
off: false,
330350
passes: 2,
331-
radius: FloatOrInt(0.0),
332-
noise: FloatOrInt(0.0),
351+
offset: 3.,
352+
noise: 0.02,
333353
ignore_alpha: FloatOrInt(0.),
334354
blur_when_keyboard_focused: false,
355+
saturation: 1.5,
335356
}
336357
}
337358
}
338359

339-
impl MergeWith<BlurRule> for Blur {
340-
fn merge_with(&mut self, part: &BlurRule) {
341-
self.on |= part.on;
342-
if part.off {
343-
self.on = false;
360+
impl MergeWith<BlurPart> for Blur {
361+
fn merge_with(&mut self, part: &BlurPart) {
362+
self.off |= part.off;
363+
if part.on {
364+
self.off = false;
344365
}
345366

346-
merge_clone!((self, part), passes, radius, noise, ignore_alpha, blur_when_keyboard_focused);
367+
merge_clone!(
368+
(self, part),
369+
ignore_alpha,
370+
passes,
371+
blur_when_keyboard_focused
372+
);
373+
374+
merge!((self, part), offset, noise, saturation);
347375
}
348376
}
349377

@@ -688,24 +716,6 @@ pub struct BorderRule {
688716
pub urgent_gradient: Option<Gradient>,
689717
}
690718

691-
#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)]
692-
pub struct BlurRule {
693-
#[knuffel(child)]
694-
pub off: bool,
695-
#[knuffel(child)]
696-
pub on: bool,
697-
#[knuffel(child, unwrap(argument))]
698-
pub passes: Option<u32>,
699-
#[knuffel(child, unwrap(argument))]
700-
pub radius: Option<FloatOrInt<0, 1024>>,
701-
#[knuffel(child, unwrap(argument))]
702-
pub noise: Option<FloatOrInt<0, 1024>>,
703-
#[knuffel(child, unwrap(argument))]
704-
pub ignore_alpha: Option<FloatOrInt<0, 1>>,
705-
#[knuffel(child, unwrap(argument))]
706-
pub blur_when_keyboard_focused: Option<bool>,
707-
}
708-
709719
#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)]
710720
pub struct ShadowRule {
711721
#[knuffel(child)]
@@ -759,10 +769,18 @@ impl MergeWith<Self> for BorderRule {
759769
}
760770
}
761771

762-
impl MergeWith<Self> for BlurRule {
772+
impl MergeWith<Self> for BlurPart {
763773
fn merge_with(&mut self, part: &Self) {
764774
merge_on_off!((self, part));
765-
merge_clone_opt!((self, part), passes, radius, noise, ignore_alpha,blur_when_keyboard_focused);
775+
merge_clone_opt!(
776+
(self, part),
777+
passes,
778+
offset,
779+
saturation,
780+
noise,
781+
ignore_alpha,
782+
blur_when_keyboard_focused
783+
);
766784
}
767785
}
768786

@@ -1078,6 +1096,72 @@ where
10781096
}
10791097
}
10801098

1099+
#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)]
1100+
pub struct BlurRule {
1101+
#[knuffel(child)]
1102+
pub off: bool,
1103+
#[knuffel(child)]
1104+
pub on: bool,
1105+
}
1106+
1107+
#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)]
1108+
pub struct BackgroundEffectRule {
1109+
#[knuffel(child, unwrap(argument))]
1110+
pub xray: Option<bool>,
1111+
#[knuffel(child, default)]
1112+
pub blur: BlurRule,
1113+
#[knuffel(child, unwrap(argument))]
1114+
pub noise: Option<FloatOrInt<0, 1000>>,
1115+
#[knuffel(child, unwrap(argument))]
1116+
pub saturation: Option<FloatOrInt<0, 1000>>,
1117+
}
1118+
1119+
impl MergeWith<Self> for BackgroundEffectRule {
1120+
fn merge_with(&mut self, part: &Self) {
1121+
merge_clone_opt!((self, part), xray, noise, saturation);
1122+
merge_on_off!((self.blur, part.blur));
1123+
}
1124+
}
1125+
1126+
/// Resolved background effect rule.
1127+
#[derive(Debug, Default, Clone, Copy, PartialEq)]
1128+
pub struct BackgroundEffect {
1129+
/// Whether to render with xray effect (see through).
1130+
pub xray: Option<bool>,
1131+
1132+
/// Whether to blur the background.
1133+
///
1134+
/// - `None`: blur when the window/layer requests it (e.g. through ext-background-effect
1135+
/// protocol)
1136+
/// - `Some(false)`: never blur
1137+
/// - `Some(true)`: always blur
1138+
pub blur: Option<bool>,
1139+
1140+
pub noise: Option<f64>,
1141+
pub saturation: Option<f64>,
1142+
}
1143+
1144+
impl MergeWith<BackgroundEffectRule> for BackgroundEffect {
1145+
fn merge_with(&mut self, part: &BackgroundEffectRule) {
1146+
merge_clone_opt!((self, part), xray);
1147+
1148+
if part.blur.on {
1149+
self.blur = Some(true);
1150+
}
1151+
if part.blur.off {
1152+
self.blur = Some(false);
1153+
}
1154+
1155+
if let Some(x) = part.noise {
1156+
self.noise = Some(x.0);
1157+
}
1158+
1159+
if let Some(x) = part.saturation {
1160+
self.saturation = Some(x.0);
1161+
}
1162+
}
1163+
}
1164+
10811165
#[cfg(test)]
10821166
mod tests {
10831167
use insta::{assert_debug_snapshot, assert_snapshot};

niri-config/src/layer_rule.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::appearance::{BlockOutFrom, BlurRule, CornerRadius, ShadowRule};
1+
use crate::appearance::{BackgroundEffectRule, BlockOutFrom, CornerRadius, ShadowRule};
22
use crate::utils::RegexEq;
33

44
#[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]
@@ -14,8 +14,8 @@ pub struct LayerRule {
1414
pub block_out_from: Option<BlockOutFrom>,
1515
#[knuffel(child, default)]
1616
pub shadow: ShadowRule,
17-
#[knuffel(child, default)]
18-
pub blur: BlurRule,
17+
// #[knuffel(child, default)]
18+
// pub blur: BlurRule,
1919
#[knuffel(child)]
2020
pub geometry_corner_radius: Option<CornerRadius>,
2121
#[knuffel(child, unwrap(argument))]
@@ -26,6 +26,8 @@ pub struct LayerRule {
2626
pub transparent_block: Option<bool>,
2727
#[knuffel(child, unwrap(argument))]
2828
pub rounding_exponent: Option<f32>,
29+
#[knuffel(child, default)]
30+
pub background_effect: BackgroundEffectRule,
2931
}
3032

3133
#[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]

niri-config/src/layout.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub struct Layout {
2727
pub gaps: f64,
2828
pub struts: Struts,
2929
pub background_color: Color,
30-
pub blur: Blur,
3130
pub background_in_working_area_only: bool,
3231
pub fullscreen_backdrop_color: Color,
3332
}
@@ -58,7 +57,6 @@ impl Default for Layout {
5857
PresetSize::Proportion(2. / 3.),
5958
],
6059
background_color: DEFAULT_BACKGROUND_COLOR,
61-
blur: Default::default(),
6260
background_in_working_area_only: false,
6361
fullscreen_backdrop_color: DEFAULT_BACKDROP_COLOR,
6462
}
@@ -78,7 +76,6 @@ impl MergeWith<LayoutPart> for Layout {
7876
empty_workspace_above_first,
7977
background_in_working_area_only,
8078
gaps,
81-
blur,
8279
);
8380

8481
merge_clone!(

0 commit comments

Comments
 (0)