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.
Mathias Gumz akira at fluxbox dot org
1 files changed,
15 insertions(+),
4 deletions(-)
jump to
M
src/FbCommands.cc
→
src/FbCommands.cc
@@ -142,6 +142,10 @@ pid_t pid = fork();
if (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()); int screen_num = m_screen_num; if (screen_num < 0) {@@ -151,17 +155,24 @@ else
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 // this process exits immediately, so we don't have to worry about memleaks const char *shell = getenv("SHELL"); if (!shell) shell = "/bin/sh"; - display.erase(display.size()-1); - display += FbTk::StringUtil::number2String(screen_num); - setsid(); - FbTk::App::setenv("DISPLAY", display.c_str()); execl(shell, shell, "-c", m_cmd.c_str(), static_cast<void*>(NULL)); exit(EXIT_SUCCESS);