Add workspace-shadow {} config to overview {}
Browse files at this commit446bc155ce15103c347c1a4f654c71a88d9991faParent: 32893244 changed files +103 -26
- niri-config/src/lib.rs +69 -0
- src/layout/workspace.rs +6 -26
- wiki/Configuration:-Miscellaneous.md +26 -0
- wiki/Overview.md +2 -0
niri-config/src/lib.rsmodified+69 -0
| @@ -754,6 +754,49 @@ pub struct ShadowOffset { | |||
| 754 | pub y: FloatOrInt<-65535, 65535>, | 754 | pub y: FloatOrInt<-65535, 65535>, |
| 755 | } | 755 | } |
| 756 | 756 | ||
| 757 | +#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] | ||
| 758 | +pub struct WorkspaceShadow { | ||
| 759 | + #[knuffel(child)] | ||
| 760 | + pub off: bool, | ||
| 761 | + #[knuffel(child, default = Self::default().offset)] | ||
| 762 | + pub offset: ShadowOffset, | ||
| 763 | + #[knuffel(child, unwrap(argument), default = Self::default().softness)] | ||
| 764 | + pub softness: FloatOrInt<0, 1024>, | ||
| 765 | + #[knuffel(child, unwrap(argument), default = Self::default().spread)] | ||
| 766 | + pub spread: FloatOrInt<-1024, 1024>, | ||
| 767 | + #[knuffel(child, default = Self::default().color)] | ||
| 768 | + pub color: Color, | ||
| 769 | +} | ||
| 770 | + | ||
| 771 | +impl Default for WorkspaceShadow { | ||
| 772 | + fn default() -> Self { | ||
| 773 | + Self { | ||
| 774 | + off: false, | ||
| 775 | + offset: ShadowOffset { | ||
| 776 | + x: FloatOrInt(0.), | ||
| 777 | + y: FloatOrInt(20.), | ||
| 778 | + }, | ||
| 779 | + softness: FloatOrInt(120.), | ||
| 780 | + spread: FloatOrInt(20.), | ||
| 781 | + color: Color::from_rgba8_unpremul(0, 0, 0, 0x70), | ||
| 782 | + } | ||
| 783 | + } | ||
| 784 | +} | ||
| 785 | + | ||
| 786 | +impl From<WorkspaceShadow> for Shadow { | ||
| 787 | + fn from(value: WorkspaceShadow) -> Self { | ||
| 788 | + Self { | ||
| 789 | + on: !value.off, | ||
| 790 | + offset: value.offset, | ||
| 791 | + softness: value.softness, | ||
| 792 | + spread: value.spread, | ||
| 793 | + draw_behind_window: false, | ||
| 794 | + color: value.color, | ||
| 795 | + inactive_color: None, | ||
| 796 | + } | ||
| 797 | + } | ||
| 798 | +} | ||
| 799 | + | ||
| 757 | #[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] | 800 | #[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] |
| 758 | pub struct TabIndicator { | 801 | pub struct TabIndicator { |
| 759 | #[knuffel(child)] | 802 | #[knuffel(child)] |
| @@ -1269,6 +1312,8 @@ pub struct Overview { | |||
| 1269 | pub zoom: FloatOrInt<0, 1>, | 1312 | pub zoom: FloatOrInt<0, 1>, |
| 1270 | #[knuffel(child, default = Self::default().backdrop_color)] | 1313 | #[knuffel(child, default = Self::default().backdrop_color)] |
| 1271 | pub backdrop_color: Color, | 1314 | pub backdrop_color: Color, |
| 1315 | + #[knuffel(child, default)] | ||
| 1316 | + pub workspace_shadow: WorkspaceShadow, | ||
| 1272 | } | 1317 | } |
| 1273 | 1318 | ||
| 1274 | impl Default for Overview { | 1319 | impl Default for Overview { |
| @@ -1276,6 +1321,7 @@ impl Default for Overview { | |||
| 1276 | Self { | 1321 | Self { |
| 1277 | zoom: FloatOrInt(0.5), | 1322 | zoom: FloatOrInt(0.5), |
| 1278 | backdrop_color: DEFAULT_BACKDROP_COLOR, | 1323 | backdrop_color: DEFAULT_BACKDROP_COLOR, |
| 1324 | + workspace_shadow: WorkspaceShadow::default(), | ||
| 1279 | } | 1325 | } |
| 1280 | } | 1326 | } |
| 1281 | } | 1327 | } |
| @@ -4611,6 +4657,29 @@ mod tests { | |||
| 4611 | b: 0.15, | 4657 | b: 0.15, |
| 4612 | a: 1.0, | 4658 | a: 1.0, |
| 4613 | }, | 4659 | }, |
| 4660 | + workspace_shadow: WorkspaceShadow { | ||
| 4661 | + off: false, | ||
| 4662 | + offset: ShadowOffset { | ||
| 4663 | + x: FloatOrInt( | ||
| 4664 | + 0.0, | ||
| 4665 | + ), | ||
| 4666 | + y: FloatOrInt( | ||
| 4667 | + 20.0, | ||
| 4668 | + ), | ||
| 4669 | + }, | ||
| 4670 | + softness: FloatOrInt( | ||
| 4671 | + 120.0, | ||
| 4672 | + ), | ||
| 4673 | + spread: FloatOrInt( | ||
| 4674 | + 20.0, | ||
| 4675 | + ), | ||
| 4676 | + color: Color { | ||
| 4677 | + r: 0.0, | ||
| 4678 | + g: 0.0, | ||
| 4679 | + b: 0.0, | ||
| 4680 | + a: 0.4392157, | ||
| 4681 | + }, | ||
| 4682 | + }, | ||
| 4614 | }, | 4683 | }, |
| 4615 | environment: Environment( | 4684 | environment: Environment( |
| 4616 | [ | 4685 | [ |
src/layout/workspace.rsmodified+6 -26
| @@ -3,8 +3,7 @@ use std::rc::Rc; | |||
| 3 | use std::time::Duration; | 3 | use std::time::Duration; |
| 4 | 4 | ||
| 5 | use niri_config::{ | 5 | use niri_config::{ |
| 6 | - CenterFocusedColumn, CornerRadius, FloatOrInt, OutputName, PresetSize, | 6 | + CenterFocusedColumn, CornerRadius, OutputName, PresetSize, Workspace as WorkspaceConfig, |
| 7 | - Workspace as WorkspaceConfig, | ||
| 8 | }; | 7 | }; |
| 9 | use niri_ipc::{ColumnDisplay, PositionChange, SizeChange}; | 8 | use niri_ipc::{ColumnDisplay, PositionChange, SizeChange}; |
| 10 | use smithay::backend::renderer::gles::GlesRenderer; | 9 | use smithay::backend::renderer::gles::GlesRenderer; |
| @@ -236,17 +235,6 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 236 | options.clone(), | 235 | options.clone(), |
| 237 | ); | 236 | ); |
| 238 | 237 | ||
| 239 | - let shadow_config = niri_config::Shadow { | ||
| 240 | - on: true, | ||
| 241 | - offset: niri_config::ShadowOffset { | ||
| 242 | - x: FloatOrInt(0.), | ||
| 243 | - y: FloatOrInt(20.), | ||
| 244 | - }, | ||
| 245 | - softness: FloatOrInt(120.), | ||
| 246 | - spread: FloatOrInt(20.), | ||
| 247 | - ..Default::default() | ||
| 248 | - }; | ||
| 249 | - | ||
| 250 | Self { | 238 | Self { |
| 251 | scrolling, | 239 | scrolling, |
| 252 | floating, | 240 | floating, |
| @@ -256,7 +244,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 256 | transform: output.current_transform(), | 244 | transform: output.current_transform(), |
| 257 | view_size, | 245 | view_size, |
| 258 | working_area, | 246 | working_area, |
| 259 | - shadow: Shadow::new(shadow_config), | 247 | + shadow: Shadow::new(niri_config::Shadow::from(options.overview.workspace_shadow)), |
| 260 | output: Some(output), | 248 | output: Some(output), |
| 261 | clock, | 249 | clock, |
| 262 | base_options, | 250 | base_options, |
| @@ -301,17 +289,6 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 301 | options.clone(), | 289 | options.clone(), |
| 302 | ); | 290 | ); |
| 303 | 291 | ||
| 304 | - let shadow_config = niri_config::Shadow { | ||
| 305 | - on: true, | ||
| 306 | - offset: niri_config::ShadowOffset { | ||
| 307 | - x: FloatOrInt(0.), | ||
| 308 | - y: FloatOrInt(20.), | ||
| 309 | - }, | ||
| 310 | - softness: FloatOrInt(120.), | ||
| 311 | - spread: FloatOrInt(20.), | ||
| 312 | - ..Default::default() | ||
| 313 | - }; | ||
| 314 | - | ||
| 315 | Self { | 292 | Self { |
| 316 | scrolling, | 293 | scrolling, |
| 317 | floating, | 294 | floating, |
| @@ -322,7 +299,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 322 | original_output, | 299 | original_output, |
| 323 | view_size, | 300 | view_size, |
| 324 | working_area, | 301 | working_area, |
| 325 | - shadow: Shadow::new(shadow_config), | 302 | + shadow: Shadow::new(niri_config::Shadow::from(options.overview.workspace_shadow)), |
| 326 | clock, | 303 | clock, |
| 327 | base_options, | 304 | base_options, |
| 328 | options, | 305 | options, |
| @@ -403,6 +380,9 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 403 | options.clone(), | 380 | options.clone(), |
| 404 | ); | 381 | ); |
| 405 | 382 | ||
| 383 | + let shadow_config = niri_config::Shadow::from(options.overview.workspace_shadow); | ||
| 384 | + self.shadow.update_config(shadow_config); | ||
| 385 | + | ||
| 406 | self.base_options = base_options; | 386 | self.base_options = base_options; |
| 407 | self.options = options; | 387 | self.options = options; |
| 408 | } | 388 | } |
wiki/Configuration:-Miscellaneous.mdmodified+26 -0
| @@ -26,6 +26,14 @@ cursor { | |||
| 26 | overview { | 26 | overview { |
| 27 | zoom 0.5 | 27 | zoom 0.5 |
| 28 | backdrop-color "#262626" | 28 | backdrop-color "#262626" |
| 29 | + | ||
| 30 | + workspace-shadow { | ||
| 31 | + // off | ||
| 32 | + softness 120 | ||
| 33 | + spread 20 | ||
| 34 | + offset x=0 y=20 | ||
| 35 | + color "#00000070" | ||
| 36 | + } | ||
| 29 | } | 37 | } |
| 30 | 38 | ||
| 31 | clipboard { | 39 | clipboard { |
| @@ -178,6 +186,24 @@ overview { | |||
| 178 | } | 186 | } |
| 179 | ``` | 187 | ``` |
| 180 | 188 | ||
| 189 | +#### `workspace-shadow` | ||
| 190 | + | ||
| 191 | +Control the shadow behind workspaces visible in the overview. | ||
| 192 | + | ||
| 193 | +Settings here mirror the normal [`shadow` config in the layout section](./Configuration:-Layout.md#shadow), so check the documentation there. | ||
| 194 | + | ||
| 195 | +Keep in mind that workspace shadows are configured for the full-screen workspace size, then zoomed out together with the workspace. | ||
| 196 | +Practically, this means that you'll want bigger spread, offset, and softness compared to window shadows. | ||
| 197 | + | ||
| 198 | +```kdl | ||
| 199 | +// Disable workspace shadows in the overview. | ||
| 200 | +overview { | ||
| 201 | + workspace-shadow { | ||
| 202 | + off | ||
| 203 | + } | ||
| 204 | +} | ||
| 205 | +``` | ||
| 206 | + | ||
| 181 | ### `clipboard` | 207 | ### `clipboard` |
| 182 | 208 | ||
| 183 | <sup>Since: 25.02</sup> | 209 | <sup>Since: 25.02</sup> |
wiki/Overview.mdmodified+2 -0
| @@ -29,6 +29,8 @@ https://github.com/user-attachments/assets/b76d5349-aa20-4889-ab90-0a51554c789d | |||
| 29 | 29 | ||
| 30 | ### Configuration | 30 | ### Configuration |
| 31 | 31 | ||
| 32 | +See the full documentation for the `overview {}` section [here](./Configuration:-Miscellaneous.md#overview). | ||
| 33 | + | ||
| 32 | You can set the zoom-out level like this: | 34 | You can set the zoom-out level like this: |
| 33 | 35 | ||
| 34 | ```kdl | 36 | ```kdl |