Browse Source

Fix crash on close; Set getDefaultDeviceId; Cleanup

Signed-off-by: falkTX <falktx@falktx.com>
tags/22.02
falkTX 3 years ago
parent
commit
94f6412b4c
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 23 additions and 17 deletions
  1. +17
    -16
      src/CardinalUI.cpp
  2. +6
    -1
      src/PluginContext.hpp

+ 17
- 16
src/CardinalUI.cpp View File

@@ -69,9 +69,19 @@ class CardinalUI : public UI,
WindowParametersRestore(context->window); WindowParametersRestore(context->window);
} }


ScopedContext(CardinalUI* const ui, const int mods)
: context(ui->fContext),
cml(context->plugin->contextMutex)
{
rack::contextSet(context);
rack::window::WindowMods(context->window, mods);
WindowParametersRestore(context->window);
}

~ScopedContext() ~ScopedContext()
{ {
WindowParametersSave(context->window);
if (context->window != nullptr)
WindowParametersSave(context->window);
rack::contextSet(nullptr); rack::contextSet(nullptr);
} }
}; };
@@ -321,9 +331,7 @@ protected:
#endif #endif
*/ */


rack::window::WindowMods(fContext->window, mods);

const ScopedContext sc(this);
const ScopedContext sc(this, mods);
return fContext->event->handleButton(fLastMousePos, button, action, mods); return fContext->event->handleButton(fLastMousePos, button, action, mods);
} }


@@ -333,9 +341,8 @@ protected:
const rack::math::Vec mouseDelta = mousePos.minus(fLastMousePos); const rack::math::Vec mouseDelta = mousePos.minus(fLastMousePos);


fLastMousePos = mousePos; fLastMousePos = mousePos;
rack::window::WindowMods(fContext->window, glfwMods(ev.mod));


const ScopedContext sc(this);
const ScopedContext sc(this, glfwMods(ev.mod));
return fContext->event->handleHover(mousePos, mouseDelta); return fContext->event->handleHover(mousePos, mouseDelta);
} }


@@ -348,9 +355,7 @@ protected:
scrollDelta = scrollDelta.mult(50.0); scrollDelta = scrollDelta.mult(50.0);
#endif #endif


rack::window::WindowMods(fContext->window, glfwMods(ev.mod));

const ScopedContext sc(this);
const ScopedContext sc(this, glfwMods(ev.mod));
return fContext->event->handleScroll(fLastMousePos, scrollDelta); return fContext->event->handleScroll(fLastMousePos, scrollDelta);
} }


@@ -359,9 +364,7 @@ protected:
if (ev.character <= ' ' || ev.character >= kKeyDelete) if (ev.character <= ' ' || ev.character >= kKeyDelete)
return false; return false;


rack::window::WindowMods(fContext->window, glfwMods(ev.mod));

const ScopedContext sc(this);
const ScopedContext sc(this, glfwMods(ev.mod));
return fContext->event->handleText(fLastMousePos, ev.character); return fContext->event->handleText(fLastMousePos, ev.character);
} }


@@ -438,7 +441,7 @@ protected:


rack::window::WindowMods(fContext->window, mods); rack::window::WindowMods(fContext->window, mods);


const ScopedContext sc(this);
const ScopedContext sc(this, mods);
return fContext->event->handleKey(fLastMousePos, key, ev.keycode, action, mods); return fContext->event->handleKey(fLastMousePos, key, ev.keycode, action, mods);
} }


@@ -447,9 +450,7 @@ protected:
if (focus) if (focus)
return; return;


rack::window::WindowMods(fContext->window, 0);

const ScopedContext sc(this);
const ScopedContext sc(this, 0);
fContext->event->handleLeave(); fContext->event->handleLeave();
} }




+ 6
- 1
src/PluginContext.hpp View File

@@ -114,7 +114,12 @@ struct CardinalAudioDriver : rack::audio::Driver {


std::vector<int> getDeviceIds() override std::vector<int> getDeviceIds() override
{ {
return std::vector<int>({ 1 });
return std::vector<int>({ 0 });
}

int getDefaultDeviceId() override
{
return 0;
} }


std::string getDeviceName(int) override std::string getDeviceName(int) override


Loading…
Cancel
Save