Add proper fix for windows not reappearing when unmapped and not sizing correctly when too small

This commit is contained in:
Ottatop 2023-07-13 18:44:07 -05:00 committed by Ottatop
parent e7f0210f40
commit cc8ec304d4
3 changed files with 10 additions and 25 deletions

View file

@ -398,9 +398,7 @@ impl<B: Backend> XdgShellHandler for State<B> {
}
fn ack_configure(&mut self, surface: WlSurface, configure: Configure) {
// tracing::debug!("start of ack_configure");
if let Some(window) = self.window_for_surface(&surface) {
// tracing::debug!("found window for surface");
window.with_state(|state| {
if let WindowResizeState::WaitingForAck(serial, new_loc) = state.resize_state {
match &configure {
@ -414,24 +412,6 @@ impl<B: Backend> XdgShellHandler for State<B> {
}
}
});
// HACK: If a window is currently going through something that generates a bunch of
// | commits, like an animation, unmapping it while it's doing that has a chance
// | to cause any send_configures to not trigger a commit. I'm not sure if this is because of
// | the way I've implemented things or if it's something else. Because of me
// | mapping the element in commit, this means that the window won't reappear on a tag
// | change. The code below is a workaround until I can figure it out.
if !self.space.elements().any(|win| win == &window) {
window.with_state(|state| {
if let WindowResizeState::WaitingForCommit(new_loc) = state.resize_state {
tracing::debug!("remapping window");
let win = window.clone();
self.loop_handle.insert_idle(move |data| {
data.state.space.map_element(win, new_loc, false);
});
}
});
}
}
}

View file

@ -174,7 +174,7 @@ impl Layout {
win1.toplevel().with_pending_state(|state| {
let new_size = (
output_geo.size.w / div_factor_w,
i32::max(output_geo.size.w / div_factor_w, 1),
i32::max(output_geo.size.h / div_factor_h, 40),
)
.into();
@ -182,7 +182,7 @@ impl Layout {
});
win2.toplevel().with_pending_state(|state| {
let new_size = (
output_geo.size.w / div_factor_w,
i32::max(output_geo.size.w / div_factor_w, 1),
i32::max(output_geo.size.h / div_factor_h, 40),
)
.into();
@ -276,7 +276,7 @@ impl Layout {
win1.toplevel().with_pending_state(|state| {
let new_size = (
output_geo.size.w / div_factor_w,
i32::max(output_geo.size.w / div_factor_w, 1),
i32::max(output_geo.size.h / div_factor_h, 40),
)
.into();
@ -284,7 +284,7 @@ impl Layout {
});
win2.toplevel().with_pending_state(|state| {
let new_size = (
output_geo.size.w / div_factor_w,
i32::max(output_geo.size.w / div_factor_w, 1),
i32::max(output_geo.size.h / div_factor_h, 40),
)
.into();

View file

@ -11,7 +11,7 @@ use std::{
os::{fd::AsRawFd, unix::net::UnixStream},
path::Path,
process::Stdio,
sync::{Arc, Mutex},
sync::{Arc, Mutex}, time::Duration,
};
use crate::{
@ -676,6 +676,11 @@ impl<B: Backend> State<B> {
})
})
});
for window in render.iter() {
// INFO: Here we send a frame with a duration of 0. This is because some windows won't
// | send a commit when they're not visible. More info in smithay::desktop::utils::send_frames_surface_tree
window.send_frame(output, self.clock.now(), Some(Duration::ZERO), surface_primary_scanout_output);
}
self.schedule_on_commit(render, |data| {
for win in do_not_render {
data.state.space.unmap_elem(&win);