Skip to content

Commit 8bbc970

Browse files
da-philTurboGit
authored andcommitted
Fix touchpad pan gesture suppressed when editing masks
A two-finger scroll (no CTRL) fell through to zoom whenever a mask overlay was visible, even with the pointer off the mask. gesture_pan now declines the pan only when the scroll would actually be consumed by the mask (pointer over a shape, or creating a size-adjustable shape) via the new dt_masks_scroll_over_mask() predicate. Elsewhere on the canvas, and while drawing a path (which has no scroll-adjustable parameter during creation), the scroll pans the image as expected.
1 parent 89c8a6e commit 8bbc970

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

‎src/develop/masks.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,10 @@ gboolean dt_masks_events_mouse_scrolled(struct dt_iop_module_t *module,
603603
const float y,
604604
const gboolean up,
605605
const uint32_t state);
606+
// Return TRUE if scrolling over the center view should adjust the visible
607+
// mask (size/border/opacity) instead of zoom/pan. Returns FALSE while drawing
608+
// a path, since path creation has no scroll-adjustable parameter.
609+
gboolean dt_masks_scroll_over_mask(void);
606610
void dt_masks_events_post_expose(const struct dt_iop_module_t *module,
607611
cairo_t *cr,
608612
const int32_t width,

‎src/develop/masks/masks.c‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,12 +1225,27 @@ gboolean dt_masks_events_button_pressed(dt_iop_module_t *module,
12251225
if(form->functions)
12261226
return form->functions->button_pressed(module, pzx, pzy, pressure,
12271227
which, type, state, form, 0, gui, 0)
1228-
|| which == 3; // swallow right-clicks even when not handled so
1229-
// right-drag rotate is disabled when forms
1230-
// visible
1228+
|| which == 3; // swallow right-clicks so right-drag rotate is disabled
12311229
return FALSE;
12321230
}
12331231

1232+
gboolean dt_masks_scroll_over_mask(void)
1233+
{
1234+
const dt_masks_form_t *form = darktable.develop->form_visible;
1235+
const dt_masks_form_gui_t *gui = darktable.develop->form_gui;
1236+
if(!form || !gui)
1237+
return FALSE;
1238+
1239+
// During shape creation, scroll adjusts size/border and stays over the mask.
1240+
// Paths/polygons are built node by node and do not use scroll here.
1241+
if(gui->creation)
1242+
return !(form->type & DT_MASKS_PATH);
1243+
1244+
// Otherwise form_visible is the group. group_edited is the active sub-form or
1245+
// -1 when none. Scroll should count only when a sub-form is active.
1246+
return gui->group_edited >= 0;
1247+
}
1248+
12341249
gboolean dt_masks_events_mouse_scrolled(dt_iop_module_t *module,
12351250
const float pzx,
12361251
const float pzy,
@@ -1250,8 +1265,7 @@ gboolean dt_masks_events_mouse_scrolled(dt_iop_module_t *module,
12501265

12511266
if(gui)
12521267
{
1253-
// for brush, the opacity is the density of the masks, do not
1254-
// update opacity here for the brush.
1268+
// Do not update brush opacity here; it is mask density.
12551269
if(gui->creation && dt_modifier_is(state, GDK_CONTROL_MASK))
12561270
{
12571271
float opacity = dt_conf_get_float("plugins/darkroom/masks/opacity");

‎src/views/darkroom.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4217,12 +4217,14 @@ gboolean gesture_pan(dt_view_t *self,
42174217
(void)state;
42184218
if(!dev) return FALSE;
42194219

4220-
// Mask editing (brush etc.) uses scroll for tool parameters.
4220+
// If pointer is over an active mask, let scroll go to the mask handler;
4221+
// otherwise allow two-finger scroll to pan the image.
42214222
if(dev->form_visible
4222-
&& !darktable.develop->darkroom_skip_mouse_events)
4223+
&& !darktable.develop->darkroom_skip_mouse_events
4224+
&& dt_masks_scroll_over_mask())
42234225
{
42244226
dt_print(DT_DEBUG_INPUT,
4225-
"[darkroom pan] ignored: mask form active");
4227+
"[darkroom pan] ignored: pointer over active mask");
42264228
return FALSE;
42274229
}
42284230

0 commit comments

Comments
 (0)