forge
Explore
Log in

Don't you dare go Hollow

layout/monitor: Extract workspace_render_idx()

Browse files at this commit

d3a79faeecc5f399b616e2b1a21a48f7b26cd720Ivan MolodetskikhParent: 21630dd
src/layout/monitor.rsmodified+11 -17
@@ -232,11 +232,7 @@ impl<W: LayoutElement> Monitor<W> {
232 }232 }
233 233
234 // FIXME: also compute and use current velocity.234 // FIXME: also compute and use current velocity.
235- let current_idx = self235+ let current_idx = self.workspace_render_idx();
236- .workspace_switch
237- .as_ref()
238- .map(|s| s.current_idx())
239- .unwrap_or(self.active_workspace_idx as f64);
240 236
241 self.previous_workspace_id = Some(self.workspaces[self.active_workspace_idx].id());237 self.previous_workspace_id = Some(self.workspaces[self.active_workspace_idx].id());
242 238
@@ -833,6 +829,14 @@ impl<W: LayoutElement> Monitor<W> {
833 Some(rect)829 Some(rect)
834 }830 }
835 831
832+ pub fn workspace_render_idx(&self) -> f64 {
833+ if let Some(switch) = &self.workspace_switch {
834+ switch.current_idx()
835+ } else {
836+ self.active_workspace_idx as f64
837+ }
838+ }
839+
836 pub fn workspaces_render_geo(&self) -> impl Iterator<Item = Rectangle<f64, Logical>> {840 pub fn workspaces_render_geo(&self) -> impl Iterator<Item = Rectangle<f64, Logical>> {
837 let scale = self.output.current_scale().fractional_scale();841 let scale = self.output.current_scale().fractional_scale();
838 let size = output_size(&self.output);842 let size = output_size(&self.output);
@@ -840,13 +844,7 @@ impl<W: LayoutElement> Monitor<W> {
840 // Ceil the workspace size in physical pixels.844 // Ceil the workspace size in physical pixels.
841 let ws_size = size.to_physical_precise_ceil(scale).to_logical(scale);845 let ws_size = size.to_physical_precise_ceil(scale).to_logical(scale);
842 846
843- let render_idx = if let Some(switch) = &self.workspace_switch {847+ let first_ws_y = -self.workspace_render_idx() * ws_size.h;
844- switch.current_idx()
845- } else {
846- self.active_workspace_idx as f64
847- };
848-
849- let first_ws_y = -render_idx * ws_size.h;
850 848
851 (0..self.workspaces.len()).map(move |idx| {849 (0..self.workspaces.len()).map(move |idx| {
852 let y = first_ws_y + idx as f64 * ws_size.h;850 let y = first_ws_y + idx as f64 * ws_size.h;
@@ -973,11 +971,7 @@ impl<W: LayoutElement> Monitor<W> {
973 971
974 pub fn workspace_switch_gesture_begin(&mut self, is_touchpad: bool) {972 pub fn workspace_switch_gesture_begin(&mut self, is_touchpad: bool) {
975 let center_idx = self.active_workspace_idx;973 let center_idx = self.active_workspace_idx;
976- let current_idx = self974+ let current_idx = self.workspace_render_idx();
977- .workspace_switch
978- .as_ref()
979- .map(|s| s.current_idx())
980- .unwrap_or(center_idx as f64);
981 975
982 let gesture = WorkspaceSwitchGesture {976 let gesture = WorkspaceSwitchGesture {
983 center_idx,977 center_idx,