From 25100019cdafbcdd5ff2fabceb2340130ab4a9f0 Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Tue, 8 Jul 2003 15:42:25 +0000
Subject: [PATCH] mods needed by Valeri to support his TGQt class.

git-svn-id: http://root.cern.ch/svn/root/trunk@6859 27541ba8-7e3a-0410-8455-c3a389f83636
---
 base/inc/TVirtualX.h      |  4 ++-
 base/src/TApplication.cxx | 12 +++++---
 config/Makefile.in        |  4 +++
 config/rootrc.in          |  8 +++--
 configure                 | 46 ++++++++++++++++++++++-----
 gpad/inc/TCanvas.h        |  7 +++--
 gpad/src/TCanvas.cxx      | 65 +++++++++++++++++++++------------------
 gpad/src/TPad.cxx         | 22 ++++++++-----
 8 files changed, 113 insertions(+), 55 deletions(-)

diff --git a/base/inc/TVirtualX.h b/base/inc/TVirtualX.h
index 4e4ec31e96e..34a8a7a18d6 100644
--- a/base/inc/TVirtualX.h
+++ b/base/inc/TVirtualX.h
@@ -1,4 +1,4 @@
-// @(#)root/base:$Name:  $:$Id: TVirtualX.h,v 1.18 2003/02/11 12:29:06 rdm Exp $
+// @(#)root/base:$Name:  $:$Id: TVirtualX.h,v 1.19 2003/02/17 18:33:14 brun Exp $
 // Author: Fons Rademakers   3/12/95
 
 /*************************************************************************
@@ -117,6 +117,7 @@ public:
    virtual Int_t     ResizePixmap(Int_t wid, UInt_t w, UInt_t h);
    virtual void      ResizeWindow(Int_t wid);
    virtual void      SelectWindow(Int_t wid);
+   virtual void      SelectPixmap(Int_t qpixid);
    virtual void      SetCharacterUp(Float_t chupx, Float_t chupy);
    virtual void      SetClipOFF(Int_t wid);
    virtual void      SetClipRegion(Int_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h);
@@ -383,6 +384,7 @@ inline void      TVirtualX::RescaleWindow(Int_t, UInt_t, UInt_t) { }
 inline Int_t     TVirtualX::ResizePixmap(Int_t, UInt_t, UInt_t) { return 0; }
 inline void      TVirtualX::ResizeWindow(Int_t) { }
 inline void      TVirtualX::SelectWindow(Int_t) { }
+inline void      TVirtualX::SelectPixmap(Int_t) { }
 inline void      TVirtualX::SetCharacterUp(Float_t, Float_t) { }
 inline void      TVirtualX::SetClipOFF(Int_t) { }
 inline void      TVirtualX::SetClipRegion(Int_t, Int_t, Int_t, UInt_t, UInt_t) { }
diff --git a/base/src/TApplication.cxx b/base/src/TApplication.cxx
index 2601b6a44db..f7595e3cfe3 100644
--- a/base/src/TApplication.cxx
+++ b/base/src/TApplication.cxx
@@ -1,4 +1,4 @@
-// @(#)root/base:$Name:  $:$Id: TApplication.cxx,v 1.45 2003/03/10 14:57:11 rdm Exp $
+// @(#)root/base:$Name:  $:$Id: TApplication.cxx,v 1.46 2003/07/07 14:51:45 rdm Exp $
 // Author: Fons Rademakers   22/12/95
 
 /*************************************************************************
@@ -535,16 +535,20 @@ void TApplication::LoadGraphicsLibs()
    if (guiBackend == "native") {
       guiBackend = nativex;
    } else {
-      name   = guiBackend;
-      title  = title1 + guiBackend;
+      name  = guiBackend;
+      title = title1 + guiBackend;
    }
+   TString guiFactory(gEnv->GetValue("Gui.Factory", "native"));
+   guiFactory.ToLower();
+   if (guiFactory == "native")
+      guiFactory = nativeg;
 
    if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualX", guiBackend))) {
       if (h->LoadPlugin() == -1)
          return;
       gVirtualX = (TVirtualX *) h->ExecPlugin(2, name.Data(), title.Data());
    }
-   if ((h = gROOT->GetPluginManager()->FindHandler("TGuiFactory", nativeg))) {
+   if ((h = gROOT->GetPluginManager()->FindHandler("TGuiFactory", guiFactory))) {
       if (h->LoadPlugin() == -1)
          return;
       gGuiFactory = (TGuiFactory *) h->ExecPlugin(0);
diff --git a/config/Makefile.in b/config/Makefile.in
index 28e851b4726..8ec10ceb921 100644
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -68,6 +68,10 @@ SAPDBLIBDIR    := @sapdblibdir@
 SAPDBCLILIB    := @sapdblib@
 SAPDBINCDIR    := @sapdbincdir@
 
+QTLIBDIR       := @qtlibdir@
+QTLIB          := @qtlib@
+QTINCDIR       := @qtincdir@
+
 SHIFTLIBDIR    := @shiftlibdir@
 SHIFTLIB       := @shiftlib@
 
diff --git a/config/rootrc.in b/config/rootrc.in
index f9b59aa6a6b..9905a6bd862 100644
--- a/config/rootrc.in
+++ b/config/rootrc.in
@@ -1,4 +1,4 @@
-# @(#)root/config:$Name:  $:$Id: rootrc.in,v 1.49 2003/06/27 11:02:34 rdm Exp $
+# @(#)root/config:$Name:  $:$Id: rootrc.in,v 1.50 2003/06/29 15:44:30 rdm Exp $
 # Author: Fons Rademakers  22/09/95
 
 # ROOT Environment settings are handled via the class TEnv. To see
@@ -94,6 +94,7 @@ WinNT.*.Root.Html.SourceDir: .;src;include
 
 # GUI specific settings
 Gui.Backend:                native
+Gui.Factory:                native
 Unix.*.Gui.DefaultFont:     -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1
 Unix.*.Gui.MenuFont:        -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1
 Unix.*.Gui.MenuHiFont:      -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1
@@ -172,7 +173,8 @@ Plugin.TVirtualFitter:  Minuit TFitter       Minuit       "TFitter(Int_t)"
 +Plugin.TVirtualFitter: Fumili TFumili       Fumili       "TFumili(Int_t)"
 Plugin.TVirtualPS:      ps     TPostScript   Postscript   "TPostScript()"
 +Plugin.TVirtualPS:     svg    TSVG          Postscript   "TSVG()"
-Plugin.TViewerX3D:          *  TViewerX3D    X3d          "TViewerX3D(TVirtualPad*,Option_t*,const char*,UInt_t,UInt_t)"
+Plugin.TViewerX3D:      x11    TViewerX3D    X3d          "TViewerX3D(TVirtualPad*,Option_t*,const char*,UInt_t,UInt_t)"
++Plugin.TViewerX3D:     qt     TQtViewerX3D  X3dQt        "TQtViewerX3D(TVirtualPad*,Option_t*,const char*,UInt_t,UInt_t)"
 Plugin.TMinuitGraph:        *  TGraph        Graf         "TGraph(Int_t,const Double_t*,const Double_t*)"
 Plugin.TPaletteEditor:      *  TASPaletteEditor  ASImage  "TASPaletteEditor(TAttImage*,UInt_t,UInt_t)"
 Plugin.TImage:              *  TASImage          ASImage  "TASImage()"
@@ -181,8 +183,10 @@ Plugin.TVirtualX:    x11       TGX11         GX11         "TGX11(const char*,con
 +Plugin.TVirtualX:   x11ttf    TGX11TTF      GX11TTF      "TGX11TTF()"
 +Plugin.TVirtualX:   win32     TGWin32       Win32        "TGWin32(const char*,const char*)"
 +Plugin.TVirtualX:   win32gdk  TGWin32       Win32gdk     "TGWin32(const char*,const char*)"
++Plugin.TVirtualX:   qt        TGQt          GQt          "TGQt(const char*,const char*)"
 Plugin.TGuiFactory:  root      TRootGuiFactory Gui        "TRootGuiFactory()"
 +Plugin.TGuiFactory: win32     TWin32GuiFactory Win32     "TWin32GuiFactory()"
++Plugin.TGuiFactory: qt        TQtGuiFactory GuiQt        "TQtGuiFactory()"
 Plugin.TVirtualProof:        * TProof        Proof        "TProof(const char*,const char*,const char*,Int_t)"
 Plugin.TProofProgressDialog: * TProofProgressDialog ProofGui  "TProofProgressDialog(TVirtualProof*,const char*,Int_t,Long64_t,Long64_t)"
 
diff --git a/configure b/configure
index e6051cbe598..5e350ca663d 100755
--- a/configure
+++ b/configure
@@ -33,6 +33,7 @@ enable_openiv=yes
 enable_pgsql=yes
 enable_pythia=yes
 enable_pythia6=yes
+enable_qt=yes
 enable_rfio=yes
 enable_rpath=no
 enable_sapdb=yes
@@ -48,9 +49,9 @@ enable_explicitlink=no
 show_pkglist=no
 
 options="enable_afs enable_cern enable_mysql enable_opengl enable_pgsql \
-         enable_pythia enable_pythia6 enable_rfio enable_dcache enable_rpath \
-         enable_sapdb enable_shadowpw enable_shared enable_soversion \
-         enable_srp enable_table enable_thread enable_venus \
+         enable_pythia enable_pythia6 enable_qt enable_rfio enable_dcache \
+         enable_rpath enable_sapdb enable_shadowpw enable_shared \
+         enable_soversion enable_srp enable_table enable_thread enable_venus \
          enable_krb5 enable_ldap enable_exceptions enable_openiv enable_alien \
          enable_asimage enable_chirp enable_explicitlink"
 
@@ -519,6 +520,8 @@ if test $# -gt 0 ; then
       --with-pgsql-libdir=*)   pgsqllibdir=$optarg   ; enable_pgsql="yes"   ;;
       --with-pythia-libdir=*)  pythialibdir=$optarg  ; enable_pythia="yes"  ;;
       --with-pythia6-libdir=*) pythia6libdir=$optarg ; enable_pythia6="yes" ;;
+      --with-qt-incdir=*)      qtincdir=$optarg      ; enable_qt="yes"      ;;
+      --with-qt-libdir=*)      qtlibdir=$optarg      ; enable_qt="yes"      ;;
       --with-sapdb-incdir=*)   sapdbincdir=$optarg   ; enable_sapdb="yes"   ;;
       --with-sapdb-libdir=*)   sapdblibdir=$optarg   ; enable_sapdb="yes"   ;;
       --with-shift-libdir=*)   shiftlibdir=$optarg   ; enable_rfio="yes"    ;;
@@ -823,7 +826,7 @@ fi
 # MySQL at all.
 #
 if test ! "x$enable_mysql" = "xno"; then
-# Check for MySQL include and library
+    # Check for MySQL include and library
     check_header "mysql.h" "$mysqlincdir" \
 	$MYSQL $MYSQL/include /usr/local/include /usr/local/include/mysql \
         /usr/local/mysql /usr/local/mysql/include /opt/mysql \
@@ -862,7 +865,7 @@ fi
 # PostgreSQL at all.
 #
 if test ! "x$enable_pgsql" = "xno"; then
-# Check for PgSQL include and library
+    # Check for PgSQL include and library
     check_header "libpq-fe.h" "$pgsqlincdir" $PGSQL $PGSQL/include \
 	/usr/include /usr/local/include /usr/local/pgsql/include \
         /usr/include/pgsql /usr/include/postgresql /usr/pgsql/include \
@@ -883,6 +886,32 @@ if test ! "x$enable_pgsql" = "xno"; then
     fi
 fi
 
+######################################################################
+#
+### echo %%% Qt Support - Optional alternative graphics backend
+#
+# If the user has set the flags "--disable-qt", we don't check for
+# Qt at all.
+#
+if test ! "x$enable_qt" = "xno"; then
+    # Check for Qt include and library
+    check_header "qt.h" "$qtincdir" $QTDIR $QTDIR/include \
+        /usr/local/include  /usr/local/qt/include /usr/include \
+        /usr/include/qt
+    qtinc=$found_hdr
+    qtincdir=$found_dir
+
+    check_library "libqt-mt libqt" "$enable_shared" "$qtlibdir" \
+        $QTDIR $QTDIR/lib /usr/local/lib /usr/local/qt/lib \
+        /usr/lib /usr/qt/lib
+    qtlib=$found_lib
+    qtlibdir=$found_dir
+
+    if test "x$qtincdir" = "x" || test "x$qtlib" = "x"; then
+        enable_qt="no"
+    fi
+fi
+
 ######################################################################
 #
 ### echo %%% SapDB Support - Third party libraries
@@ -893,7 +922,7 @@ fi
 # SapDB at all.
 #
 if test ! "x$enable_sapdb" = "xno"; then
-# Check for SapDB include and library
+    # Check for SapDB include and library
     check_header "sql.h" "$sapdbincdir" $SAPDB $SAPDB/include \
 	/opt/sapdb/interfaces/odbc/incl /usr/sapdb/interfaces/odbc/incl \
 	/usr/sapdb/include /usr/local/sapdb/interfaces/odbc/incl \
@@ -1199,7 +1228,7 @@ fi
 # LDAP at all.
 #
 if test ! "x$enable_ldap" = "xno"; then
-# Check for ldap include and library
+    # Check for ldap include and library
     check_header "ldap.h" "$ldapincdir" $LDAP $LDAP/include \
 	/usr/include /usr/local/include /usr/local/ldap/include \
         /usr/include/ldap /usr/include/openldap /usr/ldap/include \
@@ -1736,6 +1765,9 @@ sed \
     -e "s|@pythia6libdir@|$pythia6libdir|"      \
     -e "s|@pythialib@|$pythialib|"              \
     -e "s|@pythialibdir@|$pythialibdir|"        \
+    -e "s|@qtincdir@|$qtincdir|"                \
+    -e "s|@qtlib@|$qtlib|"                      \
+    -e "s|@qtlibdir@|$qtlibdir|"                \
     -e "s|@rootbuild@|$rootbuild|"              \
     -e "s|@sapdbincdir@|$sapdbincdir|"          \
     -e "s|@sapdblib@|$sapdblib|"                \
diff --git a/gpad/inc/TCanvas.h b/gpad/inc/TCanvas.h
index 5b06832264a..7f2d1625654 100644
--- a/gpad/inc/TCanvas.h
+++ b/gpad/inc/TCanvas.h
@@ -1,4 +1,4 @@
-// @(#)root/gpad:$Name:  $:$Id: TCanvas.h,v 1.18 2003/02/01 17:35:07 brun Exp $
+// @(#)root/gpad:$Name:  $:$Id: TCanvas.h,v 1.19 2003/04/04 17:06:07 brun Exp $
 // Author: Rene Brun   12/12/94
 
 /*************************************************************************
@@ -84,14 +84,15 @@ protected:
    Bool_t        fResizeOpaque;    //Resize objects in opaque mode
    Bool_t        fMenuBar;         //False if no menubar is displayed
    static Bool_t fgIsFolder;       //Indicates if canvas can be browsed as a folder
-   
+
 private:
-   TCanvas(const TCanvas &canvas);  // cannot copy canvas, use TObject::Clone
+   TCanvas(const TCanvas &canvas);  // cannot copy canvas, use TObject::Clone()
    TCanvas &operator=(const TCanvas &rhs);  // idem
    void     Build();
    void     CopyPixmaps();
    void     DrawEventStatus(Int_t event, Int_t x, Int_t y, TObject *selected);
    void     RunAutoExec();
+   void     DisconnectWidget();  // used by TCanvasImp
 
 protected:
    virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
diff --git a/gpad/src/TCanvas.cxx b/gpad/src/TCanvas.cxx
index 733aa17e945..5d38c628555 100644
--- a/gpad/src/TCanvas.cxx
+++ b/gpad/src/TCanvas.cxx
@@ -1,4 +1,4 @@
-// @(#)root/gpad:$Name:  $:$Id: TCanvas.cxx,v 1.43 2003/04/04 17:06:07 brun Exp $
+// @(#)root/gpad:$Name:  $:$Id: TCanvas.cxx,v 1.44 2003/05/15 12:12:33 brun Exp $
 // Author: Rene Brun   12/12/94
 
 /*************************************************************************
@@ -249,12 +249,14 @@ void TCanvas::Constructor(const char *name, const char *title, Int_t form)
       if (form == 4) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 40, 40, UInt_t(cx*500), UInt_t(cx*500));
       if (form == 5) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 50, 50, UInt_t(cx*500), UInt_t(cx*500));
       fCanvasImp->ShowMenuBar(fMenuBar);
-      fCanvasImp->Show();
       fBatch = kFALSE;
    }
    SetName(name);
    SetTitle(title); // requires fCanvasImp set
    Build();
+
+   // Popup canvas
+   fCanvasImp->Show();
 }
 
 //_____________________________________________________________________________
@@ -307,12 +309,14 @@ void TCanvas::Constructor(const char *name, const char *title, Int_t ww, Int_t w
       Float_t cx = gStyle->GetScreenFactor();
       fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, UInt_t(cx*ww), UInt_t(cx*wh));
       fCanvasImp->ShowMenuBar(fMenuBar);
-      fCanvasImp->Show();
       fBatch = kFALSE;
    }
    SetName(name);
    SetTitle(title); // requires fCanvasImp set
    Build();
+
+   // Popup canvas
+   fCanvasImp->Show();
 }
 
 //_____________________________________________________________________________
@@ -370,12 +374,14 @@ void TCanvas::Constructor(const char *name, const char *title, Int_t wtopx,
       Float_t cx = gStyle->GetScreenFactor();
       fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, Int_t(cx*wtopx), Int_t(cx*wtopy), UInt_t(cx*ww), UInt_t(cx*wh));
       fCanvasImp->ShowMenuBar(fMenuBar);
-      fCanvasImp->Show();
       fBatch = kFALSE;
    }
    SetName(name);
    SetTitle(title); // requires fCanvasImp set
    Build();
+
+   // Popup canvas
+   fCanvasImp->Show();
 }
 
 //_____________________________________________________________________________
@@ -422,16 +428,7 @@ void TCanvas::Build()
    // Get window identifier
    if (fCanvasID == -1 && fCanvasImp)
       fCanvasID = fCanvasImp->InitWindow();
-#ifndef WIN32
    if (fCanvasID < 0) return;
-#else
-#ifndef GDK_WIN32
-   // fCanvasID is in fact a pointer to the TGWin32 class
-   if (fCanvasID  == -1) return;
-#else
-   if (fCanvasID < 0) return;
-#endif
-#endif
 
    if (fCw < fCh) fXsizeReal = fYsizeReal*Float_t(fCw)/Float_t(fCh);
    else           fYsizeReal = fXsizeReal*Float_t(fCh)/Float_t(fCw);
@@ -488,14 +485,14 @@ void TCanvas::Build()
       SetBorderMode(gStyle->GetCanvasBorderMode());
       fBorderMode=gStyle->GetCanvasBorderMode(); // do not call SetBorderMode (function redefined in TCanvas)
       SetPad(0, 0, 1, 1);
-      Range(0, 0, 1, 1);   //Pad range is set by default to [0,1] in x and y
-      PaintBorder(GetFillColor(), kTRUE);    //Paint background
+      Range(0, 0, 1, 1);   //pad range is set by default to [0,1] in x and y
+      gVirtualX->SelectPixmap(fPixmapID);    //pixmap must be selected
+      PaintBorder(GetFillColor(), kTRUE);    //paint background
    }
 
-#ifdef WIN32
-#ifndef GDK_WIN32
-   gVirtualX->UpdateWindow(1);
-#endif
+#if defined(WIN32) && !defined(GDK_WIN32)
+   if (!strcmp(gVirtualX->GetName(), "Win32"))
+      gVirtualX->UpdateWindow(1);
 #endif
 }
 
@@ -645,9 +642,9 @@ void TCanvas::Draw(Option_t *)
    if (old == this) {
       Paint();
       return;
-   } 
+   }
    if (old) { gROOT->GetListOfCanvases()->Remove(old); delete old;}
-     
+
    if (fWindowWidth  == 0) fWindowWidth  = 800;
    if (fWindowHeight == 0) fWindowHeight = 600;
    fCanvasImp = gGuiFactory->CreateCanvasImp(this, GetName(), fWindowTopX, fWindowTopY,
@@ -1130,7 +1127,7 @@ void TCanvas::HandleInput(EEventType event, Int_t px, Int_t py)
 }
 
 //______________________________________________________________________________
-Bool_t TCanvas::IsFolder() const 
+Bool_t TCanvas::IsFolder() const
 {
    return fgIsFolder;
 }
@@ -1147,7 +1144,6 @@ void TCanvas::ls(Option_t *option) const
    TROOT::DecreaseDirLevel();
 }
 
-
 //______________________________________________________________________________
 void TCanvas::MakeDefCanvas()
 {
@@ -1478,24 +1474,24 @@ void TCanvas::SetDoubleBuffer(Int_t mode)
 {
 //*-*-*-*-*-*-*-*-*-*-*Set Double Buffer On/Off*-*-**-*-*-*-*-*-*-*-*-*-*-*-*
 //*-*                  ========================
+
    if (IsBatch()) return;
    fDoubleBuffer = mode;
    gVirtualX->SetDoubleBuffer(fCanvasID, mode);
 
    // depending of the buffer mode set the drawing window to either
    // the canvas pixmap or to the canvas on-screen window
-#ifndef WIN32
+#if !defined(WIN32) || defined(GDK_WIN32)
    if (fDoubleBuffer)
       gVirtualX->SelectWindow(fPixmapID);
    else
+      gVirtualX->SelectWindow(fCanvasID);
 #else
-#ifdef GDK_WIN32
-   if (fDoubleBuffer)
+   if (fDoubleBuffer && strcmp(gVirtualX->GetName(), "Win32"))
       gVirtualX->SelectWindow(fPixmapID);
    else
-#endif
-#endif
       gVirtualX->SelectWindow(fCanvasID);
+#endif
 }
 
 //______________________________________________________________________________
@@ -1520,11 +1516,11 @@ void TCanvas::SetFixedAspectRatio(Bool_t fixed)
 }
 
 //______________________________________________________________________________
-void TCanvas::SetFolder(Bool_t isfolder) 
+void TCanvas::SetFolder(Bool_t isfolder)
 {
 // if isfolder=kTRUE, the canvas can be browsed like a folder
 // by default a canvas is not browsable
-   
+
    fgIsFolder = isfolder;
 }
 
@@ -1685,3 +1681,12 @@ void TCanvas::Update()
 
    SetCursor(kCross);
 }
+
+//______________________________________________________________________________
+void TCanvas::DisconnectWidget()
+{
+   // Used by friend class TCanvasImp.
+
+   fCanvasID    = 0;
+   fContextMenu = 0;
+}
diff --git a/gpad/src/TPad.cxx b/gpad/src/TPad.cxx
index 39bb9f310fe..8e2bbce2fd1 100644
--- a/gpad/src/TPad.cxx
+++ b/gpad/src/TPad.cxx
@@ -1,4 +1,4 @@
-// @(#)root/gpad:$Name:  $:$Id: TPad.cxx,v 1.103 2003/05/23 14:46:53 brun Exp $
+// @(#)root/gpad:$Name:  $:$Id: TPad.cxx,v 1.104 2003/06/17 08:40:39 brun Exp $
 // Author: Rene Brun   12/12/94
 
 /*************************************************************************
@@ -58,6 +58,7 @@
 #include "TAttMarkerCanvas.h"
 #include "TAttTextCanvas.h"
 #include "TPluginManager.h"
+#include "TEnv.h"
 
 // Local scratch buffer for screen points, faster than allocating buffer on heap
 const Int_t kPXY       = 1002;
@@ -3654,14 +3655,14 @@ void TPad::Print(const char *filename, Option_t *option)
 //  being atomic with printing a page.  Particularly if pages are being
 //  generated in some loop one needs to detect the special cases of first
 //  and last page and then munge the argument to Print() accordingly.
-//  
+//
 //  The "[" and "]" can be used instead of "(" and ")".  Example:
-//  
-//    c1.Print("file.ps[");   // No actual print, just open file.ps 
+//
+//    c1.Print("file.ps[");   // No actual print, just open file.ps
 //    for (int i=0; i<10; ++i) {
 //      // fill canvas for context i
 //      // ...
-//  
+//
 //      c1.Print("file.ps");  // actually print canvas to file
 //    }// end loop
 //    c1.Print("file.ps]");   // No actual print, just close.
@@ -4133,8 +4134,8 @@ void TPad::ResizePad(Option_t *option)
          cd();
          fView->ResizePad();
          padsav->cd();
-      }   
-   }   
+      }
+   }
 }
 
 
@@ -5101,8 +5102,13 @@ void TPad::x3d(Option_t *option)
    }
 
 #ifndef WIN32
+      TString guiBackend(gEnv->GetValue("Gui.Backend", "native"));
+      guiBackend.ToLower();
+      if (guiBackend == "native")
+         guiBackend = "x11";
+
       TPluginHandler *h;
-      if ((h = gROOT->GetPluginManager()->FindHandler("TViewerX3D"))) {
+      if ((h = gROOT->GetPluginManager()->FindHandler("TViewerX3D", guiBackend))) {
          if (h->LoadPlugin() == -1)
             return;
          h->ExecPlugin(5,this,option,"X3D Viewer",800,600);
-- 
GitLab