Fix reversed order of window rendering

This commit is contained in:
Ottatop 2023-09-02 20:26:11 -05:00
parent 03b1a4e3c1
commit 861bd68839
6 changed files with 30 additions and 29 deletions

View file

@ -246,6 +246,8 @@ pub fn run_winit() -> anyhow::Result<()> {
let full_redraw = &mut backend.full_redraw; let full_redraw = &mut backend.full_redraw;
*full_redraw = full_redraw.saturating_sub(1); *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( let output_render_elements = crate::render::generate_render_elements(
&state.space, &state.space,
&state.windows, &state.windows,

View file

@ -50,9 +50,7 @@ impl FocusState {
/// to back to correct their z locations. /// to back to correct their z locations.
pub fn fix_up_focus(&self, space: &mut Space<WindowElement>) { pub fn fix_up_focus(&self, space: &mut Space<WindowElement>) {
for win in self.focus_stack.iter() { for win in self.focus_stack.iter() {
if let Some(loc) = space.element_location(win) { space.raise_element(win, false);
space.map_element(win.clone(), loc, false);
}
} }
} }
} }

View file

@ -130,7 +130,7 @@ impl CompositorHandler for State {
// correct focus layering // correct focus layering
// TODO: maybe do this at the end of every event loop cycle instead? // 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 { fn client_compositor_state<'a>(&self, client: &'a Client) -> &'a CompositorClientState {

View file

@ -4,7 +4,7 @@ use std::time::Duration;
use itertools::{Either, Itertools}; use itertools::{Either, Itertools};
use smithay::{ use smithay::{
desktop::{layer_map_for_output, utils::surface_primary_scanout_output}, desktop::{layer_map_for_output, space::SpaceElement},
output::Output, output::Output,
reexports::wayland_server::Resource, reexports::wayland_server::Resource,
utils::{IsAlive, Logical, Point, Rectangle, Size}, utils::{IsAlive, Logical, Point, Rectangle, Size},
@ -572,13 +572,27 @@ impl State {
} }
} }
// TODO: don't use the focused output, use the outputs the two windows are on // Some windows just don't want to commit on a timely basis, like VS Code on Wayland,
let output = self // unless their sizes change. In this case, if the two windows have the same size,
.focus_state // just map them to the other's location instead of going through update_windows().
.focused_output if win1.geometry().size == win2.geometry().size {
.clone() let win1_loc = self.space.element_location(win1);
.expect("no focused output"); let win2_loc = self.space.element_location(win2);
self.update_windows(&output);
// self.re_layout(&output); 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);
}
} }
} }

View file

@ -271,14 +271,8 @@ where
overlay, overlay,
} = layer_render_elements(output, renderer); } = layer_render_elements(output, renderer);
let tags = space
.outputs()
.flat_map(|op| {
op.with_state(|state| state.focused_tags().cloned().collect::<Vec<_>>())
})
.collect::<Vec<_>>();
let window_render_elements: Vec<WaylandSurfaceRenderElement<R>> = let window_render_elements: Vec<WaylandSurfaceRenderElement<R>> =
Tag::tag_render_elements(&tags, windows, space, renderer); Tag::tag_render_elements(windows, space, renderer);
let mut output_render_elements = let mut output_render_elements =
Vec::<OutputRenderElements<R, WaylandSurfaceRenderElement<R>>>::new(); Vec::<OutputRenderElements<R, WaylandSurfaceRenderElement<R>>>::new();

View file

@ -120,7 +120,6 @@ impl Tag {
/// Get the render_elements for the provided tags. /// Get the render_elements for the provided tags.
pub fn tag_render_elements<R, C>( pub fn tag_render_elements<R, C>(
tags: &[Tag],
windows: &[WindowElement], windows: &[WindowElement],
space: &Space<WindowElement>, space: &Space<WindowElement>,
renderer: &mut R, renderer: &mut R,
@ -132,14 +131,8 @@ impl Tag {
{ {
let elements = windows let elements = windows
.iter() .iter()
.filter(|win| { .rev() // rev because I treat the focus stack backwards vs how the renderer orders it
win.with_state(|state| { .filter(|win| win.is_on_active_tag(space.outputs()))
state
.tags
.iter()
.any(|tag| tags.iter().any(|tag2| tag == tag2))
})
})
.flat_map(|win| { .flat_map(|win| {
// subtract win.geometry().loc to align decorations correctly // subtract win.geometry().loc to align decorations correctly
let loc = (space.element_location(win).unwrap_or((0, 0).into()) let loc = (space.element_location(win).unwrap_or((0, 0).into())