Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scrollable): filter scroll events in the wrong direction & damage in tiny_skia #133

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions tiny_skia/src/window/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,31 +183,30 @@ pub fn present<T: AsRef<str>>(
})
.unwrap_or_else(|| vec![Rectangle::with_size(viewport.logical_size())]);

if damage.is_empty() {
return Ok(());
}

surface.primitive_stack.push_front(primitives.to_vec());
surface.background_color = background_color;

let damage = damage::group(damage, scale_factor, physical_size);
if !damage.is_empty() {
surface.background_color = background_color;

let mut pixels = tiny_skia::PixmapMut::from_bytes(
bytemuck::cast_slice_mut(&mut buffer),
physical_size.width,
physical_size.height,
)
.expect("Create pixel map");
let damage = damage::group(damage, scale_factor, physical_size);

backend.draw(
&mut pixels,
&mut surface.clip_mask,
primitives,
viewport,
&damage,
background_color,
overlay,
);
let mut pixels = tiny_skia::PixmapMut::from_bytes(
bytemuck::cast_slice_mut(&mut buffer),
physical_size.width,
physical_size.height,
)
.expect("Create pixel map");

backend.draw(
&mut pixels,
&mut surface.clip_mask,
primitives,
viewport,
&damage,
background_color,
overlay,
);
}

buffer.present().map_err(|_| compositor::SurfaceError::Lost)
}
Expand Down
7 changes: 7 additions & 0 deletions widget/src/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,13 @@ pub fn update<Message>(
}
mouse::ScrollDelta::Pixels { x, y } => Vector::new(x, y),
};
if matches!(direction, Direction::Vertical(_))
&& delta.y.abs() < 0.1
|| matches!(direction, Direction::Horizontal(_))
&& delta.x.abs() < 0.1
{
return event::Status::Ignored;
}

state.scroll(delta, direction, bounds, content_bounds);

Expand Down
Loading