JXApplication::JXApplication ( int* argc, char* argv[], const JCharacter* appSignature, const JCharacter** defaultStringData ) : JXDirector(NULL), itsIgnoreDisplayDeletedFlag(kJFalse), itsIgnoreTaskDeletedFlag(kJFalse), itsSignature(appSignature), itsRestartCmd(argv[0]) { // initialize object itsDisplayList = new JPtrArray<JXDisplay>(JPtrArrayT::kDeleteAll); assert( itsDisplayList != NULL ); itsCurrDisplayIndex = 1; itsIdleTaskStack = new IdleTaskStack(JPtrArrayT::kDeleteAll); assert( itsIdleTaskStack != NULL ); itsIdleTasks = new JPtrArray<JXIdleTask>(JPtrArrayT::kDeleteAll); assert( itsIdleTasks != NULL ); itsCurrentTime = 0; itsMaxSleepTime = 0; itsLastIdleTime = 0; itsLastIdleTaskTime = 0; itsWaitForChildCounter = 0; itsUrgentTasks = new JPtrArray<JXUrgentTask>(JPtrArrayT::kDeleteAll); assert( itsUrgentTasks != NULL ); itsHasBlockingWindowFlag = kJFalse; itsHadBlockingWindowFlag = kJFalse; itsRequestQuitFlag = kJFalse; // if no path info specified, assume it's on exec path if (JIsRelativePath(itsRestartCmd) && itsRestartCmd.Contains(ACE_DIRECTORY_SEPARATOR_STR)) { const JString pwd = JGetCurrentDirectory(); itsRestartCmd = JCombinePathAndName(pwd, itsRestartCmd); } // initialize global objects JXCreateGlobals(this, appSignature, defaultStringData); ListenTo(JThisProcess::Instance()); // for SIGTERM // create display -- requires JXGetApplication() to work JString displayName; ParseBaseOptions(argc, argv, &displayName); JXDisplay* display; if (!JXDisplay::Create(displayName, &display)) { cerr << argv[0]; if (displayName.IsEmpty()) { cerr << ": Can't open display '" << XDisplayName(NULL) << '\''; } else { cerr << ": Can't open display '" << displayName << '\''; } cerr << endl; JThisProcess::Exit(1); } // start the timer #ifndef WIN32 itimerval timerInfo; timerInfo.it_interval.tv_sec = kTimerStart; timerInfo.it_interval.tv_usec = 0; timerInfo.it_value.tv_sec = kTimerStart; timerInfo.it_value.tv_usec = 0; setitimer(ITIMER_REAL, &timerInfo, NULL); #endif // idle task to quit if add directors deactivated JXQuitIfAllDeactTask* task = new JXQuitIfAllDeactTask; assert( task != NULL ); task->Start(); }
Bool ReloadASEnvironment (ASImageManager ** old_imageman, ASFontManager ** old_fontman, BaseConfig ** config_return, Bool flush_images, Bool support_shared_images) { char *old_pixmap_path = NULL; char *old_font_path = NULL; char *configfile = NULL; BaseConfig *config = NULL; ASEnvironment *e = NULL; ScreenInfo *scr = get_current_screen (); if (Environment != NULL) { old_pixmap_path = Environment->pixmap_path; Environment->pixmap_path = NULL; old_font_path = Environment->font_path; Environment->font_path = NULL; } configfile = Session->overriding_file; if (configfile == NULL) configfile = make_session_file (Session, BASE_FILE, False /* no longer use #bpp in filenames */ ); if (configfile != NULL) { config = ParseBaseOptions (configfile, MyName); if (config != NULL) show_progress ("BASE configuration loaded from \"%s\" ...", configfile); else show_progress ("BASE could not be loaded from \"%s\" ...", configfile); if (configfile != Session->overriding_file) free (configfile); } else show_warning ("BASE configuration file cannot be found"); if (config == NULL) { if (Environment != NULL) { Environment->pixmap_path = old_pixmap_path; Environment->font_path = old_font_path; return False; } /* otherwise we should use default values - Environment should never be NULL */ Environment = make_default_environment (); } else { BaseConfig2ASEnvironment (config, &Environment); if (config_return) *config_return = config; else DestroyBaseConfig (config); } e = Environment; /* Save base filename to pass to modules */ if (mystrcmp (old_pixmap_path, e->pixmap_path) == 0 || (e->pixmap_path != NULL && scr->image_manager == NULL) || flush_images) { reload_screen_image_manager (scr, old_imageman); } if (old_pixmap_path && old_pixmap_path != e->pixmap_path) free (old_pixmap_path); if (mystrcmp (old_font_path, e->font_path) == 0 || (e->font_path != NULL && scr->font_manager == NULL)) { if (old_fontman) { *old_fontman = scr->font_manager; } else if (scr->font_manager) destroy_font_manager (scr->font_manager, False); scr->font_manager = create_font_manager (dpy, e->font_path, NULL); set_xml_font_manager (scr->font_manager); show_progress ("Font Path changed to \"%s\" ...", e->font_path ? e->font_path : ""); } if (old_font_path && old_font_path != e->font_path) free (old_font_path); if (e->desk_pages_h > 0) { if (e->desk_pages_h <= 100) scr->VxMax = (e->desk_pages_h - 1) * scr->MyDisplayWidth; else { scr->VxMax = MAX (e->desk_pages_h, scr->MyDisplayWidth) - scr->MyDisplayWidth; e->desk_pages_h = (e->desk_pages_h + scr->MyDisplayWidth - 1) / scr->MyDisplayWidth; } } else scr->VxMax = 0; if (e->desk_pages_v > 0) { if (e->desk_pages_v <= 100) scr->VyMax = (e->desk_pages_v - 1) * scr->MyDisplayHeight; else { scr->VyMax = MAX (e->desk_pages_v, scr->MyDisplayHeight) - scr->MyDisplayHeight; e->desk_pages_v = (e->desk_pages_v + scr->MyDisplayHeight - 1) / scr->MyDisplayHeight; } } else scr->VyMax = 0; scr->VScale = e->desk_scale; if (scr->VScale <= 1) scr->VScale = 2; else if (scr->VScale >= scr->MyDisplayHeight / 2) scr->VScale = scr->MyDisplayHeight / 2; #ifdef XSHMIMAGE if (support_shared_images) { if (get_flags (e->flags, ASE_NoSharedMemory)) disable_shmem_images (); else enable_shmem_images (); } SHOW_CHECKPOINT; #endif return (config != NULL); }