<commit_before>// @(#)root/gui:$Id$
// Author: <NAME>   27/12/97

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

    This source is based on Xclass95, a Win95-looking GUI toolkit.
    Copyright (C) 1996, 1997 <NAME>, <NAME>, <NAME>.

    Xclass95 is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

**************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGClient                                                             //
//                                                                      //
// Window client. In client server windowing systems, like X11 this     //
// class is used to make the initial connection to the window server.   //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "RConfigure.h"

#include "TGClient.h"
#include "TROOT.h"
#include "TApplication.h"
#include "TSystem.h"
#include "TEnv.h"
#include "THashList.h"
#include "TSysEvtHandler.h"
#include "TVirtualX.h"
#include "TGWindow.h"
#include "TGResourcePool.h"
#include "TGGC.h"
#include "TGFont.h"
#include "TGMimeTypes.h"
#include "TGFrame.h"
#include "TGIdleHandler.h"
#include "TError.h"
#include "TGlobal.h"

// Global pointer to the TGClient object
static TGClient *gClientGlobal = 0;

namespace {
static struct AddPseudoGlobals {
AddPseudoGlobals() {
   // User "gCling" as synonym for "libCore static initialization has happened".
   // This code here must not trigger it
   // FIXME: TGClient::Instance() should return reference
   // TGlobalMappedFunction::MakeFunctor("gClient", "TGClient*", TGClient::Instance);
   TGlobalMappedFunction::Add(new TGlobalMappedFunction(
      "gClient", "TGClient*", (TGlobalMappedFunction::GlobalFunc_t)((void *)&TGClient::Instance)));
}
} gAddPseudoGlobals;
}

// Initialize gClient in case libGui is loaded in batch mode
void TriggerDictionaryInitialization_libGui();
class TGClientInit {
public:
   TGClientInit() {
      TROOT *rootlocal = ROOT::Internal::gROOTLocal;
      if (rootlocal && rootlocal->IsBatch()) {
         // For now check if the heaeder files (or the module containing them)
         // has been loaded in Cling.
         // This is required because the dictionaries must be initialized
         // __before__ the TGClient creation which will induce the creation
         // of a TClass object which will need the dictionary for TGClient!
         TriggerDictionaryInitialization_libGui();
         new TGClient();
      }
      TApplication::NeedGraphicsLibs();
   }
};
static TGClientInit gClientInit;

////////////////////////////////////////////////////////////////////////////////
/// Returns global gClient (initialize graphics first, if not already done)<commit_msg>meta: use functor for providing gClient<commit_after>// @(#)root/gui:$Id$
// Author: <NAME>   27/12/97

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

    This source is based on Xclass95, a Win95-looking GUI toolkit.
    Copyright (C) 1996, 1997 <NAME>, <NAME>, <NAME>.

    Xclass95 is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

**************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGClient                                                             //
//                                                                      //
// Window client. In client server windowing systems, like X11 this     //
// class is used to make the initial connection to the window server.   //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "RConfigure.h"

#include "TGClient.h"
#include "TROOT.h"
#include "TApplication.h"
#include "TSystem.h"
#include "TEnv.h"
#include "THashList.h"
#include "TSysEvtHandler.h"
#include "TVirtualX.h"
#include "TGWindow.h"
#include "TGResourcePool.h"
#include "TGGC.h"
#include "TGFont.h"
#include "TGMimeTypes.h"
#include "TGFrame.h"
#include "TGIdleHandler.h"
#include "TError.h"
#include "TGlobal.h"

// Global pointer to the TGClient object
static TGClient *gClientGlobal = nullptr;

namespace {
static struct AddPseudoGlobals {
AddPseudoGlobals() {
   // User "gCling" as synonym for "libCore static initialization has happened".
   // This code here must not trigger it
   TGlobalMappedFunction::MakeFunctor("gClient", "TGClient*", TGClient::Instance, [] {
      TGClient::Instance(); // first ensure object is created;
      return (void *) gClientGlobal;
   });
}
} gAddPseudoGlobals;
}

// Initialize gClient in case libGui is loaded in batch mode
void TriggerDictionaryInitialization_libGui();
class TGClientInit {
public:
   TGClientInit() {
      TROOT *rootlocal = ROOT::Internal::gROOTLocal;
      if (rootlocal && rootlocal->IsBatch()) {
         // For now check if the heaeder files (or the module containing them)
         // has been loaded in Cling.
         // This is required because the dictionaries must be initialized
         // __before__ the TGClient creation which will induce the creation
         // of a TClass object which will need the dictionary for TGClient!
         TriggerDictionaryInitialization_libGui();
         new TGClient();
      }
      TApplication::NeedGraphicsLibs();
   }
};
static TGClientInit gClientInit;

////////////////////////////////////////////////////////////////////////////////
/// Returns global gClient (initialize graphics first, if not already done)
{'fraction_non_alphanumeric': 0.22672568820030434, 'fraction_numerical': 0.008714898326186195, 'mean_word_length': 1.8713264495631454, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4705156', 'n_tokens_mistral': 1762, 'n_tokens_neox': 1637, 'n_words': 554}