@@ -3591,6 +3591,33 @@ gboolean dt_action_widget_invisible(GtkWidget *w)
35913591#define ADD_EXPLANATION (cause , effect , extra , ...) if(*fb_log) \
35923592 dt_util_str_cat(&*fb_log, "\n%s \u2192 %s" extra, cause, effect, ##__VA_ARGS__)
35933593
3594+ static gboolean _unmatched_move (dt_shortcut_t * c ,
3595+ dt_shortcut_t * s ,
3596+ const dt_action_element_def_t * * elements ,
3597+ char * * fb_log )
3598+ {
3599+ if (c -> move == s -> move ) return FALSE;
3600+ if (!darktable .control -> enable_fallbacks ||
3601+ !c -> move_device || c -> move > s -> move ) return TRUE; // don't try to match mouse moves
3602+ * elements = _action_find_elements (c -> action );
3603+ if (!* elements ) return TRUE;
3604+ int skipped = s -> move - c -> move ;
3605+ if ((* elements )[c -> element ].effects == (* elements )[c -> element + 1 ].effects )
3606+ s -> element = c -> element + skipped ;
3607+ else
3608+ {
3609+ s -> action = c -> action ;
3610+ dt_action_type_t tp = s -> action -> type ;
3611+ while (skipped && (s -> action = s -> action -> next ))
3612+ if (s -> action -> type == tp ) -- skipped ;
3613+ if (skipped ) return TRUE;
3614+ }
3615+ ADD_EXPLANATION (_ ("move not assigned" ), _ ("fallback to earlier move" ), " %d -> %d" , s -> move , c -> move );
3616+
3617+ s -> move = c -> move ;
3618+ return FALSE;
3619+ }
3620+
35943621static gboolean _shortcut_closest_match (GSequenceIter * * current ,
35953622 dt_shortcut_t * s ,
35963623 gboolean * fully_matched ,
@@ -3608,7 +3635,8 @@ static gboolean _shortcut_closest_match(GSequenceIter **current,
36083635 c -> key != s -> key ||
36093636 c -> press < (s -> press & ~DT_SHORTCUT_LONG ) ||
36103637 ((c -> move_device || c -> move ) &&
3611- (c -> move_device != s -> move_device || c -> move != s -> move )) ||
3638+ (c -> move_device != s -> move_device ||
3639+ _unmatched_move (c , s , elements , fb_log ))) ||
36123640 (s -> action &&
36133641 s -> action -> type == DT_ACTION_TYPE_FALLBACK &&
36143642 s -> action -> target != c -> action -> target ))
@@ -3622,7 +3650,6 @@ static gboolean _shortcut_closest_match(GSequenceIter **current,
36223650 (c -> button != s -> button || c -> click != s -> click )) ||
36233651 (c -> mods && c -> mods != s -> mods ) ||
36243652 (c -> direction & ~s -> direction ) ||
3625- (c -> element && s -> element ) ||
36263653 (c -> effect > 0 && s -> effect > 0 ) ||
36273654 (c -> instance && s -> instance ) ||
36283655 (c -> element && s -> effect > 0 && * elements &&
@@ -3645,10 +3672,10 @@ static gboolean _shortcut_closest_match(GSequenceIter **current,
36453672 }
36463673 if (!s -> action || c -> effect != DT_ACTION_EFFECT_DEFAULT_KEY )
36473674 s -> effect = c -> effect ;
3648- if (c -> element ) s -> element = c -> element ;
3675+ if (! s -> element ) s -> element = c -> element ;
36493676 if (c -> instance ) s -> instance = c -> instance ;
36503677
3651- s -> action = c -> action ;
3678+ if (! s -> action ) s -> action = c -> action ;
36523679 if (!* elements ) * elements = _action_find_elements (s -> action );
36533680
36543681 if (ELEMENT_IS (value , s , * elements ) && c -> effect == DT_ACTION_EFFECT_SET )
@@ -3780,19 +3807,20 @@ static float _process_action(dt_action_t *action,
37803807 {
37813808 // find module instance
37823809 dt_iop_module_so_t * module = (dt_iop_module_so_t * )owner ;
3810+ dt_iop_module_t * mod = NULL ;
37833811
37843812 if (owner == & darktable .control -> actions_focus )
37853813 {
3786- action_target = dt_dev_gui_module ();
3814+ action_target = dt_dev_modulegroups_test_activated (darktable .develop )
3815+ ? (mod = dt_dev_gui_module ()) ? (gpointer )mod -> widget : NULL
3816+ : dt_ui_get_container (darktable .gui -> ui , DT_UI_CONTAINER_PANEL_RIGHT_CENTER );
37873817 if (!action_target )
37883818 return return_value ;
37893819 }
37903820 else if (instance )
37913821 {
37923822 int current_instance = abs (instance );
37933823
3794- dt_iop_module_t * mod = NULL ;
3795-
37963824 for (GList * iop_mods = instance >= 0
37973825 ? darktable .develop -> iop
37983826 : g_list_last (darktable .develop -> iop );
0 commit comments