Skip to content
Draft
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
13 changes: 9 additions & 4 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,13 +2226,14 @@ 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 inbatch = fgVisual && fgBatch; // was in batch
Bool_t noX = gROOT->IsBatch() || gVirtualX->InheritsFrom("TGWin32");

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

if (fgVisual && fgVisual->dpy) { // already initialized
Expand All @@ -2241,14 +2243,16 @@ Bool_t TASImage::InitVisual()
// batch or win32 mode
if (!fgVisual && noX) {
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
fgVisual->dpy = (Display*)1; //fake (not used)
fgVisual->dpy = nullptr; // fake (not used)
fgBatch = true;
return kTRUE;
}

#ifndef WIN32
#ifdef R__HAS_COCOA
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
fgVisual->dpy = (Display*)1; //fake (not used)
fgVisual->dpy = nullptr; // fake (not used)
fgBatch = true;
#else
Display *disp = (Display*) gVirtualX->GetDisplay();
Int_t screen = gVirtualX->GetScreen();
Expand All @@ -2265,7 +2269,8 @@ Bool_t TASImage::InitVisual()
#endif
#else
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
fgVisual->dpy = (Display*)1; //fake (not used)
fgVisual->dpy = nullptr; // fake (not used)
fgBatch = true;
#endif

return kTRUE;
Expand Down
6 changes: 3 additions & 3 deletions gui/gui/src/TGButton.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1229,8 +1229,8 @@ TGCheckButton::~TGCheckButton()

TGDimension TGCheckButton::GetDefaultSize() const
{
UInt_t w = !fTWidth ? fOff->GetWidth() : fTWidth + fOff->GetWidth() + 9;
UInt_t h = !fTHeight ? fOff->GetHeight() : fTHeight + 2;
UInt_t w = !fTWidth ? (fOff ? fOff->GetWidth() : 9) : fTWidth + (fOff ? fOff->GetWidth() : 9) + 9;
UInt_t h = !fTHeight ? (fOff ? fOff->GetHeight() : 2) : fTHeight + 2;

w = GetOptions() & kFixedWidth ? fWidth : w;
h = GetOptions() & kFixedHeight ? fHeight : h;
Expand Down Expand Up @@ -1593,7 +1593,7 @@ TGRadioButton::~TGRadioButton()

TGDimension TGRadioButton::GetDefaultSize() const
{
UInt_t w = !fTWidth ? ( fOff?fOff->GetWidth():10) : fTWidth + fOff->GetWidth() + 10;
UInt_t w = !fTWidth ? (fOff ? fOff->GetWidth() : 10) : fTWidth + (fOff ? fOff->GetWidth() : 10) + 10;
UInt_t h = !fTHeight ? ( fOff?fOff->GetHeight():2) : fTHeight + 2;

w = GetOptions() & kFixedWidth ? fWidth : w;
Expand Down
31 changes: 20 additions & 11 deletions gui/gui/src/TGGC.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ TGGC::TGGC(GCValues_t *values, Bool_t)
fContext = 0;
if (values) {
fValues = *values;
fContext = gVirtualX->CreateGC(gVirtualX->GetDefaultRootWindow(), values);
if (gVirtualX)
fContext = gVirtualX->CreateGC(gVirtualX->GetDefaultRootWindow(), values);
if (values->fMask & kGCDashList) {
if (values->fDashLen > (Int_t)sizeof(fValues.fDashes))
Warning("TGGC", "dash list can have only up to %ld elements",
(Long_t)sizeof(fValues.fDashes));
fValues.fDashLen = std::min(values->fDashLen, (Int_t)sizeof(fValues.fDashes));
gVirtualX->SetDashes(fContext, fValues.fDashOffset, fValues.fDashes,
fValues.fDashLen);
if (gVirtualX)
gVirtualX->SetDashes(fContext, fValues.fDashOffset, fValues.fDashes, fValues.fDashLen);
}
} else {
fValues = {};
Expand Down Expand Up @@ -83,7 +84,7 @@ TGGC::TGGC(GCValues_t *values)
TGGC::TGGC(const TGGC &g) : TObject(g), TRefCnt()
{
fValues = g.fValues;
if (g.fContext) {
if (g.fContext && gVirtualX) {
fContext = gVirtualX->CreateGC(gVirtualX->GetDefaultRootWindow(), &fValues);
if (fValues.fMask & kGCDashList)
gVirtualX->SetDashes(fContext, fValues.fDashOffset, fValues.fDashes,
Expand All @@ -105,7 +106,8 @@ TGGC::~TGGC()
gClient->GetGCPool()->ForceFreeGC(this);

if (fContext)
gVirtualX->DeleteGC(fContext);
if (gVirtualX)
gVirtualX->DeleteGC(fContext);
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -119,14 +121,17 @@ TGGC &TGGC::operator=(const TGGC &rhs)
if (!gc)
gClient->GetGCPool()->fList->Add(this);
}
if (fContext)
if (fContext && gVirtualX)
gVirtualX->DeleteGC(fContext);
TObject::operator=(rhs);
fValues = rhs.fValues;
fContext = gVirtualX->CreateGC(gVirtualX->GetDefaultRootWindow(), &fValues);
if (fValues.fMask & kGCDashList)
gVirtualX->SetDashes(fContext, fValues.fDashOffset, fValues.fDashes,
fValues.fDashLen);
if (gVirtualX) {
fContext = gVirtualX->CreateGC(gVirtualX->GetDefaultRootWindow(), &fValues);
if (fValues.fMask & kGCDashList)
gVirtualX->SetDashes(fContext, fValues.fDashOffset, fValues.fDashes, fValues.fDashLen);
} else {
fContext = 0;
}
}
return *this;
}
Expand Down Expand Up @@ -239,6 +244,9 @@ void TGGC::SetAttributes(GCValues_t *values)
gClient->GetGCPool()->fList->Add(this);
}

if (!gVirtualX)
return;

if (fContext)
gVirtualX->ChangeGC(fContext, values);
else
Expand Down Expand Up @@ -963,7 +971,8 @@ TGGC *TGGCPool::FindGC(GContext_t gct)
TGGC *TGGCPool::GetGC(GContext_t gct)
{
GCValues_t gval;
gVirtualX->GetGCValues(gct, gval);
if (gVirtualX)
gVirtualX->GetGCValues(gct, gval);
return GetGC(&gval, kTRUE);
}

Expand Down
11 changes: 7 additions & 4 deletions gui/gui/src/TGLabel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ TGLabel::TGLabel(const TGWindow *p, TGString *text, GContext_t norm,
wattr.fMask = kWAWinGravity | kWABitGravity;
wattr.fBitGravity = 5; // center
wattr.fWinGravity = 1;
gVirtualX->ChangeWindowAttributes(fId, &wattr);
if (gVirtualX)
gVirtualX->ChangeWindowAttributes(fId, &wattr);

Resize();
SetWindowName();
Expand Down Expand Up @@ -121,7 +122,8 @@ TGLabel::TGLabel(const TGWindow *p, const char *text, GContext_t norm,
wattr.fMask = kWAWinGravity | kWABitGravity;
wattr.fBitGravity = 5; // center
wattr.fWinGravity = 1;
gVirtualX->ChangeWindowAttributes(fId, &wattr);
if (gVirtualX)
gVirtualX->ChangeWindowAttributes(fId, &wattr);

Resize();
SetWindowName();
Expand Down Expand Up @@ -257,7 +259,7 @@ void TGLabel::DoRedraw()
DrawText(fNormGC, x, y);
break;
}
} else { // disabled
} else if (gVirtualX) { // disabled
FontH_t fontH;

if (GetDefaultFontStruct() != fFont->GetFontStruct()) {
Expand Down Expand Up @@ -438,7 +440,8 @@ void TGLabel::SetTextJustify(Int_t mode)
break;
}

gVirtualX->ChangeWindowAttributes(fId, &wattr);
if (gVirtualX)
gVirtualX->ChangeWindowAttributes(fId, &wattr);

Layout();
}
Expand Down
Loading