From b9773f6eecea38e6a5aa28745cc6fe79aa2d441f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 12 Mar 2016 10:54:52 +0100 Subject: Add parent widget pointer for contained plugin windows. Remove threaded event handling and make all event handling depend on processEcvents being called with a regular (~50ms) interval. --- plugingui/plugingui.cc | 47 +++++++---------------------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) (limited to 'plugingui/plugingui.cc') diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index 85e628c..3375817 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -33,21 +33,15 @@ namespace GUI { -PluginGUI::PluginGUI() +PluginGUI::PluginGUI(void* native_window) : MessageReceiver(MSGRCV_UI) + , native_window(native_window) { -#ifdef USE_THREAD - run(); -#else init(); -#endif/*USE_THREAD*/ - - sem.wait(); } PluginGUI::~PluginGUI() { - stopThread(); } void PluginGUI::handleMessage(Message *msg) @@ -114,27 +108,6 @@ void PluginGUI::handleMessage(Message *msg) } } -void PluginGUI::thread_main() -{ - init(); - - { // Request all engine settings - EngineSettingsMessage *msg = new EngineSettingsMessage(); - msghandler.sendMessage(MSGRCV_ENGINE, msg); - } - - while(processEvents()) - { -#ifdef WIN32 - SleepEx(50, FALSE); -#else - usleep(50000); -#endif/*WIN32*/ - } - - deinit(); -} - bool PluginGUI::processEvents() { if(!initialised) @@ -155,15 +128,6 @@ bool PluginGUI::processEvents() return running; } -void PluginGUI::stopThread() -{ - if(running) - { - running = false; - wait_stop(); - } -} - void PluginGUI::init() { DEBUG(gui, "init"); @@ -171,14 +135,17 @@ void PluginGUI::init() config = new Config(); config->load(); - window = new DGWindow(msghandler, *config); + window = new DGWindow(native_window, msghandler, *config); auto eventHandler = window->eventHandler(); CONNECT(eventHandler, closeNotifier, this, &PluginGUI::closeEventHandler); window->show(); - sem.post(); + { // Request all engine settings + EngineSettingsMessage *msg = new EngineSettingsMessage(); + msghandler.sendMessage(MSGRCV_ENGINE, msg); + } initialised = true; } -- cgit v1.2.3