From f545e0b0a61f4031f2715b77c3765e1ace33516a Mon Sep 17 00:00:00 2001
From: Albert Graef <aggraef@gmail.com>
Date: Wed, 8 Mar 2017 04:34:41 +0100
Subject: [PATCH] Make intelligent patching mode 4 controllable with the ctrl
 modifier.

Intelligent patching mode 4 often just always prefers option A (outgoing
connections). But if the user actually wants option B (incoming connections),
he can't get it because option A was chosen. This is confusing, which is why
mode 4, while very useful if it works as intended, can be rather difficult to
use right now.

We therefore now take into account the status of the ctrl modifier, which
simply reverses our choice of option A or B, so that the user now has a way of
getting option B even if option A is preferred (and vice versa). If the ctrl
modifier isn't pressed, mode 4 works exactly as before, so this change is
fully backwards-compatible.
---
 pd/src/g_editor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index 494b44004..0dc859651 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -4457,7 +4457,10 @@ int canvas_trymulticonnect(t_canvas *x, int xpos, int ypos, int which, int doit)
                 
                 // now decide which one is better
                 // (we give preference to option A if both are equal)
-                if (successA >= successB)
+                // AG: Also take into account the ctrl mod status, so
+                // that the user can reverse our default choice (otherwise
+                // we usually just end up preferring outgoing connections)
+                if (glob_ctrl ? successA < successB : successA >= successB)
                 {
                     // OPTION A (see description above)
                     for (sel = x->gl_editor->e_selection; sel; sel = sel->sel_next)
-- 
GitLab