ROOT logo
// @(#)root/gui:$Id: TRootApplication.cxx 23115 2008-04-10 13:35:37Z rdm $
// Author: Fons Rademakers   15/01/98

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TRootApplication                                                     //
//                                                                      //
// This class create the ROOT native GUI version of the ROOT            //
// application environment. This in contrast to the Win32 version.      //
// Once the native widgets work on Win32 this class can be folded into  //
// the TApplication class (since all graphic will go via TVirtualX).    //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TRootApplication.h"
#include "TSystem.h"
#include "TString.h"
#include "TGClient.h"
#include "TVirtualX.h"

ClassImp(TRootApplication)

//______________________________________________________________________________
TRootApplication::TRootApplication(const char *appClassName,
                                   Int_t *argc, char **argv)
{
   // Create ROOT application environment.
   
   fApplicationName = appClassName;
   fDisplay         = 0;

   GetOptions(argc, argv);

   if (!fDisplay)
      // Set DISPLAY based on utmp (only if DISPLAY is not yet set).
      gSystem->SetDisplay();

   fClient = new TGClient(fDisplay);

   if (fClient->IsZombie()) {
      delete fClient;
      fClient = 0;
   }
}

//______________________________________________________________________________
TRootApplication::~TRootApplication()
{
   // Delete ROOT application environment.

   delete [] fDisplay;
   delete fClient;
}

//______________________________________________________________________________
Bool_t TRootApplication::IsCmdThread()
{
   // By default (for UNIX) ROOT is a single thread application
   // For win32gdk returns kTRUE if it's called from inside of server/cmd thread

   return gVirtualX ? gVirtualX->IsCmdThread() : kTRUE;
}

//______________________________________________________________________________
void TRootApplication::GetOptions(Int_t *argc, char **argv)
{
   // Handle command line arguments. Arguments handled are removed from the
   // argument array. Currently only option "-display xserver" is considered.

   if (!argc) return;

   int i, j;
   for (i = 0; i < *argc; i++) {
      if (!strcmp(argv[i], "-display")) {
         if (argv[i+1] && strlen(argv[i+1]) && argv[i+1][0] != '-') {
            fDisplay  = StrDup(argv[i+1]);
            argv[i]   = 0;
            argv[i+1] = 0;
            i++;
         }
      }
   }

   j = 0;
   for (i = 0; i < *argc; i++) {
      if (argv[i]) {
         argv[j] = argv[i];
         j++;
      }
   }

   *argc = j;
}

 TRootApplication.cxx:1
 TRootApplication.cxx:2
 TRootApplication.cxx:3
 TRootApplication.cxx:4
 TRootApplication.cxx:5
 TRootApplication.cxx:6
 TRootApplication.cxx:7
 TRootApplication.cxx:8
 TRootApplication.cxx:9
 TRootApplication.cxx:10
 TRootApplication.cxx:11
 TRootApplication.cxx:12
 TRootApplication.cxx:13
 TRootApplication.cxx:14
 TRootApplication.cxx:15
 TRootApplication.cxx:16
 TRootApplication.cxx:17
 TRootApplication.cxx:18
 TRootApplication.cxx:19
 TRootApplication.cxx:20
 TRootApplication.cxx:21
 TRootApplication.cxx:22
 TRootApplication.cxx:23
 TRootApplication.cxx:24
 TRootApplication.cxx:25
 TRootApplication.cxx:26
 TRootApplication.cxx:27
 TRootApplication.cxx:28
 TRootApplication.cxx:29
 TRootApplication.cxx:30
 TRootApplication.cxx:31
 TRootApplication.cxx:32
 TRootApplication.cxx:33
 TRootApplication.cxx:34
 TRootApplication.cxx:35
 TRootApplication.cxx:36
 TRootApplication.cxx:37
 TRootApplication.cxx:38
 TRootApplication.cxx:39
 TRootApplication.cxx:40
 TRootApplication.cxx:41
 TRootApplication.cxx:42
 TRootApplication.cxx:43
 TRootApplication.cxx:44
 TRootApplication.cxx:45
 TRootApplication.cxx:46
 TRootApplication.cxx:47
 TRootApplication.cxx:48
 TRootApplication.cxx:49
 TRootApplication.cxx:50
 TRootApplication.cxx:51
 TRootApplication.cxx:52
 TRootApplication.cxx:53
 TRootApplication.cxx:54
 TRootApplication.cxx:55
 TRootApplication.cxx:56
 TRootApplication.cxx:57
 TRootApplication.cxx:58
 TRootApplication.cxx:59
 TRootApplication.cxx:60
 TRootApplication.cxx:61
 TRootApplication.cxx:62
 TRootApplication.cxx:63
 TRootApplication.cxx:64
 TRootApplication.cxx:65
 TRootApplication.cxx:66
 TRootApplication.cxx:67
 TRootApplication.cxx:68
 TRootApplication.cxx:69
 TRootApplication.cxx:70
 TRootApplication.cxx:71
 TRootApplication.cxx:72
 TRootApplication.cxx:73
 TRootApplication.cxx:74
 TRootApplication.cxx:75
 TRootApplication.cxx:76
 TRootApplication.cxx:77
 TRootApplication.cxx:78
 TRootApplication.cxx:79
 TRootApplication.cxx:80
 TRootApplication.cxx:81
 TRootApplication.cxx:82
 TRootApplication.cxx:83
 TRootApplication.cxx:84
 TRootApplication.cxx:85
 TRootApplication.cxx:86
 TRootApplication.cxx:87
 TRootApplication.cxx:88
 TRootApplication.cxx:89
 TRootApplication.cxx:90
 TRootApplication.cxx:91
 TRootApplication.cxx:92
 TRootApplication.cxx:93
 TRootApplication.cxx:94
 TRootApplication.cxx:95
 TRootApplication.cxx:96
 TRootApplication.cxx:97
 TRootApplication.cxx:98
 TRootApplication.cxx:99
 TRootApplication.cxx:100
 TRootApplication.cxx:101
 TRootApplication.cxx:102