Commit d86e0f00 authored by fogal1's avatar fogal1

Support display strings that include screen types.

Old code assumed DISPLAYs of the form ":d", but many systems
utilize ":d.s" nowadays, where 'd' is the display number and 's'
is the screen number.  This commits rewrites the machinery to
store a string instead of a number for the display, and thus rely
on the user giving us the full DISPLAY string, allowing them to
set it to whatever the hell they feel like.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@14776 18c085ea-50e0-402c-830e-de6fd14e8384
parent c9e7fd6c
......@@ -2170,6 +2170,7 @@ Engine::ProcessCommandLine(int argc, char **argv)
avtCallback::SetAuxSessionKey(s);
i++;
}
}
else if (strcmp(argv[i], "-launch-x") == 0)
{
this->launchXServers = true;
......@@ -3822,12 +3823,15 @@ Engine::GetProcessAttributes()
// Tom Fogal, Wed May 26 09:28:12 MDT 2010
// Tell the display whether or not to launch servers.
//
// Tom Fogal, Wed May 4 15:57:22 MDT 2011
// Handle displays as a string, to support variations more easily.
//
// ****************************************************************************
void
Engine::SetupDisplay()
{
int display = -1; // Display ID to create.
int display_num = -1; // Display ID to create.
#ifdef PARALLEL
cog_set lnodes;
......@@ -3849,7 +3853,7 @@ Engine::SetupDisplay()
if(PAR_Rank() == rank &&
static_cast<size_t>(rank-min) < this->nDisplays)
{
display = rank-min;
display_num = rank-min;
this->renderingDisplay = VDisplay::Create(VDisplay::D_X);
}
}
......@@ -3859,12 +3863,15 @@ Engine::SetupDisplay()
{
this->renderingDisplay = VDisplay::Create(VDisplay::D_X);
avtCallback::SetSoftwareRendering(false);
display = 0;
display_num = 0;
}
#endif
// Tell the display whether or not it should start X servers. This must be
// done before ::Initialize!
XDisplay* xd = dynamic_cast<XDisplay*>(this->renderingDisplay);
std::string X_Display = RuntimeSetting::lookups("x-display");
std::string disp = display_format(X_Display, PAR_Rank(), display_num);
if(xd != NULL)
{
xd->Launch(this->launchXServers);
......@@ -3875,8 +3882,8 @@ Engine::SetupDisplay()
this->renderingDisplay = VDisplay::Create(VDisplay::D_MESA);
avtCallback::SetSoftwareRendering(true);
}
if(this->renderingDisplay->Initialize(display,
split(this->X_Args, PAR_Rank(), display)))
if(this->renderingDisplay->Initialize(disp,
split(this->X_Args, PAR_Rank(), display_num)))
{
if(false == this->renderingDisplay->Connect())
{
......
......@@ -393,6 +393,7 @@ class ENGINE_MAIN_API Engine
private:
bool useIceT;
std::string X_Args;
std::string X_Display;
size_t nDisplays;
VisItDisplay *renderingDisplay;
bool launchXServers;
......
......@@ -86,10 +86,16 @@ MesaDisplay::~MesaDisplay()
// Programmer: Tom Fogal
// Creation: September 1, 2008
//
// Modifications:
//
// Tom Fogal, Wed May 4 15:00:24 MDT 2011
// Fix display type.
//
// ****************************************************************************
bool
MesaDisplay::Initialize(size_t display, const std::vector<std::string> &user_args)
MesaDisplay::Initialize(std::string display,
const std::vector<std::string> &user_args)
{
return true;
}
......
......@@ -56,6 +56,9 @@
// Tom Fogal, Tue May 25 16:08:23 MDT 2010
// Made connect return a bool.
//
// Tom Fogal, Wed May 4 14:59:45 MDT 2011
// 'Initialize' changed signature.
//
// ****************************************************************************
class ENGINE_MAIN_API MesaDisplay : public VisItDisplay
......@@ -64,7 +67,7 @@ class ENGINE_MAIN_API MesaDisplay : public VisItDisplay
MesaDisplay();
virtual ~MesaDisplay();
virtual bool Initialize(size_t n,
virtual bool Initialize(std::string display,
const std::vector<std::string> &args);
virtual bool Connect();
virtual void Teardown();
......
......@@ -63,9 +63,12 @@
// Use a debug stream instead of cerr. Use SNPRINTF macro instead of
// calling the function directly.
//
// Tom Fogal, Wed May 4 14:58:42 MDT 2011
// Rename to avoid an apparent naming conflict.
//
// ****************************************************************************
std::string
format(std::string s, size_t node, size_t display)
display_format(std::string s, size_t node, size_t display)
{
std::string::size_type percent;
if((percent = s.find('%')) != std::string::npos) {
......@@ -88,7 +91,7 @@ format(std::string s, size_t node, size_t display)
}
// If they gave multiple %'s in the same string, recurse.
if(s.find('%') != std::string::npos) {
return format(s, node, display);
return display_format(s, node, display);
}
return s;
}
......@@ -114,7 +117,7 @@ split(std::string str, size_t node, size_t display)
{
namespace SH = StringHelpers;
std::vector<std::string> ret;
ret.push_back(format(SH::car(str, ' '), node, display));
ret.push_back(display_format(SH::car(str, ' '), node, display));
if(str.find(' ') != std::string::npos) {
SH::append(ret, split(SH::cdr(str, ' '), node, display));
}
......
......@@ -73,10 +73,10 @@ class ENGINE_MAIN_API VisItDisplay
/// intervening `Teardown's result in undefined behavior.
/// Initialization may fail; success is given via the return value.
///
/// n The display number (identifier) for this display.
/// args user arguments appropriate for configuring the VisIt display.
/// display the display string to utilize.
/// args user arguments appropriate for configuring the VisIt display.
/// returns: Display initialization status.
virtual bool Initialize(size_t n,
virtual bool Initialize(std::string display,
const std::vector<std::string> &args) = 0;
/// Associates this process with the previously-`Initialize'd VisIt Display.
......@@ -93,7 +93,7 @@ class ENGINE_MAIN_API VisItDisplay
// Methods helpful in argument vector creation.
// If these were to be generalized, they would more appropriately end up in
// `StringHelpers'
std::string format(std::string s, size_t node, size_t display);
std::string display_format(std::string s, size_t node, size_t display);
std::vector<std::string> split(std::string, size_t, size_t);
namespace VDisplay {
......
......@@ -83,7 +83,7 @@ static void fix_signals();
//
// ****************************************************************************
XDisplay::XDisplay(): xserver((pid_t)-1), display(0), launch(true) { }
XDisplay::XDisplay(): xserver((pid_t)-1), launch(true) { }
// ****************************************************************************
// Method: XDisplay destructor
......@@ -133,17 +133,17 @@ XDisplay::~XDisplay()
// ****************************************************************************
bool
XDisplay::Initialize(size_t display, const std::vector<std::string> &user_args)
XDisplay::Initialize(std::string display,
const std::vector<std::string>& user_args)
{
this->display = display;
std::string disp = format(":%l", /* unused */ 0, display);
if(gethostname(this->hostname, 512) != 0)
{
debug1 << "Error " << errno << " while getting hostname.\n";
this->hostname[0] = 0;
}
if(this->launch && (this->xserver = xinit(disp, user_args)) == -1)
if(this->launch && (this->xserver = xinit(this->display, user_args)) == -1)
{
return false;
}
......@@ -185,7 +185,7 @@ XDisplay::Connect()
static char env_display[128];
debug3 << "Connecting to display " << this->display << std::endl;
SNPRINTF(env_display, 128, "DISPLAY=:%zu", this->display);
SNPRINTF(env_display, 128, "DISPLAY=%s", this->display.c_str());
if(putenv(env_display) != 0)
{
......
......@@ -60,6 +60,9 @@
// Tom Fogal, Wed May 26 09:10:08 MDT 2010
// Add a method to indicate we should not launch the server.
//
// Tom Fogal, Wed May 4 14:30:00 MDT 2011
// Change display to a string for more flexibility.
//
// ****************************************************************************
class ENGINE_MAIN_API XDisplay : public VisItDisplay
......@@ -68,7 +71,7 @@ class ENGINE_MAIN_API XDisplay : public VisItDisplay
XDisplay();
virtual ~XDisplay();
virtual bool Initialize(size_t n,
virtual bool Initialize(std::string display,
const std::vector<std::string> &args);
virtual bool Connect();
virtual void Teardown();
......@@ -78,9 +81,9 @@ class ENGINE_MAIN_API XDisplay : public VisItDisplay
void Launch(bool);
private:
pid_t xserver;
size_t display;
char hostname[256];
bool launch;
pid_t xserver;
std::string display;
char hostname[256];
bool launch;
};
#endif /* VISIT_X_DISPLAY_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment