Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions graf2d/asimage/inc/TASImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class TASImage : public TImage {

static ASVisual *fgVisual; ///< pointer to visual structure
static Bool_t fgInit; ///< global flag to init afterimage only once
static Bool_t fgBatch; ///< global flag to signal if batch mode is active ie fgVisual->dpy was set to nullptr

EImageFileTypes GetFileType(const char *ext);
void MapFileTypes(EImageFileTypes &type, UInt_t &astype, Bool_t toas = kTRUE);
Expand Down
44 changes: 16 additions & 28 deletions graf2d/asimage/src/TASImage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ extern "C" {

ASVisual *TASImage::fgVisual = nullptr;
Bool_t TASImage::fgInit = kFALSE;
Bool_t TASImage::fgBatch = kFALSE;

static ASFontManager *gFontManager = nullptr;
static unsigned long kAllPlanes = ~0;
Expand Down Expand Up @@ -2225,49 +2226,37 @@ void TASImage::GetZoomPosition(UInt_t &x, UInt_t &y, UInt_t &w, UInt_t &h) const

Bool_t TASImage::InitVisual()
{
Bool_t inbatch = fgVisual && (fgVisual->dpy == (void*)1); // was in batch
Bool_t noX = gROOT->IsBatch() || gVirtualX->InheritsFrom("TGWin32");
Bool_t noX = gROOT->IsBatch() || !gVirtualX->InheritsFrom("TGX11");

// was in batch, but switched to gui
if (inbatch && !noX) {
destroy_asvisual(fgVisual, kFALSE);
fgVisual = nullptr;
}

if (fgVisual && fgVisual->dpy) { // already initialized
if (fgVisual && (noX == fgBatch))
return kTRUE;
}

// batch or win32 mode
if (!fgVisual && noX) {
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
fgVisual->dpy = (Display*)1; //fake (not used)
return kTRUE;
}
if (fgVisual)
destroy_asvisual(fgVisual, kFALSE);
fgVisual = nullptr;
fgBatch = false;

#ifndef WIN32
#ifdef R__HAS_COCOA
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
fgVisual->dpy = (Display*)1; //fake (not used)
#else
#ifndef R__HAS_COCOA
Display *disp = (Display*) gVirtualX->GetDisplay();
Int_t screen = gVirtualX->GetScreen();
Int_t depth = gVirtualX->GetDepth();
Visual *vis = (Visual*) gVirtualX->GetVisual();
Colormap cmap = (Colormap) gVirtualX->GetColormap();

if (!vis || cmap == 0) {
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
} else {
if (vis && cmap)
fgVisual = create_asvisual_for_id(disp, screen, depth,
XVisualIDFromVisual(vis), cmap, nullptr);
}
#endif
#else
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
fgVisual->dpy = (Display*)1; //fake (not used)
#endif

if (!fgVisual) {
// create dummy fgVisual for batch mode
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
fgVisual->dpy = nullptr; // fake (not used)
fgBatch = true;
}

return kTRUE;
}

Expand Down Expand Up @@ -6753,4 +6742,3 @@ Int_t TASImage::Idx(Int_t idx)
// The size of arrays like fImage->alt.argb32 is fImage->width*fImage->height
return TMath::Min(idx,(Int_t)(fImage->width*fImage->height));
}

Loading