Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TRootApplication.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 15/01/98
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12
13/** \class TRootApplication
14 \ingroup guiwidgets
15
16This class create the ROOT native GUI version of the ROOT
17application environment. This in contrast to the Win32 version.
18Once the native widgets work on Win32 this class can be folded into
19the TApplication class (since all graphic will go via TVirtualX).
20
21*/
22
23
24#include "TRootApplication.h"
25#include "TSystem.h"
26#include "TString.h"
27#include "TGClient.h"
28#include "TVirtualX.h"
29
31
32////////////////////////////////////////////////////////////////////////////////
33/// Create ROOT application environment.
34
35TRootApplication::TRootApplication(const char *appClassName,
36 Int_t *argc, char **argv)
37{
38 fApplicationName = appClassName;
39 fDisplay = 0;
40
41 GetOptions(argc, argv);
42
43 if (!fDisplay)
44 // Set DISPLAY based on utmp (only if DISPLAY is not yet set).
46
48
49 if (fClient->IsZombie()) {
50 delete fClient;
51 fClient = 0;
52 }
53}
54
55////////////////////////////////////////////////////////////////////////////////
56/// Delete ROOT application environment.
57
59{
60 delete [] fDisplay;
61 delete fClient;
62}
63
64////////////////////////////////////////////////////////////////////////////////
65/// By default (for UNIX) ROOT is a single thread application
66/// For win32gdk returns kTRUE if it's called from inside of server/cmd thread
67
69{
70 return gVirtualX ? gVirtualX->IsCmdThread() : kTRUE;
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// Handle command line arguments. Arguments handled are removed from the
75/// argument array. Currently only option "-display xserver" is considered.
76
77void TRootApplication::GetOptions(Int_t *argc, char **argv)
78{
79 if (!argc) return;
80
81 int i, j;
82 for (i = 0; i < *argc; i++) {
83 if (argv[i] && !strcmp(argv[i], "-display")) {
84 if (argv[i+1] && strlen(argv[i+1]) && argv[i+1][0] != '-') {
85 fDisplay = StrDup(argv[i+1]);
86 argv[i] = 0;
87 argv[i+1] = 0;
88 i++;
89 }
90 }
91 }
92
93 j = 0;
94 for (i = 0; i < *argc; i++) {
95 if (argv[i]) {
96 argv[j] = argv[i];
97 j++;
98 }
99 }
100
101 *argc = j;
102}
103
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2557
R__EXTERN TSystem * gSystem
Definition TSystem.h:560
#define gVirtualX
Definition TVirtualX.h:338
Window client.
Definition TGClient.h:37
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition TObject.h:153
This class create the ROOT native GUI version of the ROOT application environment.
Bool_t IsCmdThread() override
By default (for UNIX) ROOT is a single thread application For win32gdk returns kTRUE if it's called f...
void GetOptions(Int_t *argc, char **argv)
Handle command line arguments.
~TRootApplication() override
Delete ROOT application environment.
virtual void SetDisplay()
Set DISPLAY environment variable based on utmp entry. Only for UNIX.
Definition TSystem.cxx:235