/** * Construct an object with the given parent */ CommandLineInterpreter::CommandLineInterpreter(const ScriptingEnv & environ, QWidget *parent) : ScriptEditor(parent,environ.createCodeLexer()), m_runner(), m_history(), m_inputBuffer(),m_status(Waiting), m_promptKey(markerDefine(QsciScintilla::ThreeRightArrows)), m_continuationKey(markerDefine(QsciScintilla::ThreeDots)), m_currentPromptLineIndex(0), m_pastedText(), m_pasteQueue(), m_copy(NULL), m_cut(NULL), m_paste(NULL), m_saveAs(NULL), m_zoomIn(NULL), m_zoomOut(NULL) { enableAutoCompletion(); setupEnvironment(environ); setupMargin(); setupIndentation(); setupFont(); initActions(); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint &))); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Need to disable some default key bindings that Scintilla provides as they don't really // fit here remapWindowEditingKeys(); }
Board initBoard ( #ifdef IS_WIN IplImage *globMapIplImage, IplImage *localMapIplImage #endif ) { Board b; unsigned int seed; b.db = initBoardDatabase ( #ifdef IS_WIN globMapIplImage, localMapIplImage #endif ); #ifdef BOARD initialiseCriticalSections(); #endif { seed = (unsigned int)time(0); // seed = 1380244778; // seed = seeds[seedIndex++]; srand (seed); fprintf (b.db.xmlLog, "<RandomSeed>%d</RandomSeed>\n", seed); } setupEnvironment (&b); return b; }
bool SessionManager::initialize() { // Setup environment setupEnvironment(); // Register D-Bus services if (!registerDBus()) return false; return true; }
Config::Config(KConfig *config, KileInfo *ki, QWidget* parent) : KPageDialog(parent), m_config(config), m_ki(ki) { setWindowTitle(i18n("Configure")); setModal(true); setObjectName("kileconfiguration"); setFaceType(Tree); m_config->sync(); // we need a dialog manager m_manager = new KConfigDialogManager(this,KileConfig::self()); KPageWidgetItem* kilePageWidgetItem = addConfigFolder(i18n("Kile"), "kile"); KPageWidgetItem* latexPageWidgetItem = addConfigFolder(i18n("LaTeX"), "latex-config"); KPageWidgetItem* toolsPageWidgetItem = addConfigFolder(i18n("Tools"), "system-run"); KPageWidgetItem* editorPageWidgetItem = addConfigFolder(i18n("Editor"), "accessories-text-editor"); // setup all configuration pages setupGeneralOptions(kilePageWidgetItem); setupAppearance(kilePageWidgetItem); setupCodeCompletion(kilePageWidgetItem); // complete configuration (dani) setupHelp(kilePageWidgetItem); setupScripting(kilePageWidgetItem); setupUsermenu(kilePageWidgetItem); setupLivePreview(kilePageWidgetItem); setupLatex(latexPageWidgetItem); setupEnvironment(latexPageWidgetItem); setupGraphics(latexPageWidgetItem); setupStructure(latexPageWidgetItem); setupSymbolView(latexPageWidgetItem); setupTools(toolsPageWidgetItem); setupQuickPreview(toolsPageWidgetItem); // QuickPreview (dani) setupEditor(editorPageWidgetItem); m_configDialogSize = m_config->group("KileConfigDialog"); KWindowConfig::restoreWindowSize(windowHandle(), m_configDialogSize); // setup connections //connect(m_manager, SIGNAL(widgetModified()), this, SLOT(slotWidgetModified())); connect(this, &KPageDialog::accepted, this, &Config::slotAcceptChanges); connect(this, &KPageDialog::accepted, m_manager, &KConfigDialogManager::updateSettings); connect(this, &KPageDialog::rejected, this, [=] () { m_config->markAsClean(); }); }
void CompositorLauncher::start() { // Try to detect mode and hardware detectHardware(); detectMode(); if (m_mode == UnknownMode) { qWarning() << "No mode detected, please manually specify one!"; QCoreApplication::quit(); return; } // Detect whether we have libinput detectLibInput(); // Start the process startProcess("greenisland", compositorArgs(), compositorEnv()); // Set environment so that applications will inherit it setupEnvironment(); }
bool K3Process::start(RunMode runmode, Communication comm) { if (runs) { qDebug() << "Attempted to start an already running process" << endl; return false; } uint n = arguments.count(); if (n == 0) { qDebug() << "Attempted to start a process without arguments" << endl; return false; } char **arglist; QByteArray shellCmd; if (d->useShell) { if (d->shell.isEmpty()) { qDebug() << "Invalid shell specified" << endl; return false; } for (uint i = 0; i < n; i++) { shellCmd += arguments[i]; shellCmd += ' '; // CC: to separate the arguments } arglist = static_cast<char **>(malloc( 4 * sizeof(char *))); arglist[0] = d->shell.data(); arglist[1] = (char *) "-c"; arglist[2] = shellCmd.data(); arglist[3] = 0; } else { arglist = static_cast<char **>(malloc( (n + 1) * sizeof(char *))); for (uint i = 0; i < n; i++) arglist[i] = arguments[i].data(); arglist[n] = 0; } run_mode = runmode; if (!setupCommunication(comm)) { qDebug() << "Could not setup Communication!" << endl; free(arglist); return false; } // We do this in the parent because if we do it in the child process // gdb gets confused when the application runs from gdb. #ifdef HAVE_INITGROUPS struct passwd *pw = geteuid() ? 0 : getpwuid(getuid()); #endif int fd[2]; if (pipe(fd)) fd[0] = fd[1] = -1; // Pipe failed.. continue // we don't use vfork() because // - it has unclear semantics and is not standardized // - we do way too much magic in the child pid_ = fork(); if (pid_ == 0) { // The child process close(fd[0]); // Closing of fd[1] indicates that the execvp() succeeded! fcntl(fd[1], F_SETFD, FD_CLOEXEC); if (!commSetupDoneC()) qDebug() << "Could not finish comm setup in child!" << endl; // reset all signal handlers struct sigaction act; sigemptyset(&act.sa_mask); act.sa_handler = SIG_DFL; act.sa_flags = 0; for (int sig = 1; sig < NSIG; sig++) sigaction(sig, &act, 0L); if (d->priority) setpriority(PRIO_PROCESS, 0, d->priority); if (!runPrivileged()) { setgid(getgid()); #ifdef HAVE_INITGROUPS if (pw) initgroups(pw->pw_name, pw->pw_gid); #endif if (geteuid() != getuid()) setuid(getuid()); if (geteuid() != getuid()) _exit(1); } setupEnvironment(); if (runmode == DontCare || runmode == OwnGroup) setsid(); const char *executable = arglist[0]; if (!d->executable.isEmpty()) executable = d->executable.data(); execvp(executable, arglist); char resultByte = 1; write(fd[1], &resultByte, 1); _exit(-1); } else if (pid_ == -1) { // forking failed // commAbort(); pid_ = 0; free(arglist); return false; } // the parent continues here free(arglist); if (!commSetupDoneP()) qDebug() << "Could not finish comm setup in parent!" << endl; // Check whether client could be started. close(fd[1]); for(;;) { char resultByte; int n = ::read(fd[0], &resultByte, 1); if (n == 1) { // exec() failed close(fd[0]); waitpid(pid_, 0, 0); pid_ = 0; commClose(); return false; } if (n == -1) { if (errno == EINTR) continue; // Ignore } break; // success } close(fd[0]); runs = true; switch (runmode) { case Block: for (;;) { commClose(); // drain only, unless obsolete reimplementation if (!runs) { // commClose detected data on the process exit notifification pipe K3ProcessController::instance()->unscheduleCheck(); if (waitpid(pid_, &status, WNOHANG) != 0) // error finishes, too { commClose(); // this time for real (runs is false) K3ProcessController::instance()->rescheduleCheck(); break; } runs = true; // for next commClose() iteration } else { // commClose is an obsolete reimplementation and waited until // all output channels were closed (or it was interrupted). // there is a chance that it never gets here ... waitpid(pid_, &status, 0); runs = false; break; } } // why do we do this? i think this signal should be emitted _only_ // after the process has successfully run _asynchronously_ --ossi emit processExited(this); break; default: // NotifyOnExit & OwnGroup input_data = 0; // Discard any data for stdin that might still be there break; } return true; }
// sets up the game condition bool gameState::setupState() { //AISystem *ai = AISystem::Instance(); boost::shared_ptr<AISystem> ai = AISystem::Instance(); boost::shared_ptr<renderEngine> render = renderEngine::Instance(); boost::shared_ptr<loader> load = loader::Instance(); boost::shared_ptr<physicsEngine> physEngine = physicsEngine::Instance(); boost::shared_ptr<conversion> convert = conversion::Instance(); logMsg("Setting up state!"); if (!courtModelLoaded) { logMsg("creating court instances!"); if (createCourtInstances()) // creates the court instances { courtModelLoaded = true; courtInstanceCreated = true; } } if (!basketballInstancesCreated) // checks if court model has been loaded { logMsg("creating basketball instances!"); if (createBasketballInstances()) // creates the basketball instances { basketballInstancesCreated = true; } // FIXEME! this should not be hard coded activeBBallInstance = 0; // sets the active basketball instance } if (!hoopModelLoaded) { logMsg("creating hoop instances!"); if (createHoopInstances()) // creates the hoop instances { hoopModelLoaded = true; } } setBasketballStartPositions(); // sets starting positions for all basketballs that are instantiated setCourtStartPositions(); // sets starting positions for all courts that are instantiated setHoopStartPositions(); // sets starting positions for all hoops that are instantiated logMsg("court y == " +convert->toString(courtInstance[0].getNode()->getPosition().y)); // exit(0); if (!teamInstancesCreated) // checks if teamInstances have been created { if(createTeamInstances()) // creates the team instances { logMsg("TIC!"); teamInstancesCreated = true; assignHoopToTeams(); // assigns proper hoop to the teams that were created. } } // sets the quarter being played to the first one. quarter = FIRST; // basketballInstance[activeBBallInstance].getNode()->setPosition(1.4f,5.0f,366.0f); physEngine->setupState(); // sets up the Physics Engine state // exit(0); ai->setup(); // Ogre::Entity *ent; // ent = player->getModel(0); // player->mAnimationState2 = ent->getAnimationState("Walk"); // std::vector<Ogre::Entity*> playerModels = player->getModel(); // std::vector<Ogre::SceneNode*> playerNodes = player->getNode(); // std::vector<playerState> pInstance = getPlayerInstance(); // player->setModel(playerModels); // Ogre::Vector3 playerPos = playerNodes.at(0)->getPosition(); // Ogre::Vector3 offset; // offset[0] = 2.0f; // offset[1] = 2.0f; // offset[2] = 2.0f; // bball->setAutoTracking(true,playerNode[0],playerNode[0]->getPosition(),offset); // bball->setPosition(playerPos[0] +2.0f, playerPos[1] + 4.0f, playerPos[2] - 1.0f); // exit(0); if (!setupEnvironmentCompleted) // checks if environment has been setup { if(setupEnvironment()) // sets up environment { setupEnvironmentCompleted = true; } } // loads("../../data/players/players.xml"); if (!tipOffSetupComplete) { tipOffSetupComplete = setupTipOff(); // sets up tip off conditions } return true; //#endif }
int main(int argc, char **argv) { int autoport = 0; QApplication a(argc, argv); setupEnvironment(); /* -a/-h ignored, back-compat for time control from libpcp_gui */ opts.short_options = "ahD:p:V?"; opts.long_options = longopts; (void)pmGetOptions(argc, argv, &opts); if (opts.errors || opts.optind != argc) { pmUsageMessage(&opts); exit(1); } if (!opts.guiport) { char *endnum, *envstr; autoport = 1; if ((envstr = getenv("PMTIME_PORT")) == NULL) { opts.guiport = PmTime::BasePort; } else { opts.guiport = strtol(envstr, &endnum, 0); if (*endnum != '\0' || opts.guiport < 0) { pmprintf( "%s: PMTIME_PORT must be a numeric port number (not %s)\n", pmProgname, envstr); pmflush(); exit(1); } } } console = new Console; TimeLord tl(&a); do { if (tl.listen(QHostAddress::LocalHost, opts.guiport)) break; opts.guiport++; } while (autoport && (opts.guiport >= 0)); if (!opts.guiport || tl.isListening() == false) { if (!autoport) pmprintf("%s: cannot find an available port\n", pmProgname); else pmprintf("%s: cannot connect to requested port (%d)\n", pmProgname, opts.guiport); pmflush(); exit(1); } else if (autoport) { /* write to stdout for client */ char name[32]; int c = snprintf(name, sizeof(name), "port=%u\n", opts.guiport); if (write(fileno(stdout), name, c + 1) < 0) { if (errno != EPIPE) { pmprintf("%s: cannot write port for client: %s\n", pmProgname, strerror(errno)); pmflush(); } exit(1); } } PmTimeLive hc; PmTimeArch ac; tl.setContext(&hc, &ac); hc.init(); if (!pmDebug) hc.disableConsole(); else hc.popup(1); ac.init(); if (!pmDebug) ac.disableConsole(); else ac.popup(1); a.exec(); return 0; }
int main(int argc, char* argv[]) { srand((unsigned int)time(NULL)); SDL_Init(SDL_INIT_JOYSTICK); if(SDL_NumJoysticks() > 0) { // Setup the joystick. std::cout << "========================================" << std::endl; std::cout << "Initializing game controller: " << SDL_JoystickName(0) << std::endl; gGamePad = SDL_JoystickOpen(0); std::cout << SDL_JoystickNumAxes(gGamePad) << " axes" << std::endl; std::cout << SDL_JoystickNumBalls(gGamePad) << " trackballs" << std::endl; std::cout << SDL_JoystickNumHats(gGamePad) << " hats" << std::endl; std::cout << SDL_JoystickNumButtons(gGamePad) << " buttons" << std::endl; std::cout << "========================================" << std::endl; } else { std::cout << "========================================" << std::endl; std::cout << "No game controller detected" << std::endl; std::cout << "========================================" << std::endl; } //Ogre::Overlay* trialOverlay; ///// The current amount of elapsed time within a trial. //Ogre::Real mCurrentTrialTime; ///// The length of each trial in seconds. //Ogre::Real mTrialLength; ///// The rewards received during a single trial, in rewards per step. //verve::real mAvgRewardPerStep; if (!gEngine.init()) { return 0; } gEngine.setUpdateMode(SimulationEngine::SIMULATE_REAL_TIME_MULTIPLE, 1); //// Set to capture frames at 29.97 fps. //engine.setUpdateMode(SIMULATE_CONSTANT_CHUNK, 0.0333667); // Use feet for this simulation. gEngine.getSimulator()->setGravity(opal::Vec3r(0, -30, 0)); gEngine.getSimulator()->setStepSize(gPhysicsStepSize); // Make sure we get notified at the end of each step. gEngine.getSimulator()->addPostStepEventHandler(&gPostStepEventHandler); // Create the robot. opal::Matrix44r robotTransform; robotTransform.translate(0, 1, 0); gRobot = new Robot(gEngine, 5); gRobot->init("../data/blueprints/robot1.xml", "Plastic/LightBlue", 0.5, robotTransform, 2); gRobot->resetBodyAndCreateNewAgent(); gRobot->resetBodyAndSTM(); gRobot->randomizeState(); gRobot->getFLMotor()->setMaxTorque((opal::real)2); gRobot->getFRMotor()->setMaxTorque((opal::real)2); gRobot->getFLMotor()->setMaxVelocity(1000); gRobot->getFRMotor()->setMaxVelocity(1000); // Create the car. opal::Matrix44r carTransform; carTransform.translate(-12, 2, 4); gCar = new Car(gEngine); gCar->init("../data/blueprints/car1.xml", "Plastic/Blue", 1, carTransform, 1); //DataFile dataFile(mNumTrialsPerRun); //updateOverlayData(trial); //mAvgRewardPerStep = 0; //mCurrentTrialTime = 0; gAgentDebugger = new AgentVisualDebugger(gEngine.getSceneManager()); gAgentDebugger->setAgent(gRobot->getAgent()); gAgentDebugger->setDisplayEnabled(false); Ogre::OverlayManager::getSingleton().getByName("Verve/Debug")->hide(); Ogre::OverlayManager::getSingleton().getByName("Core/DebugOverlay")->hide(); // Setup camera. gEngine.getCamera()->setPosition(opal::Point3r(0, 25, 25)); gEngine.getCamera()->lookAt(opal::Point3r(0, (opal::real)0.1, 0)); gEngine.setCameraMoveSpeed(15); setupEnvironment(); mainLoop(); delete gRobot; delete gCar; delete gAgentDebugger; return 0; }
int main(int argc, char *argv[]) { // Disable ptrace except for gdb disablePtrace(); // Setup the environment setupEnvironment(); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // Application QApplication app(argc, argv); app.setApplicationName(QLatin1String("Papyros Shell")); app.setApplicationVersion(QLatin1String(PAPYROS_SHELL_VERSION_STRING)); app.setOrganizationName(QLatin1String("Ppayros")); app.setOrganizationDomain(QLatin1String("papyros.io")); app.setFallbackSessionManagementEnabled(false); app.setQuitOnLastWindowClosed(false); // Command line parser QCommandLineParser parser; parser.setApplicationDescription(TR("Wayland compositor for the Papyros desktop environment")); parser.addHelpOption(); parser.addVersionOption(); // Wayland socket QCommandLineOption socketOption(QStringLiteral("wayland-socket-name"), TR("Wayland socket"), TR("name")); parser.addOption(socketOption); // Nested mode QCommandLineOption nestedOption( QStringList() << QStringLiteral("n") << QStringLiteral("nested"), TR("Nest into a compositor that supports _wl_fullscreen_shell")); parser.addOption(nestedOption); // Fake screen configuration QCommandLineOption fakeScreenOption(QStringLiteral("fake-screen"), TR("Use fake screen configuration"), TR("filename")); parser.addOption(fakeScreenOption); #if DEVELOPMENT_BUILD // Load shell from an arbitrary path QCommandLineOption qmlOption(QStringLiteral("qml"), QStringLiteral("Load a shell main QML file"), QStringLiteral("filename")); parser.addOption(qmlOption); #endif // Parse command line parser.process(app); // Restart with D-Bus session if necessary if (qEnvironmentVariableIsEmpty("DBUS_SESSION_BUS_ADDRESS")) { qCritical("No D-Bus session bus available, please run Hawaii with dbus-launch."); return 1; } // Arguments bool nested = parser.isSet(nestedOption); QString socket = parser.value(socketOption); QString fakeScreenData = parser.value(fakeScreenOption); // Nested mode requires running from Wayland and a socket name // and fake screen data cannot be used if (nested) { if (!QGuiApplication::platformName().startsWith(QStringLiteral("greenisland"))) { qCritical("Nested mode only make sense when running on Wayland.\n" "Please pass the \"-platform greenisland\" argument."); return 1; } if (socket.isEmpty()) { qCritical("Nested mode requires you to specify a socket name.\n" "Please specify it with the \"--wayland-socket-name\" argument."); return 1; } if (!fakeScreenData.isEmpty()) { qCritical("Fake screen configuration cannot be used when nested"); return 1; } } // Print version information qDebug("== Papyros Shell v%s (Green Island v%s) ==\n" "** http://papyros.io\n" "** Bug reports to: https://github.com/papyros/papyros-shell/issues\n" "** Build: %s-%s", PAPYROS_SHELL_VERSION_STRING, GREENISLAND_VERSION_STRING, PAPYROS_SHELL_VERSION_STRING, GIT_REV); // Application Application *papyros = new Application(); papyros->setScreenConfiguration(fakeScreenData); // Create the compositor and run bool urlAlreadySet = false; #if DEVELOPMENT_BUILD if (parser.isSet(qmlOption)) { urlAlreadySet = true; papyros->setUrl(QUrl::fromLocalFile(parser.value(qmlOption))); } #endif if (!urlAlreadySet) papyros->setUrl(QUrl(QStringLiteral("qrc:/Compositor.qml"))); QCoreApplication::postEvent(papyros, new StartupEvent()); return app.exec(); }