From 6ede20c3e82164416fac52f865a0287e36f6b4c8 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 16 Aug 2016 17:55:40 -0400 Subject: [PATCH] Prevent solo-squelch focus from interrupting user actions; acts as temporary hold as well --- src/AppFrame.cpp | 10 ++++++++++ src/AppFrame.h | 2 ++ src/demod/DemodulatorThread.cpp | 4 ++-- src/visual/InteractiveCanvas.cpp | 8 ++++++++ src/visual/InteractiveCanvas.h | 4 +++- src/visual/WaterfallCanvas.cpp | 1 + 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index bf1ccca..58e032a 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -1928,6 +1928,16 @@ void AppFrame::refreshGainUI() { gainCanvas->Refresh(); } +bool AppFrame::isUserDemodBusy() { + return (modemProps && modemProps->isMouseInView()) + || (waterfallCanvas->isMouseInView() && waterfallCanvas->isMouseDown()) + || (demodWaterfallCanvas->isMouseInView() && demodWaterfallCanvas->isMouseDown()) + || (wxGetApp().getDemodMgr().getLastActiveDemodulator() && + wxGetApp().getDemodMgr().getActiveDemodulator() && + wxGetApp().getDemodMgr().getLastActiveDemodulator() != wxGetApp().getDemodMgr().getActiveDemodulator()); +} + + #ifdef _WIN32 bool AppFrame::canFocus() { return (!wxGetApp().isDeviceSelectorOpen() && (!modemProps || !modemProps->isMouseInView())); diff --git a/src/AppFrame.h b/src/AppFrame.h index fcd73f9..4c2acee 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -101,6 +101,8 @@ public: void setViewState(long long center_freq, int bandwidth); void setViewState(long long center_freq); + bool isUserDemodBusy(); + #ifdef _WIN32 bool canFocus(); #endif diff --git a/src/demod/DemodulatorThread.cpp b/src/demod/DemodulatorThread.cpp index e514e88..259c128 100644 --- a/src/demod/DemodulatorThread.cpp +++ b/src/demod/DemodulatorThread.cpp @@ -192,7 +192,7 @@ void DemodulatorThread::run() { if (squelchEnabled) { if (!squelched && !squelchBreak) { - if (wxGetApp().getSoloMode()) { + if (wxGetApp().getSoloMode() && !wxGetApp().getAppFrame()->isUserDemodBusy()) { std::lock_guard < std::mutex > lock(squelchLockMutex); if (squelchLock.load() == nullptr) { squelchLock.store(demodInstance); @@ -406,7 +406,7 @@ bool DemodulatorThread::getSquelchBreak() { void DemodulatorThread::releaseSquelchLock(DemodulatorInstance *inst) { std::lock_guard < std::mutex > lock(squelchLockMutex); - if (squelchLock.load() == inst) { + if (inst == nullptr || squelchLock.load() == inst) { squelchLock.store(nullptr); } } \ No newline at end of file diff --git a/src/visual/InteractiveCanvas.cpp b/src/visual/InteractiveCanvas.cpp index f6557a5..e91464a 100644 --- a/src/visual/InteractiveCanvas.cpp +++ b/src/visual/InteractiveCanvas.cpp @@ -183,3 +183,11 @@ void InteractiveCanvas::OnMouseRightDown(wxMouseEvent& event) { void InteractiveCanvas::OnMouseRightReleased(wxMouseEvent& event) { mouseTracker.OnMouseRightReleased(event); } + +bool InteractiveCanvas::isMouseInView() { + return mouseTracker.mouseInView(); +} + +bool InteractiveCanvas::isMouseDown() { + return mouseTracker.mouseInView() && mouseTracker.mouseDown(); +} diff --git a/src/visual/InteractiveCanvas.h b/src/visual/InteractiveCanvas.h index 8ff6734..1877e43 100644 --- a/src/visual/InteractiveCanvas.h +++ b/src/visual/InteractiveCanvas.h @@ -25,7 +25,9 @@ public: unsigned int getBandwidth(); MouseTracker *getMouseTracker(); - + bool isMouseInView(); + bool isMouseDown(); + bool isAltDown(); bool isCtrlDown(); bool isShiftDown(); diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 26816f4..69fe127 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -730,6 +730,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) { demod->run(); wxGetApp().bindDemodulator(demod); + DemodulatorThread::releaseSquelchLock(nullptr); } if (!demod) {