diff --git a/src/backend/winit.rs b/src/backend/winit.rs index f9f14fa..fb25010 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -236,6 +236,8 @@ pub fn run_winit() -> anyhow::Result<()> { let full_redraw = &mut backend.full_redraw; *full_redraw = full_redraw.saturating_sub(1); + state.focus_state.fix_up_focus(&mut state.space); + let output_render_elements = crate::render::generate_render_elements( &state.space, &state.windows, diff --git a/src/focus.rs b/src/focus.rs index 0464958..25739b8 100644 --- a/src/focus.rs +++ b/src/focus.rs @@ -50,9 +50,7 @@ impl FocusState { /// to back to correct their z locations. pub fn fix_up_focus(&self, space: &mut Space) { for win in self.focus_stack.iter() { - if let Some(loc) = space.element_location(win) { - space.map_element(win.clone(), loc, false); - } + space.raise_element(win, false); } } } diff --git a/src/handlers.rs b/src/handlers.rs index fc2b61a..23133e4 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -130,7 +130,7 @@ impl CompositorHandler for State { // correct focus layering // TODO: maybe do this at the end of every event loop cycle instead? - self.focus_state.fix_up_focus(&mut self.space); + // self.focus_state.fix_up_focus(&mut self.space); } fn client_compositor_state<'a>(&self, client: &'a Client) -> &'a CompositorClientState { diff --git a/src/layout.rs b/src/layout.rs index 40f972a..13f6e97 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -2,7 +2,7 @@ use itertools::{Either, Itertools}; use smithay::{ - desktop::layer_map_for_output, + desktop::{layer_map_for_output, space::SpaceElement}, output::Output, utils::{Logical, Point, Rectangle, Size}, }; @@ -462,13 +462,27 @@ 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); - // self.re_layout(&output); + // Some windows just don't want to commit on a timely basis, like VS Code on Wayland, + // unless their sizes change. In this case, if the two windows have the same size, + // just map them to the other's location instead of going through update_windows(). + if win1.geometry().size == win2.geometry().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); + } } } diff --git a/src/render.rs b/src/render.rs index c2b8a1e..b0fc997 100644 --- a/src/render.rs +++ b/src/render.rs @@ -271,14 +271,8 @@ where overlay, } = layer_render_elements(output, renderer); - let tags = space - .outputs() - .flat_map(|op| { - op.with_state(|state| state.focused_tags().cloned().collect::>()) - }) - .collect::>(); let window_render_elements: Vec> = - Tag::tag_render_elements(&tags, windows, space, renderer); + Tag::tag_render_elements(windows, space, renderer); let mut output_render_elements = Vec::>>::new(); diff --git a/src/tag.rs b/src/tag.rs index 0acd870..39c6ab1 100644 --- a/src/tag.rs +++ b/src/tag.rs @@ -120,7 +120,6 @@ impl Tag { /// Get the render_elements for the provided tags. pub fn tag_render_elements( - tags: &[Tag], windows: &[WindowElement], space: &Space, renderer: &mut R, @@ -132,14 +131,8 @@ impl Tag { { let elements = windows .iter() - .filter(|win| { - win.with_state(|state| { - state - .tags - .iter() - .any(|tag| tags.iter().any(|tag2| tag == tag2)) - }) - }) + .rev() // rev because I treat the focus stack backwards vs how the renderer orders it + .filter(|win| win.is_on_active_tag(space.outputs())) .flat_map(|win| { // subtract win.geometry().loc to align decorations correctly let loc = (space.element_location(win).unwrap_or((0, 0).into())