void StActiveXCtrl::stWindowLoop() { // do not load plugin until it is placed on screen StWindow aParentWin(myResMgr, myParentWin); for(;;) { if(aParentWin.isParentOnScreen()) { break; } StThread::sleep(10); if(myToQuit) { return; } } myStApp = new StImageViewer(myResMgr, myParentWin, new StOpenInfo()); if(!myStApp->open()) { myStApp.nullify(); return; } bool isFullscreen = false; myIsActive = true; for(;;) { if(myStApp->closingDown()) { myStApp.nullify(); myIsActive = false; return; } myIsActive = myStApp->isActive(); if(myToQuit) { myStApp->exit(0); } else if(myOpenEvent.check() && myStApp->isActive()) { // load the image myStApp->open(myOpenInfo); myOpenEvent.reset(); } StHandle<StWindow> aWin = myStApp->getMainWindow(); if(myIsActive) { aWin->show(); } else { aWin->hide(); } myStApp->processEvents(); if(aWin->isFullScreen()) { if(!isFullscreen) { PostMessage(WM_TIMER, 1); isFullscreen = true; } } else if(isFullscreen) { PostMessage(WM_TIMER, 0); isFullscreen = false; } } }
void StBrowserPlugin::stWindowLoop() { // do not load plugin until it is placed on screen StWindow aParentWin(myResMgr, myParentWin); for(;;) { #ifndef _WIN32 const int32_t anActiveNb = #endif ST_PLUGIN_QUEUE.increment(); if(aParentWin.isParentOnScreen() #ifndef _WIN32 || anActiveNb <= 1 #endif ) { break; } ST_PLUGIN_QUEUE.decrement(); StThread::sleep(10); if(myToQuit) { return; } } // Load image viewer myStApp = new StImageViewer(myResMgr, myParentWin, new StOpenInfo()); if(!myStApp->open()) { ST_PLUGIN_QUEUE.decrement(); myStApp.nullify(); return; } ST_PLUGIN_QUEUE.decrement(); bool isFileOpened = false; bool isFullscreen = false; bool isFullLoaded = false; myIsActive = true; for(;;) { if(myStApp->closingDown()) { myStApp.nullify(); myIsActive = false; return; } myIsActive = myStApp->isActive(); if(myToQuit) { myStApp->exit(0); } else if(!isFileOpened && myIsActive) { // load the image StMutexAuto aLock(myMutex); if(myPreviewUrl.isEmpty()) { if(!myFullPath.isEmpty()) { myOpenInfo.setPath(myFullPath); aLock.unlock(); myStApp->open(myOpenInfo); isFileOpened = true; } } else if(!myPreviewPath.isEmpty()) { myOpenInfo.setPath(myPreviewPath); aLock.unlock(); myStApp->open(myOpenInfo); isFileOpened = true; } } StHandle<StWindow> aWin = myStApp->getMainWindow(); if(myIsActive) { aWin->show(); } else { aWin->hide(); } myStApp->processEvents(); if(aWin->isFullScreen()) { StMutexAuto aLock(myMutex); if(!isFullscreen && !myFullPath.isEmpty()) { myOpenInfo.setPath(myFullPath); aLock.unlock(); myStApp->open(myOpenInfo); isFullscreen = true; } else if(!isFullLoaded && NPNFuncs.pluginthreadasynccall != NULL) { aLock.unlock(); NPNFuncs.pluginthreadasynccall(nppInstance, StBrowserPlugin::doLoadFullSize, this); isFullLoaded = true; } } else if(isFullscreen) { StMutexAuto aLock(myMutex); if(!myPreviewPath.isEmpty()) { myOpenInfo.setPath(myPreviewPath); aLock.unlock(); myStApp->open(myOpenInfo); isFullscreen = false; } } } }