Skip to content
Snippets Groups Projects
Commit 81b148c3 authored by Jaswant Panchumarti (Kitware)'s avatar Jaswant Panchumarti (Kitware) Committed by Kitware Robot
Browse files

Merge topic 'webgpu-ensuredisplay' into release


ccc43d10 Add missing method definition SetDefaultTimeout()
409ab0fd Add EnsureDisplay() to vtkXWebGPURenderWindow

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Tested-by: default avatarbuildbot <buildbot@kitware.com>
Tested-by: default avatarJaswant Panchumarti (Kitware) <jaswant.panchumarti@kitware.com>
Acked-by: default avatarclintonstimpson <cjstimp@sandia.gov>
Merge-request: !11573
parents 04032aa2 ccc43d10
No related branches found
No related tags found
No related merge requests found
......@@ -121,6 +121,12 @@ void vtkWebGPUConfiguration::PrintSelf(ostream& os, vtkIndent indent)
this->Superclass::PrintSelf(os, indent.GetNextIndent());
}
//------------------------------------------------------------------------------
void vtkWebGPUConfiguration::SetDefaultTimeout(double t)
{
vtkWebGPUConfigurationInternals::DefaultTimeout = t;
}
//------------------------------------------------------------------------------
wgpu::Adapter vtkWebGPUConfiguration::GetAdapter()
{
......
......@@ -212,16 +212,10 @@ void vtkXWebGPURenderWindow::CreateAWindow()
xsh.height = height;
// get the default display connection
if (!this->DisplayId)
if (!this->EnsureDisplay())
{
this->DisplayId = XOpenDisplay(static_cast<char*>(nullptr));
if (this->DisplayId == nullptr)
{
vtkErrorMacro(<< "bad X server connection. DISPLAY=" << vtksys::SystemTools::GetEnv("DISPLAY")
<< ". Aborting.\n");
abort();
}
this->OwnDisplay = 1;
vtkErrorMacro(<< "Aborting in CreateAWindow(), no Display\n");
abort();
}
attr.override_redirect = False;
......@@ -688,19 +682,11 @@ vtkTypeBool vtkXWebGPURenderWindow::GetEventPending()
int* vtkXWebGPURenderWindow::GetScreenSize()
{
// get the default display connection
if (!this->DisplayId)
if (!this->EnsureDisplay())
{
this->DisplayId = XOpenDisplay(static_cast<char*>(nullptr));
if (this->DisplayId == nullptr)
{
vtkErrorMacro(<< "bad X server connection. DISPLAY=" << vtksys::SystemTools::GetEnv("DISPLAY")
<< ". Aborting.\n");
abort();
}
else
{
this->OwnDisplay = 1;
}
this->ScreenSize[0] = 0;
this->ScreenSize[1] = 0;
return this->ScreenSize;
}
this->ScreenSize[0] = XDisplayWidth(this->DisplayId, XDefaultScreen(this->DisplayId));
......@@ -743,6 +729,26 @@ Display* vtkXWebGPURenderWindow::GetDisplayId()
return this->DisplayId;
}
//------------------------------------------------------------------------------------------------
bool vtkXWebGPURenderWindow::EnsureDisplay()
{
if (!this->DisplayId)
{
this->DisplayId = XOpenDisplay(static_cast<char*>(nullptr));
if (this->DisplayId == nullptr)
{
vtkWarningMacro(<< "bad X server connection. DISPLAY="
<< vtksys::SystemTools::GetEnv("DISPLAY"));
}
else
{
this->OwnDisplay = 1;
}
}
return this->DisplayId != nullptr;
}
//------------------------------------------------------------------------------------------------
// Get this RenderWindow's parent X window id.
Window vtkXWebGPURenderWindow::GetParentId()
......@@ -807,24 +813,10 @@ void vtkXWebGPURenderWindow::SetWindowId(Window arg)
// Set this RenderWindow's X window id to a pre-existing window.
void vtkXWebGPURenderWindow::SetWindowInfo(const char* info)
{
int tmp;
// get the default display connection
if (!this->DisplayId)
{
this->DisplayId = XOpenDisplay(static_cast<char*>(nullptr));
if (this->DisplayId == nullptr)
{
vtkErrorMacro(<< "bad X server connection. DISPLAY=" << vtksys::SystemTools::GetEnv("DISPLAY")
<< ". Aborting.\n");
abort();
}
else
{
this->OwnDisplay = 1;
}
}
// note: potential Display/Window mismatch here
this->EnsureDisplay();
int tmp;
sscanf(info, "%i", &tmp);
this->SetWindowId(static_cast<Window>(tmp));
......@@ -844,24 +836,10 @@ void vtkXWebGPURenderWindow::SetNextWindowInfo(const char* info)
// Sets the X window id of the window that WILL BE created.
void vtkXWebGPURenderWindow::SetParentInfo(const char* info)
{
int tmp;
// get the default display connection
if (!this->DisplayId)
{
this->DisplayId = XOpenDisplay(static_cast<char*>(nullptr));
if (this->DisplayId == nullptr)
{
vtkErrorMacro(<< "bad X server connection. DISPLAY=" << vtksys::SystemTools::GetEnv("DISPLAY")
<< ". Aborting.\n");
abort();
}
else
{
this->OwnDisplay = 1;
}
}
// note: potential Display/Window mismatch here
this->EnsureDisplay();
int tmp;
sscanf(info, "%i", &tmp);
this->SetParentId(static_cast<Window>(tmp));
......
......@@ -138,6 +138,11 @@ public:
*/
Display* GetDisplayId();
/**
* Ensure RenderWindow's X display is opened
*/
bool EnsureDisplay() override;
///@{
/**
* Set the X display id for this RenderWindow to use to a pre-existing
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment