From a10705fb200b452802a1ba7cd47679536e0ef849 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 23 Jan 2025 10:40:52 +0300 Subject: Add toggle-window-rule-opacity action --- src/layout/floating.rs | 8 ++++++++ src/layout/mod.rs | 5 +++++ src/layout/scrolling.rs | 9 +++++++++ src/layout/tile.rs | 2 +- src/layout/workspace.rs | 8 ++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src/layout') diff --git a/src/layout/floating.rs b/src/layout/floating.rs index cb757d67..c6a17e30 100644 --- a/src/layout/floating.rs +++ b/src/layout/floating.rs @@ -365,6 +365,14 @@ impl FloatingSpace { .map(Tile::window) } + pub fn active_window_mut(&mut self) -> Option<&mut W> { + let id = self.active_window_id.as_ref()?; + self.tiles + .iter_mut() + .find(|tile| tile.window().id() == id) + .map(Tile::window_mut) + } + pub fn has_window(&self, id: &W::Id) -> bool { self.tiles.iter().any(|tile| tile.window().id() == id) } diff --git a/src/layout/mod.rs b/src/layout/mod.rs index eb702c37..63bedc7f 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -190,6 +190,7 @@ pub trait LayoutElement { fn set_active_in_column(&mut self, active: bool); fn set_floating(&mut self, floating: bool); fn set_bounds(&self, bounds: Size); + fn is_ignoring_opacity_window_rule(&self) -> bool; fn configure_intent(&self) -> ConfigureIntent; fn send_pending_configure(&mut self); @@ -4347,6 +4348,10 @@ mod tests { fn set_bounds(&self, _bounds: Size) {} + fn is_ignoring_opacity_window_rule(&self) -> bool { + false + } + fn configure_intent(&self) -> ConfigureIntent { ConfigureIntent::CanSend } diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs index 6b8bf760..ffb51ace 100644 --- a/src/layout/scrolling.rs +++ b/src/layout/scrolling.rs @@ -383,6 +383,15 @@ impl ScrollingSpace { Some(col.tiles[col.active_tile_idx].window()) } + pub fn active_window_mut(&mut self) -> Option<&mut W> { + if self.columns.is_empty() { + return None; + } + + let col = &mut self.columns[self.active_column_idx]; + Some(col.tiles[col.active_tile_idx].window_mut()) + } + pub fn active_tile_mut(&mut self) -> Option<&mut Tile> { if self.columns.is_empty() { return None; diff --git a/src/layout/tile.rs b/src/layout/tile.rs index 4a5b61a9..b8d049b0 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -720,7 +720,7 @@ impl Tile { ) -> impl Iterator> + 'a { let _span = tracy_client::span!("Tile::render_inner"); - let alpha = if self.is_fullscreen { + let alpha = if self.is_fullscreen || self.window.is_ignoring_opacity_window_rule() { 1. } else { self.window.rules().opacity.unwrap_or(1.).clamp(0., 1.) diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index f4c87342..4426c264 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -406,6 +406,14 @@ impl Workspace { } } + pub fn active_window_mut(&mut self) -> Option<&mut W> { + if self.floating_is_active.get() { + self.floating.active_window_mut() + } else { + self.scrolling.active_window_mut() + } + } + pub fn is_active_fullscreen(&self) -> bool { self.scrolling.is_active_fullscreen() } -- cgit