diff options
Diffstat (limited to 'src/layout/workspace.rs')
| -rw-r--r-- | src/layout/workspace.rs | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index da04abed..af455f97 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -2,7 +2,10 @@ use std::cmp::max; use std::rc::Rc; use std::time::Duration; -use niri_config::{CenterFocusedColumn, OutputName, PresetSize, Workspace as WorkspaceConfig}; +use niri_config::{ + CenterFocusedColumn, CornerRadius, FloatOrInt, OutputName, PresetSize, + Workspace as WorkspaceConfig, +}; use niri_ipc::{ColumnDisplay, PositionChange, SizeChange}; use smithay::backend::renderer::gles::GlesRenderer; use smithay::desktop::{layer_map_for_output, Window}; @@ -17,6 +20,7 @@ use super::floating::{FloatingSpace, FloatingSpaceRenderElement}; use super::scrolling::{ Column, ColumnWidth, ScrollDirection, ScrollingSpace, ScrollingSpaceRenderElement, }; +use super::shadow::Shadow; use super::tile::{Tile, TileRenderSnapshot}; use super::{ ActivateWindow, HitType, InsertPosition, InteractiveResizeData, LayoutElement, Options, @@ -25,6 +29,7 @@ use super::{ use crate::animation::Clock; use crate::niri_render_elements; use crate::render_helpers::renderer::NiriRenderer; +use crate::render_helpers::shadow::ShadowRenderElement; use crate::render_helpers::RenderTarget; use crate::utils::id::IdCounter; use crate::utils::transaction::{Transaction, TransactionBlocker}; @@ -80,6 +85,9 @@ pub struct Workspace<W: LayoutElement> { /// zones. working_area: Rectangle<f64, Logical>, + /// This workspace's shadow in the overview. + shadow: Shadow, + /// Clock for driving animations. pub(super) clock: Clock, @@ -228,6 +236,17 @@ impl<W: LayoutElement> Workspace<W> { options.clone(), ); + let shadow_config = niri_config::Shadow { + on: true, + offset: niri_config::ShadowOffset { + x: FloatOrInt(0.), + y: FloatOrInt(20.), + }, + softness: FloatOrInt(120.), + spread: FloatOrInt(20.), + ..Default::default() + }; + Self { scrolling, floating, @@ -237,6 +256,7 @@ impl<W: LayoutElement> Workspace<W> { transform: output.current_transform(), view_size, working_area, + shadow: Shadow::new(shadow_config), output: Some(output), clock, base_options, @@ -281,6 +301,17 @@ impl<W: LayoutElement> Workspace<W> { options.clone(), ); + let shadow_config = niri_config::Shadow { + on: true, + offset: niri_config::ShadowOffset { + x: FloatOrInt(0.), + y: FloatOrInt(20.), + }, + softness: FloatOrInt(120.), + spread: FloatOrInt(20.), + ..Default::default() + }; + Self { scrolling, floating, @@ -291,6 +322,7 @@ impl<W: LayoutElement> Workspace<W> { original_output, view_size, working_area, + shadow: Shadow::new(shadow_config), clock, base_options, options, @@ -343,6 +375,14 @@ impl<W: LayoutElement> Workspace<W> { let view_rect = Rectangle::from_size(self.view_size); self.floating .update_render_elements(is_active && self.floating_is_active.get(), view_rect); + + self.shadow.update_render_elements( + self.view_size, + true, + CornerRadius::default(), + self.scale.fractional_scale(), + 1., + ); } pub fn update_config(&mut self, base_options: Rc<Options>) { @@ -370,6 +410,7 @@ impl<W: LayoutElement> Workspace<W> { pub fn update_shaders(&mut self) { self.scrolling.update_shaders(); self.floating.update_shaders(); + self.shadow.update_shaders(); } pub fn windows(&self) -> impl Iterator<Item = &W> + '_ { @@ -1432,6 +1473,13 @@ impl<W: LayoutElement> Workspace<W> { (floating, scrolling) } + pub fn render_shadow<R: NiriRenderer>( + &self, + renderer: &mut R, + ) -> impl Iterator<Item = ShadowRenderElement> + '_ { + self.shadow.render(renderer, Point::from((0., 0.))) + } + pub fn render_above_top_layer(&self) -> bool { self.scrolling.render_above_top_layer() } @@ -1630,7 +1678,7 @@ impl<W: LayoutElement> Workspace<W> { self.scrolling.dnd_scroll_gesture_begin(); } - pub fn dnd_scroll_gesture_scroll(&mut self, pos: Point<f64, Logical>) { + pub fn dnd_scroll_gesture_scroll(&mut self, pos: Point<f64, Logical>, speed: f64) { let config = &self.options.gestures.dnd_edge_view_scroll; let trigger_width = config.trigger_width.0; @@ -1656,6 +1704,7 @@ impl<W: LayoutElement> Workspace<W> { // Normalize to [0, 1]. delta / trigger_width }; + let delta = delta * speed; self.scrolling.dnd_scroll_gesture_scroll(delta); } |
