void DirectShowEventLoop::customEvent(QEvent *event)
{
    if (event->type() == QEvent::User) {
        processEvents();
    } else {
        QObject::customEvent(event);
    }
}
bool DesignerApp::initApplication(QString cmdLine)
{
    QLocale::setDefault(QLocale(QLocale::English));
    QTextCodec::setCodecForTr(QTextCodec::codecForLocale());

    QPixmap pixmap(":/designer/splash.png");
    QSplashScreen *splash = new QSplashScreen(pixmap);
    splash->show();
    splash->showMessage(tr("Loading..."));

    processEvents();

    writeConfigValue("", "apppath", QtSingleApplication::applicationFilePath());

    dbIgame = QSqlDatabase::addDatabase("QMYSQL","igame");
    dbIgame.setDatabaseName("MoDeL");
    dbIgame.setHostName("localhost");
    dbIgame.setUserName("root");
    dbIgame.setPassword("lovewin");
    dbIgame.open();

    DesignerViewMgr::initializeIfNotYet();
    DesignerDocMgr::initializeIfNotYet();
    DesignerModelMgr::initializeIfNotYet();

    DesignerExtensionMgr::initializeIfNotYet();

    DesignerMainWnd* mainWnd = DesignerMainWnd::globalCreateNewMainWnd();
    setActivationWindow(mainWnd);
    QObject::connect(this, SIGNAL(messageReceived(const QString&)), mainWnd, SLOT(instanceMessageReceived(const QString&)));
    splash->setWindowFlags(Qt::WindowStaysOnTopHint);
    splash->setParent(mainWnd);
    splash->show();

    QTimer::singleShot(1500, splash, SLOT(close()));

    if(cmdLine!="/new")
        mainWnd->instanceMessageReceived(cmdLine);

    while(splash->isVisible())
    {
        processEvents();
    }

    return true;
}
Пример #3
0
void Game::run()
{
	while (mWindow.isOpen())
	{
		processEvents();
		render();
	}
}
Пример #4
0
void Game::run()
{
	sf::Clock clock;
	sf::Time timeSinceLastUpdate = sf::Time::Zero;
	while (mWindow.isOpen())
	{
		processEvents();
		timeSinceLastUpdate += clock.restart();
		while (timeSinceLastUpdate > TimePerFrame)
		{
			timeSinceLastUpdate -= TimePerFrame;
			processEvents();
			update(TimePerFrame);
		}
		render();
	}
}
Пример #5
0
void AmCallWatcher::run() {
  DBG("starting call watcher.\n");
  garbage_collector->start();
  while (true) {
    waitForEvent();
    processEvents();
  }
}
Пример #6
0
 /**
  * Waits for new OSX event (TODO: thread)
  * Virtual
  *
  * @return RawEvent object
  */
 void EventMonitorMac::waitForEvents() {
     int i = 10;
     while ( events.size() == 0 ) {
         // Wait for some event
         processEvents();
         usleep(75000);
     }
 }
Пример #7
0
void TuioDemo::run() {
	running=true;
	while (running) {
		drawObjects();
		processEvents();
		SDL_Delay(40);
	} 
}
Пример #8
0
 void run() {
     do {
         processEvents();
         update();
         render();
     }
     while (_window.isOpen());
 }
Пример #9
0
	void InputSystem::tick()
	{
		if (!m_isCapturing) {
			return;
		}

		processEvents();
	}
Пример #10
0
// ============================================================================
ssize_t PacketManager::sendto_Err(int s, void *buf, size_t len, int flags,
                                  const struct sockaddr *to, socklen_t tolen)
{
    int nResult = 0;

    if (buf == NULL)
    {
        ERR_PRINT("buf pointer == NULL\n");
        exit(1);
    }

    if (len == 0)
    {
        ERR_PRINT("len == 0: %u\n", len);
        exit(1);
    }

    if (to == NULL)
    {
        ERR_PRINT("sockaddr pointer == NULL\n");
        exit(1);
    }

    ++m_MsgNo;

    uint32_t seqNo = ntohl(*(uint32_t*)(buf));
    MSG_PRINT("MSG# %3u SEQ# %3u LEN %4u FLAGS 0x%08X\n", m_MsgNo, seqNo, len, flags);

    size_t lenTmp = len;
    unsigned char bufTmp[len];
    memcpy(bufTmp, buf, lenTmp);
    void* pBuf = bufTmp;

    nResult = processEvents((void**)&pBuf, &lenTmp, m_MsgNo);
    if (nResult < 0)
    {
        ERR_PRINT("prcoessEvents\n");
        return nResult;
    }
    else if ((nResult == 0) || (nResult == 1))
    {
        ssize_t lenSent = sendto(s, pBuf, lenTmp, flags, to, tolen);
        if (lenSent == (ssize_t)lenTmp)
        {
            return len;
        }
        else
        {
            return lenSent;
        }
    }
    else
    {
        return len;
    }

    return -1;
}
Пример #11
0
int main(int argc, const char** argv)
{
    XInitThreads();
    s_display = XOpenDisplay(0);

    int32_t screen = DefaultScreen(s_display);
    int32_t depth = DefaultDepth(s_display, screen);
    Visual* visual = DefaultVisual(s_display, screen);
    Window root = RootWindow(s_display, screen);

    XSetWindowAttributes windowAttrs = { 0 };
    windowAttrs.background_pixmap = 0;
    windowAttrs.border_pixel = 0;
    windowAttrs.event_mask = 0
                             | ButtonPressMask
                             | ButtonReleaseMask
                             | ExposureMask
                             | KeyPressMask
                             | KeyReleaseMask
                             | PointerMotionMask
                             | StructureNotifyMask
    ;

    int width = 800;
    int height = 600;

    s_window = XCreateWindow(s_display
                             , root
                             , 0, 0
                             , width, height, 0, depth
                             , InputOutput
                             , visual
                             , CWBorderPixel | CWEventMask
                             , &windowAttrs
                             );

    // Clear window to black.
    XSetWindowAttributes attr = { 0 };
    XChangeWindowAttributes(s_display, s_window, CWBackPixel, &attr);

    const char* wmDeleteWindowName = "WM_DELETE_WINDOW";
    XInternAtoms(s_display, (char**)&wmDeleteWindowName, 1, False, &wmDeleteWindow);
    XSetWMProtocols(s_display, s_window, &wmDeleteWindow, 1);

    XMapWindow(s_display, s_window);
    XStoreName(s_display, s_window, "ProDBG");

    bgfx::x11SetDisplayWindow(s_display, s_window);

    ProDBG_create((void*)s_window, width, height);

    processEvents();

    XUnmapWindow(s_display, s_window);
    XDestroyWindow(s_display, s_window);

    return EXIT_SUCCESS;
}
Пример #12
0
void MenuServeur::run()
{
  while (mWindow.isOpen())
  {
//    musiccc();
    processEvents();
    render();
}
}
Пример #13
0
int Application::main(int argc, char **argv) {
  app = new App(argc, argv);
  #if !defined(_WIN32)
  //Windows port uses 256x256 icon from resource file
  app->setWindowIcon(QIcon(":/bsnes.png"));
  #endif

  initargs(argc, argv);  //ensure argv[]s are in UTF-8 format
  initPaths(argv[0]);
  locateFile(configFilename = "bsnes.cfg", true);
  locateFile(styleSheetFilename = "style.qss", false);

  string customStylesheet;
  if(customStylesheet.readfile(styleSheetFilename) == true) {
    app->setStyleSheet((const char*)customStylesheet);
  } else {
    app->setStyleSheet(defaultStylesheet);
  }

  config.load(configFilename);
  init();
  snes.init();

  if(argc == 2) {
    //if valid file was specified on the command-line, attempt to load it now
    utility.loadCartridge(argv[1]);
  }

  while(terminate == false) {
    processEvents();
    utility.updateSystemState();
    inputManager.refresh();

    if(config.input.focusPolicy == Configuration::Input::FocusPolicyPauseEmulation) {
      bool inactive = (winMain->window->isActiveWindow() == false);
      if(!autopause && inactive) {
        autopause = true;
        audio.clear();
      } else if(autopause && !inactive) {
        autopause = false;
      }
    } else {
      autopause = false;
    }

    if(cartridge.loaded() && !pause && !autopause) {
      snes.runtoframe();
    } else {
      usleep(20 * 1000);
    }

    supressScreenSaver();
  }

  config.save(configFilename);
  return 0;
}
Пример #14
0
	void run()
	{
		while (mWindow.isOpen())
		{
			processEvents();
			update();
			render();
		}
	}
Пример #15
0
void PongGame::run() {
    sf::Clock clock;
    sf::Time timeSinceLastUpdate = sf::Time::Zero;

    while (mainWindow.isOpen()) {
        processEvents();
        sf::Time elapsedTime = clock.restart();
        timeSinceLastUpdate += elapsedTime;
        while (timeSinceLastUpdate > timePerFrame) {
            timeSinceLastUpdate -= timePerFrame;
            processEvents();
            // no matter what happens, give the same  delta time to the update function
            update();
        }
        updateStatistics(elapsedTime);
        render();
    }
}
Пример #16
0
void		GameEngine::run(void)
{
  sf::Clock	clock;
  sf::Time	lastUpdate = sf::Time::Zero;

  while(_mWindow.isOpen())
    {
      processEvents();
      lastUpdate += clock.restart();
      while (lastUpdate >  _timePerFrame)
	{
	  lastUpdate -= _timePerFrame;
	  processEvents();
	  update(_timePerFrame); // A revoir
	}
      render();
    }
}
Пример #17
0
void Game::run()
{
	while (mWindow.isOpen())
	{
		processEvents();
		update(timePerFrame);
		render();
	}
}
Пример #18
0
/*!
    Enters the main event loop and waits until exit() is called.
    Returns the value that was passed to exit().

    If \a flags are specified, only events of the types allowed by
    the \a flags will be processed.

    It is necessary to call this function to start event handling. The
    main event loop receives events from the window system and
    dispatches these to the application widgets.

    Generally speaking, no user interaction can take place before
    calling exec(). As a special case, modal widgets like QMessageBox
    can be used before calling exec(), because modal widgets
    use their own local event loop.

    To make your application perform idle processing (i.e. executing a
    special function whenever there are no pending events), use a
    QTimer with 0 timeout. More sophisticated idle processing schemes
    can be achieved using processEvents().

    \sa QCoreApplication::quit(), exit(), processEvents()
*/
int QEventLoop::exec(ProcessEventsFlags flags)
{
    Q_D(QEventLoop);
    //we need to protect from race condition with QThread::exit
    QMutexLocker locker(&static_cast<QThreadPrivate *>(QObjectPrivate::get(d->threadData->thread))->mutex);
    if (d->threadData->quitNow)
        return -1;

    if (d->inExec) {
        qWarning("QEventLoop::exec: instance %p has already called exec()", this);
        return -1;
    }

    struct LoopReference {
        QEventLoopPrivate *d;
        QMutexLocker &locker;

        bool exceptionCaught;
        LoopReference(QEventLoopPrivate *d, QMutexLocker &locker) : d(d), locker(locker), exceptionCaught(true)
        {
            d->inExec = true;
            d->exit.storeRelease(false);
            ++d->threadData->loopLevel;
            d->threadData->eventLoops.push(d->q_func());
            locker.unlock();
        }

        ~LoopReference()
        {
            if (exceptionCaught) {
                qWarning("Qt has caught an exception thrown from an event handler. Throwing\n"
                         "exceptions from an event handler is not supported in Qt.\n"
                         "You must not let any exception whatsoever propagate through Qt code.\n"
                         "If that is not possible, in Qt 5 you must at least reimplement\n"
                         "QCoreApplication::notify() and catch all exceptions there.\n");
            }
            locker.relock();
            QEventLoop *eventLoop = d->threadData->eventLoops.pop();
            Q_ASSERT_X(eventLoop == d->q_func(), "QEventLoop::exec()", "internal error");
            Q_UNUSED(eventLoop); // --release warning
            d->inExec = false;
            --d->threadData->loopLevel;
        }
    };
    LoopReference ref(d, locker);

    // remove posted quit events when entering a new event loop
    QCoreApplication *app = QCoreApplication::instance();
    if (app && app->thread() == thread())
        QCoreApplication::removePostedEvents(app, QEvent::Quit);

    while (!d->exit.loadAcquire())
        processEvents(flags | WaitForMoreEvents | EventLoopExec);

    ref.exceptionCaught = false;
    return d->returnCode.load();
}
Пример #19
0
 void setOpaqueChildren(bool enable)
 {
     if (opaqueChildren != enable) {
         foreach (QWidget *w, children)
             w->setAttribute(Qt::WA_OpaquePaintEvent, enable);
         opaqueChildren = enable;
         processEvents();
     }
 }
Пример #20
0
    void Tasklet::run() {
      platform::setThreadName("'"+name+"' (tasklet)");
      isAlive = true;
      bool hasError = false;
      string errorMsg = "";

      try {

        // make sure that our GL context is the current context
        if(window != NULL) {
          window->context->makeCurrent();
        }

        startup();
        if (running) {

          double framerate = config.framerate;
          double offset = clock.getTime();

          while (thread->get_state() == TaskletThread::RUNNING && running) {
            processEvents();
            if (running) {
              update(framerate);
              render();
              if(waitForEvents) { eventDispatcher->waitForEvents(); }

              framerate = clock.getElapsedAndUpdateOffset(offset);
            }
          }

          shutdown();

          // unbind GL context
          if(window != NULL) {
            window->context->clearCurrent();
          }
        }
      }
      catch(std::exception& ex)
      {
        errorMsg = ex.what();
        hasError = true;
      }
      catch (...) {
        errorMsg = "<catch all>";
        hasError = true;
      }
      isAlive = false;
      dispatchApplicationEvent(TaskletEventPtr(new TaskletEvent(TaskletEvent::DONE(), this)));
      if (hasError) {

        std::ostringstream os;
        os << "Tasklet '"<<name<<"' terminated with error: " <<errorMsg;
        throw std::runtime_error(os.str());
      }
    }
Пример #21
0
void PipeBase::run()
{
	gcTrace("");

	while (!isStopped())
	{
		processEvents();
		processLoopback();
	}
}
Пример #22
0
Файл: ugui.cpp Проект: sgh/aos
void UGui::processEvents(Drawable* d) {
	while (d) {
		d->predraw();
		eventLock();
		d->processEvents();
		eventUnlock();
		processEvents(d->_children);
		d = d->next();
	}
}
Пример #23
0
void Game::run() {
    sf::Clock c;
    srand(time(0));
    while(window.isOpen()) {
        float deltaTime = c.restart().asSeconds();
        processEvents();
        update(deltaTime);
        render();
    }
}
Пример #24
0
void pApplication::run() {
  if(Application::state.onMain) {
    while(!Application::state.quit) {
      Application::doMain();
      processEvents();
    }
  } else {
    gtk_main();
  }
}
Пример #25
0
bool DirectShowEventLoop::event(QEvent *event)
{
    if (event->type() == QEvent::WinEventAct) {
        processEvents();

        return true;
    } else {
        return QWinEventNotifier::event(event);
    }
}
Пример #26
0
void pApplication::run() {
  if(Application::main) {
    while(applicationState.quit == false) {
      processEvents();
      Application::main();
    }
  } else {
    gtk_main();
  }
}
Пример #27
0
/*!
    Process pending events that match \a flags for a maximum of \a
    maxTime milliseconds, or until there are no more events to
    process, which ever is shorter.

    This function is especially useful if you have a long running
    operation and want to show its progress without allowing user
    input, i.e. by using the \c ExcludeUserInput flag.

    NOTE: This function will not process events continuously; it
    returns after all available events are processed.

    NOTE: Specifying the \c WaitForMore flag makes no sense and will
    be ignored.
*/
void QEventLoop::processEvents( ProcessEventsFlags flags, int maxTime )
{
    QTime start = QTime::currentTime();
    QTime now;
    while ( ! d->quitnow && processEvents( flags & ~WaitForMore ) ) {
	now = QTime::currentTime();
	if ( start.msecsTo( now ) > maxTime )
	    break;
    }
}
Пример #28
0
/**
 * Initializes the LibDS system and instructs the class to close the LibDS
 * before the Qt application is closed.
 */
void DriverStation::start()
{
    if (!DS_Initialized()) {
        DS_Init();
        processEvents();
        updateElapsedTime();
        emit statusChanged (generalStatus());
        connect (qApp, SIGNAL (aboutToQuit()), this, SLOT (quitDS()));
    }
}
Пример #29
0
void EventsManager::runMainLoop() {
	while (!_doQuit) {
		// (Pre)Process all events
		processEvents();

		_queueProcessed.signal();

		// Render a frame
		GfxMan.renderScene();
	}
}
Пример #30
0
const Scene::ExitAction PlayModeSelect::run(){
	manager.restart();
	while (window.isOpen()){
		Scene::ExitAction act = processEvents();
		if (act != Scene::ExitAction::NoAction){
			return act;
		}
		render();
	}
	return Scene::ExitAction::Exit;
}