summaryrefslogtreecommitdiffstats
path: root/src/handle_event.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-28 21:41:26 +0100
committerDavid Robillard <d@drobilla.net>2020-11-28 22:49:10 +0100
commit5128bfab7ddb9504abf17375e910e5bc94af291e (patch)
tree79cc0953718e1f79ed47282b9f11f9f087edc3bc /src/handle_event.cpp
parent0f25dd575f9c74cc34a54e64468f07e6c631750d (diff)
downloadpatchage-5128bfab7ddb9504abf17375e910e5bc94af291e.tar.gz
patchage-5128bfab7ddb9504abf17375e910e5bc94af291e.tar.bz2
patchage-5128bfab7ddb9504abf17375e910e5bc94af291e.zip
Refresh by emitting events
This decouples drivers from the rest of the application, in particular the horrible situation where they were working with the canvas directly, by having them always communicate changes by emitting events.
Diffstat (limited to 'src/handle_event.cpp')
-rw-r--r--src/handle_event.cpp36
1 files changed, 8 insertions, 28 deletions
diff --git a/src/handle_event.cpp b/src/handle_event.cpp
index 2bd3609..200f819 100644
--- a/src/handle_event.cpp
+++ b/src/handle_event.cpp
@@ -15,26 +15,19 @@
*/
#include "handle_event.hpp"
+#include "event_to_string.hpp"
#include "PatchageEvent.hpp"
#include "patchage_config.h"
-#include "Driver.hpp"
+#include "event_to_string.hpp"
+
#include "Patchage.hpp"
#include "PatchageCanvas.hpp"
#include "PatchageModule.hpp"
#include "PatchagePort.hpp"
-#if defined(HAVE_JACK_DBUS)
-# include "JackDbusDriver.hpp"
-#elif defined(PATCHAGE_LIBJACK)
-# include "JackDriver.hpp"
-#endif
-#ifdef HAVE_ALSA
-# include "AlsaDriver.hpp"
-#endif
-
PATCHAGE_DISABLE_FMT_WARNINGS
#include <fmt/core.h>
#include <fmt/ostream.h>
@@ -65,27 +58,14 @@ public:
void operator()(const PortCreationEvent& event)
{
- Driver* driver = nullptr;
- if (event.id.type() == PortID::Type::jack) {
-#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
- driver = _patchage.jack_driver();
-#endif
-#ifdef HAVE_ALSA
- } else if (event.id.type() == PortID::Type::alsa) {
- driver = _patchage.alsa_driver();
-#endif
- }
_patchage.metadata().set_port(event.id, event.info);
- if (driver) {
- PatchagePort* port = driver->create_port_view(&_patchage, event.id);
- if (!port) {
- _patchage.log().error(fmt::format(
- "Unable to create view for port \"{}\"", event.id));
- }
- } else {
+ auto* const port =
+ _patchage.canvas()->create_port(_patchage, event.id, event.info);
+
+ if (!port) {
_patchage.log().error(
- fmt::format("Unknown type for port \"{}\"", event.id));
+ fmt::format("Unable to create view for port \"{}\"", event.id));
}
}