image: Deny drag gesture for touchscreens

ScrolledWindow can handle the panning in images
better than we can.

This fixes an issue where zoomed in images can't
be zoomed or rotated on touchscreens.

Issue #176

Part-of: <https://gitlab.gnome.org/GNOME/loupe/-/merge_requests/264>
This commit is contained in:
Sophie Herold 2023-07-31 18:29:08 +02:00
parent 936f89eda4
commit c4d8145dd3

View file

@ -421,14 +421,16 @@ mod imp {
drag_gesture.connect_drag_begin(glib::clone!(@weak obj => move |gesture, _, _| {
// Allow only left and middle button
if ![1, 2].contains(&gesture.current_button()) {
if ![1, 2].contains(&gesture.current_button())
// Drag gesture for touchscreens is handled by ScrolledWindow
|| gesture.device().map(|x| x.source()) == Some(gdk::InputSource::Touchscreen)
{
gesture.set_state(gtk::EventSequenceState::Denied);
return;
}
if obj.is_hscrollable() || obj.is_vscrollable() {
obj.cancel_deceleration();
gesture.set_state(gtk::EventSequenceState::Claimed);
obj.set_cursor(gdk::Cursor::from_name("grabbing", None).as_ref());
obj.imp().last_drag_value.set(Some((0., 0.)));
} else {