diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/FbCommands.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 7ff689e..4dffd8d 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc | |||
@@ -142,6 +142,10 @@ int ExecuteCmd::run() { | |||
142 | if (pid) | 142 | if (pid) |
143 | return pid; | 143 | return pid; |
144 | 144 | ||
145 | // 'display' is given as 'host:number.screen'. we want to give the | ||
146 | // new app a good home, so we remove '.screen' from what is given | ||
147 | // us from the xserver and replace it with the screen_num of the Screen | ||
148 | // the user currently points at with the mouse | ||
145 | string display = DisplayString(FbTk::App::instance()->display()); | 149 | string display = DisplayString(FbTk::App::instance()->display()); |
146 | int screen_num = m_screen_num; | 150 | int screen_num = m_screen_num; |
147 | if (screen_num < 0) { | 151 | if (screen_num < 0) { |
@@ -151,17 +155,24 @@ int ExecuteCmd::run() { | |||
151 | screen_num = Fluxbox::instance()->mouseScreen()->screenNumber(); | 155 | screen_num = Fluxbox::instance()->mouseScreen()->screenNumber(); |
152 | } | 156 | } |
153 | 157 | ||
158 | // strip away the '.screen' | ||
159 | size_t dot = display.rfind(':'); | ||
160 | dot = display.find('.', dot); | ||
161 | if (dot != string::npos) { // 'display' has actually a '.screen' part | ||
162 | display.erase(dot); | ||
163 | } | ||
164 | display += '.'; | ||
165 | display += FbTk::StringUtil::number2String(screen_num); | ||
166 | |||
167 | FbTk::App::setenv("DISPLAY", display.c_str()); | ||
168 | |||
154 | // get shell path from the environment | 169 | // get shell path from the environment |
155 | // this process exits immediately, so we don't have to worry about memleaks | 170 | // this process exits immediately, so we don't have to worry about memleaks |
156 | const char *shell = getenv("SHELL"); | 171 | const char *shell = getenv("SHELL"); |
157 | if (!shell) | 172 | if (!shell) |
158 | shell = "/bin/sh"; | 173 | shell = "/bin/sh"; |
159 | 174 | ||
160 | display.erase(display.size()-1); | ||
161 | display += FbTk::StringUtil::number2String(screen_num); | ||
162 | |||
163 | setsid(); | 175 | setsid(); |
164 | FbTk::App::setenv("DISPLAY", display.c_str()); | ||
165 | execl(shell, shell, "-c", m_cmd.c_str(), static_cast<void*>(NULL)); | 176 | execl(shell, shell, "-c", m_cmd.c_str(), static_cast<void*>(NULL)); |
166 | exit(EXIT_SUCCESS); | 177 | exit(EXIT_SUCCESS); |
167 | 178 | ||