From ef60dd81d7f72a7b452857be02bbed2a1ab6a60f Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 24 Apr 2025 18:47:40 +0300 Subject: layout/monitor: Cache scale, view_size, working_area --- src/layout/mod.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/layout/mod.rs') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index d4de5693..ceed2f60 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -1432,19 +1432,12 @@ impl Layout { pub fn update_output_size(&mut self, output: &Output) { let _span = tracy_client::span!("Layout::update_output_size"); - let MonitorSet::Normal { monitors, .. } = &mut self.monitor_set else { - panic!() + let Some(mon) = self.monitor_for_output_mut(output) else { + error!("monitor missing in update_output_size()"); + return; }; - for mon in monitors { - if &mon.output == output { - for ws in &mut mon.workspaces { - ws.update_output_size(); - } - - break; - } - } + mon.update_output_size(); } pub fn scroll_amount_to_activate(&self, window: &W::Id) -> f64 { @@ -2550,6 +2543,17 @@ impl Layout { for workspace in &monitor.workspaces { assert_eq!(self.clock, workspace.clock); + assert_eq!( + monitor.scale().integer_scale(), + workspace.scale().integer_scale() + ); + assert_eq!( + monitor.scale().fractional_scale(), + workspace.scale().fractional_scale() + ); + assert_eq!(monitor.view_size(), workspace.view_size()); + assert_eq!(monitor.working_area(), workspace.working_area()); + assert_eq!( workspace.base_options, self.options, "workspace options must be synchronized with layout" @@ -2602,7 +2606,7 @@ impl Layout { saw_view_offset_gesture = has_view_offset_gesture; } - let scale = monitor.output.current_scale().fractional_scale(); + let scale = monitor.scale().fractional_scale(); let iter = monitor.workspaces_with_render_geo(); for (_ws, ws_geo) in iter { let pos = ws_geo.loc; -- cgit