Fix find_window_and_output() returning None with no outputs

As far as I can tell, this would mess up a ton of the logic. Not sure
how anything worked with no outputs before?
This commit is contained in:
Ivan Molodetskikh
2025-02-05 09:32:47 +03:00
parent f18b1a7043
commit 734e3a6d3c
5 changed files with 60 additions and 36 deletions
+29 -20
View File
@@ -1142,26 +1142,6 @@ impl<W: LayoutElement> Layout<W> {
}
}
pub fn find_window_and_output(&self, wl_surface: &WlSurface) -> Option<(&W, &Output)> {
if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move {
if move_.tile.window().is_wl_surface(wl_surface) {
return Some((move_.tile.window(), &move_.output));
}
}
if let MonitorSet::Normal { monitors, .. } = &self.monitor_set {
for mon in monitors {
for ws in &mon.workspaces {
if let Some(window) = ws.find_wl_surface(wl_surface) {
return Some((window, &mon.output));
}
}
}
}
None
}
pub fn find_workspace_by_id(&self, id: WorkspaceId) -> Option<(usize, &Workspace<W>)> {
match &self.monitor_set {
MonitorSet::Normal { ref monitors, .. } => {
@@ -1278,6 +1258,35 @@ impl<W: LayoutElement> Layout<W> {
}
}
pub fn find_window_and_output(&self, wl_surface: &WlSurface) -> Option<(&W, Option<&Output>)> {
if let Some(InteractiveMoveState::Moving(move_)) = &self.interactive_move {
if move_.tile.window().is_wl_surface(wl_surface) {
return Some((move_.tile.window(), Some(&move_.output)));
}
}
match &self.monitor_set {
MonitorSet::Normal { monitors, .. } => {
for mon in monitors {
for ws in &mon.workspaces {
if let Some(window) = ws.find_wl_surface(wl_surface) {
return Some((window, Some(&mon.output)));
}
}
}
}
MonitorSet::NoOutputs { workspaces } => {
for ws in workspaces {
if let Some(window) = ws.find_wl_surface(wl_surface) {
return Some((window, None));
}
}
}
}
None
}
pub fn find_window_and_output_mut(
&mut self,
wl_surface: &WlSurface,