Add geometry-corner-radius and background-effect popup rules
Browse files at this commit4d214891017fa7b893df1140d24f76defba0eb88Parent: 5a24aae12 changed files +222 -28
- docs/wiki/Configuration:-Layer-Rules.md +51 -0
- docs/wiki/Configuration:-Window-Rules.md +73 -0
- docs/wiki/Window-Effects.md +4 -0
- docs/wiki/img/popup-arrow.png +3 -0
- docs/wiki/img/popup-no-arrow.png +3 -0
- niri-config/src/lib.rs +14 -0
- niri-config/src/window_rule.rs +16 -1
- src/layer/mapped.rs +9 -6
- src/layout/mod.rs +4 -2
- src/layout/tile.rs +8 -4
- src/niri.rs +27 -9
- src/window/mapped.rs +10 -6
docs/wiki/Configuration:-Layer-Rules.mdmodified+51 -0
| @@ -42,6 +42,18 @@ layer-rule { | |||
| 42 | noise 0.05 | 42 | noise 0.05 |
| 43 | saturation 3 | 43 | saturation 3 |
| 44 | } | 44 | } |
| 45 | + | ||
| 46 | + popups { | ||
| 47 | + opacity 0.5 | ||
| 48 | + geometry-corner-radius 6 | ||
| 49 | + | ||
| 50 | + background-effect { | ||
| 51 | + xray true | ||
| 52 | + blur true | ||
| 53 | + noise 0.05 | ||
| 54 | + saturation 3 | ||
| 55 | + } | ||
| 56 | + } | ||
| 45 | } | 57 | } |
| 46 | ``` | 58 | ``` |
| 47 | 59 | ||
| @@ -241,3 +253,42 @@ layer-rule { | |||
| 241 | } | 253 | } |
| 242 | } | 254 | } |
| 243 | ``` | 255 | ``` |
| 256 | + | ||
| 257 | +#### `popups` | ||
| 258 | + | ||
| 259 | +<sup>Since: next release</sup> | ||
| 260 | + | ||
| 261 | +Override properties for this layer surface's pop-ups (e.g. a menu opened by clicking an item in Waybar). | ||
| 262 | + | ||
| 263 | +The properties work the same way as the corresponding layer-rule properties, except that they apply to the layer surface's pop-ups rather than to the layer surface itself. | ||
| 264 | + | ||
| 265 | +`opacity` is applied *on top* of the layer surface's own opacity rule, so setting both will make pop-ups more transparent than the surface. | ||
| 266 | +Other properties apply independently. | ||
| 267 | + | ||
| 268 | +> [!NOTE] | ||
| 269 | +> This block affects only pop-ups created by the app via Wayland's [xdg-popup](https://wayland.app/protocols/xdg-shell#xdg_popup) (which should be most of them). | ||
| 270 | +> | ||
| 271 | +> Some desktop shells will emulate pop-ups by drawing something that looks like a pop-up inside a regular layer surface. | ||
| 272 | +> As far as niri is concerned, those are just layer surfaces and not pop-ups, so this block won't apply to them. | ||
| 273 | +> | ||
| 274 | +> This block also does not affect input-method pop-ups, such as Fcitx. | ||
| 275 | + | ||
| 276 | +```kdl | ||
| 277 | +// Blur the background behind Waybar popup menus. | ||
| 278 | +layer-rule { | ||
| 279 | + match namespace="^waybar$" | ||
| 280 | + | ||
| 281 | + popups { | ||
| 282 | + // Match the default GTK 3 popup corner radius. | ||
| 283 | + geometry-corner-radius 6 | ||
| 284 | + opacity 0.85 | ||
| 285 | + | ||
| 286 | + background-effect { | ||
| 287 | + blur true | ||
| 288 | + } | ||
| 289 | + } | ||
| 290 | +} | ||
| 291 | +``` | ||
| 292 | + | ||
| 293 | +Keep in mind that the background effect will look right only if the pop-up is shaped like a (rounded) rectangle, and the layer surface correctly sets its Wayland geometry to exclude any shadows. | ||
| 294 | +Pop-ups with custom shapes will need the app to implement the [ext-background-effect protocol](https://wayland.app/protocols/ext-background-effect-v1) to work properly. | ||
docs/wiki/Configuration:-Window-Rules.mdmodified+73 -0
| @@ -107,6 +107,18 @@ window-rule { | |||
| 107 | saturation 3 | 107 | saturation 3 |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | + popups { | ||
| 111 | + opacity 0.5 | ||
| 112 | + geometry-corner-radius 15 | ||
| 113 | + | ||
| 114 | + background-effect { | ||
| 115 | + xray true | ||
| 116 | + blur true | ||
| 117 | + noise 0.05 | ||
| 118 | + saturation 3 | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + | ||
| 110 | min-width 100 | 122 | min-width 100 |
| 111 | max-width 200 | 123 | max-width 200 |
| 112 | min-height 300 | 124 | min-height 300 |
| @@ -941,6 +953,67 @@ window-rule { | |||
| 941 | } | 953 | } |
| 942 | ``` | 954 | ``` |
| 943 | 955 | ||
| 956 | +#### `popups` | ||
| 957 | + | ||
| 958 | +<sup>Since: next release</sup> | ||
| 959 | + | ||
| 960 | +Override properties for this window's pop-ups (menus and tooltips). | ||
| 961 | + | ||
| 962 | +The properties work the same way as the corresponding window-rule properties, except that they apply to the window's pop-ups rather than to the window itself. | ||
| 963 | + | ||
| 964 | +`opacity` is applied *on top* of the layer surface's own opacity rule, so setting both will make pop-ups more transparent than the surface. | ||
| 965 | +Other properties apply independently. | ||
| 966 | + | ||
| 967 | +> [!NOTE] | ||
| 968 | +> This block affects only pop-ups created by the app via Wayland's [xdg-popup](https://wayland.app/protocols/xdg-shell#xdg_popup) (which should be most of them). | ||
| 969 | +> | ||
| 970 | +> Examples of things that look like pop-ups that won't work: | ||
| 971 | +> | ||
| 972 | +> - Fully emulated by the client, i.e. not a pop-up at all, the client just draws something that looks like a pop-up inside its window. | ||
| 973 | +> These are common in game engines and in web apps, e.g. the right click menu in Google Docs or in Electron apps like Discord. | ||
| 974 | +> | ||
| 975 | +> - Uses a wl-subsurface instead of an xdg-popup. | ||
| 976 | +> Common in older apps using GTK 3, notably Firefox still uses these for some menus. | ||
| 977 | +> Subsurfaces are an indivisible part of a surface and they aren't usually pop-ups, so it wouldn't make sense for niri to apply these rules to them. | ||
| 978 | +> | ||
| 979 | +> These emulated pop-ups come with other downsides: they cannot reliably extend outside their window, and if the app tries to do that, they will be clipped by rules such as `clip-to-geometry`. | ||
| 980 | +> So most modern apps will correctly use xdg-popup, which is the intended way to show pop-ups on Wayland. | ||
| 981 | +> | ||
| 982 | +> This block also does not affect input-method pop-ups, such as Fcitx. | ||
| 983 | +> | ||
| 984 | +> For pop-ups created by your desktop shell or desktop components, use the corresponding [layer rule](./Configuration:-Layer-Rules.md#popups). | ||
| 985 | + | ||
| 986 | +```kdl | ||
| 987 | +// Blur the background behind pop-up menus in Nautilus. | ||
| 988 | +window-rule { | ||
| 989 | + match app-id="Nautilus" | ||
| 990 | + | ||
| 991 | + popups { | ||
| 992 | + // Matches the default libadwaita pop-up corner radius. | ||
| 993 | + geometry-corner-radius 15 | ||
| 994 | + | ||
| 995 | + // Note: it'll look better to set background opacity | ||
| 996 | + // through your GTK theme CSS and not here. | ||
| 997 | + // This is just an example that makes it look obvious. | ||
| 998 | + opacity 0.5 | ||
| 999 | + | ||
| 1000 | + background-effect { | ||
| 1001 | + blur true | ||
| 1002 | + } | ||
| 1003 | + } | ||
| 1004 | +} | ||
| 1005 | +``` | ||
| 1006 | + | ||
| 1007 | +Keep in mind that the background effect will look right only if the pop-up is shaped like a (rounded) rectangle, and the window correctly sets its Wayland geometry to exclude any shadows. | ||
| 1008 | +For example, GTK 4 pop-ups with pointing arrows (`has-arrow=true` property) are *not* rounded rectangles—the arrow sticks out—so if you enable blur, it will also stick out of the pop-up. | ||
| 1009 | + | ||
| 1010 | +| Correct | Wrong | | ||
| 1011 | +|-----------------------------------------------------|--------------------------------------------------------------------------------| | ||
| 1012 | +| The pop-up is a rounded rectangle. Blur looks fine. | The pop-up is not a rounded rectangle. Blur extends above, where the arrow is. | | ||
| 1013 | +|  |  | | ||
| 1014 | + | ||
| 1015 | +These pop-ups with custom shapes will need the app to implement the [ext-background-effect protocol](https://wayland.app/protocols/ext-background-effect-v1) to work properly. | ||
| 1016 | + | ||
| 944 | #### Size Overrides | 1017 | #### Size Overrides |
| 945 | 1018 | ||
| 946 | You can amend the window's minimum and maximum size in logical pixels. | 1019 | You can amend the window's minimum and maximum size in logical pixels. |
docs/wiki/Window-Effects.mdmodified+4 -0
| @@ -40,6 +40,10 @@ Blur enabled via the window rule will follow the window corner radius set via [` | |||
| 40 | On the other hand, blur enabled through `ext-background-effect` will exactly follow the shape requested by the window. | 40 | On the other hand, blur enabled through `ext-background-effect` will exactly follow the shape requested by the window. |
| 41 | If the window or layer has clientside rounded corners or other complex shape, it should set a corresponding blur shape through `ext-background-effect`, then it will get correctly shaped background blur without any manual niri configuration. | 41 | If the window or layer has clientside rounded corners or other complex shape, it should set a corresponding blur shape through `ext-background-effect`, then it will get correctly shaped background blur without any manual niri configuration. |
| 42 | 42 | ||
| 43 | +Windows can also blur their pop-up menus using `ext-background-effect`. | ||
| 44 | +On the niri side, you can do it with a `popups` block inside [`window-rule`](./Configuration:-Window-Rules.md#popups) and [`layer-rule`](./Configuration:-Layer-Rules.md#popups). | ||
| 45 | +See those wiki pages for examples and limitations. | ||
| 46 | + | ||
| 43 | Global blur settings are configured in the [`blur {}` config section](./Configuration:-Miscellaneous.md#blur) and apply to all background blur. | 47 | Global blur settings are configured in the [`blur {}` config section](./Configuration:-Miscellaneous.md#blur) and apply to all background blur. |
| 44 | 48 | ||
| 45 | ### Xray | 49 | ### Xray |
docs/wiki/img/popup-arrow.pngadded+3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | +version https://git-lfs.github.com/spec/v1 | ||
| 2 | +oid sha256:b5a63ea3cc2f158e175c00dd058988a2bbf676e2a2aac5c2ef1603bd983589d5 | ||
| 3 | +size 166777 | ||
docs/wiki/img/popup-no-arrow.pngadded+3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | +version https://git-lfs.github.com/spec/v1 | ||
| 2 | +oid sha256:bef0c57d617916bf6014fe08e268c8201d7f6ef682e3aea3395e76116b1d0400 | ||
| 3 | +size 56936 | ||
niri-config/src/lib.rsmodified+14 -0
| @@ -1864,6 +1864,13 @@ mod tests { | |||
| 1864 | }, | 1864 | }, |
| 1865 | popups: PopupsRule { | 1865 | popups: PopupsRule { |
| 1866 | opacity: None, | 1866 | opacity: None, |
| 1867 | + geometry_corner_radius: None, | ||
| 1868 | + background_effect: BackgroundEffectRule { | ||
| 1869 | + xray: None, | ||
| 1870 | + blur: None, | ||
| 1871 | + noise: None, | ||
| 1872 | + saturation: None, | ||
| 1873 | + }, | ||
| 1867 | }, | 1874 | }, |
| 1868 | }, | 1875 | }, |
| 1869 | ], | 1876 | ], |
| @@ -1908,6 +1915,13 @@ mod tests { | |||
| 1908 | }, | 1915 | }, |
| 1909 | popups: PopupsRule { | 1916 | popups: PopupsRule { |
| 1910 | opacity: None, | 1917 | opacity: None, |
| 1918 | + geometry_corner_radius: None, | ||
| 1919 | + background_effect: BackgroundEffectRule { | ||
| 1920 | + xray: None, | ||
| 1921 | + blur: None, | ||
| 1922 | + noise: None, | ||
| 1923 | + saturation: None, | ||
| 1924 | + }, | ||
| 1911 | }, | 1925 | }, |
| 1912 | }, | 1926 | }, |
| 1913 | ], | 1927 | ], |
niri-config/src/window_rule.rsmodified+16 -1
| @@ -1,7 +1,8 @@ | |||
| 1 | use niri_ipc::ColumnDisplay; | 1 | use niri_ipc::ColumnDisplay; |
| 2 | 2 | ||
| 3 | use crate::appearance::{ | 3 | use crate::appearance::{ |
| 4 | - BackgroundEffectRule, BlockOutFrom, BorderRule, CornerRadius, ShadowRule, TabIndicatorRule, | 4 | + BackgroundEffect, BackgroundEffectRule, BlockOutFrom, BorderRule, CornerRadius, ShadowRule, |
| 5 | + TabIndicatorRule, | ||
| 5 | }; | 6 | }; |
| 6 | use crate::layout::DefaultPresetSize; | 7 | use crate::layout::DefaultPresetSize; |
| 7 | use crate::utils::{MergeWith, RegexEq}; | 8 | use crate::utils::{MergeWith, RegexEq}; |
| @@ -85,6 +86,10 @@ pub struct WindowRule { | |||
| 85 | pub struct PopupsRule { | 86 | pub struct PopupsRule { |
| 86 | #[knuffel(child, unwrap(argument))] | 87 | #[knuffel(child, unwrap(argument))] |
| 87 | pub opacity: Option<f32>, | 88 | pub opacity: Option<f32>, |
| 89 | + #[knuffel(child)] | ||
| 90 | + pub geometry_corner_radius: Option<CornerRadius>, | ||
| 91 | + #[knuffel(child, default)] | ||
| 92 | + pub background_effect: BackgroundEffectRule, | ||
| 88 | } | 93 | } |
| 89 | 94 | ||
| 90 | /// Resolved popup-specific rules. | 95 | /// Resolved popup-specific rules. |
| @@ -92,6 +97,12 @@ pub struct PopupsRule { | |||
| 92 | pub struct ResolvedPopupsRules { | 97 | pub struct ResolvedPopupsRules { |
| 93 | /// Extra opacity to draw popups with. | 98 | /// Extra opacity to draw popups with. |
| 94 | pub opacity: Option<f32>, | 99 | pub opacity: Option<f32>, |
| 100 | + | ||
| 101 | + /// Corner radius to assume the popups have. | ||
| 102 | + pub geometry_corner_radius: Option<CornerRadius>, | ||
| 103 | + | ||
| 104 | + /// Background effect configuration for popups. | ||
| 105 | + pub background_effect: BackgroundEffect, | ||
| 95 | } | 106 | } |
| 96 | 107 | ||
| 97 | impl MergeWith<PopupsRule> for ResolvedPopupsRules { | 108 | impl MergeWith<PopupsRule> for ResolvedPopupsRules { |
| @@ -99,6 +110,10 @@ impl MergeWith<PopupsRule> for ResolvedPopupsRules { | |||
| 99 | if let Some(x) = part.opacity { | 110 | if let Some(x) = part.opacity { |
| 100 | self.opacity = Some(x); | 111 | self.opacity = Some(x); |
| 101 | } | 112 | } |
| 113 | + if let Some(x) = part.geometry_corner_radius { | ||
| 114 | + self.geometry_corner_radius = Some(x); | ||
| 115 | + } | ||
| 116 | + self.background_effect.merge_with(&part.background_effect); | ||
| 102 | } | 117 | } |
| 103 | } | 118 | } |
| 104 | 119 | ||
src/layer/mapped.rsmodified+9 -6
| @@ -260,6 +260,7 @@ impl MappedLayer { | |||
| 260 | mut ctx: RenderCtx<R>, | 260 | mut ctx: RenderCtx<R>, |
| 261 | ns: Option<usize>, | 261 | ns: Option<usize>, |
| 262 | location: Point<f64, Logical>, | 262 | location: Point<f64, Logical>, |
| 263 | + xray_pos: XrayPos, | ||
| 263 | push: &mut dyn FnMut(LayerSurfaceRenderElement<R>), | 264 | push: &mut dyn FnMut(LayerSurfaceRenderElement<R>), |
| 264 | ) { | 265 | ) { |
| 265 | if ctx.target.should_block_out(self.rules.block_out_from) { | 266 | if ctx.target.should_block_out(self.rules.block_out_from) { |
| @@ -299,10 +300,12 @@ impl MappedLayer { | |||
| 299 | let geometry = Rectangle::new(location + offset.to_f64(), popup_geo.size.to_f64()); | 300 | let geometry = Rectangle::new(location + offset.to_f64(), popup_geo.size.to_f64()); |
| 300 | let surface_off = popup_geo.loc.upscale(-1).to_f64(); | 301 | let surface_off = popup_geo.loc.upscale(-1).to_f64(); |
| 301 | let surface_anim_scale = Scale::from(1.); | 302 | let surface_anim_scale = Scale::from(1.); |
| 302 | - let effect = niri_config::BackgroundEffect { | 303 | + let mut effect = popup_rules.background_effect; |
| 303 | - xray: Some(false), | 304 | + // Default xray to false for pop-ups since they're always on top of something. |
| 304 | - ..Default::default() | 305 | + if effect.xray.is_none() { |
| 305 | - }; | 306 | + effect.xray = Some(false); |
| 307 | + } | ||
| 308 | + let xray_pos = xray_pos.offset(offset.to_f64()); | ||
| 306 | background_effect::render_for_tile( | 309 | background_effect::render_for_tile( |
| 307 | ctx.as_gles(), | 310 | ctx.as_gles(), |
| 308 | ns, | 311 | ns, |
| @@ -313,10 +316,10 @@ impl MappedLayer { | |||
| 313 | surface_off, | 316 | surface_off, |
| 314 | surface_anim_scale, | 317 | surface_anim_scale, |
| 315 | self.blur_config, | 318 | self.blur_config, |
| 316 | - niri_config::CornerRadius::default(), | 319 | + popup_rules.geometry_corner_radius.unwrap_or_default(), |
| 317 | effect, | 320 | effect, |
| 318 | false, | 321 | false, |
| 319 | - XrayPos::default(), | 322 | + xray_pos, |
| 320 | &mut |elem| push(elem.into()), | 323 | &mut |elem| push(elem.into()), |
| 321 | ); | 324 | ); |
| 322 | } | 325 | } |
src/layout/mod.rsmodified+4 -2
| @@ -166,9 +166,10 @@ pub trait LayoutElement { | |||
| 166 | location: Point<f64, Logical>, | 166 | location: Point<f64, Logical>, |
| 167 | scale: Scale<f64>, | 167 | scale: Scale<f64>, |
| 168 | alpha: f32, | 168 | alpha: f32, |
| 169 | + xray_pos: XrayPos, | ||
| 169 | push: &mut dyn FnMut(LayoutElementRenderElement<R>), | 170 | push: &mut dyn FnMut(LayoutElementRenderElement<R>), |
| 170 | ) { | 171 | ) { |
| 171 | - self.render_popups(ctx.r(), location, scale, alpha, push); | 172 | + self.render_popups(ctx.r(), location, scale, alpha, xray_pos, push); |
| 172 | self.render_normal(ctx.r(), location, scale, alpha, push); | 173 | self.render_normal(ctx.r(), location, scale, alpha, push); |
| 173 | } | 174 | } |
| 174 | 175 | ||
| @@ -191,9 +192,10 @@ pub trait LayoutElement { | |||
| 191 | location: Point<f64, Logical>, | 192 | location: Point<f64, Logical>, |
| 192 | scale: Scale<f64>, | 193 | scale: Scale<f64>, |
| 193 | alpha: f32, | 194 | alpha: f32, |
| 195 | + xray_pos: XrayPos, | ||
| 194 | push: &mut dyn FnMut(LayoutElementRenderElement<R>), | 196 | push: &mut dyn FnMut(LayoutElementRenderElement<R>), |
| 195 | ) { | 197 | ) { |
| 196 | - let _ = (ctx, location, scale, alpha, push); | 198 | + let _ = (ctx, location, scale, alpha, xray_pos, push); |
| 197 | } | 199 | } |
| 198 | 200 | ||
| 199 | /// Renders the background effect behind the main surface of the element. | 201 | /// Renders the background effect behind the main surface of the element. |
src/layout/tile.rsmodified+8 -4
| @@ -1065,10 +1065,14 @@ impl<W: LayoutElement> Tile<W> { | |||
| 1065 | .scaled_by(1. - expanded_progress as f32); | 1065 | .scaled_by(1. - expanded_progress as f32); |
| 1066 | 1066 | ||
| 1067 | // Popups go on top, whether it's resize or not. | 1067 | // Popups go on top, whether it's resize or not. |
| 1068 | - self.window | 1068 | + self.window.render_popups( |
| 1069 | - .render_popups(ctx.r(), window_render_loc, scale, win_alpha, &mut |elem| { | 1069 | + ctx.r(), |
| 1070 | - push(elem.into()) | 1070 | + window_render_loc, |
| 1071 | - }); | 1071 | + scale, |
| 1072 | + win_alpha, | ||
| 1073 | + xray_pos, | ||
| 1074 | + &mut |elem| push(elem.into()), | ||
| 1075 | + ); | ||
| 1072 | 1076 | ||
| 1073 | // If we're resizing, try to render a shader, or a fallback. | 1077 | // If we're resizing, try to render a shader, or a fallback. |
| 1074 | let mut pushed_resize = false; | 1078 | let mut pushed_resize = false; |
src/niri.rsmodified+27 -9
| @@ -4271,17 +4271,29 @@ impl Niri { | |||
| 4271 | // We use macros instead of closures to avoid borrowing issues (renderer and push() go | 4271 | // We use macros instead of closures to avoid borrowing issues (renderer and push() go |
| 4272 | // into different functions). | 4272 | // into different functions). |
| 4273 | macro_rules! push_popups_from_layer { | 4273 | macro_rules! push_popups_from_layer { |
| 4274 | - ($layer:expr, $ns:expr, $backdrop:expr, $push:expr) => {{ | 4274 | + ($layer:expr, $ns:expr, $xray_pos:expr, $backdrop:expr, $push:expr) => {{ |
| 4275 | - self.render_layer_popups(ctx.r(), $ns, &layer_map, $layer, $backdrop, $push); | 4275 | + self.render_layer_popups( |
| 4276 | + ctx.r(), | ||
| 4277 | + $ns, | ||
| 4278 | + &layer_map, | ||
| 4279 | + $layer, | ||
| 4280 | + $xray_pos, | ||
| 4281 | + $backdrop, | ||
| 4282 | + $push, | ||
| 4283 | + ); | ||
| 4276 | }}; | 4284 | }}; |
| 4277 | ($layer:expr, true) => {{ | 4285 | ($layer:expr, true) => {{ |
| 4278 | - push_popups_from_layer!($layer, None, true, &mut |elem| push(elem.into())); | 4286 | + push_popups_from_layer!($layer, None, XrayPos::default(), true, &mut |elem| push( |
| 4287 | + elem.into() | ||
| 4288 | + )); | ||
| 4279 | }}; | 4289 | }}; |
| 4280 | - ($layer:expr, $ns:expr, $push:expr) => {{ | 4290 | + ($layer:expr, $ns:expr, $xray_pos:expr, $push:expr) => {{ |
| 4281 | - push_popups_from_layer!($layer, $ns, false, $push); | 4291 | + push_popups_from_layer!($layer, $ns, $xray_pos, false, $push); |
| 4282 | }}; | 4292 | }}; |
| 4283 | ($layer:expr) => {{ | 4293 | ($layer:expr) => {{ |
| 4284 | - push_popups_from_layer!($layer, None, false, &mut |elem| push(elem.into())); | 4294 | + push_popups_from_layer!($layer, None, XrayPos::default(), false, &mut |elem| push( |
| 4295 | + elem.into() | ||
| 4296 | + )); | ||
| 4285 | }}; | 4297 | }}; |
| 4286 | } | 4298 | } |
| 4287 | macro_rules! push_normal_from_layer { | 4299 | macro_rules! push_normal_from_layer { |
| @@ -4359,8 +4371,9 @@ impl Niri { | |||
| 4359 | 4371 | ||
| 4360 | for (ws, geo) in mon.workspaces_with_render_geo() { | 4372 | for (ws, geo) in mon.workspaces_with_render_geo() { |
| 4361 | let ns = Some(ws.id().get() as usize); | 4373 | let ns = Some(ws.id().get() as usize); |
| 4362 | - push_popups_from_layer!(Layer::Bottom, ns, process!(geo)); | 4374 | + let xray_pos = XrayPos::new(geo.loc, zoom); |
| 4363 | - push_popups_from_layer!(Layer::Background, ns, process!(geo)); | 4375 | + push_popups_from_layer!(Layer::Bottom, ns, xray_pos, process!(geo)); |
| 4376 | + push_popups_from_layer!(Layer::Background, ns, xray_pos, process!(geo)); | ||
| 4364 | } | 4377 | } |
| 4365 | 4378 | ||
| 4366 | mon.render_workspaces(ctx.r(), focus_ring, &mut |elem| push(elem.into())); | 4379 | mon.render_workspaces(ctx.r(), focus_ring, &mut |elem| push(elem.into())); |
| @@ -4515,17 +4528,21 @@ impl Niri { | |||
| 4515 | } | 4528 | } |
| 4516 | } | 4529 | } |
| 4517 | 4530 | ||
| 4531 | + #[allow(clippy::too_many_arguments)] | ||
| 4518 | fn render_layer_popups<R: NiriRenderer>( | 4532 | fn render_layer_popups<R: NiriRenderer>( |
| 4519 | &self, | 4533 | &self, |
| 4520 | mut ctx: RenderCtx<R>, | 4534 | mut ctx: RenderCtx<R>, |
| 4521 | ns: Option<usize>, | 4535 | ns: Option<usize>, |
| 4522 | layer_map: &LayerMap, | 4536 | layer_map: &LayerMap, |
| 4523 | layer: Layer, | 4537 | layer: Layer, |
| 4538 | + xray_pos: XrayPos, | ||
| 4524 | for_backdrop: bool, | 4539 | for_backdrop: bool, |
| 4525 | push: &mut dyn FnMut(LayerSurfaceRenderElement<R>), | 4540 | push: &mut dyn FnMut(LayerSurfaceRenderElement<R>), |
| 4526 | ) { | 4541 | ) { |
| 4527 | for (mapped, geo) in self.layers_in_render_order(layer_map, layer, for_backdrop) { | 4542 | for (mapped, geo) in self.layers_in_render_order(layer_map, layer, for_backdrop) { |
| 4528 | - mapped.render_popups(ctx.r(), ns, geo.loc.to_f64(), push); | 4543 | + let loc = geo.loc.to_f64(); |
| 4544 | + let xray_pos = xray_pos.offset(loc); | ||
| 4545 | + mapped.render_popups(ctx.r(), ns, loc, xray_pos, push); | ||
| 4529 | } | 4546 | } |
| 4530 | } | 4547 | } |
| 4531 | 4548 | ||
| @@ -5571,6 +5588,7 @@ impl Niri { | |||
| 5571 | mapped.window.geometry().loc.to_f64(), | 5588 | mapped.window.geometry().loc.to_f64(), |
| 5572 | scale, | 5589 | scale, |
| 5573 | alpha, | 5590 | alpha, |
| 5591 | + XrayPos::default(), | ||
| 5574 | &mut |elem| elements.push(elem.into()), | 5592 | &mut |elem| elements.push(elem.into()), |
| 5575 | ); | 5593 | ); |
| 5576 | 5594 | ||
src/window/mapped.rsmodified+10 -6
| @@ -535,6 +535,7 @@ impl Mapped { | |||
| 535 | location, | 535 | location, |
| 536 | scale, | 536 | scale, |
| 537 | 1., | 537 | 1., |
| 538 | + XrayPos::default(), | ||
| 538 | &mut |elem| push(use_border(elem)), | 539 | &mut |elem| push(use_border(elem)), |
| 539 | ); | 540 | ); |
| 540 | } | 541 | } |
| @@ -661,6 +662,7 @@ impl LayoutElement for Mapped { | |||
| 661 | location: Point<f64, Logical>, | 662 | location: Point<f64, Logical>, |
| 662 | scale: Scale<f64>, | 663 | scale: Scale<f64>, |
| 663 | alpha: f32, | 664 | alpha: f32, |
| 665 | + xray_pos: XrayPos, | ||
| 664 | push: &mut dyn FnMut(LayoutElementRenderElement<R>), | 666 | push: &mut dyn FnMut(LayoutElementRenderElement<R>), |
| 665 | ) { | 667 | ) { |
| 666 | if ctx.target.should_block_out(self.rules.block_out_from) { | 668 | if ctx.target.should_block_out(self.rules.block_out_from) { |
| @@ -693,10 +695,12 @@ impl LayoutElement for Mapped { | |||
| 693 | let geometry = Rectangle::new(location + offset.to_f64(), popup_geo.size.to_f64()); | 695 | let geometry = Rectangle::new(location + offset.to_f64(), popup_geo.size.to_f64()); |
| 694 | let surface_off = popup_geo.loc.upscale(-1).to_f64(); | 696 | let surface_off = popup_geo.loc.upscale(-1).to_f64(); |
| 695 | let surface_anim_scale = Scale::from(1.); | 697 | let surface_anim_scale = Scale::from(1.); |
| 696 | - let effect = niri_config::BackgroundEffect { | 698 | + let mut effect = popup_rules.background_effect; |
| 697 | - xray: Some(false), | 699 | + // Default xray to false for pop-ups since they're always on top of something. |
| 698 | - ..Default::default() | 700 | + if effect.xray.is_none() { |
| 699 | - }; | 701 | + effect.xray = Some(false); |
| 702 | + } | ||
| 703 | + let xray_pos = xray_pos.offset(offset.to_f64()); | ||
| 700 | background_effect::render_for_tile( | 704 | background_effect::render_for_tile( |
| 701 | ctx.as_gles(), | 705 | ctx.as_gles(), |
| 702 | None, | 706 | None, |
| @@ -707,10 +711,10 @@ impl LayoutElement for Mapped { | |||
| 707 | surface_off, | 711 | surface_off, |
| 708 | surface_anim_scale, | 712 | surface_anim_scale, |
| 709 | self.blur_config, | 713 | self.blur_config, |
| 710 | - CornerRadius::default(), | 714 | + popup_rules.geometry_corner_radius.unwrap_or_default(), |
| 711 | effect, | 715 | effect, |
| 712 | false, | 716 | false, |
| 713 | - XrayPos::default(), | 717 | + xray_pos, |
| 714 | &mut |elem| push(elem.into()), | 718 | &mut |elem| push(elem.into()), |
| 715 | ); | 719 | ); |
| 716 | } | 720 | } |