bugfix: do not assume ':number.screen' as the result of 'DisplayString()'
a newer xlib recently changed the result of 'DisplayString()' a little bit: instead of returning ':0.0' or ':1.0' it yields ':0' or ':1'. our code to transform this string into something that includes the currently used Screen worked only on something like ':0.0'. we now find the '.' after the ':' and strip that part away.
This commit is contained in:
parent
e2d52a3948
commit
e8ce9ed3a3
1 changed files with 15 additions and 4 deletions
|
@ -142,6 +142,10 @@ int ExecuteCmd::run() {
|
||||||
if (pid)
|
if (pid)
|
||||||
return pid;
|
return pid;
|
||||||
|
|
||||||
|
// 'display' is given as 'host:number.screen'. we want to give the
|
||||||
|
// new app a good home, so we remove '.screen' from what is given
|
||||||
|
// us from the xserver and replace it with the screen_num of the Screen
|
||||||
|
// the user currently points at with the mouse
|
||||||
string display = DisplayString(FbTk::App::instance()->display());
|
string display = DisplayString(FbTk::App::instance()->display());
|
||||||
int screen_num = m_screen_num;
|
int screen_num = m_screen_num;
|
||||||
if (screen_num < 0) {
|
if (screen_num < 0) {
|
||||||
|
@ -151,17 +155,24 @@ int ExecuteCmd::run() {
|
||||||
screen_num = Fluxbox::instance()->mouseScreen()->screenNumber();
|
screen_num = Fluxbox::instance()->mouseScreen()->screenNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// strip away the '.screen'
|
||||||
|
size_t dot = display.rfind(':');
|
||||||
|
dot = display.find('.', dot);
|
||||||
|
if (dot != string::npos) { // 'display' has actually a '.screen' part
|
||||||
|
display.erase(dot);
|
||||||
|
}
|
||||||
|
display += '.';
|
||||||
|
display += FbTk::StringUtil::number2String(screen_num);
|
||||||
|
|
||||||
|
FbTk::App::setenv("DISPLAY", display.c_str());
|
||||||
|
|
||||||
// get shell path from the environment
|
// get shell path from the environment
|
||||||
// this process exits immediately, so we don't have to worry about memleaks
|
// this process exits immediately, so we don't have to worry about memleaks
|
||||||
const char *shell = getenv("SHELL");
|
const char *shell = getenv("SHELL");
|
||||||
if (!shell)
|
if (!shell)
|
||||||
shell = "/bin/sh";
|
shell = "/bin/sh";
|
||||||
|
|
||||||
display.erase(display.size()-1);
|
|
||||||
display += FbTk::StringUtil::number2String(screen_num);
|
|
||||||
|
|
||||||
setsid();
|
setsid();
|
||||||
FbTk::App::setenv("DISPLAY", display.c_str());
|
|
||||||
execl(shell, shell, "-c", m_cmd.c_str(), static_cast<void*>(NULL));
|
execl(shell, shell, "-c", m_cmd.c_str(), static_cast<void*>(NULL));
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue