aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2011-01-06 07:33:34 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2011-01-06 07:33:34 (GMT)
commite8ce9ed3a38e1b4a3e5727d408d0fac0e2ff1ada (patch)
tree31aa316f3ec48464ed7e619872a7bb497a42db35 /src
parente2d52a39485d0ab9d5cb5ae027372b612eb32e60 (diff)
downloadfluxbox-e8ce9ed3a38e1b4a3e5727d408d0fac0e2ff1ada.zip
fluxbox-e8ce9ed3a38e1b4a3e5727d408d0fac0e2ff1ada.tar.bz2
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.
Diffstat (limited to 'src')
-rw-r--r--src/FbCommands.cc19
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