Don't pass invalid positioner size on popup reconfigure

Mentioned in #144
This commit is contained in:
Shawn Wallace 2025-05-28 22:24:54 -04:00
parent 76ace3c656
commit ae1759077e
3 changed files with 48 additions and 7 deletions

View file

@ -851,8 +851,8 @@ impl<C: XConnection> ServerState<C> {
((event.y() as i32 - win.output_offset.y) as f64 / data.scale_factor) as i32,
);
popup.positioner.set_size(
(event.width() as f64 / data.scale_factor) as i32,
(event.height() as f64 / data.scale_factor) as i32,
1.max((event.width() as f64 / data.scale_factor) as i32),
1.max((event.height() as f64 / data.scale_factor) as i32),
);
popup.popup.reposition(&popup.positioner, 0);
}

View file

@ -2073,6 +2073,31 @@ fn fractional_scale_small_popup() {
.expect("Missing popup data");
let pos = &data.popup().positioner_state;
assert_eq!(pos.size.unwrap(), testwl::Vec2 { x: 1, y: 1 });
f.satellite.reconfigure_window(x::ConfigureNotifyEvent::new(
popup,
popup,
x::WINDOW_NONE,
0,
0,
2,
1,
0,
true,
));
f.run();
f.run();
let dims = f.connection().window(popup).dims;
assert!(dims.width > 0);
assert!(dims.height > 0);
let data = f
.testwl
.get_surface_data(popup_id)
.expect("Missing popup data");
let pos = &data.popup().positioner_state;
assert_eq!(pos.size.unwrap(), testwl::Vec2 { x: 1, y: 1 });
}
#[test]