From 95ee731d9118eec110ecb2de5c9094d561a004bd Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Thu, 6 Jan 2011 08:33:34 +0100 Subject: [PATCH] Backported 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. Backported from e8ce9ed3a38e1b4a3e5727d408d0fac0e2ff1ada --- src/FbCommands.cc | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/FbCommands.cc b/src/FbCommands.cc index fd3f71e..fc9e7a2 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc @@ -142,9 +142,13 @@ int ExecuteCmd::run() { 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 displaystring("DISPLAY="); - displaystring += DisplayString(FbTk::App::instance()->display()); char intbuff[64]; + string display = DisplayString(FbTk::App::instance()->display()); int screen_num = m_screen_num; if (screen_num < 0) { if (Fluxbox::instance()->mouseScreen() == 0) @@ -155,6 +159,15 @@ int ExecuteCmd::run() { sprintf(intbuff, "%d", screen_num); + // 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 += intbuff; + // get shell path from the environment // this process exits immediately, so we don't have to worry about memleaks const char *shell = getenv("SHELL"); @@ -162,8 +175,7 @@ int ExecuteCmd::run() { shell = "/bin/sh"; // remove last number of display and add screen num - displaystring.erase(displaystring.size()-1); - displaystring += intbuff; + displaystring += DisplayString(FbTk::App::instance()->display()); setsid(); putenv(const_cast(displaystring.c_str())); -- 1.7.4.rc1