1
0
Fork 0
forked from wry/wry

tree: use trunc instead of round when scrolling containers

This commit is contained in:
Julian Orth 2022-05-07 18:06:55 +02:00
parent b7831e1019
commit ec9710983c
14 changed files with 70 additions and 6 deletions

View file

@ -302,6 +302,13 @@ impl TestBackendMouse {
));
self.common.event(InputEvent::Frame);
}
pub fn scroll_px(&self, dy: i32) {
self.common.event(InputEvent::AxisSource(AxisSource::Wheel));
self.common
.event(InputEvent::Axis(Fixed::from_int(dy), ScrollAxis::Vertical));
self.common.event(InputEvent::Frame);
}
}
pub struct TestBackendKb {

View file

@ -40,6 +40,7 @@ mod t0011_set_keymap;
mod t0012_subsurface_focus;
mod t0013_graphics_initialized;
mod t0014_container_scroll_focus;
mod t0015_scroll_partial;
pub trait TestCase: Sync {
fn name(&self) -> &'static str;
@ -72,5 +73,6 @@ pub fn tests() -> Vec<&'static dyn TestCase> {
t0012_subsurface_focus,
t0013_graphics_initialized,
t0014_container_scroll_focus,
t0015_scroll_partial,
}
}

View file

@ -48,7 +48,6 @@ async fn test(run: Rc<TestRun>) -> TestResult {
let mono_container = w_mono2.tl.container_parent()?;
let container_pos = mono_container.tl_data().pos.get();
log::info!("cp {:?}", container_pos);
let w_mono1_title = mono_container.render_data.borrow_mut().title_rects[0]
.move_(container_pos.x1(), container_pos.y1());
ds.mouse.abs(
@ -63,8 +62,6 @@ async fn test(run: Rc<TestRun>) -> TestResult {
ds.mouse.scroll(-1);
client.sync().await;
client.save_screenshot("s2").await?;
let enter = enters.next().with_context(|| "no enter event 2")?;
tassert_eq!(enter.surface, w_mono1.surface.id);

View file

@ -0,0 +1,48 @@
use {
crate::{
it::{test_error::TestResult, testrun::TestRun},
tree::ToplevelNode,
},
std::rc::Rc,
};
testcase!();
async fn test(run: Rc<TestRun>) -> TestResult {
let ds = run.create_default_setup().await?;
ds.mouse.rel(1.0, 1.0);
let client = run.create_client().await?;
let dss = client.get_default_seat().await?;
let w_mono1 = client.create_window().await?;
w_mono1.map2().await?;
let w_mono2 = client.create_window().await?;
w_mono2.map2().await?;
run.cfg.set_mono(ds.seat.id(), true)?;
client.sync().await;
let container = w_mono2.tl.container_parent()?;
let pos = container.tl_data().pos.get();
let w_mono1_title = container.render_data.borrow_mut().title_rects[0].move_(pos.x1(), pos.y1());
ds.mouse.abs(
&ds.connector,
w_mono1_title.x1() as f64,
w_mono1_title.y1() as f64,
);
client.sync().await;
let enters = dss.kb.enter.expect()?;
ds.mouse.scroll_px(-14);
client.sync().await;
tassert!(enters.next().is_err());
ds.mouse.scroll_px(-1);
client.sync().await;
tassert!(enters.next().is_ok());
Ok(())
}