From 3e31c134a602dd876f2b446071e5802fa4a0c3ec Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Tue, 6 May 2025 16:51:18 +0300 Subject: Implement place-within-backdrop layer rule --- src/layer/mapped.rs | 18 ++++++++++++++++++ src/layer/mod.rs | 7 +++++++ 2 files changed, 25 insertions(+) (limited to 'src/layer') diff --git a/src/layer/mapped.rs b/src/layer/mapped.rs index 5e62d033..78cfadbf 100644 --- a/src/layer/mapped.rs +++ b/src/layer/mapped.rs @@ -6,6 +6,7 @@ use smithay::backend::renderer::element::surface::{ use smithay::backend::renderer::element::Kind; use smithay::desktop::{LayerSurface, PopupManager}; use smithay::utils::{Logical, Point, Scale, Size}; +use smithay::wayland::shell::wlr_layer::{ExclusiveZone, Layer}; use super::ResolvedLayerRules; use crate::layout::shadow::Shadow; @@ -96,6 +97,23 @@ impl MappedLayer { true } + pub fn place_within_backdrop(&self) -> bool { + if !self.rules.place_within_backdrop { + return false; + } + + if self.surface.layer() != Layer::Background { + return false; + } + + let state = self.surface.cached_state(); + if state.exclusive_zone != ExclusiveZone::DontCare { + return false; + } + + true + } + pub fn render( &self, renderer: &mut R, diff --git a/src/layer/mod.rs b/src/layer/mod.rs index 36e7ee67..3b27737c 100644 --- a/src/layer/mod.rs +++ b/src/layer/mod.rs @@ -19,6 +19,9 @@ pub struct ResolvedLayerRules { /// Corner radius to assume this layer surface has. pub geometry_corner_radius: Option, + + /// Whether to place this layer surface within the overview backdrop. + pub place_within_backdrop: bool, } impl ResolvedLayerRules { @@ -37,6 +40,7 @@ impl ResolvedLayerRules { inactive_color: None, }, geometry_corner_radius: None, + place_within_backdrop: false, } } @@ -73,6 +77,9 @@ impl ResolvedLayerRules { if let Some(x) = rule.geometry_corner_radius { resolved.geometry_corner_radius = Some(x); } + if let Some(x) = rule.place_within_backdrop { + resolved.place_within_backdrop = x; + } resolved.shadow.merge_with(&rule.shadow); } -- cgit