From 430fb76fc8bf6a5c0f2edc0f3d8b856eaa0acb6f Mon Sep 17 00:00:00 2001 From: Ottatop Date: Mon, 4 Sep 2023 01:54:10 -0500 Subject: [PATCH] Re-add stuff I removed --- src/layout.rs | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/layout.rs b/src/layout.rs index 6252d0d..988c1fd 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -572,12 +572,36 @@ impl State { } } - // TODO: don't use the focused output, use the outputs the two windows are on - let output = self - .focus_state - .focused_output - .clone() - .expect("no focused output"); - self.update_windows(&output); + let mut same_suggested_size = false; + + if let WindowElement::Wayland(w1) = win1 { + if let WindowElement::Wayland(w2) = win2 { + if let Some(w1_size) = w1.toplevel().current_state().size { + if let Some(w2_size) = w2.toplevel().current_state().size { + same_suggested_size = w1_size == w2_size; + } + } + } + } + + if same_suggested_size { + let win1_loc = self.space.element_location(win1); + let win2_loc = self.space.element_location(win2); + + if let Some(win1_loc) = win1_loc { + if let Some(win2_loc) = win2_loc { + self.space.map_element(win1.clone(), win2_loc, false); + self.space.map_element(win2.clone(), win1_loc, false); + } + } + } else { + // TODO: don't use the focused output, use the outputs the two windows are on + let output = self + .focus_state + .focused_output + .clone() + .expect("no focused output"); + self.update_windows(&output); + } } }