void NPN_PluginThreadAsyncCall(NPP npp, void (*func)(void *), void *userData)
{
  NPNFuncs.pluginthreadasynccall(npp, func, userData);
}
Пример #2
0
//TODO: understand the Call... wrappers and npupp.h
void NPN_PluginThreadAsyncCall(NPP instance, void (*func) (void *), void *userData)
{
  NPNFuncs.pluginthreadasynccall(instance, func, userData);
}
Пример #3
0
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;
            }
        }
    }
}