From d1a9d9dddc04e44da27dfe95f800443af518e1a2 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Wed, 29 Jan 2025 01:16:58 +0100 Subject: [PATCH] edit/crop: Work around gesture bug After clicking the "apply crop" button, the drag button to change the selection is getting stuck. Adding manual claim for the click gesture for the button early fixes this. --- src/widgets/edit/crop_selection.rs | 17 +++++++++++++++++ src/widgets/edit/crop_selection.ui | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/widgets/edit/crop_selection.rs b/src/widgets/edit/crop_selection.rs index c917c04..e68169e 100644 --- a/src/widgets/edit/crop_selection.rs +++ b/src/widgets/edit/crop_selection.rs @@ -189,6 +189,8 @@ mod imp { #[template_child] apply_button: TemplateChild, + #[template_child] + apply_button_click: TemplateChild, #[template_child] selection_move: TemplateChild, @@ -281,6 +283,21 @@ mod imp { self.selection.set_cursor_from_name(Some("move")); self.apply_button.set_cursor_from_name(Some("default")); + // Gesture bug workaround + self.apply_button_click.connect_begin(move |gesture, _| { + gesture.set_state(gtk::EventSequenceState::Claimed); + }); + + self.apply_button_click.connect_released(glib::clone!( + #[weak] + obj, + move |_, _, x, y| { + if obj.imp().apply_button.contains(x, y) { + let _ = obj.activate_action("edit-crop.apply-crop", None); + } + } + )); + // Drag begin self.selection_move.connect_drag_begin(glib::clone!( #[weak] diff --git a/src/widgets/edit/crop_selection.ui b/src/widgets/edit/crop_selection.ui index e645cf5..4cf8f25 100644 --- a/src/widgets/edit/crop_selection.ui +++ b/src/widgets/edit/crop_selection.ui @@ -49,6 +49,9 @@ + + +