diff --git a/src/matrix.cpp b/src/matrix.cpp index e5e35ae..2d66643 100644 --- a/src/matrix.cpp +++ b/src/matrix.cpp @@ -548,6 +548,9 @@ bool Matrix::on_button_press_event(GdkEventButton *event) ClientList::iterator clit; for (clit = pm.m_clients.begin(); clit != pm.m_clients.end(); ++clit) { Client *c = *clit; + + if (m_port_type != PT_ALL && m_port_type != (c->m_is_midi ? PT_MIDI : PT_AUDIO)) continue; + if (c->rect.Hit(event->x, event->y)) { c->m_expanded = !c->m_expanded; Refresh(); @@ -567,33 +570,34 @@ bool Matrix::on_button_press_event(GdkEventButton *event) } } - Port *p1 = NULL; - Port *p2 = NULL; - // Check port hit - PortList::iterator plit; - for (plit = pm.m_ports.begin(); plit != pm.m_ports.end(); ++plit) { - Port *p = *plit; - - if (p->rect.HitX(event->x)) p1 = p; - if (p->rect.HitY(event->y)) p2 = p; - - if (p1 != NULL && p2 != NULL) { - pm.ToggleConnect(p1, p2); - return true; - } - } - PortGroup *pg1 = NULL; PortGroup *pg2 = NULL; + Port *p1 = NULL; + Port *p2 = NULL; for (clit = pm.m_clients.begin(); clit != pm.m_clients.end(); ++clit) { Client *c = *clit; + if (m_port_type != PT_ALL && m_port_type != (c->m_is_midi ? PT_MIDI : PT_AUDIO)) continue; + PortGroupList::iterator pglit; for (pglit = c->m_groups.begin(); pglit != c->m_groups.end(); ++pglit) { PortGroup *pg = *pglit; + PortList::iterator plit; + for (plit = pg->m_ports.begin(); plit != pg->m_ports.end(); ++plit) { + Port *p = *plit; + + if (p->rect.HitX(event->x)) p1 = p; + if (p->rect.HitY(event->y)) p2 = p; + + if (p1 != NULL && p2 != NULL) { + pm.ToggleConnect(p1, p2); + return true; + } + } + if (pg->rect.HitX(event->x)) pg1 = pg; if (pg->rect.HitY(event->y)) pg2 = pg; @@ -612,6 +616,5 @@ bool Matrix::on_button_press_event(GdkEventButton *event) } } - std::cout << event->x << ", " << event->y << std::endl; - return true; + return false; }