From: <sag...@us...> - 2014-03-20 20:00:58
|
Revision: 3921 http://sourceforge.net/p/modplug/code/3921 Author: saga-games Date: 2014-03-20 20:00:47 +0000 (Thu, 20 Mar 2014) Log Message: ----------- [Mod] Plugin bridge: Remove periodic redraw. This harms many plugin GUIs and is usually not necessary anyway. [Imp] Plugin bridge: Pass keys back to the editor to trigger notes and indicate bridging status in window title. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/pluginBridge/Bridge.cpp trunk/OpenMPT/pluginBridge/BridgeCommon.h trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-03-20 16:48:09 UTC (rev 3920) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-03-20 20:00:47 UTC (rev 3921) @@ -386,6 +386,8 @@ Title.Append(m_VstPlugin.m_pMixStruct->GetName()); else Title.Append(mpt::ToLocale(mpt::CharsetUTF8, m_VstPlugin.m_pMixStruct->GetLibraryName()).c_str()); + if(m_VstPlugin.isBridged) + Title.Append(" (Bridged)"); SetWindowText(Title); } @@ -449,8 +451,9 @@ { if(m_VstPlugin.CanRecieveMidiEvents()) { + SetForegroundWindow(); // Might have to steal focus from plugin bridge child window if(!m_VstPlugin.isInstrument() || m_VstPlugin.GetSoundFile().GetModSpecifications().instrumentsMax == 0 || - Reporting::Confirm(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), false, false, false, this) == cnfNo) + Reporting::Confirm(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), false, false, this) == cnfNo) { return false; } else Modified: trunk/OpenMPT/pluginBridge/Bridge.cpp =================================================================== --- trunk/OpenMPT/pluginBridge/Bridge.cpp 2014-03-20 16:48:09 UTC (rev 3920) +++ trunk/OpenMPT/pluginBridge/Bridge.cpp 2014-03-20 20:00:47 UTC (rev 3921) @@ -60,7 +60,7 @@ { if(argc != 2) { - MessageBox(NULL, _T("This executable is part of OpenMPT. You do not need to run it by yourself."), _T("Plugin Bridge"), 0); + MessageBox(NULL, _T("This executable is part of OpenMPT. You do not need to run it by yourself."), _T("OpenMPT Plugin Bridge"), 0); return -1; } @@ -112,10 +112,11 @@ if(!queueMem.Open(memName) || !CreateSignals(memName)) { - MessageBox(NULL, _T("Could not connect to host."), _T("Plugin Bridge"), 0); + MessageBox(NULL, _T("Could not connect to OpenMPT."), _T("OpenMPT Plugin Bridge"), 0); delete this; return; } + sharedMem = reinterpret_cast<SharedMemLayout *>(queueMem.view); // Store parent process handle so that we can terminate the bridge process when OpenMPT closes (e.g. through a crash). @@ -124,17 +125,13 @@ sigThreadExit.Create(true); otherThread = mpt::thread_member<PluginBridge, &PluginBridge::RenderThread>(this); - // Tell the parent process that we've initialized the shared memory and are ready to go. - sigToHost.Confirm(); - mpt::thread_member<PluginBridge, &PluginBridge::MessageThread>(this); } PluginBridge::~PluginBridge() { - sigThreadExit.Trigger(); - WaitForSingleObject(otherThread, INFINITE); + SignalObjectAndWait(sigThreadExit, otherThread, INFINITE, FALSE); sharedMem = nullptr; queueMem.Close(); @@ -480,8 +477,6 @@ windowClass.hInstance, NULL); - // Periodically update the window, in case redrawing failed. - SetTimer(window, 0x1337, 1000, nullptr); windowParent = reinterpret_cast<HWND>(msg->ptr); } break; @@ -1026,36 +1021,34 @@ LRESULT CALLBACK PluginBridge::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + PluginBridge *that = reinterpret_cast<PluginBridge *>(GetProp(hwnd, _T("MPT"))); + if(that == nullptr) + { + return DefWindowProc(hwnd, uMsg, wParam, lParam); + } + switch(uMsg) { case WM_NCACTIVATE: if(wParam == TRUE) { // Window is activated - put the plugin window into foreground - PluginBridge *that = reinterpret_cast<PluginBridge *>(GetProp(hwnd, _T("MPT"))); - if(that != nullptr) - { - SetForegroundWindow(that->windowParent); - SetForegroundWindow(that->window); - } + SetForegroundWindow(that->windowParent); + SetForegroundWindow(that->window); } break; + case WM_SYSKEYUP: + case WM_SYSKEYDOWN: + case WM_KEYUP: + case WM_KEYDOWN: + // Let the host handle these keys, too. + PostMessage(GetParent(that->windowParent), uMsg, wParam, lParam); + break; + case WM_ERASEBKGND: // Pretend that we erased the background - if(GetProp(hwnd, _T("MPT")) != nullptr) - { - return 1; - } - break; - - case WM_TIMER: - if(wParam == 0x1337) - { - // Fix failed plugin window redrawing by periodically forcing a redraw - RedrawWindow(hwnd, nullptr, nullptr, RDW_INVALIDATE | RDW_ALLCHILDREN); - } - break; + return 1; } return DefWindowProc(hwnd, uMsg, wParam, lParam); Modified: trunk/OpenMPT/pluginBridge/BridgeCommon.h =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeCommon.h 2014-03-20 16:48:09 UTC (rev 3920) +++ trunk/OpenMPT/pluginBridge/BridgeCommon.h 2014-03-20 20:00:47 UTC (rev 3921) @@ -40,11 +40,12 @@ public: Event() : handle(nullptr) { } - ~Event() { CloseHandle(handle); } + ~Event() { Close(); } // Create a new event bool Create(bool manual = false, const wchar_t *name = nullptr) { + Close(); handle = CreateEventW(nullptr, manual ? TRUE : FALSE, FALSE, name); return handle != nullptr; } @@ -52,9 +53,15 @@ // Duplicate a local event bool DuplicateFrom(HANDLE source) { + Close(); return DuplicateHandle(GetCurrentProcess(), source, GetCurrentProcess(), &handle, 0, FALSE, DUPLICATE_SAME_ACCESS) != FALSE; } + void Close() + { + CloseHandle(handle); + } + void Trigger() { SetEvent(handle); Modified: trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp =================================================================== --- trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-03-20 16:48:09 UTC (rev 3920) +++ trunk/OpenMPT/pluginBridge/BridgeWrapper.cpp 2014-03-20 20:00:47 UTC (rev 3921) @@ -198,12 +198,6 @@ sharedMem->effect.process = Process; memcpy(&(sharedMem->effect.resvd2), "OMPT", 4); - if(WaitForSingleObject(sigToHost.ack, 5000) != WAIT_OBJECT_0) - { - Reporting::Error("Plugin bridge timed out."); - return false; - } - sigThreadExit.Create(true); sigAutomation.Create(true); @@ -231,8 +225,7 @@ BridgeWrapper::~BridgeWrapper() { - sigThreadExit.Trigger(); - WaitForSingleObject(otherThread, INFINITE); + SignalObjectAndWait(sigThreadExit, otherThread, INFINITE, FALSE); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |